From 624d15a1baedef4b872dfea64331532c9ef31b4e Mon Sep 17 00:00:00 2001 From: wangpengfei <274878379@qq.com> Date: 星期五, 21 七月 2023 13:43:59 +0800 Subject: [PATCH] add --- api/v1/index.go | 2 service/dataServer.go | 21 model/saleChance.go | 65 +- model/request/currency.go | 15 pkg/ecode/code.go | 9 service/currency.go | 69 +++ docs/swagger.yaml | 154 +++++++- docs/docs.go | 236 +++++++++++- docs/swagger.json | 236 +++++++++++- model/response/response.go | 22 api/v1/currency.go | 113 ++++++ api/v1/saleChance.go | 3 service/index.go | 1 model/index.go | 1 router/index.go | 2 model/currency.go | 85 ++++ router/currency.go | 20 + 17 files changed, 937 insertions(+), 117 deletions(-) diff --git a/api/v1/currency.go b/api/v1/currency.go new file mode 100644 index 0000000..7fa7513 --- /dev/null +++ b/api/v1/currency.go @@ -0,0 +1,113 @@ + +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, + }) +} diff --git a/api/v1/index.go b/api/v1/index.go index e9b468c..d7f869b 100644 --- a/api/v1/index.go +++ b/api/v1/index.go @@ -5,6 +5,7 @@ ) type Group struct { + CurrencyApi QuotationStatusApi RepositoryApi SalesReturnStatusApi @@ -126,4 +127,5 @@ salesReturnStatusService = service.ServiceGroup.SalesReturnStatusService repositoryService = service.ServiceGroup.RepositoryService quotationStatusService = service.ServiceGroup.QuotationStatusService + currencyService = service.ServiceGroup.CurrencyService ) \ No newline at end of file diff --git a/api/v1/saleChance.go b/api/v1/saleChance.go index 9b4b26d..35d91b1 100644 --- a/api/v1/saleChance.go +++ b/api/v1/saleChance.go @@ -1,7 +1,6 @@ package v1 import ( - "aps_crm/constvar" "aps_crm/model" "aps_crm/model/request" "aps_crm/model/response" @@ -186,7 +185,7 @@ 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 diff --git a/docs/docs.go b/docs/docs.go index cf08ca0..7f94009 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1395,6 +1395,125 @@ } } }, + "/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": [ @@ -6696,27 +6815,6 @@ } }, "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": [ @@ -7175,6 +7273,17 @@ "items": { "$ref": "#/definitions/model.Province" } + } + } + }, + "model.Currency": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" } } }, @@ -7649,7 +7758,7 @@ "type": "integer" }, "currency": { - "$ref": "#/definitions/constvar.CurrencyType" + "type": "integer" }, "detail_address": { "type": "string" @@ -8154,6 +8263,17 @@ } } }, + "model.Status": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, "model.SubOrder": { "type": "object", "properties": { @@ -8506,6 +8626,17 @@ "properties": { "name": { "description": "鍥藉鍚嶇О", + "type": "string" + } + } + }, + "request.AddCurrency": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { "type": "string" } } @@ -10202,6 +10333,35 @@ } } }, + "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": { @@ -11620,6 +11780,17 @@ } } }, + "response.CurrencyResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/model.Currency" + } + } + } + }, "response.DataResponse": { "type": "object", "properties": { @@ -11670,6 +11841,13 @@ "type": "array", "items": { "$ref": "#/definitions/model.Country" + } + }, + "currency": { + "description": "甯佺", + "type": "array", + "items": { + "$ref": "#/definitions/model.Currency" } }, "department": { @@ -11726,6 +11904,13 @@ "type": "array", "items": { "$ref": "#/definitions/model.OrderType" + } + }, + "possibility": { + "description": "鍙兘鎬�", + "type": "array", + "items": { + "$ref": "#/definitions/model.Possibility" } }, "province": { @@ -11840,6 +12025,13 @@ "$ref": "#/definitions/model.SolveRate" } }, + "status": { + "description": "鐘舵��", + "type": "array", + "items": { + "$ref": "#/definitions/model.Status" + } + }, "timely_rate": { "description": "鍙婃椂鐜�", "type": "array", diff --git a/docs/swagger.json b/docs/swagger.json index 79000a0..695c299 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1383,6 +1383,125 @@ } } }, + "/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": [ @@ -6684,27 +6803,6 @@ } }, "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": [ @@ -7163,6 +7261,17 @@ "items": { "$ref": "#/definitions/model.Province" } + } + } + }, + "model.Currency": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" } } }, @@ -7637,7 +7746,7 @@ "type": "integer" }, "currency": { - "$ref": "#/definitions/constvar.CurrencyType" + "type": "integer" }, "detail_address": { "type": "string" @@ -8142,6 +8251,17 @@ } } }, + "model.Status": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, "model.SubOrder": { "type": "object", "properties": { @@ -8494,6 +8614,17 @@ "properties": { "name": { "description": "鍥藉鍚嶇О", + "type": "string" + } + } + }, + "request.AddCurrency": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { "type": "string" } } @@ -10190,6 +10321,35 @@ } } }, + "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": { @@ -11608,6 +11768,17 @@ } } }, + "response.CurrencyResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/model.Currency" + } + } + } + }, "response.DataResponse": { "type": "object", "properties": { @@ -11658,6 +11829,13 @@ "type": "array", "items": { "$ref": "#/definitions/model.Country" + } + }, + "currency": { + "description": "甯佺", + "type": "array", + "items": { + "$ref": "#/definitions/model.Currency" } }, "department": { @@ -11714,6 +11892,13 @@ "type": "array", "items": { "$ref": "#/definitions/model.OrderType" + } + }, + "possibility": { + "description": "鍙兘鎬�", + "type": "array", + "items": { + "$ref": "#/definitions/model.Possibility" } }, "province": { @@ -11828,6 +12013,13 @@ "$ref": "#/definitions/model.SolveRate" } }, + "status": { + "description": "鐘舵��", + "type": "array", + "items": { + "$ref": "#/definitions/model.Status" + } + }, "timely_rate": { "description": "鍙婃椂鐜�", "type": "array", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 099f6ba..1520f1c 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1,21 +1,4 @@ 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 @@ -327,6 +310,13 @@ $ref: '#/definitions/model.Province' type: array type: object + model.Currency: + properties: + id: + type: integer + name: + type: string + type: object model.CustomerServiceSheet: properties: handleStatus: @@ -634,7 +624,7 @@ country_id: type: integer currency: - $ref: '#/definitions/constvar.CurrencyType' + type: integer detail_address: type: string disadvantages: @@ -965,6 +955,13 @@ name: type: string type: object + model.Status: + properties: + id: + type: integer + name: + type: string + type: object model.SubOrder: properties: client: @@ -1210,6 +1207,13 @@ name: description: 鍥藉鍚嶇О type: string + type: object + request.AddCurrency: + properties: + name: + type: string + required: + - name type: object request.AddCustomerServiceSheet: properties: @@ -2354,6 +2358,25 @@ 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: @@ -3292,6 +3315,13 @@ $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: @@ -3328,6 +3358,11 @@ description: 鍥藉鏁版嵁 items: $ref: '#/definitions/model.Country' + type: array + currency: + description: 甯佺 + items: + $ref: '#/definitions/model.Currency' type: array department: description: 閮ㄩ棬 @@ -3368,6 +3403,11 @@ description: 宸ュ崟绫诲瀷 items: $ref: '#/definitions/model.OrderType' + type: array + possibility: + description: 鍙兘鎬� + items: + $ref: '#/definitions/model.Possibility' type: array province: description: 鐪佷唤鏁版嵁 @@ -3448,6 +3488,11 @@ description: 瑙e喅鐜� items: $ref: '#/definitions/model.SolveRate' + type: array + status: + description: 鐘舵�� + items: + $ref: '#/definitions/model.Status' type: array timely_rate: description: 鍙婃椂鐜� @@ -4590,6 +4635,79 @@ 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: diff --git a/model/currency.go b/model/currency.go new file mode 100644 index 0000000..12c96ba --- /dev/null +++ b/model/currency.go @@ -0,0 +1,85 @@ +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 +} diff --git a/model/index.go b/model/index.go index 1f5aff7..7a0f17c 100644 --- a/model/index.go +++ b/model/index.go @@ -78,6 +78,7 @@ SalesReturnStatus{}, Repository{}, QuotationStatus{}, + Currency{}, ) return err } \ No newline at end of file diff --git a/model/request/currency.go b/model/request/currency.go new file mode 100644 index 0000000..94d615a --- /dev/null +++ b/model/request/currency.go @@ -0,0 +1,15 @@ + +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"` +} diff --git a/model/response/response.go b/model/response/response.go index 751b2b6..04ea37d 100644 --- a/model/response/response.go +++ b/model/response/response.go @@ -180,45 +180,39 @@ 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"` @@ -265,6 +259,10 @@ TimelyRate []*model.TimelyRate `json:"timely_rate"` // 瑙e喅鐜� SolveRate []*model.SolveRate `json:"solve_rate"` + // 鍙兘鎬� + Possibility []*model.Possibility `json:"possibility"` + // 鐘舵�� + Status []*model.Status `json:"status"` } DepartmentResponse struct { @@ -326,4 +324,8 @@ QuotationStatusResponse struct { List []*model.QuotationStatus `json:"list"` } + + CurrencyResponse struct { + List []*model.Currency `json:"list"` + } ) \ No newline at end of file diff --git a/model/saleChance.go b/model/saleChance.go index 1f88811..fdfb54b 100644 --- a/model/saleChance.go +++ b/model/saleChance.go @@ -1,7 +1,6 @@ package model import ( - "aps_crm/constvar" "aps_crm/pkg/mysqlx" "gorm.io/gorm" "time" @@ -9,38 +8,38 @@ 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:鑱旂郴浜篒D"` - 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:閿�鍞礋璐d汉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:鍙兘鎬D"` - 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:鐘舵�両D"` - 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:绔炰簤瀵规墜瑙e喅鏂规"` - Advantages string `json:"advantages" gorm:"column:advantages;type:text;comment:绔炰簤浼樺娍"` - Disadvantages string `json:"disadvantages" gorm:"column:disadvantages;type:text;comment:绔炰簤鍔e娍"` - 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:鑱旂郴浜篒D"` + 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:閿�鍞礋璐d汉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:鍙兘鎬D"` + 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:鐘舵�両D"` + 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:绔炰簤瀵规墜瑙e喅鏂规"` + Advantages string `json:"advantages" gorm:"column:advantages;type:text;comment:绔炰簤浼樺娍"` + Disadvantages string `json:"disadvantages" gorm:"column:disadvantages;type:text;comment:绔炰簤鍔e娍"` + 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:"-"` diff --git a/pkg/ecode/code.go b/pkg/ecode/code.go index e224a24..3656b29 100644 --- a/pkg/ecode/code.go +++ b/pkg/ecode/code.go @@ -376,4 +376,11 @@ QuotationStatusSetErr = 5500004 // 璁剧疆鎶ヤ环鍗曠姸鎬佸け璐� QuotationStatusUpdateErr = 5500005 // 鏇存柊鎶ヤ环鍗曠姸鎬佸け璐� -) + + CurrencyExist = 5000001 // 甯佺宸插瓨鍦� + CurrencyNotExist = 5000002 // 甯佺涓嶅瓨鍦� + CurrencyListErr = 5000003 // 鑾峰彇甯佺鍒楄〃澶辫触 + CurrencySetErr = 5000004 // 璁剧疆甯佺澶辫触 + CurrencyUpdateErr = 5000005 // 鏇存柊甯佺澶辫触 + +) \ No newline at end of file diff --git a/router/currency.go b/router/currency.go new file mode 100644 index 0000000..cf7beb3 --- /dev/null +++ b/router/currency.go @@ -0,0 +1,20 @@ + +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$鍒楄〃 + } +} \ No newline at end of file diff --git a/router/index.go b/router/index.go index 65db83d..43f890a 100644 --- a/router/index.go +++ b/router/index.go @@ -11,6 +11,7 @@ ) type Group struct { + CurrencyRouter QuotationStatusRouter RepositoryRouter SalesReturnStatusRouter @@ -155,6 +156,7 @@ routerGroup.InitSalesReturnStatusRouter(PrivateGroup) routerGroup.InitRepositoryRouter(PrivateGroup) routerGroup.InitQuotationStatusRouter(PrivateGroup) + routerGroup.InitCurrencyRouter(PrivateGroup) } return Router } \ No newline at end of file diff --git a/service/currency.go b/service/currency.go new file mode 100644 index 0000000..8ea2399 --- /dev/null +++ b/service/currency.go @@ -0,0 +1,69 @@ + +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 +} diff --git a/service/dataServer.go b/service/dataServer.go index 7cbe924..ab15917 100644 --- a/service/dataServer.go +++ b/service/dataServer.go @@ -100,51 +100,54 @@ 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 diff --git a/service/index.go b/service/index.go index 3110c5e..e48386e 100644 --- a/service/index.go +++ b/service/index.go @@ -59,6 +59,7 @@ SalesReturnStatusService RepositoryService QuotationStatusService + CurrencyService } var ServiceGroup = new(Group) \ No newline at end of file -- Gitblit v1.8.0