From d9ec14b9adf6e90309d763e3b3b1b0f22773f8da Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期二, 18 七月 2023 15:07:47 +0800
Subject: [PATCH] fix

---
 api/v1/client.go      |    2 
 service/dataServer.go |    1 
 service/province.go   |   20 +
 api/v1/getAllData.go  |    1 
 service/region.go     |   21 +
 docs/swagger.yaml     |  116 +++++++++++
 model/province.go     |    9 
 docs/docs.go          |  170 ++++++++++++++++
 docs/swagger.json     |  170 ++++++++++++++++
 router/data.go        |    1 
 service/index.go      |    1 
 api/v1/province.go    |   11 
 api/v1/region.go      |   11 
 router/index.go       |    2 
 api/v1/city.go        |   14 
 model/region.go       |    5 
 16 files changed, 525 insertions(+), 30 deletions(-)

diff --git a/api/v1/city.go b/api/v1/city.go
index 724b032..c7ef526 100644
--- a/api/v1/city.go
+++ b/api/v1/city.go
@@ -70,12 +70,12 @@
 
 // List
 //
-//		@Tags		City
-//		@Summary	鑾峰彇鍩庡競鍒楄〃
-//		@Produce	application/json
-//	 @Param		provinceId	query	int	false	"鐪佷唤ID"
-//		@Success	200	{object}	contextx.Response{data=response.CityResponse}	"鎴愬姛"
-//		@Router		/api/city/list [get]
+//	@Tags		City
+//	@Summary	鑾峰彇鍩庡競鍒楄〃
+//	@Produce	application/json
+//	@Param		province_id	query		int												false	"鐪佷唤ID"
+//	@Success	200			{object}	contextx.Response{data=response.CityResponse}	"鎴愬姛"
+//	@Router		/api/city/list [get]
 func (ci *CityApi) List(c *gin.Context) {
 	ctx, ok := contextx.NewContext(c, nil)
 	if !ok {
@@ -83,7 +83,7 @@
 	}
 
 	// 鑾峰彇鐪佷唤ID
-	provinceId, _ := strconv.Atoi(c.Query("provinceId"))
+	provinceId, _ := strconv.Atoi(c.Query("province_id"))
 	cities, errCode := cityService.ListCities(provinceId)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
diff --git a/api/v1/client.go b/api/v1/client.go
index 2e3d7ee..8df8a21 100644
--- a/api/v1/client.go
+++ b/api/v1/client.go
@@ -168,7 +168,7 @@
 //	@Produce	application/json
 //	@Param		object	body		request.UpdateClient	true	"鏌ヨ鍙傛暟"
 //	@Success	200		{object}	contextx.Response{}
-//	@Router		/api/client/update [post]
+//	@Router		/api/client/update [put]
 func (cli *ClientApi) Update(c *gin.Context) {
 	var params request.UpdateClient
 	ctx, ok := contextx.NewContext(c, &params)
diff --git a/api/v1/getAllData.go b/api/v1/getAllData.go
new file mode 100644
index 0000000..b7b1f99
--- /dev/null
+++ b/api/v1/getAllData.go
@@ -0,0 +1 @@
+package v1
diff --git a/api/v1/province.go b/api/v1/province.go
index 93d6692..0c71dc9 100644
--- a/api/v1/province.go
+++ b/api/v1/province.go
@@ -13,6 +13,7 @@
 type ProvinceApi struct{}
 
 // Add
+//
 //	@Tags		Province
 //	@Summary	娣诲姞鐪佷唤
 //	@Produce	application/json
@@ -39,6 +40,7 @@
 }
 
 // Update
+//
 //	@Tags		Province
 //	@Summary	鏇存柊鐪佷唤
 //	@Produce	application/json
@@ -62,10 +64,12 @@
 }
 
 // List
+//
 //	@Tags		Province
 //	@Summary	鑾峰彇鐪佷唤鍒楄〃
 //	@Produce	application/json
-//	@Success	200	{object}	contextx.Response{data=response.ProvinceResponse}
+//	@Param		country_id	query		int	true	"鍥藉ID"
+//	@Success	200			{object}	contextx.Response{data=response.ProvinceResponse}
 //	@Router		/api/province/list [get]
 func (p *ProvinceApi) List(c *gin.Context) {
 	ctx, ok := contextx.NewContext(c, nil)
@@ -73,7 +77,8 @@
 		return
 	}
 
-	provinces, errCode := provinceService.GetProvinces()
+	countryId, _ := strconv.Atoi(c.Query("country_id"))
+	provinces, errCode := provinceService.GetProvinces(countryId)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
@@ -85,6 +90,7 @@
 }
 
 // Set
