123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- package ai_summary
- import (
- "eta_gn/eta_api/global"
- "time"
- )
- type AiPrompt struct {
- AiPromptId int `gorm:"primaryKey;column:ai_prompt_id;type:int(10) unsigned;not null"` // ai纪要提示词id
- PromptContent string `gorm:"column:prompt_content;type:longtext"` // 提示词内容
- SysAdminId int `gorm:"column:sys_admin_id;type:int(10) unsigned;not null;default:0"` // 创建人ID
- SysAdminName string `gorm:"column:sys_admin_name;type:varchar(128);not null;default:''"` // 创建人姓名
- Title string `gorm:"column:title;type:varchar(255);not null;default:''"` // 文档标题
- CreateTime time.Time `gorm:"column:create_time;type:datetime"` // 创建时间
- ModifyTime time.Time `gorm:"column:modify_time;type:datetime"` // 更新时间
- IsShare int `gorm:"column:is_share;type:tinyint(9) unsigned;default:0"` // 是否分享,0:不分享,1:分享
- Sort int `gorm:"column:sort;type:int(9) unsigned;default:10"` // 排序字段,越小越靠前,默认值:10
- }
- type AiPromptItem struct {
- AiPromptId int `gorm:"primaryKey;column:ai_prompt_id;type:int(10) unsigned;not null"` // ai纪要提示词id
- PromptContent string `gorm:"column:prompt_content;type:longtext"` // 提示词内容
- SysAdminId int `gorm:"column:sys_admin_id;type:int(10) unsigned;not null;default:0"` // 创建人ID
- SysAdminName string `gorm:"column:sys_admin_name;type:varchar(128);not null;default:''"` // 创建人姓名
- Title string `gorm:"column:title;type:varchar(255);not null;default:''"` // 文档标题
- CreateTime string `gorm:"column:create_time;type:datetime"` // 创建时间
- ModifyTime string `gorm:"column:modify_time;type:datetime"` // 更新时间
- IsShare int `gorm:"column:is_share;type:tinyint(9) unsigned;default:0"` // 是否分享,0:不分享,1:分享
- Sort int `gorm:"column:sort;type:int(9) unsigned;default:10"` // 排序字段,越小越靠前,默认值:10
- }
- 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 `
- }
- err = global.DEFAULT_DmSQL.Raw(sql, sysUserId).Find(&items).Error
- return
- }
- func GetAiPromptShareList() (items []*AiPromptItem, err error) {
- sql := ``
- sql = ` SELECT * FROM ai_prompt WHERE is_share=1 ORDER BY create_time DESC `
- err = global.DEFAULT_DmSQL.Raw(sql).Find(&items).Error
- 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) {
- err = global.DEFAULT_DmSQL.Create(item).Error
- lastId = int64(item.AiPromptId)
- return
- }
- type AiPromptEditReq struct {
- PromptContent string // 原始内容
- Title string // 文档标题
- AiPromptId int // ai纪要提示词id
- }
- func (aiPrompt *AiPrompt) Update(cols []string) (err error) {
- err = global.DEFAULT_DmSQL.Select(cols).Updates(aiPrompt).Error
- return
- }
- // DelAiPromptyId 根据纪要id删除纪要
- func DelAiPromptyId(aiPromptId int) (err error) {
- sql := `delete from ai_prompt where ai_prompt_id = ? `
- err = global.DEFAULT_DmSQL.Exec(sql, aiPromptId).Error
- return
- }
- func GetAiPromptById(promptId int) (item *AiPrompt, err error) {
- sql := `SELECT * FROM ai_prompt WHERE 1=1 AND ai_prompt_id=? `
- err = global.DEFAULT_DmSQL.Raw(sql, promptId).First(&item).Error
- 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) {
- sql := `SELECT COALESCE(MAX(sort), 0) AS sort FROM ai_prompt WHERE sys_admin_id=? `
- err = global.DEFAULT_DmSQL.Raw(sql, adminId).First(&sort).Error
- return
- }
- // MoveDownPromptBySort 往下移动提示词
- func MoveDownPromptBySort(sysAdminId, prevSort, currentSort int) (err error) {
- sql := `update ai_prompt set sort = sort - 1 where sys_admin_id = ? and sort <= ? and sort> ? `
- err = global.DEFAULT_DmSQL.Exec(sql, sysAdminId, prevSort, currentSort).Error
- return
- }
- // MoveUpPromptBySort 往上移动提示词
- func MoveUpPromptBySort(sysAdminId, nextSort, currentSort int) (err error) {
- sql := `update ai_prompt set sort = sort + 1 where sys_admin_id = ? and sort >= ? and sort< ?`
- err = global.DEFAULT_DmSQL.Exec(sql, sysAdminId, nextSort, currentSort).Error
- return
- }
|