123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package model
- import (
- "time"
- "git.getensh.com/common/gopkgsv2/database"
- "gorm.io/gorm"
- )
- type MaintenanceTitleTemplateModel interface {
- Insert(db *gorm.DB, data interface{}) error
- Count(db *gorm.DB) (int64, error)
- List(db *gorm.DB, pagination *Pagination) ([]MaintenanceTitleTemplate, error)
- Get(db *gorm.DB) (*MaintenanceTitleTemplate, error)
- Update(db *gorm.DB, values interface{}) error
- }
- type MaintenanceTitleTemplate struct {
- ID int64 `gorm:"column:id" json:"id"`
- Tid int64 `gorm:"column:tid" json:"tid"`
- 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 defaultMaintenanceTitleTemplateModel struct {
- tableName string
- fields string
- }
- func NewMaintenanceTitleTemplateModel() MaintenanceTitleTemplateModel {
- return &defaultMaintenanceTitleTemplateModel{
- "db_adm_management.t_adm_maintenance_title_template",
- "id, tid, start_mile, start_date, maintain_mile_min_cycle, maintain_date_min_cycle, wash_cycle, repair_cycle, created_at, updated_at",
- }
- }
- func (d *defaultMaintenanceTitleTemplateModel) Insert(db *gorm.DB, data interface{}) error {
- return database.Create(db, data, database.Option{
- TableName: d.tableName,
- })
- }
- func (d *defaultMaintenanceTitleTemplateModel) Count(db *gorm.DB) (int64, error) {
- return database.Count(db, database.Option{
- TableName: d.tableName,
- })
- }
- func (d *defaultMaintenanceTitleTemplateModel) List(db *gorm.DB, pagination *Pagination) ([]MaintenanceTitleTemplate, error) {
- var res []MaintenanceTitleTemplate
- err := database.List(db, &res, database.Option{
- TableName: d.tableName,
- Fields: d.fields,
- Limit: pagination.Limit,
- OffSet: pagination.Offset,
- })
- return res, err
- }
- func (d *defaultMaintenanceTitleTemplateModel) Get(db *gorm.DB) (*MaintenanceTitleTemplate, error) {
- var res MaintenanceTitleTemplate
- err := database.Get(db, &res, database.Option{
- TableName: d.tableName,
- Fields: d.fields,
- })
- return &res, err
- }
- func (d *defaultMaintenanceTitleTemplateModel) Update(db *gorm.DB, values interface{}) error {
- return database.Update(db, values, database.Option{
- TableName: d.tableName,
- })
- }
|