123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package services
- import (
- "fmt"
- "lzyd-user-api/common"
- "lzyd-user-api/models"
- )
- /**
- 获取所有省份
- */
- func QueryProvinceCode() []models.ReqProvince {
- var province []models.ReqProvince
- sql := `SELECT id, code, name
- FROM province`
- common.DB.Raw(sql).Find(&province)
- fmt.Println("你获取的是:", province)
- return province
- }
- /**
- 根据省code查询市
- */
- func QueryCityCode(code string) []models.ReqCity {
- var city []models.ReqCity
- sql := `SELECT id, code, name, province_code
- FROM city
- WHERE province_code = ?`
- common.DB.Raw(sql, code).Find(&city)
- fmt.Println("你获取的是:", city)
- return city
- }
- /**
- 根据市code查询区
- */
- func QueryAreaCode(code string) []models.ReqArea {
- var area []models.ReqArea
- sql := `SELECT id, code, name, city_code
- FROM area
- WHERE city_code = ?`
- common.DB.Raw(sql, code).Find(&area)
- fmt.Println("你获取的是:", area)
- return area
- }
|