123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- package data_manage
- import (
- "eta/eta_api/global"
- "eta/eta_api/utils"
- "time"
- )
- // BaseFromPurangClassify Purang原始数据分类表
- type BaseFromPurangClassify struct {
- ClassifyId int `orm:"column(classify_id);pk" gorm:"column:classify_id;primary_key"`
- ClassifyName string `description:"分类名称"`
- ParentId int `description:"父级id"`
- SysUserId int `description:"创建人id"`
- SysUserRealName string `description:"创建人姓名"`
- Level int `description:"层级"`
- Sort int `description:"排序字段,越小越靠前,默认值:10"`
- ModifyTime time.Time `description:"修改时间"`
- CreateTime time.Time `description:"创建时间"`
- }
- // GetBaseFromPurangClassifyCount 获取分类名称的个数
- func GetBaseFromPurangClassifyCount(classifyName string, parentId int) (count int, err error) {
- sql := `SELECT COUNT(1) AS count FROM base_from_purang_classify WHERE classify_name=? AND parent_id=? `
- err = global.DbMap[utils.DbNameIndex].Raw(sql, classifyName, parentId).Scan(&count).Error
- return
- }
- // GetBaseFromPurangClassifyById 通过分类id的获取分类信息
- func GetBaseFromPurangClassifyById(classifyId int) (item *BaseFromPurangClassify, err error) {
- sql := `SELECT * FROM base_from_purang_classify WHERE classify_id=? `
- err = global.DbMap[utils.DbNameIndex].Raw(sql, classifyId).Find(&item).Error
- return
- }
- // GetBaseFromPurangClassifyByIds 通过分类id的获取分类信息
- func GetBaseFromPurangClassifyByIds(classifyIds []int) (items []*BaseFromPurangClassify, err error) {
- if len(classifyIds) == 0 {
- return
- }
- sql := `SELECT * FROM base_from_purang_classify WHERE classify_id IN (` + utils.GetOrmInReplace(len(classifyIds)) + `) `
- err = global.DbMap[utils.DbNameIndex].Raw(sql, classifyIds).Find(&items).Error
- return
- }
- // EditBaseFromPurangClassify 修改Purang原始数据分类
- func EditBaseFromPurangClassify(classifyId int, classifyName string) (err error) {
- sql := `UPDATE base_from_purang_classify SET classify_name=?,modify_time=NOW() WHERE classify_id=? `
- err = global.DbMap[utils.DbNameIndex].Exec(sql, classifyName, classifyId).Error
- return
- }
- // UpdateBaseFromPurangClassifySort 修改Purang原始数据分类的排序
- func UpdateBaseFromPurangClassifySort(classifyId int) (err error) {
- sql := `UPDATE base_from_purang_classify SET sort=classify_id, modify_time=NOW() WHERE classify_id=? `
- err = global.DbMap[utils.DbNameIndex].Exec(sql, classifyId).Error
- return
- }
- type BaseFromPurangClassifyItems struct {
- ClassifyId int `description:"分类ID"`
- BaseFromPurangIndexId int `description:"指标类型ID"`
- IndexCode string `description:"指标唯一编码"`
- ClassifyName string `description:"分类名称"`
- ClassifyNameEn string `description:"分类名称"`
- UniqueCode string `description:"分类唯一编码"`
- ParentId int `description:"父级id"`
- Level int `description:"层级"`
- Sort int `description:"排序字段,越小越靠前,默认值:10"`
- Children []*BaseFromPurangClassifyItems `gorm:"-"`
- }
- type BaseFromPurangClassifyNameItems struct {
- ClassifyId int `description:"分类ID"`
- ClassifyName string `description:"分类名称"`
- ParentId int `description:"父级id"`
- }
- type BaseFromPurangClassifyResp struct {
- List []*BaseFromPurangClassifyItems
- }
- type BaseFromPurangClassifyNameResp struct {
- List []*BaseFromPurangClassifyNameItems
- }
- type BaseFromPurangClassifyItemsButton struct {
- AddButton bool `description:"是否可添加"`
- OpButton bool `description:"是否可编辑"`
- DeleteButton bool `description:"是否可删除"`
- MoveButton bool `description:"是否可移动"`
- }
- // GetBaseFromPurangClassifyByParentId 根据上级id获取当下的分类列表数据
- func GetBaseFromPurangClassifyByParentId(parentId int) (items []*BaseFromPurangClassifyItems, err error) {
- sql := ` SELECT * FROM base_from_purang_classify WHERE parent_id=? order by sort asc,classify_id asc`
- err = global.DbMap[utils.DbNameIndex].Raw(sql, parentId).Find(&items).Error
- return
- }
- // GetAllBaseFromPurangClassify 获取所有的分类列表数据
- func GetAllBaseFromPurangClassify() (items []*BaseFromPurangClassifyItems, err error) {
- sql := ` SELECT * FROM base_from_purang_classify order by parent_id asc, sort asc,classify_id asc`
- err = global.DbMap[utils.DbNameIndex].Raw(sql).Find(&items).Error
- return
- }
- type DeleteBaseFromPurangClassifyReq struct {
- ClassifyId int `description:"分类id"`
- EdbInfoId int `description:"指标id"`
- }
- type BaseFromPurangClassifyListResp struct {
- AllNodes []*BaseFromPurangClassifyItems
- CanOpClassify bool `description:"是否允许操作分类"`
- }
- type BaseFromPurangClassifySimplify struct {
- ClassifyId int `description:"分类id"`
- ClassifyName string `description:"分类名称"`
- ParentId int
- }
- // GetFirstBaseFromPurangClassify 获取当前分类下,且排序数相同 的排序第一条的数据
- func GetFirstBaseFromPurangClassify() (item *BaseFromPurangClassify, err error) {
- sql := ` SELECT * FROM base_from_purang_classify order by sort asc,classify_id asc limit 1`
- err = global.DbMap[utils.DbNameIndex].Raw(sql).First(&item).Error
- return
- }
- // Update 更新分类基础信息
- func (BaseFromPurangClassify *BaseFromPurangClassify) Update(cols []string) (err error) {
- err = global.DbMap[utils.DbNameIndex].Select(cols).Updates(BaseFromPurangClassify).Error
- return
- }
- type AddPurangClassifyResp struct {
- ClassifyId int
- }
|