fix
Add a request field to get the province, region information based on the country id, cityId
| | |
| | | |
| | | // 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 { |
| | |
| | | } |
| | | |
| | | // 获取省份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) |
| | |
| | | // @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, ¶ms) |
| | |
| | | type ProvinceApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags Province |
| | | // @Summary 添加省份 |
| | | // @Produce application/json |
| | |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags Province |
| | | // @Summary 更新省份 |
| | | // @Produce application/json |
| | |
| | | } |
| | | |
| | | // 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) |
| | |
| | | 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 |
| | |
| | | } |
| | | |
| | | // Set |
| | | // |
| | | // @Tags Province |
| | | // @Summary 设置省份 |
| | | // @Produce application/json |
| | |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags Province |
| | | // @Summary 删除省份 |
| | | // @Produce application/json |
| | |
| | | type RegionApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags Region |
| | | // @Summary 添加地区 |
| | | // @Produce application/json |
| | |
| | | } |
| | | |
| | | // Set |
| | | // |
| | | // @Tags Region |
| | | // @Summary 设置地区 |
| | | // @Produce application/json |
| | |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags Region |
| | | // @Summary 删除地区 |
| | | // @Produce application/json |
| | |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags Region |
| | | // @Summary 更新地区 |
| | | // @Produce application/json |
| | |
| | | } |
| | | |
| | | // 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) |
| | |
| | | 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 |
| | |
| | | { |
| | | "type": "integer", |
| | | "description": "省份ID", |
| | | "name": "provinceId", |
| | | "name": "province_id", |
| | | "in": "query" |
| | | } |
| | | ], |
| | |
| | | } |
| | | }, |
| | | "/api/client/update": { |
| | | "post": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | |
| | | "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" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | |
| | | "Province" |
| | | ], |
| | | "summary": "获取省份列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "国家ID", |
| | | "name": "country_id", |
| | | "in": "query", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | |
| | | "Region" |
| | | ], |
| | | "summary": "地区列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "城市ID", |
| | | "name": "city_id", |
| | | "in": "query", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "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": { |
| | |
| | | { |
| | | "type": "integer", |
| | | "description": "省份ID", |
| | | "name": "provinceId", |
| | | "name": "province_id", |
| | | "in": "query" |
| | | } |
| | | ], |
| | |
| | | } |
| | | }, |
| | | "/api/client/update": { |
| | | "post": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | |
| | | "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" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | |
| | | "Province" |
| | | ], |
| | | "summary": "获取省份列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "国家ID", |
| | | "name": "country_id", |
| | | "in": "query", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | |
| | | "Region" |
| | | ], |
| | | "summary": "地区列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "城市ID", |
| | | "name": "city_id", |
| | | "in": "query", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "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": { |
| | |
| | | $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: |
| | |
| | | parameters: |
| | | - description: 省份ID |
| | | in: query |
| | | name: provinceId |
| | | name: province_id |
| | | type: integer |
| | | produces: |
| | | - application/json |
| | |
| | | tags: |
| | | - Client |
| | | /api/client/update: |
| | | post: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | |
| | | 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: |
| | |
| | | - Province |
| | | /api/province/list: |
| | | get: |
| | | parameters: |
| | | - description: 国家ID |
| | | in: query |
| | | name: country_id |
| | | required: true |
| | | type: integer |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | - Region |
| | | /api/region/list: |
| | | get: |
| | | parameters: |
| | | - description: 城市ID |
| | | in: query |
| | | name: city_id |
| | | required: true |
| | | type: integer |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | db = db.Where("name = ?", slf.Name) |
| | | } |
| | | |
| | | if slf.CountryId != 0 { |
| | | db = db.Where("country_id = ?", slf.CountryId) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | ServiceFeeManageRouter |
| | | AuthorityRouter |
| | | MenuRouter |
| | | DataRouter |
| | | } |
| | | |
| | | func InitRouter() *gin.Engine { |
| | |
| | | routerGroup.InitServiceFeeManageRouter(PrivateGroup) // 注册serviceFeeManage路由 |
| | | routerGroup.InitAuthorityRouter(PrivateGroup) // 注册authority路由 |
| | | routerGroup.InitMenuRouter(PrivateGroup) // 注册menu路由 |
| | | routerGroup.InitDataRouter(PrivateGroup) // 注册data路由 |
| | | } |
| | | return Router |
| | | } |
| | |
| | | CasbinService |
| | | AuthorityService |
| | | MenuService |
| | | DataServer |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |
| | |
| | | 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 { |
| | |
| | | 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 |
| | | } |
| | | } |