excel_info_rule_mapping.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package models
  2. import (
  3. "eta_gn/eta_chart_lib/global"
  4. "time"
  5. )
  6. type ExcelInfoRuleMapping struct {
  7. ExcelInfoRuleMappingId int `gorm:"column:excel_info_rule_mapping_id;primaryKey" description:"主键"`
  8. ExcelInfoId int `gorm:"column:excel_info_id" description:"Excel信息ID"`
  9. RuleType int `gorm:"column:rule_type" description:"规则类型"`
  10. LeftValue string `gorm:"column:left_value" description:"左值"`
  11. LeftValueShow string `gorm:"column:left_value_show" description:"左值前端显示"`
  12. LeftValueType int `gorm:"column:left_value_type" description:"左值类型"`
  13. RightValue string `gorm:"column:right_value" description:"右值"`
  14. RightValueShow string `gorm:"column:right_value_show" description:"右值前端显示"`
  15. RightValueType int `gorm:"column:right_value_type" description:"右值类型"`
  16. FontColor string `gorm:"column:font_color" description:"字体颜色"`
  17. BackgroundColor string `gorm:"column:background_color" description:"背景颜色"`
  18. Remark string `gorm:"column:remark" description:"预设颜色说明"`
  19. RemarkEn string `gorm:"column:remark_en" description:"预设颜色英文说明"`
  20. Scope string `gorm:"column:scope" description:"作用范围"`
  21. ScopeCoord string `gorm:"column:scope_coord" description:"作用范围坐标"`
  22. ScopeShow string `gorm:"column:scope_show" description:"作用范围坐标前端显示"`
  23. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  24. }
  25. func (e *ExcelInfoRuleMapping) TableName() string {
  26. return "excel_info_rule_mapping"
  27. }
  28. type ExcelInfoRuleMappingView struct {
  29. ExcelInfoRuleMappingId int `gorm:"column:excel_info_rule_mapping_id;primaryKey" description:"主键"`
  30. ExcelInfoId int `gorm:"column:excel_info_id" description:"Excel信息ID"`
  31. RuleType int `gorm:"column:rule_type" description:"规则类型:1-大于,2-小于,3-介于,4-等于,5-发生日期"`
  32. LeftValue string `gorm:"column:left_value" description:"左值"`
  33. LeftValueBack string `gorm:"column:left_value_back" description:"左值前端显示"`
  34. LeftValueType int `gorm:"column:left_value_type" description:"左值类型"`
  35. RightValue string `gorm:"column:right_value" description:"右值"`
  36. RightValueBack string `gorm:"column:right_value_back" description:"右值前端显示"`
  37. RightValueType int `gorm:"column:right_value_type" description:"右值类型"`
  38. FontColor string `gorm:"column:font_color" description:"字体颜色"`
  39. BackgroundColor string `gorm:"column:background_color" description:"背景颜色"`
  40. Remark string `gorm:"column:remark" description:"预设颜色说明"`
  41. RemarkEn string `gorm:"column:remark_en" description:"预设颜色英文说明"`
  42. Scope string `gorm:"column:scope" description:"作用范围"`
  43. ScopeCoord string `gorm:"column:scope_coord" description:"作用范围坐标"`
  44. ScopeShow string `gorm:"column:scope_show" description:"作用范围坐标前端显示"`
  45. CreateTime string `gorm:"column:create_time" description:"创建时间"`
  46. }
  47. func (e *ExcelInfoRuleMapping) Insert() (insertId int64, err error) {
  48. o := global.DmSQL["data"]
  49. err = o.Create(e).Error
  50. insertId = int64(e.ExcelInfoRuleMappingId)
  51. return
  52. }
  53. func (e *ExcelInfoRuleMapping) Update(cols []string) (err error) {
  54. o := global.DmSQL["data"]
  55. err = o.Model(e).Select(cols).Updates(e).Error
  56. return
  57. }
  58. func GetExcelRuleMappingByExcelInfoId(id int) (items []*ExcelInfoRuleMappingView, err error) {
  59. o := global.DmSQL["data"]
  60. sql := `SELECT * FROM excel_info_rule_mapping WHERE excel_info_id = ? ORDER BY create_time ASC`
  61. err = o.Raw(sql, id).Scan(&items).Error
  62. return
  63. }
  64. func GetExcelRuleMappingById(id int) (item *ExcelInfoRuleMappingView, err error) {
  65. o := global.DmSQL["data"]
  66. sql := `SELECT * FROM excel_info_rule_mapping WHERE excel_info_rule_mapping_id = ?`
  67. err = o.Raw(sql, id).First(&item).Error
  68. return
  69. }
  70. func DeleteExcelRuleMappingById(id int) (err error) {
  71. o := global.DmSQL["data"]
  72. sql := `DELETE FROM excel_info_rule_mapping WHERE excel_info_rule_mapping_id = ?`
  73. err = o.Exec(sql, id).Error
  74. return
  75. }