add
saleStage 销售阶段
add, Delete, update, list
| | |
| | | SalesSourcesApi |
| | | FollowRecordApi |
| | | SaleChanceApi |
| | | SaleStageApi |
| | | } |
| | | |
| | | var ApiGroup = new(Group) |
| | |
| | | salesSourcesService = service.ServiceGroup.SalesSourcesService |
| | | followRecordService = service.ServiceGroup.FollowRecordService |
| | | saleChanceService = service.ServiceGroup.SaleChanceService |
| | | saleStageService = service.ServiceGroup.SaleStageService |
| | | ) |
New file |
| | |
| | | package v1 |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/model/response" |
| | | "aps_crm/pkg/contextx" |
| | | "aps_crm/pkg/ecode" |
| | | "github.com/gin-gonic/gin" |
| | | "strconv" |
| | | ) |
| | | |
| | | type SaleStageApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags SaleStage |
| | | // @Summary 添加销售阶段 |
| | | // @Produce application/json |
| | | // @Param object body request.AddSaleStage true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/saleStage/add [post] |
| | | func (s *SaleStageApi) Add(c *gin.Context) { |
| | | var params request.AddSaleStage |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | saleStage := new(model.SaleStage) |
| | | saleStage.Name = params.Name |
| | | |
| | | errCode := saleStageService.AddSaleStage(saleStage) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags SaleStage |
| | | // @Summary 删除销售阶段 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/saleStage/delete/{id} [delete] |
| | | func (s *SaleStageApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := saleStageService.DeleteSaleStage(id) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags SaleStage |
| | | // @Summary 更新销售阶段 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateSaleStages true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/saleStage/update [put] |
| | | func (s *SaleStageApi) Update(c *gin.Context) { |
| | | var params request.UpdateSaleStages |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode := saleStageService.UpdateSaleStage(params.SaleStages) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags SaleStage |
| | | // @Summary 获取销售阶段列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.SaleStageResponse} |
| | | // @Router /api/saleStage/list [get] |
| | | func (s *SaleStageApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | saleStages, errCode := saleStageService.GetSaleStageList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.SaleStageResponse{ |
| | | List: saleStages, |
| | | }) |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/saleStage/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SaleStage" |
| | | ], |
| | | "summary": "添加销售阶段", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddSaleStage" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/saleStage/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SaleStage" |
| | | ], |
| | | "summary": "删除销售阶段", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/saleStage/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SaleStage" |
| | | ], |
| | | "summary": "获取销售阶段列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.SaleStageResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/saleStage/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SaleStage" |
| | | ], |
| | | "summary": "更新销售阶段", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateSaleStages" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesLeads/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "city_id": { |
| | | "type": "integer" |
| | | }, |
| | | "client_id": { |
| | | "type": "integer" |
| | | }, |
| | | "country": { |
| | | "$ref": "#/definitions/model.Country" |
| | | }, |
| | | "country_id": { |
| | | "type": "integer" |
| | | }, |
| | | "desc": { |
| | | "type": "string" |
| | | }, |
| | | "email": { |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "is_first": { |
| | | "type": "boolean" |
| | | }, |
| | | "member_id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "phone": { |
| | | "type": "string" |
| | | }, |
| | | "position": { |
| | | "type": "string" |
| | | }, |
| | | "province": { |
| | | "$ref": "#/definitions/model.Province" |
| | | }, |
| | | "province_id": { |
| | | "type": "integer" |
| | | }, |
| | | "region": { |
| | | "$ref": "#/definitions/model.Region" |
| | | }, |
| | | "region_id": { |
| | | "type": "integer" |
| | | }, |
| | | "wechat": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.ContactDetail": { |
| | | "type": "object", |
| | | "properties": { |
| | | "birthday": { |
| | | "type": "string" |
| | | }, |
| | | "city": { |
| | | "$ref": "#/definitions/model.City" |
| | | }, |
| | | "city_id": { |
| | | "type": "integer" |
| | | }, |
| | | "client": { |
| | | "$ref": "#/definitions/model.Client" |
| | | }, |
| | |
| | | "city_id": { |
| | | "type": "integer" |
| | | }, |
| | | "client": { |
| | | "$ref": "#/definitions/model.Client" |
| | | }, |
| | | "client_id": { |
| | | "type": "integer" |
| | | }, |
| | | "competitors": { |
| | | "type": "string" |
| | | }, |
| | | "contact": { |
| | | "$ref": "#/definitions/model.Contact" |
| | | }, |
| | | "contact_id": { |
| | | "type": "integer" |
| | |
| | | "sale_type_id": { |
| | | "type": "integer" |
| | | }, |
| | | "salesSources": { |
| | | "$ref": "#/definitions/model.SalesSources" |
| | | }, |
| | | "sales_sources_id": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "type": "string" |
| | | }, |
| | | "whether_established": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.SaleStage": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | }, |
| | | "request.AddSaleChance": { |
| | | "type": "object", |
| | | "required": [ |
| | | "advantages", |
| | | "budget", |
| | | "capital_budget", |
| | | "client_id", |
| | | "competitors", |
| | | "contact_id", |
| | | "currency", |
| | | "disadvantages", |
| | | "expected_time", |
| | | "key_factors", |
| | | "key_maker", |
| | | "member_id", |
| | | "name", |
| | | "number", |
| | | "opportunities", |
| | | "pain_points", |
| | | "possibilities", |
| | | "process", |
| | | "projected_amount", |
| | | "regular_customers_id", |
| | | "sale_stage_id", |
| | | "sale_type_id", |
| | | "sales_sources_id", |
| | | "solutions", |
| | | "status_id", |
| | | "threats", |
| | | "whether_established" |
| | | ], |
| | | "properties": { |
| | | "advantages": { |
| | | "type": "string" |
| | |
| | | "type": "string" |
| | | }, |
| | | "whether_established": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddSaleStage": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | "request.UpdateSaleChance": { |
| | | "type": "object", |
| | | "required": [ |
| | | "advantages", |
| | | "budget", |
| | | "capital_budget", |
| | | "client_id", |
| | | "competitors", |
| | | "contact_id", |
| | | "currency", |
| | | "disadvantages", |
| | | "expected_time", |
| | | "id", |
| | | "key_factors", |
| | | "key_maker", |
| | | "member_id", |
| | | "name", |
| | | "number", |
| | | "opportunities", |
| | | "pain_points", |
| | | "possibilities", |
| | | "process", |
| | | "projected_amount", |
| | | "regular_customers_id", |
| | | "sale_stage_id", |
| | | "sale_type_id", |
| | | "sales_sources_id", |
| | | "solutions", |
| | | "status_id", |
| | | "threats", |
| | | "whether_established" |
| | | "id" |
| | | ], |
| | | "properties": { |
| | | "advantages": { |
| | |
| | | }, |
| | | "whether_established": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSaleStage": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSaleStages": { |
| | | "type": "object", |
| | | "required": [ |
| | | "sale_stages" |
| | | ], |
| | | "properties": { |
| | | "sale_stages": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateSaleStage" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Contact" |
| | | "$ref": "#/definitions/model.ContactDetail" |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.SaleStageResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.SaleStage" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.SalesLeadsResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/saleStage/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SaleStage" |
| | | ], |
| | | "summary": "添加销售阶段", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddSaleStage" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/saleStage/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SaleStage" |
| | | ], |
| | | "summary": "删除销售阶段", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/saleStage/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SaleStage" |
| | | ], |
| | | "summary": "获取销售阶段列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.SaleStageResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/saleStage/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SaleStage" |
| | | ], |
| | | "summary": "更新销售阶段", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateSaleStages" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesLeads/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "city_id": { |
| | | "type": "integer" |
| | | }, |
| | | "client_id": { |
| | | "type": "integer" |
| | | }, |
| | | "country": { |
| | | "$ref": "#/definitions/model.Country" |
| | | }, |
| | | "country_id": { |
| | | "type": "integer" |
| | | }, |
| | | "desc": { |
| | | "type": "string" |
| | | }, |
| | | "email": { |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "is_first": { |
| | | "type": "boolean" |
| | | }, |
| | | "member_id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "phone": { |
| | | "type": "string" |
| | | }, |
| | | "position": { |
| | | "type": "string" |
| | | }, |
| | | "province": { |
| | | "$ref": "#/definitions/model.Province" |
| | | }, |
| | | "province_id": { |
| | | "type": "integer" |
| | | }, |
| | | "region": { |
| | | "$ref": "#/definitions/model.Region" |
| | | }, |
| | | "region_id": { |
| | | "type": "integer" |
| | | }, |
| | | "wechat": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.ContactDetail": { |
| | | "type": "object", |
| | | "properties": { |
| | | "birthday": { |
| | | "type": "string" |
| | | }, |
| | | "city": { |
| | | "$ref": "#/definitions/model.City" |
| | | }, |
| | | "city_id": { |
| | | "type": "integer" |
| | | }, |
| | | "client": { |
| | | "$ref": "#/definitions/model.Client" |
| | | }, |
| | |
| | | "city_id": { |
| | | "type": "integer" |
| | | }, |
| | | "client": { |
| | | "$ref": "#/definitions/model.Client" |
| | | }, |
| | | "client_id": { |
| | | "type": "integer" |
| | | }, |
| | | "competitors": { |
| | | "type": "string" |
| | | }, |
| | | "contact": { |
| | | "$ref": "#/definitions/model.Contact" |
| | | }, |
| | | "contact_id": { |
| | | "type": "integer" |
| | |
| | | "sale_type_id": { |
| | | "type": "integer" |
| | | }, |
| | | "salesSources": { |
| | | "$ref": "#/definitions/model.SalesSources" |
| | | }, |
| | | "sales_sources_id": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "type": "string" |
| | | }, |
| | | "whether_established": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.SaleStage": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | }, |
| | | "request.AddSaleChance": { |
| | | "type": "object", |
| | | "required": [ |
| | | "advantages", |
| | | "budget", |
| | | "capital_budget", |
| | | "client_id", |
| | | "competitors", |
| | | "contact_id", |
| | | "currency", |
| | | "disadvantages", |
| | | "expected_time", |
| | | "key_factors", |
| | | "key_maker", |
| | | "member_id", |
| | | "name", |
| | | "number", |
| | | "opportunities", |
| | | "pain_points", |
| | | "possibilities", |
| | | "process", |
| | | "projected_amount", |
| | | "regular_customers_id", |
| | | "sale_stage_id", |
| | | "sale_type_id", |
| | | "sales_sources_id", |
| | | "solutions", |
| | | "status_id", |
| | | "threats", |
| | | "whether_established" |
| | | ], |
| | | "properties": { |
| | | "advantages": { |
| | | "type": "string" |
| | |
| | | "type": "string" |
| | | }, |
| | | "whether_established": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddSaleStage": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | "request.UpdateSaleChance": { |
| | | "type": "object", |
| | | "required": [ |
| | | "advantages", |
| | | "budget", |
| | | "capital_budget", |
| | | "client_id", |
| | | "competitors", |
| | | "contact_id", |
| | | "currency", |
| | | "disadvantages", |
| | | "expected_time", |
| | | "id", |
| | | "key_factors", |
| | | "key_maker", |
| | | "member_id", |
| | | "name", |
| | | "number", |
| | | "opportunities", |
| | | "pain_points", |
| | | "possibilities", |
| | | "process", |
| | | "projected_amount", |
| | | "regular_customers_id", |
| | | "sale_stage_id", |
| | | "sale_type_id", |
| | | "sales_sources_id", |
| | | "solutions", |
| | | "status_id", |
| | | "threats", |
| | | "whether_established" |
| | | "id" |
| | | ], |
| | | "properties": { |
| | | "advantages": { |
| | |
| | | }, |
| | | "whether_established": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSaleStage": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSaleStages": { |
| | | "type": "object", |
| | | "required": [ |
| | | "sale_stages" |
| | | ], |
| | | "properties": { |
| | | "sale_stages": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateSaleStage" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Contact" |
| | | "$ref": "#/definitions/model.ContactDetail" |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.SaleStageResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.SaleStage" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.SalesLeadsResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | $ref: '#/definitions/model.City' |
| | | city_id: |
| | | type: integer |
| | | client_id: |
| | | type: integer |
| | | country: |
| | | $ref: '#/definitions/model.Country' |
| | | country_id: |
| | | type: integer |
| | | desc: |
| | | type: string |
| | | email: |
| | | type: string |
| | | id: |
| | | type: integer |
| | | is_first: |
| | | type: boolean |
| | | member_id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | number: |
| | | type: string |
| | | phone: |
| | | type: string |
| | | position: |
| | | type: string |
| | | province: |
| | | $ref: '#/definitions/model.Province' |
| | | province_id: |
| | | type: integer |
| | | region: |
| | | $ref: '#/definitions/model.Region' |
| | | region_id: |
| | | type: integer |
| | | wechat: |
| | | type: string |
| | | type: object |
| | | model.ContactDetail: |
| | | properties: |
| | | birthday: |
| | | type: string |
| | | city: |
| | | $ref: '#/definitions/model.City' |
| | | city_id: |
| | | type: integer |
| | | client: |
| | | $ref: '#/definitions/model.Client' |
| | | client_id: |
| | |
| | | $ref: '#/definitions/model.City' |
| | | city_id: |
| | | type: integer |
| | | client: |
| | | $ref: '#/definitions/model.Client' |
| | | client_id: |
| | | type: integer |
| | | competitors: |
| | | type: string |
| | | contact: |
| | | $ref: '#/definitions/model.Contact' |
| | | contact_id: |
| | | type: integer |
| | | country: |
| | |
| | | type: integer |
| | | sales_sources_id: |
| | | type: integer |
| | | salesSources: |
| | | $ref: '#/definitions/model.SalesSources' |
| | | solutions: |
| | | type: string |
| | | status_id: |
| | |
| | | threats: |
| | | type: string |
| | | whether_established: |
| | | type: string |
| | | type: object |
| | | model.SaleStage: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.SalesLeads: |
| | |
| | | type: string |
| | | whether_established: |
| | | type: string |
| | | type: object |
| | | request.AddSaleStage: |
| | | properties: |
| | | name: |
| | | type: string |
| | | required: |
| | | - advantages |
| | | - budget |
| | | - capital_budget |
| | | - client_id |
| | | - competitors |
| | | - contact_id |
| | | - currency |
| | | - disadvantages |
| | | - expected_time |
| | | - key_factors |
| | | - key_maker |
| | | - member_id |
| | | - name |
| | | - number |
| | | - opportunities |
| | | - pain_points |
| | | - possibilities |
| | | - process |
| | | - projected_amount |
| | | - regular_customers_id |
| | | - sale_stage_id |
| | | - sale_type_id |
| | | - sales_sources_id |
| | | - solutions |
| | | - status_id |
| | | - threats |
| | | - whether_established |
| | | type: object |
| | | request.AddSalesLeads: |
| | | properties: |
| | |
| | | whether_established: |
| | | type: string |
| | | required: |
| | | - advantages |
| | | - budget |
| | | - capital_budget |
| | | - client_id |
| | | - competitors |
| | | - contact_id |
| | | - currency |
| | | - disadvantages |
| | | - expected_time |
| | | - id |
| | | - key_factors |
| | | - key_maker |
| | | - member_id |
| | | type: object |
| | | request.UpdateSaleStage: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | required: |
| | | - id |
| | | - name |
| | | - number |
| | | - opportunities |
| | | - pain_points |
| | | - possibilities |
| | | - process |
| | | - projected_amount |
| | | - regular_customers_id |
| | | - sale_stage_id |
| | | - sale_type_id |
| | | - sales_sources_id |
| | | - solutions |
| | | - status_id |
| | | - threats |
| | | - whether_established |
| | | type: object |
| | | request.UpdateSaleStages: |
| | | properties: |
| | | sale_stages: |
| | | items: |
| | | $ref: '#/definitions/request.UpdateSaleStage' |
| | | type: array |
| | | required: |
| | | - sale_stages |
| | | type: object |
| | | request.UpdateSalesLeads: |
| | | properties: |
| | |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.Contact' |
| | | $ref: '#/definitions/model.ContactDetail' |
| | | type: array |
| | | type: object |
| | | response.CountryResponse: |
| | |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.SaleChance' |
| | | type: array |
| | | type: object |
| | | response.SaleStageResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.SaleStage' |
| | | type: array |
| | | type: object |
| | | response.SalesLeadsResponse: |
| | |
| | | summary: 更新销售机会 |
| | | tags: |
| | | - SaleChance |
| | | /api/saleStage/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddSaleStage' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加销售阶段 |
| | | tags: |
| | | - SaleStage |
| | | /api/saleStage/delete/{id}: |
| | | delete: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: path |
| | | name: id |
| | | required: true |
| | | type: integer |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 删除销售阶段 |
| | | tags: |
| | | - SaleStage |
| | | /api/saleStage/list: |
| | | get: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.SaleStageResponse' |
| | | type: object |
| | | summary: 获取销售阶段列表 |
| | | tags: |
| | | - SaleStage |
| | | /api/saleStage/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateSaleStages' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新销售阶段 |
| | | tags: |
| | | - SaleStage |
| | | /api/salesLeads/add: |
| | | post: |
| | | parameters: |
| | |
| | | SaleChance{}, |
| | | SalesLeads{}, |
| | | SalesSources{}, |
| | | SaleStage{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | package request |
| | | |
| | | type AddSaleStage struct { |
| | | Name string `json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateSaleStage struct { |
| | | Id int `json:"id" binding:"required"` |
| | | Name string `json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateSaleStages struct { |
| | | SaleStages []*UpdateSaleStage `json:"sale_stages" binding:"required"` |
| | | } |
| | |
| | | SaleChanceResponse struct { |
| | | List []*model.SaleChance `json:"list"` |
| | | } |
| | | |
| | | SaleStageResponse struct { |
| | | List []*model.SaleStage `json:"list"` |
| | | } |
| | | ) |
New file |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | ) |
| | | |
| | | type ( |
| | | // SaleStage 商机阶段 |
| | | SaleStage struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name;type:varchar(255);comment:商机阶段名称"` |
| | | } |
| | | |
| | | // SaleStageSearch 商机阶段搜索条件 |
| | | SaleStageSearch struct { |
| | | SaleStage |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | | |
| | | func (SaleStage) TableName() string { |
| | | return "sale_stage" |
| | | } |
| | | |
| | | func NewSaleStageSearch() *SaleStageSearch { |
| | | return &SaleStageSearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *SaleStageSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&SaleStage{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | if slf.Name != "" { |
| | | db = db.Where("name = ?", slf.Name) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *SaleStageSearch) Create(record *SaleStage) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *SaleStageSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&SaleStage{}).Error |
| | | } |
| | | |
| | | func (slf *SaleStageSearch) Update(record *SaleStage) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *SaleStageSearch) Find() (*SaleStage, error) { |
| | | var db = slf.build() |
| | | var record = new(SaleStage) |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *SaleStageSearch) FindAll() ([]*SaleStage, error) { |
| | | var db = slf.build() |
| | | var records = make([]*SaleStage, 0) |
| | | err := db.Find(&records).Error |
| | | return records, err |
| | | } |
| | | |
| | | func (slf *SaleStageSearch) SetId(id int) *SaleStageSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *SaleStageSearch) SetName(name string) *SaleStageSearch { |
| | | slf.Name = name |
| | | return slf |
| | | } |
| | | |
| | | func (slf *SaleStageSearch) Updates(data map[string]interface{}) error { |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | |
| | | SaleChangeSetErr = 1900004 // 设置销售机会失败 |
| | | SaleChangeUpdateErr = 1900005 // 更新销售机会失败 |
| | | SaleChangeDeleteErr = 1900006 // 删除销售机会失败 |
| | | |
| | | SaleStageExist = 2000001 // 销售阶段已存在 |
| | | SaleStageNotExist = 2000002 // 销售阶段不存在 |
| | | SaleStageListErr = 2000003 // 获取销售阶段列表失败 |
| | | SaleStageSetErr = 2000004 // 设置销售阶段失败 |
| | | ) |
| | |
| | | SalesSourcesRouter |
| | | FollowRecordRouter |
| | | SaleChanceRouter |
| | | SaleStageRouter |
| | | } |
| | | |
| | | func InitRouter() *gin.Engine { |
| | |
| | | routerGroup.InitSalesSourcesRouter(PrivateGroup) // 注册salesSources路由 |
| | | routerGroup.InitFollowRecordRouter(PrivateGroup) // 注册followRecord路由 |
| | | routerGroup.InitSaleChanceRouter(PrivateGroup) // 注册saleChance路由 |
| | | routerGroup.InitSaleStageRouter(PrivateGroup) // 注册saleStage路由 |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type SaleStageRouter struct{} |
| | | |
| | | func (s *SaleStageRouter) InitSaleStageRouter(router *gin.RouterGroup) { |
| | | saleStageRouter := router.Group("saleStage") |
| | | saleStageApi := v1.ApiGroup.SaleStageApi |
| | | { |
| | | saleStageRouter.POST("add", saleStageApi.Add) // 添加销售阶段 |
| | | saleStageRouter.DELETE("delete/:id", saleStageApi.Delete) // 删除销售阶段 |
| | | saleStageRouter.PUT("update", saleStageApi.Update) // 更新销售阶段 |
| | | saleStageRouter.GET("list", saleStageApi.List) // 获取销售阶段列表 |
| | | } |
| | | } |
| | |
| | | SalesSourcesService |
| | | FollowRecordService |
| | | SaleChanceService |
| | | SaleStageService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |
New file |
| | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type SaleStageService struct{} |
| | | |
| | | func (SaleStageService) AddSaleStage(saleStage *model.SaleStage) int { |
| | | err := model.NewSaleStageSearch().Create(saleStage) |
| | | if err != nil { |
| | | return ecode.SaleStageExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SaleStageService) DeleteSaleStage(id int) int { |
| | | _, err := model.NewSaleStageSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.SaleStageNotExist |
| | | } |
| | | |
| | | err = model.NewSaleStageSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.SaleStageNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SaleStageService) GetSaleStageList() ([]*model.SaleStage, int) { |
| | | list, err := model.NewSaleStageSearch().FindAll() |
| | | if err != nil { |
| | | return nil, ecode.SaleStageListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | func (SaleStageService) UpdateSaleStage(saleStages []*request.UpdateSaleStage) int { |
| | | for _, v := range saleStages { |
| | | // check saleStage exist |
| | | _, err := model.NewSaleStageSearch().SetId(v.Id).Find() |
| | | if err != nil { |
| | | return ecode.SaleStageNotExist |
| | | } |
| | | |
| | | err = model.NewSaleStageSearch().SetId(v.Id).Updates(map[string]interface{}{ |
| | | "name": v.Name, |
| | | }) |
| | | if err != nil { |
| | | return ecode.SaleStageSetErr |
| | | } |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SaleStageService) GetSaleStageDetail(id int) (*model.SaleStage, int) { |
| | | saleStage, err := model.NewSaleStageSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return nil, ecode.SaleStageNotExist |
| | | } |
| | | |
| | | return saleStage, ecode.OK |
| | | } |