excel_info_rule_mapping.go 3.5 KB

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