qixiaoning
2025-08-28 eac932eb827c93e2e998ac1210c3f5e548af0dbf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package models
 
type GbCodeArea struct {
    Id int `gorm:"column:id;primary_key;AUTO_INCREMENT" json:"id"`
    ParentId int `gorm:"column:parent_id" json:"parent_id"`
    Name string `gorm:"column:name" json:"name"`
    Longitude float32 `gorm:"column:longitude" json:"longitude"`
    Latitude float32 `gorm:"column:latitude" json:"latitude"`
    Level int `gorm:"column:level" json:"level"`
    Sort int `gorm:"column:sort" json:"sort"`
}
 
func (GbCodeArea) TableName() string {
    return "gb_code_area"
}
 
func (gba *GbCodeArea) FindByParentId(parentId int) (list []GbCodeArea,err error) {
    result := db.Table(gba.TableName()).Where("parent_id=?",parentId).Order("sort asc").Find(&list)
    if result.Error != nil {
        return nil,result.Error
    }
    return list, nil
}
 
func (gba *GbCodeArea) SelectById(id int) (rows int64, err error) {
    dbselect := db.Where("id = ?", id).First(&gba)
    if dbselect.Error != nil || dbselect.RowsAffected == 0 {
        return 0, err
    }
    return dbselect.RowsAffected, nil
}