From c5f6c0270066c6ec2cd749ecf20bfddd2d7c7871 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 12 Sep 2024 15:13:29 +0800 Subject: [PATCH] 1 --- app/db/model/city.go | 7 +++++++ app/hdl/hdl_store.go | 25 +++++++++++++++++++++++++ app/router/router.go | 1 + 3 files changed, 33 insertions(+) create mode 100644 app/db/model/city.go diff --git a/app/db/model/city.go b/app/db/model/city.go new file mode 100644 index 0000000..5437b62 --- /dev/null +++ b/app/db/model/city.go @@ -0,0 +1,7 @@ +package model + +type City struct { + Name string `json:"name" xorm:"VARCHAR(64)"` + Id string `json:"id" xorm:"not null pk VARCHAR(12)"` + ProvinceId string `json:"province_id" xorm:"index VARCHAR(12)"` +} diff --git a/app/hdl/hdl_store.go b/app/hdl/hdl_store.go index cb73d25..a18fed0 100644 --- a/app/hdl/hdl_store.go +++ b/app/hdl/hdl_store.go @@ -1,11 +1,36 @@ package hdl import ( + "applet/app/db" "applet/app/e" "applet/app/svc" + "fmt" "github.com/gin-gonic/gin" ) +func City(c *gin.Context) { + var arg = make(map[string]string) + c.ShouldBindJSON(&arg) + sql := `select IF(city.name='省直辖县级行政区划' or city.name='市辖区',province.name,city.name) as newname from city +LEFT JOIN province on province.id=city.province_id +where %s +order by CONVERT(newname USING gbk)` + str := "1=1" + if arg["name"] != "" { + str += " and newname like '%" + arg["name"] + "%'" + } + sql = fmt.Sprintf(sql, str) + nativeString, _ := db.QueryNativeString(svc.MasterDb(c), sql) + nodeList := make([]map[string]string, 0) + for _, item := range nativeString { + tmp := map[string]string{ + "name": item["newname"], + } + nodeList = append(nodeList, tmp) + } + e.OutSuc(c, nodeList, nil) + return +} func BankStoreCate(c *gin.Context) { var res = []map[string]string{ {"name": "全部网点", "value": ""}, diff --git a/app/router/router.go b/app/router/router.go index e5cf5cc..81a2d01 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -45,6 +45,7 @@ func routeCommunityTeam(r *gin.RouterGroup) { r.Use(mw.CheckBody) //body参数转换 r.Use(mw.CheckSign) //签名校验 r.Use(mw.Checker) + r.POST("/city", hdl.City) r.GET("/bank/store/cate", hdl.BankStoreCate) r.POST("/bank/store/list", hdl.BankStore) r.POST("/store", hdl.Store)