add
wangpengfei
2023-07-21 624d15a1baedef4b872dfea64331532c9ef31b4e
add

Currency 币种
add, Delete, update, lis
5个文件已添加
12个文件已修改
1054 ■■■■ 已修改文件
api/v1/currency.go 113 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/index.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/saleChance.go 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 236 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 236 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 154 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/currency.go 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/currency.go 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/response/response.go 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/saleChance.go 65 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pkg/ecode/code.go 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/currency.go 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/index.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/currency.go 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/dataServer.go 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/currency.go
New file
@@ -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, &params)
    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, &params)
    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,
    })
}
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
)
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
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",
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",
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: 解决率
        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:
model/currency.go
New file
@@ -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
}
model/index.go
@@ -78,6 +78,7 @@
        SalesReturnStatus{},
        Repository{},
        QuotationStatus{},
        Currency{},
    )
    return err
}
model/request/currency.go
New file
@@ -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"`
}
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"`
        // 解决率
        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"`
    }
)
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:联系人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:"-"`
pkg/ecode/code.go
@@ -376,4 +376,11 @@
    QuotationStatusSetErr    = 5500004 // 设置报价单状态失败
    QuotationStatusUpdateErr = 5500005 // 更新报价单状态失败
)
    CurrencyExist     = 5000001 // 币种已存在
    CurrencyNotExist  = 5000002 // 币种不存在
    CurrencyListErr   = 5000003 // 获取币种列表失败
    CurrencySetErr    = 5000004 // 设置币种失败
    CurrencyUpdateErr = 5000005 // 更新币种失败
)
router/currency.go
New file
@@ -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$列表
    }
}
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
}
service/currency.go
New file
@@ -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
}
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
service/index.go
@@ -59,6 +59,7 @@
    SalesReturnStatusService
    RepositoryService
    QuotationStatusService
    CurrencyService
}
var ServiceGroup = new(Group)