123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- package model
- import (
- "git.getensh.com/common/gopkgsv2/database"
- "gorm.io/gorm"
- )
- type Dws13Model interface {
- Get(db *gorm.DB) (*Dws13, error)
- List(db *gorm.DB) ([]P07Table, error)
- List1(db *gorm.DB) ([]Dws13, error)
- Count(db *gorm.DB) (int64, error)
- Update(db *gorm.DB, values interface{}) error
- Insert(db *gorm.DB, datab []Dws13) error
- }
- type Dws13 struct {
- ID int64 `gorm:"column:id" json:"id"`
- Source string `gorm:"column:source" json:"source"`
- ThirdBrandId string `gorm:"column:third_brand_id" json:"third_brand_id"`
- ThirdBrandName string `gorm:"column:third_brand_name" json:"third_brand_name"`
- ThirdSeriesId string `gorm:"column:third_series_id" json:"third_series_id"`
- ThirdSeriesName string `gorm:"column:third_series_name" json:"third_series_name"`
- ThirdStyleId string `gorm:"column:third_style_id" json:"third_style_id"`
- ThirdStyleName string `gorm:"column:third_style_name" json:"third_style_name"`
- ThirdMaker string `gorm:"column:third_maker" json:"third_maker"`
- ModelYear string `gorm:"column:model_year" json:"model_year"`
- StyleId string `gorm:"column:style_id" json:"style_id"`
- CreatedAt int64 `gorm:"column:created_at" json:"created_at"`
- UpdatedAt int64 `gorm:"column:updated_at" json:"updated_at"`
- }
- type P07Table struct {
- Price string `gorm:"column:price" json:"price" form:"price"`
- BrandId string `gorm:"column:brand_id" json:"brand_id" form:"brand_id"`
- BrandName string `gorm:"column:brand_name" json:"brand_name" form:"brand_name"`
- ModelYear string `gorm:"column:model_year" json:"model_year" form:"model_year"`
- SeriesId string `gorm:"column:series_id" json:"series_id" form:"series_id"`
- MakerId string `gorm:"column:maker_id" json:"maker_id" form:"maker_id"`
- Maker string `gorm:"column:maker" json:"maker" form:"maker"`
- SeriesImg string `gorm:"column:series_img" json:"series_img" form:"series_img"`
- SeriesName string `gorm:"column:series_name" json:"series_name" form:"series_name"`
- StyleId string `gorm:"column:style_id" json:"style_id" form:"style_id"`
- StyleName string `gorm:"column:style_name" json:"style_name" form:"style_name"`
- }
- type defaultDws13Model struct {
- tableName string
- fields string
- }
- func NewDws13Model() Dws13Model {
- return &defaultDws13Model{
- tableName: "t_adm_dws13",
- fields: "id, source, third_brand_id, third_brand_name, third_series_id, third_series_name, third_style_id, third_style_name, third_maker, model_year, style_id, created_at, updated_at",
- }
- }
- func (d *defaultDws13Model) Get(db *gorm.DB) (*Dws13, error) {
- var res Dws13
- err := database.Get(db, &res, database.Option{
- TableName: d.tableName,
- Fields: d.fields,
- })
- return &res, err
- }
- func (d *defaultDws13Model) List1(db *gorm.DB) ([]Dws13, error) {
- var res []Dws13
- err := database.List(db, &res, database.Option{
- TableName: d.tableName,
- Fields: d.fields,
- })
- return res, err
- }
- func (d *defaultDws13Model) List(db *gorm.DB) ([]P07Table, error) {
- var res []P07Table
- err := database.List(db, &res, database.Option{
- TableName: d.tableName + " AS t1",
- Fields: "price,brand_id,brand_name,t1.model_year,series_id,maker_id,maker,series_name,t1.style_id,style_name",
- Joins: []string{"left join db_adm_ads.t_adm_ads5 as t2 on t1.style_id = t2.style_id"},
- })
- return res, err
- }
- func (d *defaultDws13Model) Count(db *gorm.DB) (int64, error) {
- return database.Count(db, database.Option{
- TableName: d.tableName,
- })
- }
- func (d *defaultDws13Model) Update(db *gorm.DB, values interface{}) error {
- return database.Update(db, values, database.Option{
- TableName: d.tableName,
- })
- }
- func (d *defaultDws13Model) Insert(db *gorm.DB, data []Dws13) error {
- return database.Create(db, data, database.Option{
- TableName: d.tableName,
- })
- }
|