weather_cityid_item.go 990 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2019 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. package model
  4. import (
  5. "github.com/jaryhe/gopkgs/logger"
  6. "github.com/jinzhu/gorm"
  7. jsoniter "github.com/json-iterator/go"
  8. "go.uber.org/zap"
  9. )
  10. // 替换encoding/json包
  11. var json = jsoniter.ConfigCompatibleWithStandardLibrary
  12. type CityidItem struct {
  13. ID int64 `gorm:"primary_key" gorm:"column:ID"`
  14. CityId string `json:"city_id" gorm:"column:CityId"`
  15. Province string `json:"province" gorm:"column:Province"`
  16. Region string `json:"region" gorm:"column:Region"`
  17. }
  18. func (CityidItem) TableName() string {
  19. return "CityidItem"
  20. }
  21. func (p *CityidItem) Query(db *gorm.DB, filter map[string]interface{}) error {
  22. err := db.Where(filter).Find(p).Error
  23. if err != nil {
  24. fields, _ := json.MarshalToString(filter)
  25. logger.Error("mysql",
  26. zap.String("sql", "select from CityidItem"),
  27. zap.String("fields", fields),
  28. zap.String("error", err.Error()))
  29. }
  30. return err
  31. }