fix
wangpengfei
2023-07-18 d9ec14b9adf6e90309d763e3b3b1b0f22773f8da
fix

Add a request field to get the province, region information based on the country id, cityId
3个文件已添加
13个文件已修改
555 ■■■■■ 已修改文件
api/v1/city.go 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/client.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/getAllData.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/province.go 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/region.go 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 170 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 170 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 116 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/province.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/region.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/data.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/index.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/dataServer.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/province.go 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/region.go 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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)
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)
api/v1/getAllData.go
New file
@@ -0,0 +1 @@
package v1
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
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
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": {
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": {
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:
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
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
router/data.go
New file
@@ -0,0 +1 @@
package router
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
}
service/dataServer.go
New file
@@ -0,0 +1 @@
package service
service/index.go
@@ -42,6 +42,7 @@
    CasbinService
    AuthorityService
    MenuService
    DataServer
}
var ServiceGroup = new(Group)
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 {
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
    }
}