add
Currency 币种
add, Delete, update, lis
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 CurrencyApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags Currency |
| | | // @Summary 添加币种 |
| | | // @Produce application/json |
| | | // @Param object body request.AddCurrency true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/currency/add [post] |
| | | func (s *CurrencyApi) Add(c *gin.Context) { |
| | | var params request.AddCurrency |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | currency := new(model.Currency) |
| | | currency.Name = params.Name |
| | | |
| | | errCode := currencyService.AddCurrency(currency) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags Currency |
| | | // @Summary 删除币种 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/currency/delete/{id} [delete] |
| | | func (s *CurrencyApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := currencyService.DeleteCurrency(id) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags Currency |
| | | // @Summary 更新币种 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateCurrencys true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/currency/update [put] |
| | | func (s *CurrencyApi) Update(c *gin.Context) { |
| | | var params request.UpdateCurrencys |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode := currencyService.UpdateCurrency(params.Currencys) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags Currency |
| | | // @Summary 获取币种列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.CurrencyResponse} |
| | | // @Router /api/currency/list [get] |
| | | func (s *CurrencyApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | currencys, errCode := currencyService.GetCurrencyList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.CurrencyResponse{ |
| | | List: currencys, |
| | | }) |
| | | } |
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | CurrencyApi |
| | | QuotationStatusApi |
| | | RepositoryApi |
| | | SalesReturnStatusApi |
| | |
| | | salesReturnStatusService = service.ServiceGroup.SalesReturnStatusService |
| | | repositoryService = service.ServiceGroup.RepositoryService |
| | | quotationStatusService = service.ServiceGroup.QuotationStatusService |
| | | currencyService = service.ServiceGroup.CurrencyService |
| | | ) |
| | |
| | | package v1 |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/model/response" |
| | |
| | | sc.PossibilitiesId = saleChance.Possibilities |
| | | sc.Budget = saleChance.Budget |
| | | sc.ProjectedAmount = saleChance.ProjectedAmount |
| | | sc.Currency = constvar.CurrencyType(saleChance.Currency) |
| | | sc.Currency = saleChance.Currency |
| | | sc.StatusId = saleChance.StatusId |
| | | sc.PainPoints = saleChance.PainPoints |
| | | sc.WhetherEstablished = saleChance.WhetherEstablished |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/currency/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Currency" |
| | | ], |
| | | "summary": "添加币种", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddCurrency" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/currency/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Currency" |
| | | ], |
| | | "summary": "删除币种", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/currency/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Currency" |
| | | ], |
| | | "summary": "获取币种列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.CurrencyResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/currency/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Currency" |
| | | ], |
| | | "summary": "更新币种", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateCurrencys" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/customerServiceSheet/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | }, |
| | | "definitions": { |
| | | "constvar.CurrencyType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2, |
| | | 3, |
| | | 4 |
| | | ], |
| | | "x-enum-comments": { |
| | | "CurrencyTypeCNY": "人民币", |
| | | "CurrencyTypeEUR": "欧元", |
| | | "CurrencyTypeGBP": "英镑", |
| | | "CurrencyTypeUSD": "美元" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "CurrencyTypeCNY", |
| | | "CurrencyTypeUSD", |
| | | "CurrencyTypeEUR", |
| | | "CurrencyTypeGBP" |
| | | ] |
| | | }, |
| | | "constvar.SalesStatus": { |
| | | "type": "integer", |
| | | "enum": [ |
| | |
| | | "items": { |
| | | "$ref": "#/definitions/model.Province" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "model.Currency": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "type": "integer" |
| | | }, |
| | | "currency": { |
| | | "$ref": "#/definitions/constvar.CurrencyType" |
| | | "type": "integer" |
| | | }, |
| | | "detail_address": { |
| | | "type": "string" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.Status": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.SubOrder": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "properties": { |
| | | "name": { |
| | | "description": "国家名称", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddCurrency": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateCurrency": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateCurrencys": { |
| | | "type": "object", |
| | | "required": [ |
| | | "currency" |
| | | ], |
| | | "properties": { |
| | | "currency": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateCurrency" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateCustomerServiceSheet": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.CurrencyResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Currency" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.DataResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Country" |
| | | } |
| | | }, |
| | | "currency": { |
| | | "description": "币种", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Currency" |
| | | } |
| | | }, |
| | | "department": { |
| | |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.OrderType" |
| | | } |
| | | }, |
| | | "possibility": { |
| | | "description": "可能性", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Possibility" |
| | | } |
| | | }, |
| | | "province": { |
| | |
| | | "$ref": "#/definitions/model.SolveRate" |
| | | } |
| | | }, |
| | | "status": { |
| | | "description": "状态", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Status" |
| | | } |
| | | }, |
| | | "timely_rate": { |
| | | "description": "及时率", |
| | | "type": "array", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/currency/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Currency" |
| | | ], |
| | | "summary": "添加币种", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddCurrency" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/currency/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Currency" |
| | | ], |
| | | "summary": "删除币种", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/currency/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Currency" |
| | | ], |
| | | "summary": "获取币种列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.CurrencyResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/currency/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Currency" |
| | | ], |
| | | "summary": "更新币种", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateCurrencys" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/customerServiceSheet/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | }, |
| | | "definitions": { |
| | | "constvar.CurrencyType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2, |
| | | 3, |
| | | 4 |
| | | ], |
| | | "x-enum-comments": { |
| | | "CurrencyTypeCNY": "人民币", |
| | | "CurrencyTypeEUR": "欧元", |
| | | "CurrencyTypeGBP": "英镑", |
| | | "CurrencyTypeUSD": "美元" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "CurrencyTypeCNY", |
| | | "CurrencyTypeUSD", |
| | | "CurrencyTypeEUR", |
| | | "CurrencyTypeGBP" |
| | | ] |
| | | }, |
| | | "constvar.SalesStatus": { |
| | | "type": "integer", |
| | | "enum": [ |
| | |
| | | "items": { |
| | | "$ref": "#/definitions/model.Province" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "model.Currency": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "type": "integer" |
| | | }, |
| | | "currency": { |
| | | "$ref": "#/definitions/constvar.CurrencyType" |
| | | "type": "integer" |
| | | }, |
| | | "detail_address": { |
| | | "type": "string" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.Status": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.SubOrder": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "properties": { |
| | | "name": { |
| | | "description": "国家名称", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddCurrency": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateCurrency": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateCurrencys": { |
| | | "type": "object", |
| | | "required": [ |
| | | "currency" |
| | | ], |
| | | "properties": { |
| | | "currency": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateCurrency" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateCustomerServiceSheet": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.CurrencyResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Currency" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.DataResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Country" |
| | | } |
| | | }, |
| | | "currency": { |
| | | "description": "币种", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Currency" |
| | | } |
| | | }, |
| | | "department": { |
| | |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.OrderType" |
| | | } |
| | | }, |
| | | "possibility": { |
| | | "description": "可能性", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Possibility" |
| | | } |
| | | }, |
| | | "province": { |
| | |
| | | "$ref": "#/definitions/model.SolveRate" |
| | | } |
| | | }, |
| | | "status": { |
| | | "description": "状态", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Status" |
| | | } |
| | | }, |
| | | "timely_rate": { |
| | | "description": "及时率", |
| | | "type": "array", |
| | |
| | | definitions: |
| | | constvar.CurrencyType: |
| | | enum: |
| | | - 1 |
| | | - 2 |
| | | - 3 |
| | | - 4 |
| | | type: integer |
| | | x-enum-comments: |
| | | CurrencyTypeCNY: 人民币 |
| | | CurrencyTypeEUR: 欧元 |
| | | CurrencyTypeGBP: 英镑 |
| | | CurrencyTypeUSD: 美元 |
| | | x-enum-varnames: |
| | | - CurrencyTypeCNY |
| | | - CurrencyTypeUSD |
| | | - CurrencyTypeEUR |
| | | - CurrencyTypeGBP |
| | | constvar.SalesStatus: |
| | | enum: |
| | | - 1 |
| | |
| | | $ref: '#/definitions/model.Province' |
| | | type: array |
| | | type: object |
| | | model.Currency: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.CustomerServiceSheet: |
| | | properties: |
| | | handleStatus: |
| | |
| | | country_id: |
| | | type: integer |
| | | currency: |
| | | $ref: '#/definitions/constvar.CurrencyType' |
| | | type: integer |
| | | detail_address: |
| | | type: string |
| | | disadvantages: |
| | |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.Status: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.SubOrder: |
| | | properties: |
| | | client: |
| | |
| | | name: |
| | | description: 国家名称 |
| | | type: string |
| | | type: object |
| | | request.AddCurrency: |
| | | properties: |
| | | name: |
| | | type: string |
| | | required: |
| | | - name |
| | | type: object |
| | | request.AddCustomerServiceSheet: |
| | | properties: |
| | |
| | | description: 国家名称 |
| | | type: string |
| | | type: object |
| | | request.UpdateCurrency: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | required: |
| | | - id |
| | | - name |
| | | type: object |
| | | request.UpdateCurrencys: |
| | | properties: |
| | | currency: |
| | | items: |
| | | $ref: '#/definitions/request.UpdateCurrency' |
| | | type: array |
| | | required: |
| | | - currency |
| | | type: object |
| | | request.UpdateCustomerServiceSheet: |
| | | properties: |
| | | handleStatus: |
| | |
| | | $ref: '#/definitions/model.Country' |
| | | type: array |
| | | type: object |
| | | response.CurrencyResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.Currency' |
| | | type: array |
| | | type: object |
| | | response.DataResponse: |
| | | properties: |
| | | accountId: |
| | |
| | | description: 国家数据 |
| | | items: |
| | | $ref: '#/definitions/model.Country' |
| | | type: array |
| | | currency: |
| | | description: 币种 |
| | | items: |
| | | $ref: '#/definitions/model.Currency' |
| | | type: array |
| | | department: |
| | | description: 部门 |
| | |
| | | description: 工单类型 |
| | | items: |
| | | $ref: '#/definitions/model.OrderType' |
| | | type: array |
| | | possibility: |
| | | description: 可能性 |
| | | items: |
| | | $ref: '#/definitions/model.Possibility' |
| | | type: array |
| | | province: |
| | | description: 省份数据 |
| | |
| | | description: 解决率 |
| | | items: |
| | | $ref: '#/definitions/model.SolveRate' |
| | | type: array |
| | | status: |
| | | description: 状态 |
| | | items: |
| | | $ref: '#/definitions/model.Status' |
| | | type: array |
| | | timely_rate: |
| | | description: 及时率 |
| | |
| | | summary: 更新国家 |
| | | tags: |
| | | - Country |
| | | /api/currency/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddCurrency' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加币种 |
| | | tags: |
| | | - Currency |
| | | /api/currency/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: |
| | | - Currency |
| | | /api/currency/list: |
| | | get: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.CurrencyResponse' |
| | | type: object |
| | | summary: 获取币种列表 |
| | | tags: |
| | | - Currency |
| | | /api/currency/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateCurrencys' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新币种 |
| | | tags: |
| | | - Currency |
| | | /api/customerServiceSheet/add: |
| | | post: |
| | | parameters: |
New file |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | ) |
| | | |
| | | type ( |
| | | // Currency 商机阶段 |
| | | Currency struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name;type:varchar(255);comment:商机阶段名称"` |
| | | } |
| | | |
| | | CurrencySearch struct { |
| | | Currency |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | | |
| | | func (Currency) TableName() string { |
| | | return "currency" |
| | | } |
| | | |
| | | func NewCurrencySearch() *CurrencySearch { |
| | | return &CurrencySearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *CurrencySearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Currency{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | if slf.Name != "" { |
| | | db = db.Where("name = ?", slf.Name) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *CurrencySearch) Create(record *Currency) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *CurrencySearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&Currency{}).Error |
| | | } |
| | | |
| | | func (slf *CurrencySearch) Update(record *Currency) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *CurrencySearch) Find() (*Currency, error) { |
| | | var db = slf.build() |
| | | var record = new(Currency) |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *CurrencySearch) FindAll() ([]*Currency, error) { |
| | | var db = slf.build() |
| | | var records = make([]*Currency, 0) |
| | | err := db.Find(&records).Error |
| | | return records, err |
| | | } |
| | | |
| | | func (slf *CurrencySearch) SetId(id int) *CurrencySearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *CurrencySearch) SetName(name string) *CurrencySearch { |
| | | slf.Name = name |
| | | return slf |
| | | } |
| | | |
| | | func (slf *CurrencySearch) Updates(data map[string]interface{}) error { |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | |
| | | SalesReturnStatus{}, |
| | | Repository{}, |
| | | QuotationStatus{}, |
| | | Currency{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | |
| | | package request |
| | | |
| | | type AddCurrency struct { |
| | | Name string ` json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateCurrency struct { |
| | | Id int `json:"id" binding:"required"` |
| | | Name string `json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateCurrencys struct { |
| | | Currencys []*UpdateCurrency `json:"currency" binding:"required"` |
| | | } |
| | |
| | | |
| | | DataResponse struct { |
| | | |
| | | // 币种 |
| | | Currency []*model.Currency `json:"currency"` |
| | | |
| | | |
| | | // 报价单状态 |
| | | QuotationStatus []*model.QuotationStatus `json:"quotationStatus"` |
| | | |
| | | |
| | | // 退货仓库 |
| | | Repository []*model.Repository `json:"repository"` |
| | | |
| | | |
| | | // 退货单状态 |
| | | SalesReturnStatus []*model.SalesReturnStatus `json:"salesReturnStatus"` |
| | | |
| | | |
| | | // 账户 |
| | | AccountId []*model.AccountId `json:"accountId"` |
| | | |
| | | |
| | | // 是否开票 |
| | | IsInvoice []*model.IsInvoice `json:"isInvoice"` |
| | | |
| | | |
| | | // 退款方式 |
| | | RefundMethod []*model.RefundMethod `json:"refundMethod"` |
| | | |
| | | |
| | | // 服务合同类型 |
| | | ServiceContractType []*model.ServiceContractType `json:"serviceContractType"` |
| | | |
| | | |
| | | // 服务合同状态 |
| | | ServiceContractStatus []*model.ServiceContractStatus `json:"serviceContractStatus"` |
| | | |
| | | |
| | | // 工单类型 |
| | | OrderType []*model.OrderType `json:"orderType"` |
| | | |
| | | |
| | | // 报表来源 |
| | | ReportSource []*model.ReportSource `json:"reportSource"` |
| | | |
| | | |
| | | // 服务人员是否来过 |
| | | IsVisit []*model.IsVisit `json:"isVisit"` |
| | |
| | | TimelyRate []*model.TimelyRate `json:"timely_rate"` |
| | | // 解决率 |
| | | SolveRate []*model.SolveRate `json:"solve_rate"` |
| | | // 可能性 |
| | | Possibility []*model.Possibility `json:"possibility"` |
| | | // 状态 |
| | | Status []*model.Status `json:"status"` |
| | | } |
| | | |
| | | DepartmentResponse struct { |
| | |
| | | QuotationStatusResponse struct { |
| | | List []*model.QuotationStatus `json:"list"` |
| | | } |
| | | |
| | | CurrencyResponse struct { |
| | | List []*model.Currency `json:"list"` |
| | | } |
| | | ) |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "time" |
| | |
| | | |
| | | type ( |
| | | SaleChance struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name;type:varchar(255);comment:公司名称"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:销售线索编号"` |
| | | ContactId int `json:"contact_id" gorm:"column:contact_id;type:int(11);comment:联系人ID"` |
| | | ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:客户ID"` |
| | | SalesSourcesId int `json:"sales_sources_id" gorm:"column:sales_sources_id;type:int(11);comment:商机来源ID"` |
| | | SaleTypeId int `json:"sale_type_id" gorm:"column:sale_type_id;type:int(11);comment:商机类型ID"` |
| | | SaleStageId int `json:"sale_stage_id" gorm:"column:sale_stage_id;type:int(11);comment:商机阶段ID"` |
| | | MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:销售负责人ID"` |
| | | RegularCustomersId int `json:"regular_customers_id" gorm:"column:regular_customers_id;type:int(11);comment:常客ID"` |
| | | Competitors string `json:"competitors" gorm:"column:competitors;type:varchar(255);comment:竞争对手"` |
| | | PossibilitiesId int `json:"possibilities_id" gorm:"column:possibilities_id;type:int(11);comment:可能性ID"` |
| | | Budget float64 `json:"budget" gorm:"column:budget;type:decimal(10,2);comment:预算"` |
| | | ProjectedAmount float64 `json:"projected_amount" gorm:"column:projected_amount;type:decimal(10,2);comment:预计金额"` |
| | | Currency constvar.CurrencyType `json:"currency" gorm:"column:currency;type:int(11);comment:货币类型"` |
| | | ExpectedTime time.Time `json:"expected_time" gorm:"column:expected_time;type:datetime;comment:预计成交时间"` |
| | | StatusId int `json:"status_id" gorm:"column:status_id;type:int(11);comment:状态ID"` |
| | | PainPoints string `json:"pain_points" gorm:"column:pain_points;type:text;comment:痛点"` |
| | | WhetherEstablished string `json:"whether_established" gorm:"column:whether_established;type:text;comment:是否成立"` |
| | | CapitalBudget string `json:"capital_budget" gorm:"column:capital_budget;type:text;comment:资金预算"` |
| | | KeyMaker string `json:"key_maker" gorm:"column:key_maker;type:text;comment:关键人"` |
| | | KeyFactors string `json:"key_factors" gorm:"column:key_factors;type:text;comment:关键因素"` |
| | | Process string `json:"process" gorm:"column:process;type:text;comment:决策流程"` |
| | | Solutions string `json:"solutions" gorm:"column:solutions;type:text;comment:竞争对手解决方案"` |
| | | Advantages string `json:"advantages" gorm:"column:advantages;type:text;comment:竞争优势"` |
| | | Disadvantages string `json:"disadvantages" gorm:"column:disadvantages;type:text;comment:竞争劣势"` |
| | | Opportunities string `json:"opportunities" gorm:"column:opportunities;type:text;comment:竞争机会"` |
| | | Threats string `json:"threats" gorm:"column:threats;type:text;comment:竞争威胁"` |
| | | DetailAddress string `json:"detail_address" gorm:"column:detail_address;type:text;comment:详细地址"` |
| | | Remark string `json:"remark" gorm:"column:remark;type:text;comment:备注"` |
| | | Contact Contact `json:"contact" gorm:"foreignKey:ContactId;references:Id"` |
| | | Client Client `json:"client" gorm:"foreignKey:ClientId;references:Id"` |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name;type:varchar(255);comment:公司名称"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:销售线索编号"` |
| | | ContactId int `json:"contact_id" gorm:"column:contact_id;type:int(11);comment:联系人ID"` |
| | | ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:客户ID"` |
| | | SalesSourcesId int `json:"sales_sources_id" gorm:"column:sales_sources_id;type:int(11);comment:商机来源ID"` |
| | | SaleTypeId int `json:"sale_type_id" gorm:"column:sale_type_id;type:int(11);comment:商机类型ID"` |
| | | SaleStageId int `json:"sale_stage_id" gorm:"column:sale_stage_id;type:int(11);comment:商机阶段ID"` |
| | | MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:销售负责人ID"` |
| | | RegularCustomersId int `json:"regular_customers_id" gorm:"column:regular_customers_id;type:int(11);comment:常客ID"` |
| | | Competitors string `json:"competitors" gorm:"column:competitors;type:varchar(255);comment:竞争对手"` |
| | | PossibilitiesId int `json:"possibilities_id" gorm:"column:possibilities_id;type:int(11);comment:可能性ID"` |
| | | Budget float64 `json:"budget" gorm:"column:budget;type:decimal(10,2);comment:预算"` |
| | | ProjectedAmount float64 `json:"projected_amount" gorm:"column:projected_amount;type:decimal(10,2);comment:预计金额"` |
| | | Currency int `json:"currency" gorm:"column:currency;type:int(11);comment:币种"` |
| | | ExpectedTime time.Time `json:"expected_time" gorm:"column:expected_time;type:datetime;comment:预计成交时间"` |
| | | StatusId int `json:"status_id" gorm:"column:status_id;type:int(11);comment:状态ID"` |
| | | PainPoints string `json:"pain_points" gorm:"column:pain_points;type:text;comment:痛点"` |
| | | WhetherEstablished string `json:"whether_established" gorm:"column:whether_established;type:text;comment:是否成立"` |
| | | CapitalBudget string `json:"capital_budget" gorm:"column:capital_budget;type:text;comment:资金预算"` |
| | | KeyMaker string `json:"key_maker" gorm:"column:key_maker;type:text;comment:关键人"` |
| | | KeyFactors string `json:"key_factors" gorm:"column:key_factors;type:text;comment:关键因素"` |
| | | Process string `json:"process" gorm:"column:process;type:text;comment:决策流程"` |
| | | Solutions string `json:"solutions" gorm:"column:solutions;type:text;comment:竞争对手解决方案"` |
| | | Advantages string `json:"advantages" gorm:"column:advantages;type:text;comment:竞争优势"` |
| | | Disadvantages string `json:"disadvantages" gorm:"column:disadvantages;type:text;comment:竞争劣势"` |
| | | Opportunities string `json:"opportunities" gorm:"column:opportunities;type:text;comment:竞争机会"` |
| | | Threats string `json:"threats" gorm:"column:threats;type:text;comment:竞争威胁"` |
| | | DetailAddress string `json:"detail_address" gorm:"column:detail_address;type:text;comment:详细地址"` |
| | | Remark string `json:"remark" gorm:"column:remark;type:text;comment:备注"` |
| | | Contact Contact `json:"contact" gorm:"foreignKey:ContactId;references:Id"` |
| | | Client Client `json:"client" gorm:"foreignKey:ClientId;references:Id"` |
| | | SalesSources SalesSources |
| | | Address |
| | | gorm.Model `json:"-"` |
| | |
| | | QuotationStatusSetErr = 5500004 // 设置报价单状态失败 |
| | | QuotationStatusUpdateErr = 5500005 // 更新报价单状态失败 |
| | | |
| | | ) |
| | | |
| | | CurrencyExist = 5000001 // 币种已存在 |
| | | CurrencyNotExist = 5000002 // 币种不存在 |
| | | CurrencyListErr = 5000003 // 获取币种列表失败 |
| | | CurrencySetErr = 5000004 // 设置币种失败 |
| | | CurrencyUpdateErr = 5000005 // 更新币种失败 |
| | | |
| | | ) |
New file |
| | |
| | | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type CurrencyRouter struct{} |
| | | |
| | | func (s *CurrencyRouter) InitCurrencyRouter(router *gin.RouterGroup) { |
| | | currencyRouter := router.Group("currency") |
| | | currencyApi := v1.ApiGroup.CurrencyApi |
| | | { |
| | | currencyRouter.POST("add", currencyApi.Add) // 添加$CName$ |
| | | currencyRouter.DELETE("delete/:id", currencyApi.Delete) // 删除$CName$ |
| | | currencyRouter.PUT("update", currencyApi.Update) // 更新$CName$ |
| | | currencyRouter.GET("list", currencyApi.List) // 获取$CName$列表 |
| | | } |
| | | } |
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | CurrencyRouter |
| | | QuotationStatusRouter |
| | | RepositoryRouter |
| | | SalesReturnStatusRouter |
| | |
| | | routerGroup.InitSalesReturnStatusRouter(PrivateGroup) |
| | | routerGroup.InitRepositoryRouter(PrivateGroup) |
| | | routerGroup.InitQuotationStatusRouter(PrivateGroup) |
| | | routerGroup.InitCurrencyRouter(PrivateGroup) |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type CurrencyService struct{} |
| | | |
| | | func (CurrencyService) AddCurrency(currency *model.Currency) int { |
| | | err := model.NewCurrencySearch().Create(currency) |
| | | if err != nil { |
| | | return ecode.CurrencyExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (CurrencyService) DeleteCurrency(id int) int { |
| | | _, err := model.NewCurrencySearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.CurrencyNotExist |
| | | } |
| | | |
| | | err = model.NewCurrencySearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.CurrencyNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (CurrencyService) GetCurrencyList() ([]*model.Currency, int) { |
| | | list, err := model.NewCurrencySearch().FindAll() |
| | | if err != nil { |
| | | return nil, ecode.CurrencyListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | func (CurrencyService) UpdateCurrency(currencys []*request.UpdateCurrency) int { |
| | | for _, v := range currencys { |
| | | // check currency exist |
| | | _, err := model.NewCurrencySearch().SetId(v.Id).Find() |
| | | if err != nil { |
| | | return ecode.CurrencyNotExist |
| | | } |
| | | |
| | | err = model.NewCurrencySearch().SetId(v.Id).Updates(map[string]interface{}{ |
| | | "name": v.Name, |
| | | }) |
| | | if err != nil { |
| | | return ecode.CurrencySetErr |
| | | } |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (CurrencyService) GetCurrencyDetail(id int) (*model.Currency, int) { |
| | | currency, err := model.NewCurrencySearch().SetId(id).Find() |
| | | if err != nil { |
| | | return nil, ecode.CurrencyNotExist |
| | | } |
| | | |
| | | return currency, ecode.OK |
| | | } |
| | |
| | | reportSourceList, _ := ServiceGroup.GetReportSourceList() |
| | | data.ReportSource = reportSourceList |
| | | |
| | | |
| | | // get OrderType list |
| | | orderTypeList, _ := ServiceGroup.GetOrderTypeList() |
| | | data.OrderType = orderTypeList |
| | | |
| | | |
| | | // get ServiceContractStatus list |
| | | serviceContractStatusList, _ := ServiceGroup.GetServiceContractStatusList() |
| | | data.ServiceContractStatus = serviceContractStatusList |
| | | |
| | | |
| | | // get ServiceContractType list |
| | | serviceContractTypeList, _ := ServiceGroup.GetServiceContractTypeList() |
| | | data.ServiceContractType = serviceContractTypeList |
| | | |
| | | |
| | | // get RefundMethod list |
| | | refundMethodList, _ := ServiceGroup.GetRefundMethodList() |
| | | data.RefundMethod = refundMethodList |
| | | |
| | | |
| | | // get IsInvoice list |
| | | isInvoiceList, _ := ServiceGroup.GetIsInvoiceList() |
| | | data.IsInvoice = isInvoiceList |
| | | |
| | | |
| | | // get AccountId list |
| | | accountIdList, _ := ServiceGroup.GetAccountIdList() |
| | | data.AccountId = accountIdList |
| | | |
| | | |
| | | // get SalesReturnStatus list |
| | | salesReturnStatusList, _ := ServiceGroup.GetSalesReturnStatusList() |
| | | data.SalesReturnStatus = salesReturnStatusList |
| | | |
| | | |
| | | // get Repository list |
| | | repositoryList, _ := ServiceGroup.GetRepositoryList() |
| | | data.Repository = repositoryList |
| | | |
| | | |
| | | // get QuotationStatus list |
| | | quotationStatusList, _ := ServiceGroup.GetQuotationStatusList() |
| | | data.QuotationStatus = quotationStatusList |
| | | |
| | | // get Possibility list |
| | | possibilityList, _ := ServiceGroup.GetPossibilityList() |
| | | data.Possibility = possibilityList |
| | | |
| | | // get Status list |
| | | statusList, _ := ServiceGroup.GetStatusList() |
| | | data.Status = statusList |
| | | |
| | | // get Currency list |
| | | currencyList, _ := ServiceGroup.GetCurrencyList() |
| | | data.Currency = currencyList |
| | | |
| | | |
| | | errCode = ecode.OK |
| | | |
| | |
| | | SalesReturnStatusService |
| | | RepositoryService |
| | | QuotationStatusService |
| | | CurrencyService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |