1234567891011121314151617181920212223242526272829 |
- package model
- import "github.com/jinzhu/gorm"
- type AreaCode struct {
- ID int64 `gorm:"column:ID"`
- Code string `gorm:"column:Code"`
- Addr string `gorm:"column:Addr"`
- }
- func (AreaCode) TableName() string {
- return "AreaCode"
- }
- func (p *AreaCode) List(db *gorm.DB, where map[string]interface{}) (list []AreaCode, 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
- }
|