base_from_gpr_risk_classify.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package data_manage
  2. import (
  3. "eta/eta_api/utils"
  4. "time"
  5. "github.com/beego/beego/v2/client/orm"
  6. )
  7. // BaseFromUsdaFasClassify UsdaFas原始数据分类表
  8. type BaseFromGprRiskClassify struct {
  9. ClassifyId int `orm:"column(classify_id);pk"`
  10. ClassifyName string `description:"分类名称"`
  11. ParentId int `description:"父级id"`
  12. SysUserId int `description:"创建人id"`
  13. SysUserRealName string `description:"创建人姓名"`
  14. Level int `description:"层级"`
  15. Sort int `description:"排序字段,越小越靠前,默认值:10"`
  16. ModifyTime time.Time `description:"修改时间"`
  17. CreateTime time.Time `description:"创建时间"`
  18. }
  19. // GetBaseFromGprRiskClassifyCount 获取分类名称的个数
  20. func GetBaseFromGprRiskClassifyCount(classifyName string, parentId int) (count int, err error) {
  21. o := orm.NewOrmUsingDB("data")
  22. sql := `SELECT COUNT(1) AS count FROM base_from_gpr_risk_classify WHERE classify_name=? AND parent_id=? `
  23. err = o.Raw(sql, classifyName, parentId).QueryRow(&count)
  24. return
  25. }
  26. // GetBaseFromGprRiskClassifyById 通过分类id的获取分类信息
  27. func GetBaseFromGprRiskClassifyById(classifyId int) (item *BaseFromGprRiskClassify, err error) {
  28. o := orm.NewOrmUsingDB("data")
  29. sql := `SELECT * FROM base_from_gpr_risk_classify WHERE classify_id=? `
  30. err = o.Raw(sql, classifyId).QueryRow(&item)
  31. return
  32. }
  33. // GetBaseFromGprRiskClassifyById 通过分类id的获取分类信息
  34. func GetBaseFromGprRiskClassifyByIds(classifyIds []int) (items []*BaseFromGprRiskClassify, err error) {
  35. if len(classifyIds) == 0 {
  36. return
  37. }
  38. o := orm.NewOrmUsingDB("data")
  39. sql := `SELECT * FROM base_from_gpr_risk_classify WHERE classify_id IN (` + utils.GetOrmInReplace(len(classifyIds)) + `) `
  40. _, err = o.Raw(sql, classifyIds).QueryRows(&items)
  41. return
  42. }
  43. // EditBaseFromGprRiskClassify 修改GprRisk原始数据分类
  44. func EditBaseFromGprRiskClassify(classifyId int, classifyName string) (err error) {
  45. o := orm.NewOrmUsingDB("data")
  46. sql := `UPDATE base_from_gpr_risk_classify SET classify_name=?,modify_time=NOW() WHERE classify_id=? `
  47. _, err = o.Raw(sql, classifyName, classifyId).Exec()
  48. return
  49. }
  50. // UpdateBaseFromGprRiskClassifySort 修改GprRisk原始数据分类的排序
  51. func UpdateBaseFromGprRiskClassifySort(classifyId int) (err error) {
  52. o := orm.NewOrmUsingDB("data")
  53. sql := `UPDATE base_from_gpr_risk_classify SET sort=classify_id, modify_time=NOW() WHERE classify_id=? `
  54. _, err = o.Raw(sql, classifyId).Exec()
  55. return
  56. }
  57. type BaseFromGprRiskClassifyItems struct {
  58. ClassifyId int `description:"分类ID"`
  59. BaseFromGprRiskIndexId int `description:"指标类型ID"`
  60. IndexCode string `description:"指标唯一编码"`
  61. ClassifyName string `description:"分类名称"`
  62. ClassifyNameEn string `description:"分类名称"`
  63. UniqueCode string `description:"分类唯一编码"`
  64. ParentId int `description:"父级id"`
  65. Level int `description:"层级"`
  66. Sort int `description:"排序字段,越小越靠前,默认值:10"`
  67. Children []*BaseFromGprRiskClassifyItems
  68. }
  69. type BaseFromGprRiskClassifyNameItems struct {
  70. ClassifyId int `description:"分类ID"`
  71. ClassifyName string `description:"分类名称"`
  72. ParentId int `description:"父级id"`
  73. }
  74. type BaseFromGprRiskClassifyResp struct {
  75. List []*BaseFromGprRiskClassifyItems
  76. }
  77. type BaseFromGprRiskClassifyNameResp struct {
  78. List []*BaseFromGprRiskClassifyNameItems
  79. }
  80. type BaseFromGprRiskClassifyItemsButton struct {
  81. AddButton bool `description:"是否可添加"`
  82. OpButton bool `description:"是否可编辑"`
  83. DeleteButton bool `description:"是否可删除"`
  84. MoveButton bool `description:"是否可移动"`
  85. }
  86. // GetBaseFromGprRiskClassifyByParentId 根据上级id获取当下的分类列表数据
  87. func GetBaseFromGprRiskClassifyByParentId(parentId int) (items []*BaseFromGprRiskClassifyItems, err error) {
  88. o := orm.NewOrmUsingDB("data")
  89. sql := ` SELECT * FROM base_from_gpr_risk_classify WHERE parent_id=? order by sort asc,classify_id asc`
  90. _, err = o.Raw(sql, parentId).QueryRows(&items)
  91. return
  92. }
  93. // GetAllBaseFromGprRiskClassify 获取所有的分类列表数据
  94. func GetAllBaseFromGprRiskClassify() (items []*BaseFromGprRiskClassifyItems, err error) {
  95. o := orm.NewOrmUsingDB("data")
  96. sql := ` SELECT * FROM base_from_gpr_risk_classify order by parent_id asc, sort asc,classify_id asc`
  97. _, err = o.Raw(sql).QueryRows(&items)
  98. return
  99. }
  100. type DeleteBaseFromGprRiskClassifyReq struct {
  101. ClassifyId int `description:"分类id"`
  102. EdbInfoId int `description:"指标id"`
  103. }
  104. type BaseFromGprRiskClassifyListResp struct {
  105. AllNodes []*BaseFromGprRiskClassifyItems
  106. CanOpClassify bool `description:"是否允许操作分类"`
  107. }
  108. type BaseFromGprRiskClassifySimplify struct {
  109. ClassifyId int `description:"分类id"`
  110. ClassifyName string `description:"分类名称"`
  111. ParentId int
  112. }
  113. // GetFirstBaseFromGprRiskClassify 获取当前分类下,且排序数相同 的排序第一条的数据
  114. func GetFirstBaseFromGprRiskClassify() (item *BaseFromGprRiskClassify, err error) {
  115. o := orm.NewOrmUsingDB("data")
  116. sql := ` SELECT * FROM base_from_gpr_risk_classify order by sort asc,classify_id asc limit 1`
  117. err = o.Raw(sql).QueryRow(&item)
  118. return
  119. }
  120. // Update 更新分类基础信息
  121. func (BaseFromGprRiskClassify *BaseFromGprRiskClassify) Update(cols []string) (err error) {
  122. o := orm.NewOrmUsingDB("data")
  123. _, err = o.Update(BaseFromGprRiskClassify, cols...)
  124. return
  125. }
  126. type AddGprRiskClassifyResp struct {
  127. ClassifyId int
  128. }