| | |
| | | "basic.com/valib/logger.git" |
| | | "errors" |
| | | "gorm.io/gorm" |
| | | "strconv" |
| | | ) |
| | | |
| | | // 查询小区表 |
| | |
| | | return nil, result.Error |
| | | } |
| | | return device, nil |
| | | } |
| | | |
| | | func GetPublicHouseData() ([]PublicHouse, error) { |
| | | // 查询数据 |
| | | var db = DB |
| | | var ph []PublicHouse |
| | | result := db.Table("public_house").Where("1 = 1").Find(&ph) |
| | | if result.Error != nil { |
| | | return nil, result.Error |
| | | } |
| | | return ph, nil |
| | | } |
| | | |
| | | // 查询全部数据 |
| | |
| | | } |
| | | |
| | | // 查询人物属性 |
| | | func GetDBPersonStatusData(id string) ([]PersonStatus, error) { |
| | | func GetDBPersonStatus(id, communityId string) string { |
| | | var db = DB |
| | | // 查询数据 |
| | | var personStatusList []PersonStatus |
| | | if err := db.Table("person_status"). |
| | | Select("documentNumber, status, frequentAddress"). |
| | | Where("communityID = ?", id). |
| | | Find(&personStatusList).Error; err != nil { |
| | | return nil, err |
| | | } |
| | | |
| | | return personStatusList, nil |
| | | // 查询数据 |
| | | var personStatus string |
| | | db.Table("snapshot_count_summary"). |
| | | Select("status"). |
| | | Where("community_id = ? and document_number = ?", communityId, id). |
| | | Find(&personStatus) |
| | | |
| | | return personStatus |
| | | } |
| | | |
| | | // 查询小区档案表 (原查询任务属性) |
| | |
| | | func GetAgeById(id string) (int, error) { |
| | | var db = DB |
| | | // 查询数据 |
| | | var age int |
| | | var age string |
| | | if err := db.Table("dbtablepersons"). |
| | | Select("age"). |
| | | Where("id = ?", id). |
| | |
| | | return 0, err |
| | | } |
| | | |
| | | return age, nil |
| | | return strconv.Atoi(age) |
| | | } |
| | | |
| | | // 查询人物身份证号 |
| | | func GetIdCardById(id string) string { |
| | | var db = DB |
| | | // 查询数据 |
| | | var idCard string |
| | | db.Table("dbtablepersons"). |
| | | Select("idCard"). |
| | | Where("id = ?", id). |
| | | Find(&idCard) |
| | | |
| | | return idCard |
| | | } |
| | | |
| | | //// 根据社区id和住户属性查询住户档案编号 |
| | |
| | | // 根据dbtablepersons表id查询目标档案年龄 |
| | | func QueryAgeById(id string) (int, error) { |
| | | var db = DB |
| | | var age int |
| | | var age string |
| | | err := db.Table("dbtablepersons"). |
| | | Select("age"). |
| | | Where("id = ?", id). |
| | |
| | | if err != nil { |
| | | return 0, err |
| | | } |
| | | return age, nil |
| | | |
| | | return strconv.Atoi(age) |
| | | } |
| | | |
| | | // UpdatePersonInfo 更新或插入多个人员信息 |