+//
 //	@Tags		Province
 //	@Summary	璁剧疆鐪佷唤
 //	@Produce	application/json
@@ -108,6 +114,7 @@
 }
 
 // Delete
+//
 //	@Tags		Province
 //	@Summary	鍒犻櫎鐪佷唤
 //	@Produce	application/json
diff --git a/api/v1/region.go b/api/v1/region.go
index 2e123c2..df63a21 100644
--- a/api/v1/region.go
+++ b/api/v1/region.go
@@ -13,6 +13,7 @@
 type RegionApi struct{}
 
 // Add
+//
 //	@Tags		Region
 //	@Summary	娣诲姞鍦板尯
 //	@Produce	application/json
@@ -39,6 +40,7 @@
 }
 
 // Set
+//
 //	@Tags		Region
 //	@Summary	璁剧疆鍦板尯
 //	@Produce	application/json
@@ -62,6 +64,7 @@
 }
 
 // Delete
+//
 //	@Tags		Region
 //	@Summary	鍒犻櫎鍦板尯
 //	@Produce	application/json
@@ -86,6 +89,7 @@
 }
 
 // Update
+//
 //	@Tags		Region
 //	@Summary	鏇存柊鍦板尯
 //	@Produce	application/json
@@ -109,10 +113,12 @@
 }
 
 // List
+//
 //	@Tags		Region
 //	@Summary	鍦板尯鍒楄〃
 //	@Produce	application/json
-//	@Success	200	{object}	contextx.Response{}
+//	@Param		city_id	query		int	true	"鍩庡競ID"
+//	@Success	200		{object}	contextx.Response{}
 //	@Router		/api/region/list [get]
 func (r *RegionApi) List(c *gin.Context) {
 	ctx, ok := contextx.NewContext(c, nil)
@@ -120,7 +126,8 @@
 		return
 	}
 
-	regionList, errCode := regionService.ListRegions()
+	cityId, _ := strconv.Atoi(c.Query("city_id"))
+	regionList, errCode := regionService.ListRegions(cityId)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
diff --git a/docs/docs.go b/docs/docs.go
index 55e80a2..1f314e2 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -236,7 +236,7 @@
                     {
                         "type": "integer",
                         "description": "鐪佷唤ID",
-                        "name": "provinceId",
+                        "name": "province_id",
                         "in": "query"
                     }
                 ],
@@ -412,7 +412,7 @@
             }
         },
         "/api/client/update": {
-            "post": {
+            "put": {
                 "produces": [
                     "application/json"
                 ],
@@ -1378,6 +1378,37 @@
                         "description": "OK",
                         "schema": {
                             "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/data/getAllData": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "Data"
+                ],
+                "summary": "鑾峰彇鎵�鏈夋暟鎹�",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/contextx.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "$ref": "#/definitions/response.DataResponse"
+                                        }
+                                    }
+                                }
+                            ]
                         }
                     }
                 }
@@ -2466,6 +2497,15 @@
                     "Province"
                 ],
                 "summary": "鑾峰彇鐪佷唤鍒楄〃",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鍥藉ID",
+                        "name": "country_id",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
                 "responses": {
                     "200": {
                         "description": "OK",
@@ -2734,6 +2774,15 @@
                     "Region"
                 ],
                 "summary": "鍦板尯鍒楄〃",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鍩庡競ID",
+                        "name": "city_id",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
                 "responses": {
                     "200": {
                         "description": "OK",
@@ -8851,6 +8900,123 @@
                 }
             }
         },
+        "response.DataResponse": {
+            "type": "object",
+            "properties": {
+                "city": {
+                    "description": "鍩庡競鏁版嵁",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.City"
+                    }
+                },
+                "client_level": {
+                    "description": "瀹㈡埛绛夌骇",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ClientLevel"
+                    }
+                },
+                "client_origin": {
+                    "description": "瀹㈡埛鏉ユ簮",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ClientOrigin"
+                    }
+                },
+                "client_status": {
+                    "description": "瀹㈡埛鐘舵��",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ClientStatus"
+                    }
+                },
+                "client_type": {
+                    "description": "瀹㈡埛绫诲瀷",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ClientType"
+                    }
+                },
+                "country": {
+                    "description": "鍥藉鏁版嵁",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.Country"
+                    }
+                },
+                "enterprise_nature": {
+                    "description": "浼佷笟鎬ц川",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.EnterpriseNature"
+                    }
+                },
+                "enterprise_scale": {
+                    "description": "浼佷笟瑙勬ā",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.EnterpriseScale"
+                    }
+                },
+                "industry": {
+                    "description": "琛屼笟",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.Industry"
+                    }
+                },
+                "province": {
+                    "description": "鐪佷唤鏁版嵁",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.Province"
+                    }
+                },
+                "region": {
+                    "description": "鍖哄煙鏁版嵁",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.Region"
+                    }
+                },
+                "registered_capital": {
+                    "description": "娉ㄥ唽璧勯噾",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.RegisteredCapital"
+                    }
+                },
+                "regular_customers": {
+                    "description": "鑰佸鎴疯惀閿�",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.RegularCustomers"
+                    }
+                },
+                "sale_stage": {
+                    "description": "閿�鍞樁娈�",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.SaleStage"
+                    }
+                },
+                "sale_type": {
+                    "description": "閿�鍞被鍨�",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.SaleType"
+                    }
+                },
+                "sales_source": {
+                    "description": "鍟嗘満鏉ユ簮",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.SalesSources"
+                    }
+                }
+            }
+        },
         "response.EnterpriseNatureResponse": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 27a60ff..77ee54e 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -224,7 +224,7 @@
                     {
                         "type": "integer",
                         "description": "鐪佷唤ID",
-                        "name": "provinceId",
+                        "name": "province_id",
                         "in": "query"
                     }
                 ],
@@ -400,7 +400,7 @@
             }
         },
         "/api/client/update": {
-            "post": {
+            "put": {
                 "produces": [
                     "application/json"
                 ],
@@ -1366,6 +1366,37 @@
                         "description": "OK",
                         "schema": {
                             "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/data/getAllData": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "Data"
+                ],
+                "summary": "鑾峰彇鎵�鏈夋暟鎹�",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/contextx.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "$ref": "#/definitions/response.DataResponse"
+                                        }
+                                    }
+                                }
+                            ]
                         }
                     }
                 }
@@ -2454,6 +2485,15 @@
                     "Province"
                 ],
                 "summary": "鑾峰彇鐪佷唤鍒楄〃",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鍥藉ID",
+                        "name": "country_id",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
                 "responses": {
                     "200": {
                         "description": "OK",
@@ -2722,6 +2762,15 @@
                     "Region"
                 ],
                 "summary": "鍦板尯鍒楄〃",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鍩庡競ID",
+                        "name": "city_id",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
                 "responses": {
                     "200": {
                         "description": "OK",
@@ -8839,6 +8888,123 @@
                 }
             }
         },
+        "response.DataResponse": {
+            "type": "object",
+            "properties": {
+                "city": {
+                    "description": "鍩庡競鏁版嵁",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.City"
+                    }
+                },
+                "client_level": {
+                    "description": "瀹㈡埛绛夌骇",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ClientLevel"
+                    }
+                },
+                "client_origin": {
+                    "description": "瀹㈡埛鏉ユ簮",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ClientOrigin"
+                    }
+                },
+                "client_status": {
+                    "description": "瀹㈡埛鐘舵��",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ClientStatus"
+                    }
+                },
+                "client_type": {
+                    "description": "瀹㈡埛绫诲瀷",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ClientType"
+                    }
+                },
+                "country": {
+                    "description": "鍥藉鏁版嵁",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.Country"
+                    }
+                },
+                "enterprise_nature": {
+                    "description": "浼佷笟鎬ц川",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.EnterpriseNature"
+                    }
+                },
+                "enterprise_scale": {
+                    "description": "浼佷笟瑙勬ā",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.EnterpriseScale"
+                    }
+                },
+                "industry": {
+                    "description": "琛屼笟",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.Industry"
+                    }
+                },
+                "province": {
+                    "description": "鐪佷唤鏁版嵁",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.Province"
+                    }
+                },
+                "region": {
+                    "description": "鍖哄煙鏁版嵁",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.Region"
+                    }
+                },
+                "registered_capital": {
+                    "description": "娉ㄥ唽璧勯噾",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.RegisteredCapital"
+                    }
+                },
+                "regular_customers": {
+                    "description": "鑰佸鎴疯惀閿�",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.RegularCustomers"
+                    }
+                },
+                "sale_stage": {
+                    "description": "閿�鍞樁娈�",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.SaleStage"
+                    }
+                },
+                "sale_type": {
+                    "description": "閿�鍞被鍨�",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.SaleType"
+                    }
+                },
+                "sales_source": {
+                    "description": "鍟嗘満鏉ユ簮",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.SalesSources"
+                    }
+                }
+            }
+        },
         "response.EnterpriseNatureResponse": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 5d4b73c..9ebebbd 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -2707,6 +2707,89 @@
           $ref: '#/definitions/model.Country'
         type: array
     type: object
