123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- package material
- import (
- "eta/eta_mobile/utils"
- "fmt"
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type MaterialClassify struct {
- ClassifyId int `orm:"column(classify_id);pk"`
- ClassifyName string `description:"分类名称"`
- ClassifyNameEn string `description:"英文分类名称"`
- ParentId int `description:"父级id"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- SysUserId int `description:"创建人id"`
- SysUserRealName string `description:"创建人姓名"`
- Level int `description:"层级"`
- Sort int `description:"排序字段,越小越靠前,默认值:10"`
- LevelPath string `description:"层级路径"`
- }
- func AddMaterialClassify(item *MaterialClassify) (lastId int64, err error) {
- o := orm.NewOrmUsingDB("rddp")
- lastId, err = o.Insert(item)
- return
- }
- // GetMaterialClassifyByParentId
- func GetMaterialClassifyByParentId(parentId int) (items []*MaterialClassifyItems, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := ` SELECT * FROM material_classify WHERE parent_id=? order by sort asc,classify_id asc`
- _, err = o.Raw(sql, parentId).QueryRows(&items)
- return
- }
- // GetMaterialClassifyAll
- func GetMaterialClassifyAll() (items []*MaterialClassifyItems, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := ` SELECT * FROM material_classify WHERE parent_id<>0 order by sort asc,classify_id asc`
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- type MaterialClassifyItems struct {
- ClassifyId int `orm:"column(classify_id);pk"`
- ClassifyName string `description:"分类名称"`
- ClassifyNameEn string `description:"英文分类名称"`
- ParentId int `description:"父级id"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- SysUserId int `description:"创建人id"`
- SysUserName string `description:"创建人姓名"`
- Level int `description:"层级"`
- Sort int `description:"排序字段,越小越靠前,默认值:10"`
- Children []*MaterialClassifyItems
- }
- type MaterialClassifyListResp struct {
- AllNodes []*MaterialClassifyItems
- }
- type AddMaterialClassifyReq struct {
- ClassifyName string `description:"分类名称"`
- ParentId int `description:"父级id,第一级传0"`
- //Level int `description:"层级,第一级传0,其余传上一级的层级"`
- }
- func GetMaterialClassifyNameCount(classifyName string, parentId int) (count int, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT COUNT(1) AS count FROM material_classify WHERE parent_id=? AND classify_name=? `
- err = o.Raw(sql, parentId, classifyName).QueryRow(&count)
- return
- }
- func GetMaterialClassifyNameEnCount(classifyName string, parentId int) (count int, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT COUNT(1) AS count FROM material_classify WHERE parent_id=? AND classify_name_en=? `
- err = o.Raw(sql, parentId, classifyName).QueryRow(&count)
- return
- }
- func GetMaterialClassifyNameNotSelfCount(id int, classifyName string, parentId int) (count int, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT COUNT(1) AS count FROM material_classify WHERE classify_id !=? AND parent_id=? AND classify_name=? `
- err = o.Raw(sql, id, parentId, classifyName).QueryRow(&count)
- return
- }
- func GetMaterialClassifyNameEnNotSelfCount(id int, classifyName string, parentId int) (count int, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT COUNT(1) AS count FROM material_classify WHERE classify_id !=? AND parent_id=? AND classify_name_en=? `
- err = o.Raw(sql, id, parentId, classifyName).QueryRow(&count)
- return
- }
- // GetMaterialClassifyMaxSort 获取沙盘分类下最大的排序数
- func GetMaterialClassifyMaxSort(parentId int) (sort int, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT MAX(sort) AS sort FROM material_classify WHERE parent_id=? `
- err = o.Raw(sql, parentId).QueryRow(&sort)
- return
- }
- type EditMaterialClassifyReq struct {
- ClassifyName string `description:"分类名称"`
- ClassifyId int `description:"分类id"`
- }
- func GetMaterialClassifyById(classifyId int) (item *MaterialClassify, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT * FROM material_classify WHERE classify_id=? `
- err = o.Raw(sql, classifyId).QueryRow(&item)
- return
- }
- type MaterialClassifyDeleteCheckReq struct {
- ClassifyId int `description:"分类id"`
- }
- type MaterialClassifyDeleteCheckResp struct {
- DeleteStatus int `description:"检测状态:0:默认值,如果为0,继续走其他校验,1:该分类下关联图表不可删除,2:确认删除当前目录及包含的子目录吗"`
- TipsMsg string `description:"提示信息"`
- }
- type DeleteMaterialClassifyReq struct {
- ClassifyId int `description:"分类id"`
- // MaterialId int `description:"素材id"`
- }
- func DeleteMaterialClassify(classifyIds []string) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := ` DELETE FROM material_classify WHERE classify_id IN(` + utils.GetOrmInReplace(len(classifyIds)) + `) `
- _, err = o.Raw(sql, classifyIds).Exec()
- return
- }
- // MoveMaterialClassifyReq 移动沙盘分类请求参数
- type MoveMaterialClassifyReq struct {
- ClassifyId int `description:"分类id"`
- //MaterialId int `description:"沙盘ID"`
- ParentClassifyId int `description:"目标父级分类id"`
- PrevClassifyId int `description:"上一个兄弟节点分类id"`
- NextClassifyId int `description:"下一个兄弟节点分类id"`
- //PrevType int `description:"上一个兄弟节点类型 1分类 2沙盘 "`
- //NextType int `description:"上一个兄弟节点类型 1分类 2沙盘 "`
- }
- // UpdateMaterialClassifySortByParentId 根据沙盘父类id更新排序
- func UpdateMaterialClassifySortByParentId(parentId, classifyId, nowSort int, updateSort string) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := ` update material_classify set sort = ` + updateSort + ` WHERE parent_id=? and sort > ? `
- if classifyId > 0 {
- sql += ` or ( classify_id > ` + fmt.Sprint(classifyId) + ` and sort= ` + fmt.Sprint(nowSort) + `)`
- }
- _, err = o.Raw(sql, parentId, nowSort).Exec()
- return
- }
- // GetFirstMaterialClassifyByParentId 获取当前父级沙盘分类下的排序第一条的数据
- func GetFirstMaterialClassifyByParentId(parentId int) (item *MaterialClassify, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := ` SELECT * FROM material_classify WHERE parent_id=? order by sort asc,classify_id asc limit 1`
- err = o.Raw(sql, parentId).QueryRow(&item)
- return
- }
- // Update 更新沙盘分类基础信息
- func (m *MaterialClassify) Update(cols []string) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- _, err = o.Update(m, cols...)
- return
- }
- // GetMaterialClassifyAndInfoByParentId
- func GetMaterialClassifyAndInfoByParentId(parentId int) (items []*MaterialClassifyItems, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := ` SELECT *
- FROM
- material_classify
- WHERE
- parent_id = ?
- ORDER BY
- sort ASC,
- classify_id ASC`
- _, err = o.Raw(sql, parentId).QueryRows(&items)
- return
- }
- type SandboxLinkCheckReq struct {
- EdbInfoIdList []int `description:"指标id列表"`
- ChartInfoIdList []int `description:"图库id列表"`
- ReportIdList []int `description:"报告id列表"`
- }
- type SandboxLinkCheckItem struct {
- Id int `description:"id"`
- Name string `description:"名称"`
- UniqueCode string `description:"唯一编码"`
- ClassifyId int `description:"分类id"`
- }
- type SandboxLinkCheckResp struct {
- EdbInfoIdList []*SandboxLinkCheckItem `description:"指标id列表"`
- ChartInfoIdList []*SandboxLinkCheckItem `description:"图库id列表"`
- ReportIdList []*SandboxLinkCheckItem `description:"报告id列表"`
- }
- func GetMaterialClassifyByLevelPath(levelPath string) (items []*MaterialClassify, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT * FROM material_classify where level_path like "` + levelPath + `%"`
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
|