12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package model
- import (
- "time"
- "git.getensh.com/common/gopkgsv2/database"
- "gorm.io/gorm"
- )
- type MaintainTitleModel interface {
- Get(db *gorm.DB) (*GdMaintainTitle, error)
- Insert(db *gorm.DB, data interface{}) error
- Update(db *gorm.DB, values interface{}) error
- Delete(db *gorm.DB) error
- }
- type GdMaintainTitle struct {
- ID int64 `gorm:"column:id" json:"id"`
- StyleId string `gorm:"column:style_id" json:"style_id"`
- StartMile int64 `gorm:"column:start_mile" json:"start_mile"`
- StartDate int64 `gorm:"column:start_date" json:"start_date"`
- MaintainMileMinCycle int64 `gorm:"column:maintain_mile_min_cycle" json:"maintain_mile_min_cycle"`
- MaintainDateMinCycle int64 `gorm:"column:maintain_date_min_cycle" json:"maintain_date_min_cycle"`
- WashCycle int64 `gorm:"column:wash_cycle" json:"wash_cycle"`
- RepairCycle int64 `gorm:"column:repair_cycle" json:"repair_cycle"`
- CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
- UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
- }
- type defalutMaintainTitleModel struct {
- tableName string
- fileds string
- }
- func NewMaintainTitleModel() MaintainTitleModel {
- return &defalutMaintainTitleModel{
- tableName: "db_adm_dws.t_adm_ads13",
- fileds: "id, style_id, start_mile, start_date, maintain_mile_min_cycle, maintain_date_min_cycle, wash_cycle, repair_cycle, created_at, updated_at",
- }
- }
- func (d *defalutMaintainTitleModel) Get(db *gorm.DB) (*GdMaintainTitle, error) {
- var res GdMaintainTitle
- err := database.Get(db, &res, database.Option{
- TableName: d.tableName,
- Fields: d.fileds,
- })
- return &res, err
- }
- func (d *defalutMaintainTitleModel) Insert(db *gorm.DB, data interface{}) error {
- return database.Create(db, data, database.Option{
- TableName: d.tableName,
- })
- }
- func (d *defalutMaintainTitleModel) Update(db *gorm.DB, values interface{}) error {
- return database.Update(db, values, database.Option{
- TableName: d.tableName,
- })
- }
- func (d *defalutMaintainTitleModel) Delete(db *gorm.DB) error {
- m := GdMaintainTitle{}
- return db.Table(d.tableName).Delete(&m).Error
- }
|