+  response.DataResponse:
+    properties:
+      city:
+        description: 鍩庡競鏁版嵁
+        items:
+          $ref: '#/definitions/model.City'
+        type: array
+      client_level:
+        description: 瀹㈡埛绛夌骇
+        items:
+          $ref: '#/definitions/model.ClientLevel'
+        type: array
+      client_origin:
+        description: 瀹㈡埛鏉ユ簮
+        items:
+          $ref: '#/definitions/model.ClientOrigin'
+        type: array
+      client_status:
+        description: 瀹㈡埛鐘舵��
+        items:
+          $ref: '#/definitions/model.ClientStatus'
+        type: array
+      client_type:
+        description: 瀹㈡埛绫诲瀷
+        items:
+          $ref: '#/definitions/model.ClientType'
+        type: array
+      country:
+        description: 鍥藉鏁版嵁
+        items:
+          $ref: '#/definitions/model.Country'
+        type: array
+      enterprise_nature:
+        description: 浼佷笟鎬ц川
+        items:
+          $ref: '#/definitions/model.EnterpriseNature'
+        type: array
+      enterprise_scale:
+        description: 浼佷笟瑙勬ā
+        items:
+          $ref: '#/definitions/model.EnterpriseScale'
+        type: array
+      industry:
+        description: 琛屼笟
+        items:
+          $ref: '#/definitions/model.Industry'
+        type: array
+      province:
+        description: 鐪佷唤鏁版嵁
+        items:
+          $ref: '#/definitions/model.Province'
+        type: array
+      region:
+        description: 鍖哄煙鏁版嵁
+        items:
+          $ref: '#/definitions/model.Region'
+        type: array
+      registered_capital:
+        description: 娉ㄥ唽璧勯噾
+        items:
+          $ref: '#/definitions/model.RegisteredCapital'
+        type: array
+      regular_customers:
+        description: 鑰佸鎴疯惀閿�
+        items:
+          $ref: '#/definitions/model.RegularCustomers'
+        type: array
+      sale_stage:
+        description: 閿�鍞樁娈�
+        items:
+          $ref: '#/definitions/model.SaleStage'
+        type: array
+      sale_type:
+        description: 閿�鍞被鍨�
+        items:
+          $ref: '#/definitions/model.SaleType'
+        type: array
+      sales_source:
+        description: 鍟嗘満鏉ユ簮
+        items:
+          $ref: '#/definitions/model.SalesSources'
+        type: array
+    type: object
   response.EnterpriseNatureResponse:
     properties:
       list:
@@ -3024,7 +3107,7 @@
       parameters:
       - description: 鐪佷唤ID
         in: query
-        name: provinceId
+        name: province_id
         type: integer
       produces:
       - application/json
@@ -3134,7 +3217,7 @@
       tags:
       - Client
   /api/client/update:
-    post:
+    put:
       parameters:
       - description: 鏌ヨ鍙傛暟
         in: body
@@ -3732,6 +3815,23 @@
       summary: 鏇存柊瀹㈡湇鍗�
       tags:
       - CustomerServiceSheet
+  /api/data/getAllData:
+    get:
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            allOf:
+            - $ref: '#/definitions/contextx.Response'
+            - properties:
+                data:
+                  $ref: '#/definitions/response.DataResponse'
+              type: object
+      summary: 鑾峰彇鎵�鏈夋暟鎹�
+      tags:
+      - Data
   /api/enterpriseNature/add:
     post:
       parameters:
@@ -4392,6 +4492,12 @@
       - Province
   /api/province/list:
     get:
+      parameters:
+      - description: 鍥藉ID
+        in: query
+        name: country_id
+        required: true
+        type: integer
       produces:
       - application/json
       responses:
@@ -4557,6 +4663,12 @@
       - Region
   /api/region/list:
     get:
+      parameters:
+      - description: 鍩庡競ID
+        in: query
+        name: city_id
+        required: true
+        type: integer
       produces:
       - application/json
       responses:
diff --git a/model/province.go b/model/province.go
index 2d7524c..6e9e908 100644
--- a/model/province.go
+++ b/model/province.go
@@ -44,6 +44,10 @@
 		db = db.Where("name = ?", slf.Name)
 	}
 
+	if slf.CountryId != 0 {
+		db = db.Where("country_id = ?", slf.CountryId)
+	}
+
 	return db
 }
 
@@ -85,6 +89,11 @@
 	return slf
 }
 
