1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- // Copyright 2019 githup.com. All rights reserved.
- // Use of this source code is governed by githup.com.
- package model
- import (
- "github.com/jinzhu/gorm"
- "time"
- )
- type ProviderDeviceTesting struct {
- Id int64 `gorm:"column:ID" json:"id" form:"id"`
- ProviderId int64 `gorm:"column:ProviderId" json:"provider_id" form:"provider_id"`
- DeviceCode int32 `gorm:"column:DeviceCode" json:"device_code" form:"device_code"`
- Status int32 `gorm:"column:Status" json:"status" form:"status"`
- CreatedAt time.Time `gorm:"column:CreatedAt"`
- Feedback string `gorm:"column:Feedback"`
- Comment string `gorm:"column:Comment"`
- Appendix string `gorm:"column:Appendix"`
- Agent string `gorm:"column:Agent"`
- AgentPhone string `gorm:"column:AgentPhone"`
- ApproveTime time.Time `gorm:"column:ApproveTime"`
- Reviewer string `gorm:"column:Reviewer"`
- }
- func (ProviderDeviceTesting) TableName() string {
- return "ProviderDeviceTesting"
- }
- func (p *ProviderDeviceTesting) Insert(db *gorm.DB) error {
- return db.Table(p.TableName()).Create(p).Error
- }
- func (p *ProviderDeviceTesting) Find(db *gorm.DB, where map[string]interface{}) error {
- cond, val, err := whereBuild(where)
- if err != nil {
- return err
- }
- return db.Table(p.TableName()).Where(cond, val...).First(p).Error
- }
- func (p *ProviderDeviceTesting) Update(db *gorm.DB, where map[string]interface{}, values map[string]interface{}) error {
- cond, val, err := whereBuild(where)
- if err != nil {
- return err
- }
- return db.Table(p.TableName()).Table(p.TableName()).Where(cond, val...).Updates(values).Error
- }
- func (p *ProviderDeviceTesting) Save(db *gorm.DB) error {
- return db.Table(p.TableName()).Save(p).Error
- }
- func (p *ProviderDeviceTesting) List(db *gorm.DB, where map[string]interface{}) (list []ProviderDeviceTesting, err error) {
- if len(where) > 0 {
- cond, val, err := whereBuild(where)
- if err != nil {
- return list, err
- }
- result := db.Table(p.TableName()).Where(cond, val...).Find(&list)
- return list, result.Error
- }
- result := db.Table(p.TableName()).Find(&list)
- return list, result.Error
- }
- func (p *ProviderDeviceTesting) Count(db *gorm.DB, where map[string]interface{}) (int64, error) {
- if len(where) > 0 {
- cond, val, err := whereBuild(where)
- if err != nil {
- return 0, err
- }
- ret := int64(0)
- err = db.Table(p.TableName()).Where(cond, val...).Count(&ret).Error
- return ret, err
- }
- ret := int64(0)
- err := db.Table(p.TableName()).Count(&ret).Error
- return ret, err
- }
- func (p *ProviderDeviceTesting) Del(db *gorm.DB, where map[string]interface{}) error {
- cond, val, err := whereBuild(where)
- if err != nil {
- return err
- }
- return db.Table(p.TableName()).Where(cond, val...).Delete(p).Error
- }
|