package controllers import ( "fmt" "github.com/gin-gonic/gin" "lzyd-user-api/common" "lzyd-user-api/models" "lzyd-user-api/services" "regexp" ) // @tags area // @Description 获取省市区 // @Summary 获取省市区 // @Produce json // @Param p_code query string false "地区code" // @Success 200 {string} json "{"code":200,"message":"success","data":{"token":"","customer":{"id":"","code":"","name":""}}}" // @Router /area/getArea [get] func GetArea(c *gin.Context) { PCode := c.Query("p_code") var ( code = common.Success ) if len(PCode) == 0 { var ( model []models.ReqProvince ) model = services.QueryProvinceCode() common.GenResp(c, code, "SUCCESS", model) return } //PCode_int, _ := strconv.Atoi(PCode) reg := regexp.MustCompile(`0000`) fmt.Println(reg.FindAllString(PCode, -1)) if len(reg.FindAllString(PCode, -1)) > 0 { var ( model []models.ReqCity ) model = services.QueryCityCode(PCode) common.GenResp(c, code, "SUCCESS", model) return } if len(reg.FindAllString(PCode, -1)) == 0 { var ( model []models.ReqArea ) model = services.QueryAreaCode(PCode) common.GenResp(c, code, "SUCCESS", model) return } //model = services.QueryAreaCode(PCode) //if model.Id == 0 { // code = common.SystemHasNoUser //} //if common.Success == code { // // 修改上一次登录时间 // //_ = model.UpdateLoginTime() // common.GenResp(c, code, "SUCCESS", model) //} else { // common.GenResp(c, code, "内部错误", nil) //} }