+func (slf *ProvinceSearch) SetCountryId(countryId int) *ProvinceSearch {
+	slf.CountryId = countryId
+	return slf
+}
+
 func (slf *ProvinceSearch) UpdateList(m map[string]interface{}, ids []int) error {
 	var db = slf.build()
 	return db.Where("id in (?)", ids).Updates(m).Error
diff --git a/model/region.go b/model/region.go
index 320c11d..097d201 100644
--- a/model/region.go
+++ b/model/region.go
@@ -77,6 +77,11 @@
 	return slf
 }
 
+func (slf *RegionSearch) SetCityId(cityId int) *RegionSearch {
+	slf.CityId = cityId
+	return slf
+}
+
 func (slf *RegionSearch) First() (*Region, error) {
 	var db = slf.build()
 	var record Region
diff --git a/router/data.go b/router/data.go
new file mode 100644
index 0000000..7ef135b
--- /dev/null
+++ b/router/data.go
@@ -0,0 +1 @@
+package router
diff --git a/router/index.go b/router/index.go
index cdac9d3..cfe067d 100644
--- a/router/index.go
+++ b/router/index.go
@@ -52,6 +52,7 @@
 	ServiceFeeManageRouter
 	AuthorityRouter
 	MenuRouter
+	DataRouter
 }
 
 func InitRouter() *gin.Engine {
@@ -123,6 +124,7 @@
 		routerGroup.InitServiceFeeManageRouter(PrivateGroup)     // 娉ㄥ唽serviceFeeManage璺敱
 		routerGroup.InitAuthorityRouter(PrivateGroup)            // 娉ㄥ唽authority璺敱
 		routerGroup.InitMenuRouter(PrivateGroup)                 // 娉ㄥ唽menu璺敱
+		routerGroup.InitDataRouter(PrivateGroup)                 // 娉ㄥ唽data璺敱
 	}
 	return Router
 }
diff --git a/service/dataServer.go b/service/dataServer.go
new file mode 100644
index 0000000..6d43c33
--- /dev/null
+++ b/service/dataServer.go
@@ -0,0 +1 @@
+package service
diff --git a/service/index.go b/service/index.go
index 9ee20bc..eeffe08 100644
--- a/service/index.go
+++ b/service/index.go
@@ -42,6 +42,7 @@
 	CasbinService
 	AuthorityService
 	MenuService
+	DataServer
 }
 
 var ServiceGroup = new(Group)
diff --git a/service/province.go b/service/province.go
index 75cc20c..533c9f4 100644
--- a/service/province.go
+++ b/service/province.go
@@ -45,13 +45,21 @@
 	return ecode.OK
 }
 
-func (ProvinceService) GetProvinces() ([]*model.Province, int) {
-	list, err := model.NewProvinceSearch(nil).FindAll()
-	if err != nil {
-		return nil, ecode.ProvinceGetListErr
+func (ProvinceService) GetProvinces(countryId int) ([]*model.Province, int) {
+	// get province list
+	if countryId != 0 {
+		list, err := model.NewProvinceSearch(nil).SetCountryId(countryId).FindAll()
+		if err != nil {
+			return nil, ecode.ProvinceNotExist
+		}
+		return list, ecode.OK
+	} else {
+		list, err := model.NewProvinceSearch(nil).FindAll()
+		if err != nil {
+			return nil, ecode.ProvinceNotExist
+		}
+		return list, ecode.OK
 	}
-
-	return list, ecode.OK
 }
 
 func (ProvinceService) SetProvinces(countryId int, list []int) int {
diff --git a/service/region.go b/service/region.go
index f7b2a7c..cfaf096 100644
--- a/service/region.go
+++ b/service/region.go
@@ -61,12 +61,21 @@
 	return ecode.OK
 }
 
-func (RegionService) ListRegions() ([]*model.Region, int) {
+func (RegionService) ListRegions(id int) ([]*model.Region, int) {
 	// get region list
-	list, err := model.NewRegionSearch().FindAll()
-	if err != nil {
-		return nil, ecode.RegionListErr
-	}
+	if id != 0 {
+		list, err := model.NewRegionSearch().SetCityId(id).FindAll()
+		if err != nil {
+			return nil, ecode.RegionListErr
+		}
 
-	return list, ecode.OK
+		return list, ecode.OK
+	} else {
+		list, err := model.NewRegionSearch().FindAll()
+		if err != nil {
+			return nil, ecode.RegionListErr
+		}
+
+		return list, ecode.OK
+	}
 }

--
Gitblit v1.8.0