excel_info_rule_mapping.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package models
  2. import (
  3. "eta/eta_chart_lib/global"
  4. "eta/eta_chart_lib/utils"
  5. "time"
  6. )
  7. type ExcelInfoRuleMapping struct {
  8. //ExcelInfoRuleMappingId int `orm:"pk" description:"主键"`
  9. ExcelInfoRuleMappingId int `gorm:"primaryKey"`
  10. ExcelInfoId int `description:"Excel信息ID"`
  11. RuleType int `description:"规则类型"`
  12. LeftValue string `description:"左值"`
  13. LeftValueShow string `description:"左值前端显示"`
  14. LeftValueType int `description:"左值类型"`
  15. RightValue string `description:"右值"`
  16. RightValueShow string `description:"右值前端显示"`
  17. RightValueType int `description:"右值类型"`
  18. FontColor string `description:"字体颜色"`
  19. BackgroundColor string `description:"背景颜色"`
  20. Remark string `description:"预设颜色说明"`
  21. RemarkEn string `description:"预设颜色英文说明"`
  22. Scope string `description:"作用范围"`
  23. ScopeCoord string `description:"作用范围坐标"`
  24. ScopeShow string `description:"作用范围坐标前端显示"`
  25. CreateTime time.Time `description:"创建时间"`
  26. }
  27. type ExcelInfoRuleMappingView struct {
  28. //ExcelInfoRuleMappingId int `orm:"pk" description:"主键"`
  29. ExcelInfoRuleMappingId int `gorm:"primaryKey"`
  30. ExcelInfoId int `description:"Excel信息ID"`
  31. RuleType int `description:"规则类型:1-大于,2-小于,3-介于,4-等于,5-发生日期"`
  32. LeftValue string `description:"左值"`
  33. LeftValueBack string `description:"左值前端显示"`
  34. LeftValueType int `description:"左值类型"`
  35. RightValue string `description:"右值"`
  36. RightValueBack string `description:"右值前端显示"`
  37. RightValueType int `description:"右值类型"`
  38. FontColor string `description:"字体颜色"`
  39. BackgroundColor string `description:"背景颜色"`
  40. Remark string `description:"预设颜色说明"`
  41. RemarkEn string `description:"预设颜色英文说明"`
  42. Scope string `description:"作用范围"`
  43. ScopeCoord string `description:"作用范围坐标"`
  44. ScopeShow string `description:"作用范围坐标前端显示"`
  45. CreateTime string `description:"创建时间"`
  46. }
  47. func (e *ExcelInfoRuleMapping) Insert() (insertId int64, err error) {
  48. //o := orm.NewOrmUsingDB("data")
  49. //insertId, err = o.Insert(e)
  50. err = global.DbMap[utils.DbNameIndex].Create(&e).Error
  51. if err != nil {
  52. return
  53. }
  54. insertId = int64(e.ExcelInfoRuleMappingId)
  55. return
  56. }
  57. func (e *ExcelInfoRuleMapping) Update(cols []string) (err error) {
  58. //o := orm.NewOrmUsingDB("data")
  59. //_, err = o.Update(e, cols...)
  60. err = global.DbMap[utils.DbNameIndex].Model(&e).Select(cols).Updates(&e).Error
  61. return
  62. }
  63. // GetExcelRuleMappingByExcelInfoId 根据excelInfoId获取规则映射信息
  64. func GetExcelRuleMappingByExcelInfoId(id int) (items []*ExcelInfoRuleMappingView, err error) {
  65. //o := orm.NewOrmUsingDB("data")
  66. sql := `SELECT * FROM excel_info_rule_mapping WHERE excel_info_id = ? ORDER BY create_time ASC`
  67. //_, err = o.Raw(sql, id).QueryRows(&items)
  68. err = global.DbMap[utils.DbNameIndex].Raw(sql, id).Find(&items).Error
  69. return
  70. }
  71. // GetExcelRuleMappingById 根据主键Id获取规则映射信息
  72. func GetExcelRuleMappingById(id int) (item *ExcelInfoRuleMappingView, err error) {
  73. //o := orm.NewOrmUsingDB("data")
  74. sql := `SELECT * FROM excel_info_rule_mapping WHERE excel_info_rule_mapping_id = ?`
  75. //err = o.Raw(sql, id).QueryRow(&item)
  76. err = global.DbMap[utils.DbNameIndex].Raw(sql, id).First(&item).Error
  77. return
  78. }
  79. func DeleteExcelRuleMappingById(id int) (err error) {
  80. //o := orm.NewOrmUsingDB("data")
  81. sql := `DELETE FROM excel_info_rule_mapping WHERE excel_info_rule_mapping_id = ?`
  82. //_, err = o.Raw(sql, id).Exec()
  83. err = global.DbMap[utils.DbNameIndex].Exec(sql, id).Error
  84. return
  85. }