ads13.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package model
  2. import (
  3. "time"
  4. "git.getensh.com/common/gopkgsv2/database"
  5. "gorm.io/gorm"
  6. )
  7. type Ads13Model interface {
  8. Get(db *gorm.DB) (*Ads13, error)
  9. Insert(db *gorm.DB, datab interface{}) error
  10. Update(db *gorm.DB, values interface{}) error
  11. }
  12. type Ads13 struct {
  13. ID int64 `gorm:"column:id" json:"id" form:"id"`
  14. StyleId string `gorm:"column:style_id" json:"style_id" form:"style_id"`
  15. StartMile int64 `gorm:"column:start_mile" json:"start_mile" form:"start_mile"`
  16. StartDate int64 `gorm:"column:start_date" json:"start_date" form:"start_date"`
  17. MaintainMileMinCycle int64 `gorm:"column:maintain_mile_min_cycle" json:"maintain_mile_min_cycle" form:"maintain_mile_min_cycle"`
  18. MaintainDateMinCycle int64 `gorm:"column:maintain_date_min_cycle" json:"maintain_date_min_cycle" form:"maintain_date_min_cycle"`
  19. WashCycle int64 `gorm:"column:wash_cycle" json:"wash_cycle" form:"wash_cycle"`
  20. RepairCycle int64 `gorm:"column:repair_cycle" json:"repair_cycle" form:"repair_cycle"`
  21. CreatedAt time.Time `gorm:"column:created_at" json:"created_at" form:"created_at"`
  22. UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at" form:"updated_at"`
  23. }
  24. type defalutAds13Model struct {
  25. tableName string
  26. fileds string
  27. }
  28. func NewAds13Model() Ads13Model {
  29. return &defalutAds13Model{
  30. tableName: "db_adm_ads.t_adm_ads13",
  31. fileds: "id, style_id, start_mile, start_date, maintain_mile_min_cycle, maintain_date_min_cycle, wash_cycle, repair_cycle, created_at, updated_at",
  32. }
  33. }
  34. func (d *defalutAds13Model) Get(db *gorm.DB) (*Ads13, error) {
  35. var res Ads13
  36. err := database.Get(db, &res, database.Option{
  37. TableName: d.tableName,
  38. Fields: d.fileds,
  39. })
  40. return &res, err
  41. }
  42. func (d *defalutAds13Model) Insert(db *gorm.DB, data interface{}) error {
  43. return database.Create(db, data, database.Option{
  44. TableName: d.tableName,
  45. })
  46. }
  47. func (d *defalutAds13Model) Update(db *gorm.DB, values interface{}) error {
  48. return database.Update(db, values, database.Option{
  49. TableName: d.tableName,
  50. })
  51. }