12345678910111213141516171819202122232425262728293031323334353637 |
- // Copyright 2019 getensh.com. All rights reserved.
- // Use of this source code is governed by getensh.com.
- package model
- import (
- "github.com/jaryhe/gopkgs/logger"
- "github.com/jinzhu/gorm"
- jsoniter "github.com/json-iterator/go"
- "go.uber.org/zap"
- )
- // 替换encoding/json包
- var json = jsoniter.ConfigCompatibleWithStandardLibrary
- type CityidItem struct {
- ID int64 `gorm:"primary_key" gorm:"column:ID"`
- CityId string `json:"city_id" gorm:"column:CityId"`
- Province string `json:"province" gorm:"column:Province"`
- Region string `json:"region" gorm:"column:Region"`
- }
- func (CityidItem) TableName() string {
- return "CityidItem"
- }
- func (p *CityidItem) Query(db *gorm.DB, filter map[string]interface{}) error {
- err := db.Where(filter).Find(p).Error
- if err != nil {
- fields, _ := json.MarshalToString(filter)
- logger.Error("mysql",
- zap.String("sql", "select from CityidItem"),
- zap.String("fields", fields),
- zap.String("error", err.Error()))
- }
- return err
- }
|