edb_classify.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package data_manage
  2. import (
  3. "eta_gn/eta_task/global"
  4. "time"
  5. )
  6. type EdbClassify struct {
  7. ClassifyID int64 `gorm:"column:classify_id;primaryKey"` //`orm:"column(classify_id);pk"`
  8. ClassifyType uint32
  9. ClassifyName string
  10. ParentID int64
  11. HasData int32
  12. CreateTime time.Time
  13. ModifyTime time.Time
  14. SysUserID int64
  15. SysUserRealName string
  16. Level int64
  17. UniqueCode string
  18. Sort uint32
  19. RootID int64
  20. LastModifyUserID uint32
  21. LastModifyUserRealName string
  22. IsJoinPermission int64
  23. ClassifyNameEn string
  24. }
  25. // GetAllEdbClassifyListByCondition
  26. // @Description: 获取分类列表
  27. // @author: Roc
  28. // @datetime 2024-02-29 10:55:38
  29. // @param condition string
  30. // @param pars []interface{}
  31. // @return item []*EdbInfoUpdateLog
  32. // @return err error
  33. func GetAllEdbClassifyListByCondition(condition string, pars []interface{}) (item []*EdbClassify, err error) {
  34. //o := orm.NewOrmUsingDB("data")
  35. sql := ` SELECT * FROM edb_classify WHERE 1=1 `
  36. if condition != "" {
  37. sql += condition
  38. }
  39. sql += `ORDER BY classify_id ASC `
  40. //_, err = o.Raw(sql, pars).QueryRows(&item)
  41. err = global.DmSQL["data"].Raw(sql, pars...).Find(&item).Error
  42. return
  43. }
  44. // AddEdbClassify
  45. // @Description: 新增分类
  46. // @param item
  47. // @return err
  48. func AddEdbClassify(item *EdbClassify) (err error) {
  49. err = global.DmSQL["data"].Create(item).Error
  50. if err != nil {
  51. return
  52. }
  53. return
  54. }
  55. // Update
  56. // @Description: 更新指定参数
  57. // @receiver m
  58. // @param cols
  59. // @return err
  60. func (m *EdbClassify) Update(cols []string) (err error) {
  61. err = global.DmSQL["data"].Select(cols).Updates(m).Error
  62. return
  63. }