package db import ( "encoding/base64" "sdkCompare/util" ) type Layouts struct { Id string `gorm:"column:id"` TableId string `gorm:"column:tableId"` Name string `gorm:"column:name"` Phone string `gorm:"column:phone"` Address string `gorm:"column:address"` Age string `gorm:"column:age"` Gender string `gorm:"column:gender"` IdCard string `gorm:"column:id_card"` PersonType string `gorm:"column:person_type"` //'1:常驻人口,2:前科人员,3:涉毒人员,4:涉稳人员;5:在逃人员,6:流动人口,7:寄住人口,', Feature string `gorm:"column:feature"` } func (l *Layouts) TableName() string { return "layouts" } func (l *Layouts) GetRealNamePersonList() (arr []*FeatureCacheBase, err error) { var persons []Layouts sql := "select id, tableId, person_type, feature from layouts" err = db.Raw(sql).Find(&persons).Error if err != nil { return nil, nil } for _, p := range persons { if p.Feature != "" { byteFeat, err := base64.StdEncoding.DecodeString(p.Feature) if err != nil { continue } arr = append(arr, &FeatureCacheBase{ Id: p.Id, TableId: p.TableId, FaceFeature: util.ByteSlice2float32Slice(byteFeat), }) } } return } func (l *Layouts) GetKeyPersonList() (arr []*FeatureCacheBase, err error) { var persons []Layouts sql := "select id, id_card, person_type, feature from layouts where person_type != '1'" err = db.Raw(sql).Find(&persons).Error if err != nil { return nil, nil } for _, p := range persons { if p.Feature != "" { byteFeat, err := base64.StdEncoding.DecodeString(p.Feature) if err != nil { continue } arr = append(arr, &FeatureCacheBase{ Id: p.Id, TableId: p.IdCard, FaceFeature: util.ByteSlice2float32Slice(byteFeat), }) } } return }