ppt_english_group.go 11 KB

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