123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- package data_manage
- import (
- "eta/eta_api/utils"
- "time"
- "github.com/beego/beego/v2/client/orm"
- )
- // BaseFromUsdaFasClassify UsdaFas原始数据分类表
- type BaseFromGprRiskClassify struct {
- ClassifyId int `orm:"column(classify_id);pk"`
- 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:"创建时间"`
- }
- // GetBaseFromGprRiskClassifyCount 获取分类名称的个数
- func GetBaseFromGprRiskClassifyCount(classifyName string, parentId int) (count int, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT COUNT(1) AS count FROM base_from_gpr_risk_classify WHERE classify_name=? AND parent_id=? `
- err = o.Raw(sql, classifyName, parentId).QueryRow(&count)
- return
- }
- // GetBaseFromGprRiskClassifyById 通过分类id的获取分类信息
- func GetBaseFromGprRiskClassifyById(classifyId int) (item *BaseFromGprRiskClassify, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_gpr_risk_classify WHERE classify_id=? `
- err = o.Raw(sql, classifyId).QueryRow(&item)
- return
- }
- // GetBaseFromGprRiskClassifyById 通过分类id的获取分类信息
- func GetBaseFromGprRiskClassifyByIds(classifyIds []int) (items []*BaseFromGprRiskClassify, err error) {
- if len(classifyIds) == 0 {
- return
- }
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_gpr_risk_classify WHERE classify_id IN (` + utils.GetOrmInReplace(len(classifyIds)) + `) `
- _, err = o.Raw(sql, classifyIds).QueryRows(&items)
- return
- }
- // EditBaseFromGprRiskClassify 修改GprRisk原始数据分类
- func EditBaseFromGprRiskClassify(classifyId int, classifyName string) (err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `UPDATE base_from_gpr_risk_classify SET classify_name=?,modify_time=NOW() WHERE classify_id=? `
- _, err = o.Raw(sql, classifyName, classifyId).Exec()
- return
- }
- // UpdateBaseFromGprRiskClassifySort 修改GprRisk原始数据分类的排序
- func UpdateBaseFromGprRiskClassifySort(classifyId int) (err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `UPDATE base_from_gpr_risk_classify SET sort=classify_id, modify_time=NOW() WHERE classify_id=? `
- _, err = o.Raw(sql, classifyId).Exec()
- return
- }
- type BaseFromGprRiskClassifyItems struct {
- ClassifyId int `description:"分类ID"`
- BaseFromGprRiskIndexId 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 []*BaseFromGprRiskClassifyItems
- }
- type BaseFromGprRiskClassifyNameItems struct {
- ClassifyId int `description:"分类ID"`
- ClassifyName string `description:"分类名称"`
- ParentId int `description:"父级id"`
- }
- type BaseFromGprRiskClassifyResp struct {
- List []*BaseFromGprRiskClassifyItems
- }
- type BaseFromGprRiskClassifyNameResp struct {
- List []*BaseFromGprRiskClassifyNameItems
- }
- type BaseFromGprRiskClassifyItemsButton struct {
- AddButton bool `description:"是否可添加"`
- OpButton bool `description:"是否可编辑"`
- DeleteButton bool `description:"是否可删除"`
- MoveButton bool `description:"是否可移动"`
- }
- // GetBaseFromGprRiskClassifyByParentId 根据上级id获取当下的分类列表数据
- func GetBaseFromGprRiskClassifyByParentId(parentId int) (items []*BaseFromGprRiskClassifyItems, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT * FROM base_from_gpr_risk_classify WHERE parent_id=? order by sort asc,classify_id asc`
- _, err = o.Raw(sql, parentId).QueryRows(&items)
- return
- }
- // GetAllBaseFromGprRiskClassify 获取所有的分类列表数据
- func GetAllBaseFromGprRiskClassify() (items []*BaseFromGprRiskClassifyItems, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT * FROM base_from_gpr_risk_classify order by parent_id asc, sort asc,classify_id asc`
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- type DeleteBaseFromGprRiskClassifyReq struct {
- ClassifyId int `description:"分类id"`
- EdbInfoId int `description:"指标id"`
- }
- type BaseFromGprRiskClassifyListResp struct {
- AllNodes []*BaseFromGprRiskClassifyItems
- CanOpClassify bool `description:"是否允许操作分类"`
- }
- type BaseFromGprRiskClassifySimplify struct {
- ClassifyId int `description:"分类id"`
- ClassifyName string `description:"分类名称"`
- ParentId int
- }
- // GetFirstBaseFromGprRiskClassify 获取当前分类下,且排序数相同 的排序第一条的数据
- func GetFirstBaseFromGprRiskClassify() (item *BaseFromGprRiskClassify, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT * FROM base_from_gpr_risk_classify order by sort asc,classify_id asc limit 1`
- err = o.Raw(sql).QueryRow(&item)
- return
- }
- // Update 更新分类基础信息
- func (BaseFromGprRiskClassify *BaseFromGprRiskClassify) Update(cols []string) (err error) {
- o := orm.NewOrmUsingDB("data")
- _, err = o.Update(BaseFromGprRiskClassify, cols...)
- return
- }
- type AddGprRiskClassifyResp struct {
- ClassifyId int
- }
|