ppt_v2_group.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. package models
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "time"
  6. )
  7. type PptV2Group struct {
  8. GroupId int64 `gorm:"column:group_id;primaryKey;autoIncrement" description:"ppt目录ID"`
  9. GroupName string `gorm:"column:group_name" description:"目录名称"`
  10. AdminId int `gorm:"column:admin_id" description:"目录创建者账号ID"`
  11. IsShare int8 `gorm:"column:is_share" description:"是否共享,0私有,1共享"`
  12. GroupSort int64 `gorm:"column:group_sort" description:"目录排序标识"`
  13. IsShareAdd int8 `gorm:"column:is_share_add" description:"是否是通过单个ppt共享生成的目录,0不是,1-是"`
  14. CreateTime time.Time `gorm:"column:create_time;autoCreateTime" description:"创建时间"`
  15. ModifyTime time.Time `gorm:"column:modify_time;autoUpdateTime" description:"修改时间"`
  16. ShareTime time.Time `gorm:"column:share_time" description:"分享时间"`
  17. }
  18. // GetPrivatePptGroups 获取私有目录
  19. func GetPrivatePptGroups(adminId int) (list []*PptV2Group, err error) {
  20. sql := "select * from ppt_v2_group where admin_id=? order by group_sort asc, group_id asc"
  21. err = global.DmSQL["rddp"].Raw(sql, adminId).Find(&list).Error
  22. return
  23. }
  24. // GetPrivatePptGroupsByAdminId 获取用户自己的私有目录
  25. func GetPrivatePptGroupsByAdminId(adminId int) (list []*PptV2Group, err error) {
  26. sql := "select * from ppt_v2_group where admin_id=? AND is_share_add=0 order by group_sort asc, group_id asc"
  27. err = global.DmSQL["rddp"].Raw(sql, adminId).Find(&list).Error
  28. return
  29. }
  30. // GetPublicPptGroups 获取ppt公共目录
  31. func GetPublicPptGroups() (list []*PptV2Group, err error) {
  32. sql := "select * from ppt_v2_group where is_share=1 order by share_time asc, group_id asc"
  33. err = global.DmSQL["rddp"].Raw(sql).Find(&list).Error
  34. return
  35. }
  36. // GetPptGroupByName 根据目录名称查询
  37. func GetPptGroupByName(groupName string, adminId int) (item *PptV2Group, err error) {
  38. sql := "select * from ppt_v2_group where admin_id=? and group_name=?"
  39. err = global.DmSQL["rddp"].Raw(sql, adminId, groupName).Find(&item).Error
  40. return
  41. }
  42. // GetPptGroupById 根据目录Id查询
  43. func GetPptGroupByGroupIdAdminId(groupId int64, adminId int) (item *PptV2Group, err error) {
  44. sql := "select * from ppt_v2_group where admin_id=? and group_id=?"
  45. err = global.DmSQL["rddp"].Raw(sql, adminId, groupId).First(&item).Error
  46. return
  47. }
  48. // GetPptGroupByGroupId 根据目录Id查询
  49. func GetPptGroupByGroupId(groupId int64) (item *PptV2Group, err error) {
  50. sql := "select * from ppt_v2_group where group_id=?"
  51. err = global.DmSQL["rddp"].Raw(sql, groupId).First(&item).Error
  52. return
  53. }
  54. // AddPptGroup 新增目录
  55. func AddPptGroup(item *PptV2Group) (lastId int64, err error) {
  56. err = global.DmSQL["rddp"].Create(item).Error
  57. lastId = item.GroupId
  58. return
  59. }
  60. // DeletePptGroup 删除单个ppt目录
  61. func DeletePptGroup(groupId int64) (err error) {
  62. sql := `DELETE FROM ppt_v2_group WHERE group_id=? `
  63. err = global.DmSQL["rddp"].Exec(sql, groupId).Error
  64. return
  65. }
  66. // DeletePptGroupByGroupIds 删除单个ppt目录
  67. func DeletePptGroupByGroupIds(groupIds string) (err error) {
  68. sql := `DELETE FROM ppt_v2_group WHERE group_id in ` + groupIds
  69. err = global.DmSQL["rddp"].Exec(sql).Error
  70. return
  71. }
  72. // Update 更新ppt目录基础信息
  73. func (item *PptV2Group) Update(cols []string) (err error) {
  74. err = global.DmSQL["rddp"].Select(cols).Updates(item).Error
  75. return
  76. }
  77. // MoveUpGroupBySort 往上移动目录
  78. func MoveUpGroupBySort(nextSort, currentSort int64) (err error) {
  79. sql := `update ppt_v2_group set group_sort = group_sort + 1 where group_sort >= ? and group_sort< ?`
  80. err = global.DmSQL["rddp"].Exec(sql, nextSort, currentSort).Error
  81. return
  82. }
  83. // MoveDownGroupBySort 往下移动目录
  84. func MoveDownGroupBySort(prevSort, currentSort int64) (err error) {
  85. sql := `update ppt_v2_group set group_sort = group_sort - 1 where group_sort <= ? and group_sort> ? `
  86. err = global.DmSQL["rddp"].Exec(sql, prevSort, currentSort).Error
  87. return
  88. }
  89. // GetPptGroupNamesByAdminId 获取当前目录的所有名称
  90. func GetPptGroupNamesByAdminId(adminId int) (names []string, err error) {
  91. sql := "select group_name from ppt_v2_group where admin_id = ?"
  92. err = global.DmSQL["rddp"].Raw(sql, adminId).Scan(&names).Error
  93. return
  94. }
  95. // GetPptGroupIdAndGroupNameByAdminId 查找分组名称和标识
  96. func GetPptGroupIdAndGroupNameByAdminId(adminId int) (list []*RespPptGroupName, err error) {
  97. sql := "select group_id, group_name from ppt_v2_group where admin_id = ? and is_share_add != 1 order by group_sort asc, group_id asc"
  98. err = global.DmSQL["rddp"].Raw(sql, adminId).Find(&list).Error
  99. return
  100. }
  101. // AddPptGroupMappingMulti 批量新增ppt和目录的映射关系
  102. func AddPptGroupMulti(list []*PptV2Group) (err error) {
  103. err = global.DmSQL["rddp"].CreateInBatches(list, utils.MultiAddNum).Error
  104. return
  105. }
  106. // UpdatePptGroupSortMulti 批量更新初始排序标识
  107. func UpdatePptGroupSortMulti(groupIds []int64) (err error) {
  108. tx := global.DmSQL["rddp"].Begin()
  109. for _, v := range groupIds {
  110. err = tx.Exec("UPDATE ppt_v2_group SET group_sort = group_id WHERE group_id = ?", v).Error
  111. if err != nil {
  112. tx.Rollback()
  113. return
  114. }
  115. }
  116. tx.Commit()
  117. return
  118. }
  119. type ReqAddPptGroup struct {
  120. GroupName string `description:"目录名称"`
  121. }
  122. type RespAddPptGroup struct {
  123. GroupId int64 `description:"目录id"`
  124. }
  125. type ReqPptGroup struct {
  126. GroupId int64 `description:"目录id"`
  127. }
  128. type ReqRenamePptGroup struct {
  129. GroupId int64 `description:"目录id"`
  130. GroupName string `description:"目录名称"`
  131. }
  132. type RespPptGroupShare struct {
  133. GroupId int64 `description:"目录id"`
  134. IsShare int8 `description:"是否共享,0私有,1共享"`
  135. }
  136. type RespGroupList struct {
  137. PublicList []*RespGroupListItem
  138. PrivateList []*RespGroupListItem
  139. GrantList []RespGroupListItem
  140. }
  141. type RespGroupListItem struct {
  142. GroupId int64 `description:"目录id"`
  143. GroupName string `description:"目录名称"`
  144. AdminId int `description:"目录创建者账号ID"`
  145. IsShare int8 `description:"是否共享,0私有,1共享"`
  146. OnlyOld bool `description:"是否只包含ppt旧版本的目录,只包含旧版的ppt:true,否则 false"`
  147. PptList []*RespGroupPptNameListItem
  148. }
  149. type RespGroupPptNameListItem struct {
  150. GroupPptId int64 `description:"目录和ppt绑定序号"`
  151. PptId int64 `description:"ppt ID"`
  152. Title string `description:"标题"`
  153. AdminId int `description:"移动ppt到该目录的系统用户id"`
  154. AdminRealName string `description:"系统用户名称"`
  155. PptVersion int8 `description:"是否ppt的旧版本;1:旧的,2:新的"`
  156. IsSingleShare int8 `description:"是否是单个共享ppt,0未单个共享,1共享"`
  157. PptxUrl string `description:"pptx下载地址"`
  158. ReportId int `description:"关联的报告ID"`
  159. ReportCode string `description:"关联的报告code"`
  160. PptCreateTime string `description:"ppt创建时间"`
  161. PptModifyTime string `description:"ppt修改时间"`
  162. PublishTime string `description:"发布时间"`
  163. PptPage int `description:"PPT总页数"`
  164. IsReceived int8 `description:"是否收到的共享,0:不是,1:是"`
  165. IsGrant int8 `description:"是否分配了权限,0:不是,1:是"`
  166. TitleSetting string `description:"PPT标题设置"`
  167. }
  168. type RespGroupPptListItem struct {
  169. GroupPptId int64 `description:"目录和ppt绑定序号"`
  170. PptId int64 `description:"ppt ID"`
  171. TemplateType int `description:"模版类型"`
  172. BackgroundImg string `description:"背景图片"`
  173. Title string `description:"标题"`
  174. PptCreateTime string `description:"ppt创建时间"`
  175. PptModifyTime string `description:"ppt修改时间"`
  176. AdminId int `description:"移动ppt到该目录的系统用户id"`
  177. AdminRealName string `description:"系统用户名称"`
  178. PptVersion int8 `description:"是否ppt的旧版本;1:旧的,2:新的"`
  179. IsSingleShare int8 `description:"是否是单个共享ppt,0未单个共享,1共享"`
  180. PptxUrl string `description:"pptx下载地址"`
  181. PptPage int `description:"PPT总页数"`
  182. ReportId int `description:"关联的报告ID"`
  183. ReportCode string `description:"关联的报告code"`
  184. PublishTime string `description:"发布时间"`
  185. Editor PPTEditingCache `description:"编辑人信息"`
  186. }
  187. func (p RespGroupPptList) Len() int {
  188. return len(p.List)
  189. }
  190. func (p RespGroupPptList) Less(i, j int) bool {
  191. if p.List[i].PptCreateTime < p.List[j].PptCreateTime {
  192. return false
  193. }
  194. return true
  195. }
  196. func (p RespGroupPptList) Swap(i, j int) {
  197. p.List[i], p.List[j] = p.List[j], p.List[i]
  198. }
  199. type ReqPptShare struct {
  200. GroupPptId int64 `description:"目录和ppt绑定序号"`
  201. }
  202. type RespPptShare struct {
  203. GroupPptId int64 `description:"目录和ppt绑定自增序号"`
  204. IsSingleShare int8 `description:"是否是单个共享ppt,0未单个共享,1共享"`
  205. }
  206. type RespGroupPptList struct {
  207. List []*RespGroupPptListItem
  208. Total int `description:"ppt总数"`
  209. }
  210. type ReqMoveGroupPpt struct {
  211. GroupId int64 `description:"目标目录id"`
  212. GroupPptId int64 `description:"当前被移动的目录里的ppt绑定序号"`
  213. PrevGroupPptId int64 `description:"上一个目录里的ppt绑定序号,ppt最终在目录中置顶,则传0值"`
  214. NextGroupPptId int64 `description:"下一个目录里的ppt绑定序号,ppt最终在目录末尾,则传0值"`
  215. }
  216. type ReqMoveGroup struct {
  217. GroupId int64 `description:"目标目录id"`
  218. PrevGroupId int64 `description:"上一个目录Id,置顶,则传0值"`
  219. NextGroupId int64 `description:"下一个目录Id,放到末尾,则传0值"`
  220. }
  221. type ReqCopyPpt struct {
  222. GroupId int64 `description:"目录id"`
  223. PptId int `description:"PptId" `
  224. }
  225. type RespPptGroupNameList struct {
  226. List []*RespPptGroupName
  227. }
  228. type RespPptGroupName struct {
  229. GroupId int64 `gorm:"column:group_id` // `description:"目录id"`
  230. GroupName string `gorm:"column:group_name"` //`description:"目录名称"`
  231. }
  232. type RespSearchGroupPptList struct {
  233. List []*RespSearchGroupPptListItem
  234. }
  235. type RespSearchGroupPptListItem struct {
  236. GroupPptId int64 `description:"目录和ppt绑定序号"`
  237. PptId int64 `description:"ppt ID"`
  238. Title string `description:"标题"`
  239. }
  240. // ReqPptShareV2 共享ppt请求参数
  241. type ReqPptShareV2 struct {
  242. PptId int `description:"pptId"`
  243. }
  244. // RespPptShareV2 共享ppt返回参数
  245. type RespPptShareV2 struct {
  246. PptId int `description:"目录和ppt绑定自增序号"`
  247. IsShare int8 `description:"是否是单个共享ppt,0未单个共享,1共享"`
  248. }