123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- package ai_summary
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type AiPrompt struct {
- AiPromptId int `orm:"column(ai_prompt_id);pk"` // ai纪要提示词id
- PromptContent string // 原始内容
- SysAdminId int // 创建人ID
- SysAdminName string // 创建人姓名
- Title string // 文档标题
- CreateTime time.Time // 创建时间
- ModifyTime time.Time // 更新时间
- IsShare int // 是否分享,0:不分享,1:分享
- Sort int // 排序
- }
- type AiPromptItem struct {
- AiPromptId int `orm:"column(ai_prompt_id);pk"` // ai纪要提示词id
- PromptContent string // 原始内容
- SysAdminId int // 创建人ID
- SysAdminName string // 创建人姓名
- Title string // 文档标题
- CreateTime string // 创建时间
- ModifyTime string // 更新时间
- IsShare int // 是否分享,0:不分享,1:分享
- Sort int // 排序
- }
- func GetAiPromptList(sysUserId, isShare int) (items []*AiPromptItem, err error) {
- sql := ``
- if isShare == 1 {
- sql = ` SELECT * FROM ai_prompt WHERE sys_admin_id=? and is_share=1 ORDER BY sort `
- } else {
- sql = ` SELECT * FROM ai_prompt WHERE sys_admin_id=? ORDER BY sort `
- }
- o := orm.NewOrm()
- _, err = o.Raw(sql, sysUserId).QueryRows(&items)
- return
- }
- func GetAiPromptShareList() (items []*AiPromptItem, err error) {
- sql := ``
- sql = ` SELECT * FROM ai_prompt WHERE is_share=1 ORDER BY create_time DESC `
- o := orm.NewOrm()
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- type RespGroupListItem struct {
- GroupId int64 `description:"目录id"`
- GroupName string `description:"目录名称"`
- AdminId int `description:"目录创建者账号ID"`
- IsShare int8 `description:"是否共享,0私有,1共享"`
- PromptList []*AiPromptItem
- }
- type AiPromptAddReq struct {
- PromptContent string // 原始内容
- Title string // 文档标题
- }
- func AddPropmt(item *AiPrompt) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- type AiPromptEditReq struct {
- PromptContent string // 原始内容
- Title string // 文档标题
- AiPromptId int // ai纪要提示词id
- }
- // Update
- func (aiPrompt *AiPrompt) Update(cols []string) (err error) {
- o := orm.NewOrm()
- _, err = o.Update(aiPrompt, cols...)
- return
- }
- // DelAiSummaryById 根据纪要id删除纪要
- func DelAiPromptyId(aiPromptId int) (err error) {
- o := orm.NewOrm()
- sql := `delete from ai_prompt where ai_prompt_id = ? `
- _, err = o.Raw(sql, aiPromptId).Exec()
- return
- }
- func GetAiPromptById(promptId int) (item *AiPrompt, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM ai_prompt WHERE 1=1 AND ai_prompt_id=? `
- err = o.Raw(sql, promptId).QueryRow(&item)
- return
- }
- type DeleteAipromptReq struct {
- AiPromptId int // ai纪要提示词id
- }
- type ReqMovePrompt struct {
- AiPromptId int `description:"当前被移动的目录里的ppt绑定序号"`
- PrevAiPromptId int `description:"上一个目录里的ppt绑定序号,ppt最终在目录中置顶,则传0值"`
- NextAiPromptId int `description:"下一个目录里的ppt绑定序号,ppt最终在目录末尾,则传0值"`
- }
- // GetAiPromptMaxSort 获取ai提示词下最大的排序数
- func GetAiPromptMaxSort(adminId int) (sort int, err error) {
- o := orm.NewOrm()
- sql := `SELECT Max(sort) AS sort FROM ai_prompt WHERE sys_admin_id=? `
- err = o.Raw(sql, adminId).QueryRow(&sort)
- return
- }
- // MoveDownPromptBySort 往下移动提示词
- func MoveDownPromptBySort(sysAdminId, prevSort, currentSort int) (err error) {
- o := orm.NewOrm()
- sql := `update ai_prompt set sort = sort - 1 where sys_admin_id = ? and sort <= ? and sort> ? `
- _, err = o.Raw(sql, sysAdminId, prevSort, currentSort).Exec()
- return
- }
- // MoveUpPromptBySort 往上移动提示词
- func MoveUpPromptBySort(sysAdminId, nextSort, currentSort int) (err error) {
- o := orm.NewOrm()
- sql := `update ai_prompt set sort = sort + 1 where sys_admin_id = ? and sort >= ? and sort< ?`
- _, err = o.Raw(sql, sysAdminId, nextSort, currentSort).Exec()
- return
- }
|