ai_pormpt.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package ai_summary
  2. import (
  3. "eta_gn/eta_api/global"
  4. "time"
  5. )
  6. type AiPrompt struct {
  7. AiPromptId int `gorm:"primaryKey;column:ai_prompt_id;type:int(10) unsigned;not null"` // ai纪要提示词id
  8. PromptContent string `gorm:"column:prompt_content;type:longtext"` // 提示词内容
  9. SysAdminId int `gorm:"column:sys_admin_id;type:int(10) unsigned;not null;default:0"` // 创建人ID
  10. SysAdminName string `gorm:"column:sys_admin_name;type:varchar(128);not null;default:''"` // 创建人姓名
  11. Title string `gorm:"column:title;type:varchar(255);not null;default:''"` // 文档标题
  12. CreateTime time.Time `gorm:"column:create_time;type:datetime"` // 创建时间
  13. ModifyTime time.Time `gorm:"column:modify_time;type:datetime"` // 更新时间
  14. IsShare int `gorm:"column:is_share;type:tinyint(9) unsigned;default:0"` // 是否分享,0:不分享,1:分享
  15. Sort int `gorm:"column:sort;type:int(9) unsigned;default:10"` // 排序字段,越小越靠前,默认值:10
  16. }
  17. type AiPromptItem struct {
  18. AiPromptId int `gorm:"primaryKey;column:ai_prompt_id;type:int(10) unsigned;not null"` // ai纪要提示词id
  19. PromptContent string `gorm:"column:prompt_content;type:longtext"` // 提示词内容
  20. SysAdminId int `gorm:"column:sys_admin_id;type:int(10) unsigned;not null;default:0"` // 创建人ID
  21. SysAdminName string `gorm:"column:sys_admin_name;type:varchar(128);not null;default:''"` // 创建人姓名
  22. Title string `gorm:"column:title;type:varchar(255);not null;default:''"` // 文档标题
  23. CreateTime string `gorm:"column:create_time;type:datetime"` // 创建时间
  24. ModifyTime string `gorm:"column:modify_time;type:datetime"` // 更新时间
  25. IsShare int `gorm:"column:is_share;type:tinyint(9) unsigned;default:0"` // 是否分享,0:不分享,1:分享
  26. Sort int `gorm:"column:sort;type:int(9) unsigned;default:10"` // 排序字段,越小越靠前,默认值:10
  27. }
  28. func GetAiPromptList(sysUserId, isShare int) (items []*AiPromptItem, err error) {
  29. sql := ``
  30. if isShare == 1 {
  31. sql = ` SELECT * FROM ai_prompt WHERE sys_admin_id=? and is_share=1 ORDER BY sort `
  32. } else {
  33. sql = ` SELECT * FROM ai_prompt WHERE sys_admin_id=? ORDER BY sort `
  34. }
  35. err = global.DEFAULT_DmSQL.Raw(sql, sysUserId).Find(&items).Error
  36. return
  37. }
  38. func GetAiPromptShareList() (items []*AiPromptItem, err error) {
  39. sql := ``
  40. sql = ` SELECT * FROM ai_prompt WHERE is_share=1 ORDER BY create_time DESC `
  41. err = global.DEFAULT_DmSQL.Raw(sql).Find(&items).Error
  42. return
  43. }
  44. type RespGroupListItem struct {
  45. GroupId int64 `description:"目录id"`
  46. GroupName string `description:"目录名称"`
  47. AdminId int `description:"目录创建者账号ID"`
  48. IsShare int8 `description:"是否共享,0私有,1共享"`
  49. PromptList []*AiPromptItem
  50. }
  51. type AiPromptAddReq struct {
  52. PromptContent string // 原始内容
  53. Title string // 文档标题
  54. }
  55. func AddPropmt(item *AiPrompt) (lastId int64, err error) {
  56. err = global.DEFAULT_DmSQL.Create(item).Error
  57. lastId = int64(item.AiPromptId)
  58. return
  59. }
  60. type AiPromptEditReq struct {
  61. PromptContent string // 原始内容
  62. Title string // 文档标题
  63. AiPromptId int // ai纪要提示词id
  64. }
  65. func (aiPrompt *AiPrompt) Update(cols []string) (err error) {
  66. err = global.DEFAULT_DmSQL.Select(cols).Updates(aiPrompt).Error
  67. return
  68. }
  69. func DelAiPromptyId(aiPromptId int) (err error) {
  70. sql := `delete from ai_prompt where ai_prompt_id = ? `
  71. err = global.DEFAULT_DmSQL.Exec(sql, aiPromptId).Error
  72. return
  73. }
  74. func GetAiPromptById(promptId int) (item *AiPrompt, err error) {
  75. sql := `SELECT * FROM ai_prompt WHERE 1=1 AND ai_prompt_id=? `
  76. err = global.DEFAULT_DmSQL.Raw(sql, promptId).First(&item).Error
  77. return
  78. }
  79. type DeleteAipromptReq struct {
  80. AiPromptId int // ai纪要提示词id
  81. }
  82. type ReqMovePrompt struct {
  83. AiPromptId int `description:"当前被移动的目录里的ppt绑定序号"`
  84. PrevAiPromptId int `description:"上一个目录里的ppt绑定序号,ppt最终在目录中置顶,则传0值"`
  85. NextAiPromptId int `description:"下一个目录里的ppt绑定序号,ppt最终在目录末尾,则传0值"`
  86. }
  87. func GetAiPromptMaxSort(adminId int) (sort int, err error) {
  88. sql := `SELECT COALESCE(MAX(sort), 0) AS sort FROM ai_prompt WHERE sys_admin_id=? `
  89. err = global.DEFAULT_DmSQL.Raw(sql, adminId).First(&sort).Error
  90. return
  91. }
  92. func MoveDownPromptBySort(sysAdminId, prevSort, currentSort int) (err error) {
  93. sql := `update ai_prompt set sort = sort - 1 where sys_admin_id = ? and sort <= ? and sort> ? `
  94. err = global.DEFAULT_DmSQL.Exec(sql, sysAdminId, prevSort, currentSort).Error
  95. return
  96. }
  97. func MoveUpPromptBySort(sysAdminId, nextSort, currentSort int) (err error) {
  98. sql := `update ai_prompt set sort = sort + 1 where sys_admin_id = ? and sort >= ? and sort< ?`
  99. err = global.DEFAULT_DmSQL.Exec(sql, sysAdminId, nextSort, currentSort).Error
  100. return
  101. }