1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package model
- import (
- "git.getensh.com/common/gopkgsv2/database"
- "gorm.io/gorm"
- )
- type Ads12Model interface {
- Get(db *gorm.DB) (*Ads12, error)
- List(db *gorm.DB, fields string) ([]Ads12, error)
- }
- type Ads12 struct {
- ID int64 `gorm:"column:id" json:"id"`
- ItemId int64 `gorm:"column:item_id" json:"item_id"`
- ItemName string `gorm:"column:item_name" json:"item_name"`
- ItemType int64 `gorm:"column:item_type" json:"item_type"`
- }
- type defaultAds12Model struct {
- tableName string
- fields string
- }
- func NewAds12Model() Ads12Model {
- return &defaultAds12Model{
- tableName: "t_dip_ads12",
- fields: "id, item_id, item_name, item_type",
- }
- }
- func (d *defaultAds12Model) Get(db *gorm.DB) (*Ads12, error) {
- var res Ads12
- err := database.Get(db, &res, database.Option{
- TableName: d.tableName,
- Fields: d.fields,
- })
- return &res, err
- }
- func (d *defaultAds12Model) List(db *gorm.DB, fields string) ([]Ads12, error) {
- if fields == "" {
- fields = d.fields
- }
- var res []Ads12
- err := database.List(db, &res, database.Option{
- TableName: d.tableName,
- Fields: fields,
- })
- return res, err
- }
|