123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- package ppt_english
- import (
- "time"
- "github.com/beego/beego/v2/client/orm"
- )
- type PptEnglishGroup struct {
- GroupId int64 `orm:"column(group_id);pk;auto" description:"ppt目录ID"`
- GroupName string `description:"目录名称"`
- AdminId int `description:"目录创建者账号ID"`
- IsShare int8 `description:"是否共享,0私有,1共享"`
- GroupSort int64 `description:"目录排序标识"`
- IsShareAdd int8 `description:"是否是通过单个ppt共享生成的目录,0不是,1-是"`
- CreateTime time.Time `orm:"auto_now_add;type(datetime)" description:"创建时间"`
- ModifyTime time.Time `orm:"auto_now;type(datetime)" description:"修改时间"`
- ShareTime time.Time `description:"分享时间"`
- }
- // GetPrivatePptGroups 获取私有目录
- func GetPrivatePptGroups(adminId int) (list []*PptEnglishGroup, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := "select * from ppt_english_group where admin_id=? order by group_sort asc, group_id asc"
- _, err = o.Raw(sql, adminId).QueryRows(&list)
- return
- }
- // GetPrivatePptGroupsByAdminId 获取用户自己的私有目录
- func GetPrivatePptGroupsByAdminId(adminId int) (list []*PptEnglishGroup, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := "select * from ppt_english_group where admin_id=? AND is_share_add=0 order by group_sort asc, group_id asc"
- _, err = o.Raw(sql, adminId).QueryRows(&list)
- return
- }
- // GetPublicPptGroups 获取ppt公共目录
- func GetPublicPptGroups() (list []*PptEnglishGroup, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := "select * from ppt_english_group where is_share=1 order by share_time asc, group_id asc"
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
- // GetPptGroupByName 根据目录名称查询
- func GetPptGroupByName(groupName string, adminId int) (item *PptEnglishGroup, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := "select * from ppt_english_group where admin_id=? and group_name=?"
- err = o.Raw(sql, adminId, groupName).QueryRow(&item)
- return
- }
- // GetPptGroupById 根据目录Id查询
- func GetPptGroupByGroupIdAdminId(groupId int64, adminId int) (item *PptEnglishGroup, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := "select * from ppt_english_group where admin_id=? and group_id=?"
- err = o.Raw(sql, adminId, groupId).QueryRow(&item)
- return
- }
- // GetPptGroupByGroupId 根据目录Id查询
- func GetPptGroupByGroupId(groupId int64) (item *PptEnglishGroup, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := "select * from ppt_english_group where group_id=?"
- err = o.Raw(sql, groupId).QueryRow(&item)
- return
- }
- // AddPptGroup 新增目录
- func AddPptGroup(item *PptEnglishGroup) (lastId int64, err error) {
- o := orm.NewOrmUsingDB("rddp")
- lastId, err = o.Insert(item)
- return
- }
- // DeletePptGroup 删除单个ppt目录
- func DeletePptGroup(groupId int64) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `DELETE FROM ppt_english_group WHERE group_id=? `
- _, err = o.Raw(sql, groupId).Exec()
- return
- }
- // DeletePptGroupByGroupIds 删除单个ppt目录
- func DeletePptGroupByGroupIds(groupIds string) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `DELETE FROM ppt_english_group WHERE group_id in ` + groupIds
- _, err = o.Raw(sql).Exec()
- return
- }
- // Update 更新ppt目录基础信息
- func (item *PptEnglishGroup) Update(cols []string) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- _, err = o.Update(item, cols...)
- return
- }
- // MoveUpGroupBySort 往上移动目录
- func MoveUpGroupBySort(nextSort, currentSort int64) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `update ppt_english_group set group_sort = group_sort + 1 where group_sort >= ? and group_sort< ?`
- _, err = o.Raw(sql, nextSort, currentSort).Exec()
- return
- }
- // MoveDownGroupBySort 往下移动目录
- func MoveDownGroupBySort(prevSort, currentSort int64) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `update ppt_english_group set group_sort = group_sort - 1 where group_sort <= ? and group_sort> ? `
- _, err = o.Raw(sql, prevSort, currentSort).Exec()
- return
- }
- // GetPptGroupNamesByAdminId 获取当前目录的所有名称
- func GetPptGroupNamesByAdminId(adminId int) (names []string, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := "select group_name from ppt_english_group where admin_id = ?"
- _, err = o.Raw(sql, adminId).QueryRows(&names)
- return
- }
- // GetPptGroupIdAndGroupNameByAdminId 查找分组名称和标识
- func GetPptGroupIdAndGroupNameByAdminId(adminId int) (list []*RespPptGroupName, err error) {
- o := orm.NewOrmUsingDB("rddp")
- 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"
- _, err = o.Raw(sql, adminId).QueryRows(&list)
- return
- }
- // AddPptGroupMappingMulti 批量新增ppt和目录的映射关系
- func AddPptGroupMulti(list []*PptEnglishGroup) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- _, err = o.InsertMulti(1, list)
- return
- }
- // UpdatePptGroupSortMulti 批量更新初始排序标识
- func UpdatePptGroupSortMulti(groupIds []int64) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- p, err := o.Raw("UPDATE ppt_english_group SET group_sort = group_id WHERE group_id = ?").Prepare()
- if err != nil {
- return
- }
- defer func() {
- _ = p.Close() // 别忘记关闭 statement
- }()
- for _, v := range groupIds {
- _, err = p.Exec(v)
- if err != nil {
- return
- }
- }
- return
- }
- type ReqAddPptGroup struct {
- GroupName string `description:"目录名称"`
- }
- type RespAddPptGroup struct {
- GroupId int64 `description:"目录id"`
- }
- type ReqPptGroup struct {
- GroupId int64 `description:"目录id"`
- }
- type ReqRenamePptGroup struct {
- GroupId int64 `description:"目录id"`
- GroupName string `description:"目录名称"`
- }
- type RespPptGroupShare struct {
- GroupId int64 `description:"目录id"`
- IsShare int8 `description:"是否共享,0私有,1共享"`
- }
- type RespGroupList struct {
- PublicList []*RespGroupListItem
- PrivateList []*RespGroupListItem
- GrantList []RespGroupListItem
- }
- type RespGroupListItem struct {
- GroupId int64 `description:"目录id"`
- GroupName string `description:"目录名称"`
- AdminId int `description:"目录创建者账号ID"`
- IsShare int8 `description:"是否共享,0私有,1共享"`
- OnlyOld bool `description:"是否只包含ppt旧版本的目录,只包含旧版的ppt:true,否则 false"`
- PptList []*RespGroupPptNameListItem
- //GroupSort int64 `description:"目录排序标识"`
- //IsShareAdd int8 `description:"是否是通过单个ppt共享生成的目录,0不是,1-是"`
- //CreateTime string `description:"创建时间"`
- //ModifyTime string `description:"修改时间"`
- }
- type RespGroupPptNameListItem struct {
- GroupPptId int64 `description:"目录和ppt绑定序号"`
- PptId int64 `description:"ppt ID"`
- Title string `description:"标题"`
- AdminId int `description:"移动ppt到该目录的系统用户id"`
- AdminRealName string `description:"系统用户名称"`
- PptVersion int8 `description:"是否ppt的旧版本;1:旧的,2:新的"`
- IsSingleShare int8 `description:"是否是单个共享ppt,0未单个共享,1共享"`
- PptxUrl string `description:"pptx下载地址"`
- ReportId int `description:"关联的报告ID"`
- ReportCode string `description:"关联的报告code"`
- PptCreateTime string `description:"ppt创建时间"`
- PptModifyTime string `description:"ppt修改时间"`
- PublishTime string `description:"发布时间"`
- PptPage int `description:"PPT总页数"`
- IsReceived int8 `description:"是否收到的共享,0:不是,1:是"`
- IsGrant int8 `description:"是否分配了权限,0:不是,1:是"`
- TitleSetting string `description:"PPT标题设置"`
- }
- type RespGroupPptListItem struct {
- GroupPptId int64 `description:"目录和ppt绑定序号"`
- PptId int64 `description:"ppt ID"`
- TemplateType int `description:"模版类型"`
- BackgroundImg string `description:"背景图片"`
- Title string `description:"标题"`
- PptCreateTime string `description:"ppt创建时间"`
- PptModifyTime string `description:"ppt修改时间"`
- AdminId int `description:"移动ppt到该目录的系统用户id"`
- AdminRealName string `description:"系统用户名称"`
- PptVersion int8 `description:"是否ppt的旧版本;1:旧的,2:新的"`
- IsSingleShare int8 `description:"是否是单个共享ppt,0未单个共享,1共享"`
- PptxUrl string `description:"pptx下载地址"`
- PptPage int `description:"PPT总页数"`
- ReportId int `description:"关联的报告ID"`
- ReportCode string `description:"关联的报告code"`
- PublishTime string `description:"发布时间"`
- Editor PPTEditingCache `description:"编辑人信息"`
- }
- func (p RespGroupPptList) Len() int {
- return len(p.List)
- }
- func (p RespGroupPptList) Less(i, j int) bool {
- if p.List[i].PptCreateTime < p.List[j].PptCreateTime {
- return false
- }
- return true
- }
- func (p RespGroupPptList) Swap(i, j int) {
- p.List[i], p.List[j] = p.List[j], p.List[i]
- }
- type ReqPptShare struct {
- GroupPptId int64 `description:"目录和ppt绑定序号"`
- }
- type RespPptShare struct {
- GroupPptId int64 `description:"目录和ppt绑定自增序号"`
- IsSingleShare int8 `description:"是否是单个共享ppt,0未单个共享,1共享"`
- }
- type RespGroupPptList struct {
- List []*RespGroupPptListItem
- Total int `description:"ppt总数"`
- }
- type ReqMoveGroupPpt struct {
- GroupId int64 `description:"目标目录id"`
- GroupPptId int64 `description:"当前被移动的目录里的ppt绑定序号"`
- PrevGroupPptId int64 `description:"上一个目录里的ppt绑定序号,ppt最终在目录中置顶,则传0值"`
- NextGroupPptId int64 `description:"下一个目录里的ppt绑定序号,ppt最终在目录末尾,则传0值"`
- }
- type ReqMoveGroup struct {
- GroupId int64 `description:"目标目录id"`
- PrevGroupId int64 `description:"上一个目录Id,置顶,则传0值"`
- NextGroupId int64 `description:"下一个目录Id,放到末尾,则传0值"`
- }
- type ReqCopyPpt struct {
- GroupId int64 `description:"目录id"`
- PptId int `description:"PptId" `
- }
- type RespPptGroupNameList struct {
- List []*RespPptGroupName
- }
- type RespPptGroupName struct {
- GroupId int64 `description:"目录id"`
- GroupName string `description:"目录名称"`
- }
- type RespSearchGroupPptList struct {
- List []*RespSearchGroupPptListItem
- }
- type RespSearchGroupPptListItem struct {
- GroupPptId int64 `description:"目录和ppt绑定序号"`
- PptId int64 `description:"ppt ID"`
- Title string `description:"标题"`
- }
- // ReqPptShareEnglish 共享ppt请求参数
- type ReqPptShareEnglish struct {
- PptId int `description:"pptId"`
- }
- // RespPptShareEnglish 共享ppt返回参数
- type RespPptShareEnglish struct {
- PptId int `description:"目录和ppt绑定自增序号"`
- IsShare int8 `description:"是否是单个共享ppt,0未单个共享,1共享"`
- }
|