package models import ( "eta_gn/eta_api/global" "eta_gn/eta_api/utils" "time" ) type PptV2Group struct { GroupId int64 `gorm:"column:group_id;primaryKey;autoIncrement" description:"ppt目录ID"` GroupName string `gorm:"column:group_name" description:"目录名称"` AdminId int `gorm:"column:admin_id" description:"目录创建者账号ID"` IsShare int8 `gorm:"column:is_share" description:"是否共享,0私有,1共享"` GroupSort int64 `gorm:"column:group_sort" description:"目录排序标识"` IsShareAdd int8 `gorm:"column:is_share_add" description:"是否是通过单个ppt共享生成的目录,0不是,1-是"` CreateTime time.Time `gorm:"column:create_time;autoCreateTime" description:"创建时间"` ModifyTime time.Time `gorm:"column:modify_time;autoUpdateTime" description:"修改时间"` ShareTime time.Time `gorm:"column:share_time" description:"分享时间"` } // GetPrivatePptGroups 获取私有目录 func GetPrivatePptGroups(adminId int) (list []*PptV2Group, err error) { sql := "select * from ppt_v2_group where admin_id=? order by group_sort asc, group_id asc" err = global.DmSQL["rddp"].Raw(sql, adminId).Find(&list).Error return } // GetPrivatePptGroupsByAdminId 获取用户自己的私有目录 func GetPrivatePptGroupsByAdminId(adminId int) (list []*PptV2Group, err error) { sql := "select * from ppt_v2_group where admin_id=? AND is_share_add=0 order by group_sort asc, group_id asc" err = global.DmSQL["rddp"].Raw(sql, adminId).Find(&list).Error return } // GetPublicPptGroups 获取ppt公共目录 func GetPublicPptGroups() (list []*PptV2Group, err error) { sql := "select * from ppt_v2_group where is_share=1 order by share_time asc, group_id asc" err = global.DmSQL["rddp"].Raw(sql).Find(&list).Error return } // GetPptGroupByName 根据目录名称查询 func GetPptGroupByName(groupName string, adminId int) (item *PptV2Group, err error) { sql := "select * from ppt_v2_group where admin_id=? and group_name=?" err = global.DmSQL["rddp"].Raw(sql, adminId, groupName).Find(&item).Error return } // GetPptGroupById 根据目录Id查询 func GetPptGroupByGroupIdAdminId(groupId int64, adminId int) (item *PptV2Group, err error) { sql := "select * from ppt_v2_group where admin_id=? and group_id=?" err = global.DmSQL["rddp"].Raw(sql, adminId, groupId).First(&item).Error return } // GetPptGroupByGroupId 根据目录Id查询 func GetPptGroupByGroupId(groupId int64) (item *PptV2Group, err error) { sql := "select * from ppt_v2_group where group_id=?" err = global.DmSQL["rddp"].Raw(sql, groupId).First(&item).Error return } // AddPptGroup 新增目录 func AddPptGroup(item *PptV2Group) (lastId int64, err error) { err = global.DmSQL["rddp"].Create(item).Error lastId = item.GroupId return } // DeletePptGroup 删除单个ppt目录 func DeletePptGroup(groupId int64) (err error) { sql := `DELETE FROM ppt_v2_group WHERE group_id=? ` err = global.DmSQL["rddp"].Exec(sql, groupId).Error return } // DeletePptGroupByGroupIds 删除单个ppt目录 func DeletePptGroupByGroupIds(groupIds string) (err error) { sql := `DELETE FROM ppt_v2_group WHERE group_id in ` + groupIds err = global.DmSQL["rddp"].Exec(sql).Error return } // Update 更新ppt目录基础信息 func (item *PptV2Group) Update(cols []string) (err error) { err = global.DmSQL["rddp"].Select(cols).Updates(item).Error return } // MoveUpGroupBySort 往上移动目录 func MoveUpGroupBySort(nextSort, currentSort int64) (err error) { sql := `update ppt_v2_group set group_sort = group_sort + 1 where group_sort >= ? and group_sort< ?` err = global.DmSQL["rddp"].Exec(sql, nextSort, currentSort).Error return } // MoveDownGroupBySort 往下移动目录 func MoveDownGroupBySort(prevSort, currentSort int64) (err error) { sql := `update ppt_v2_group set group_sort = group_sort - 1 where group_sort <= ? and group_sort> ? ` err = global.DmSQL["rddp"].Exec(sql, prevSort, currentSort).Error return } // GetPptGroupNamesByAdminId 获取当前目录的所有名称 func GetPptGroupNamesByAdminId(adminId int) (names []string, err error) { sql := "select group_name from ppt_v2_group where admin_id = ?" err = global.DmSQL["rddp"].Raw(sql, adminId).Scan(&names).Error return } // GetPptGroupIdAndGroupNameByAdminId 查找分组名称和标识 func GetPptGroupIdAndGroupNameByAdminId(adminId int) (list []*RespPptGroupName, err error) { 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" err = global.DmSQL["rddp"].Raw(sql, adminId).Find(&list).Error return } // AddPptGroupMappingMulti 批量新增ppt和目录的映射关系 func AddPptGroupMulti(list []*PptV2Group) (err error) { err = global.DmSQL["rddp"].CreateInBatches(list, utils.MultiAddNum).Error return } // UpdatePptGroupSortMulti 批量更新初始排序标识 func UpdatePptGroupSortMulti(groupIds []int64) (err error) { tx := global.DmSQL["rddp"].Begin() for _, v := range groupIds { err = tx.Exec("UPDATE ppt_v2_group SET group_sort = group_id WHERE group_id = ?", v).Error if err != nil { tx.Rollback() return } } tx.Commit() 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 } 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 `gorm:"column:group_id` // `description:"目录id"` GroupName string `gorm:"column:group_name"` //`description:"目录名称"` } type RespSearchGroupPptList struct { List []*RespSearchGroupPptListItem } type RespSearchGroupPptListItem struct { GroupPptId int64 `description:"目录和ppt绑定序号"` PptId int64 `description:"ppt ID"` Title string `description:"标题"` } // ReqPptShareV2 共享ppt请求参数 type ReqPptShareV2 struct { PptId int `description:"pptId"` } // RespPptShareV2 共享ppt返回参数 type RespPptShareV2 struct { PptId int `description:"目录和ppt绑定自增序号"` IsShare int8 `description:"是否是单个共享ppt,0未单个共享,1共享"` }