add
wangpengfei
2023-07-21 58b19364744f6f61c64978dda97b01eec37823b0
add

ServiceContractStatus 服务合同状态
add, Delete, update, list
5个文件已添加
13个文件已修改
879 ■■■■■ 已修改文件
api/v1/index.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/serviceContractStatus.go 113 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/serviceContracts.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 194 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 194 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/serviceContractStatus.go 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/response/response.go 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceContractStatus.go 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceContracts.go 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceFollowup.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pkg/ecode/code.go 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/index.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/serviceContractStatus.go 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/dataServer.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/serviceContractStatus.go 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/index.go
@@ -5,6 +5,7 @@
)
type Group struct {
    ServiceContractStatusApi
    OrderTypeApi
    ReportSourceApi
    IsVisitApi
@@ -110,4 +111,5 @@
    isVisitService              = service.ServiceGroup.IsVisitService
   reportSourceService    = service.ServiceGroup.ReportSourceService
   orderTypeService    = service.ServiceGroup.OrderTypeService
   serviceContractStatusService    = service.ServiceGroup.ServiceContractStatusService
)
api/v1/serviceContractStatus.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 ServiceContractStatusApi struct{}
// Add
//
//    @Tags        ServiceContractStatus
//    @Summary    添加服务合同状态
//    @Produce    application/json
//    @Param        object    body        request.AddServiceContractStatus    true    "查询参数"
//    @Success    200        {object}    contextx.Response{}
//    @Router        /api/serviceContractStatus/add [post]
func (s *ServiceContractStatusApi) Add(c *gin.Context) {
    var params request.AddServiceContractStatus
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    serviceContractStatus := new(model.ServiceContractStatus)
    serviceContractStatus.Name = params.Name
    errCode := serviceContractStatusService.AddServiceContractStatus(serviceContractStatus)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.Ok()
}
// Delete
//
//    @Tags        ServiceContractStatus
//    @Summary    删除服务合同状态
//    @Produce    application/json
//    @Param        id    path        int    true    "查询参数"
//    @Success    200    {object}    contextx.Response{}
//    @Router        /api/serviceContractStatus/delete/{id} [delete]
func (s *ServiceContractStatusApi) Delete(c *gin.Context) {
    ctx, ok := contextx.NewContext(c, nil)
    if !ok {
        return
    }
    id, _ := strconv.Atoi(c.Param("id"))
    errCode := serviceContractStatusService.DeleteServiceContractStatus(id)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.Ok()
}
// Update
//
//    @Tags        ServiceContractStatus
//    @Summary    更新服务合同状态
//    @Produce    application/json
//    @Param        object    body        request.UpdateServiceContractStatuss    true    "查询参数"
//    @Success    200        {object}    contextx.Response{}
//    @Router        /api/serviceContractStatus/update [put]
func (s *ServiceContractStatusApi) Update(c *gin.Context) {
    var params request.UpdateServiceContractStatuss
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    errCode := serviceContractStatusService.UpdateServiceContractStatus(params.ServiceContractStatuss)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.Ok()
}
// List
//
//    @Tags        ServiceContractStatus
//    @Summary    获取服务合同状态列表
//    @Produce    application/json
//    @Success    200    {object}    contextx.Response{data=response.ServiceContractStatusResponse}
//    @Router        /api/serviceContractStatus/list [get]
func (s *ServiceContractStatusApi) List(c *gin.Context) {
    ctx, ok := contextx.NewContext(c, nil)
    if !ok {
        return
    }
    serviceContractStatuss, errCode := serviceContractStatusService.GetServiceContractStatusList()
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.OkWithDetailed(response.ServiceContractStatusResponse{
        List: serviceContractStatuss,
    })
}
api/v1/serviceContracts.go
@@ -165,7 +165,7 @@
    result.SaleChanceId = serviceContract.SaleChanceId
    result.QuotationId = serviceContract.QuotationId
    result.TypeId = serviceContract.TypeId
    result.StatusId = serviceContract.StatusId
    result.ServiceContractStatusId = serviceContract.StatusId
    result.ServiceTimes = serviceContract.ServiceTimes
    result.Terms = serviceContract.Terms
    result.Products = serviceContract.Products
docs/docs.go
@@ -4757,6 +4757,125 @@
                }
            }
        },
        "/api/serviceContractStatus/add": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceContractStatus"
                ],
                "summary": "添加服务合同状态",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.AddServiceContractStatus"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/serviceContractStatus/delete/{id}": {
            "delete": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceContractStatus"
                ],
                "summary": "删除服务合同状态",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "查询参数",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/serviceContractStatus/list": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceContractStatus"
                ],
                "summary": "获取服务合同状态列表",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.ServiceContractStatusResponse"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/serviceContractStatus/update": {
            "put": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceContractStatus"
                ],
                "summary": "更新服务合同状态",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateServiceContractStatuss"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/serviceFeeManage/add": {
            "post": {
                "produces": [
@@ -7007,6 +7126,9 @@
                "saleChanceId": {
                    "type": "integer"
                },
                "serviceContractStatusId": {
                    "type": "integer"
                },
                "serviceTimes": {
                    "type": "integer"
                },
@@ -7016,14 +7138,22 @@
                "startTime": {
                    "type": "string"
                },
                "statusId": {
                    "type": "integer"
                },
                "terms": {
                    "type": "string"
                },
                "typeId": {
                    "type": "integer"
                }
            }
        },
        "model.ServiceContractStatus": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
@@ -7987,6 +8117,17 @@
                },
                "typeId": {
                    "type": "integer"
                }
            }
        },
        "request.AddServiceContractStatus": {
            "type": "object",
            "required": [
                "name"
            ],
            "properties": {
                "name": {
                    "type": "string"
                }
            }
        },
@@ -9887,6 +10028,35 @@
                }
            }
        },
        "request.UpdateServiceContractStatus": {
            "type": "object",
            "required": [
                "id",
                "name"
            ],
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "request.UpdateServiceContractStatuss": {
            "type": "object",
            "required": [
                "service_contract_status"
            ],
            "properties": {
                "service_contract_status": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/request.UpdateServiceContractStatus"
                    }
                }
            }
        },
        "request.UpdateServiceFeeManage": {
            "type": "object",
            "properties": {
@@ -10406,6 +10576,13 @@
                        "$ref": "#/definitions/model.Satisfaction"
                    }
                },
                "serviceContractStatus": {
                    "description": "服务合同状态",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.ServiceContractStatus"
                    }
                },
                "solve_rate": {
                    "description": "解决率",
                    "type": "array",
@@ -10726,6 +10903,17 @@
                }
            }
        },
        "response.ServiceContractStatusResponse": {
            "type": "object",
            "properties": {
                "list": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.ServiceContractStatus"
                    }
                }
            }
        },
        "response.ServiceContractsResponse": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -4745,6 +4745,125 @@
                }
            }
        },
        "/api/serviceContractStatus/add": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceContractStatus"
                ],
                "summary": "添加服务合同状态",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.AddServiceContractStatus"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/serviceContractStatus/delete/{id}": {
            "delete": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceContractStatus"
                ],
                "summary": "删除服务合同状态",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "查询参数",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/serviceContractStatus/list": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceContractStatus"
                ],
                "summary": "获取服务合同状态列表",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.ServiceContractStatusResponse"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/serviceContractStatus/update": {
            "put": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceContractStatus"
                ],
                "summary": "更新服务合同状态",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateServiceContractStatuss"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/serviceFeeManage/add": {
            "post": {
                "produces": [
@@ -6995,6 +7114,9 @@
                "saleChanceId": {
                    "type": "integer"
                },
                "serviceContractStatusId": {
                    "type": "integer"
                },
                "serviceTimes": {
                    "type": "integer"
                },
@@ -7004,14 +7126,22 @@
                "startTime": {
                    "type": "string"
                },
                "statusId": {
                    "type": "integer"
                },
                "terms": {
                    "type": "string"
                },
                "typeId": {
                    "type": "integer"
                }
            }
        },
        "model.ServiceContractStatus": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
@@ -7975,6 +8105,17 @@
                },
                "typeId": {
                    "type": "integer"
                }
            }
        },
        "request.AddServiceContractStatus": {
            "type": "object",
            "required": [
                "name"
            ],
            "properties": {
                "name": {
                    "type": "string"
                }
            }
        },
@@ -9875,6 +10016,35 @@
                }
            }
        },
        "request.UpdateServiceContractStatus": {
            "type": "object",
            "required": [
                "id",
                "name"
            ],
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "request.UpdateServiceContractStatuss": {
            "type": "object",
            "required": [
                "service_contract_status"
            ],
            "properties": {
                "service_contract_status": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/request.UpdateServiceContractStatus"
                    }
                }
            }
        },
        "request.UpdateServiceFeeManage": {
            "type": "object",
            "properties": {
@@ -10394,6 +10564,13 @@
                        "$ref": "#/definitions/model.Satisfaction"
                    }
                },
                "serviceContractStatus": {
                    "description": "服务合同状态",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.ServiceContractStatus"
                    }
                },
                "solve_rate": {
                    "description": "解决率",
                    "type": "array",
@@ -10714,6 +10891,17 @@
                }
            }
        },
        "response.ServiceContractStatusResponse": {
            "type": "object",
            "properties": {
                "list": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.ServiceContractStatus"
                    }
                }
            }
        },
        "response.ServiceContractsResponse": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -839,18 +839,25 @@
        type: string
      saleChanceId:
        type: integer
      serviceContractStatusId:
        type: integer
      serviceTimes:
        type: integer
      signTime:
        type: string
      startTime:
        type: string
      statusId:
        type: integer
      terms:
        type: string
      typeId:
        type: integer
    type: object
  model.ServiceContractStatus:
    properties:
      id:
        type: integer
      name:
        type: string
    type: object
  model.ServiceFeeManage:
    properties:
@@ -1495,6 +1502,13 @@
        type: string
      typeId:
        type: integer
    type: object
  request.AddServiceContractStatus:
    properties:
      name:
        type: string
    required:
    - name
    type: object
  request.AddServiceFeeManage:
    properties:
@@ -2779,6 +2793,25 @@
      typeId:
        type: integer
    type: object
  request.UpdateServiceContractStatus:
    properties:
      id:
        type: integer
      name:
        type: string
    required:
    - id
    - name
    type: object
  request.UpdateServiceContractStatuss:
    properties:
      service_contract_status:
        items:
          $ref: '#/definitions/request.UpdateServiceContractStatus'
        type: array
    required:
    - service_contract_status
    type: object
  request.UpdateServiceFeeManage:
    properties:
      business_scope:
@@ -3133,6 +3166,11 @@
        items:
          $ref: '#/definitions/model.Satisfaction'
        type: array
      serviceContractStatus:
        description: 服务合同状态
        items:
          $ref: '#/definitions/model.ServiceContractStatus'
        type: array
      solve_rate:
        description: 解决率
        items:
@@ -3336,6 +3374,13 @@
      list:
        items:
          $ref: '#/definitions/model.Satisfaction'
        type: array
    type: object
  response.ServiceContractStatusResponse:
    properties:
      list:
        items:
          $ref: '#/definitions/model.ServiceContractStatus'
        type: array
    type: object
  response.ServiceContractsResponse:
@@ -6295,6 +6340,79 @@
      summary: 更新服务合同
      tags:
      - ServiceContract
  /api/serviceContractStatus/add:
    post:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.AddServiceContractStatus'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 添加服务合同状态
      tags:
      - ServiceContractStatus
  /api/serviceContractStatus/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:
      - ServiceContractStatus
  /api/serviceContractStatus/list:
    get:
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            allOf:
            - $ref: '#/definitions/contextx.Response'
            - properties:
                data:
                  $ref: '#/definitions/response.ServiceContractStatusResponse'
              type: object
      summary: 获取服务合同状态列表
      tags:
      - ServiceContractStatus
  /api/serviceContractStatus/update:
    put:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.UpdateServiceContractStatuss'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 更新服务合同状态
      tags:
      - ServiceContractStatus
  /api/serviceFeeManage/add:
    post:
      parameters:
model/index.go
@@ -70,6 +70,7 @@
        IsVisit{},
        ReportSource{},
        OrderType{},
        ServiceContractStatus{},
    )
    return err
}
model/request/serviceContractStatus.go
New file
@@ -0,0 +1,15 @@
package request
type AddServiceContractStatus struct {
    Name string `  json:"name" binding:"required"`
}
type UpdateServiceContractStatus struct {
    Id   int    `json:"id" binding:"required"`
    Name string `json:"name" binding:"required"`
}
type UpdateServiceContractStatuss struct {
    ServiceContractStatuss []*UpdateServiceContractStatus `json:"service_contract_status" binding:"required"`
}
model/response/response.go
@@ -180,6 +180,10 @@
    DataResponse struct {
        // 服务合同状态
        ServiceContractStatus []*model.ServiceContractStatus `json:"serviceContractStatus"`
        // 工单类型
        OrderType []*model.OrderType `json:"orderType"`
@@ -262,4 +266,8 @@
    OrderTypeResponse struct {
        List []*model.OrderType `json:"list"`
    }
    ServiceContractStatusResponse struct {
        List []*model.ServiceContractStatus `json:"list"`
    }
)
model/serviceContractStatus.go
New file
@@ -0,0 +1,85 @@
package model
import (
    "aps_crm/pkg/mysqlx"
    "gorm.io/gorm"
)
type (
    // ServiceContractStatus 商机阶段
    ServiceContractStatus struct {
        Id   int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
        Name string `json:"name" gorm:"column:name;type:varchar(255);comment:商机阶段名称"`
    }
    ServiceContractStatusSearch struct {
        ServiceContractStatus
        Orm *gorm.DB
    }
)
func (ServiceContractStatus) TableName() string {
    return "service_contract_status"
}
func NewServiceContractStatusSearch() *ServiceContractStatusSearch {
    return &ServiceContractStatusSearch{
        Orm: mysqlx.GetDB(),
    }
}
func (slf *ServiceContractStatusSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&ServiceContractStatus{})
    if slf.Id != 0 {
        db = db.Where("id = ?", slf.Id)
    }
    if slf.Name != "" {
        db = db.Where("name = ?", slf.Name)
    }
    return db
}
func (slf *ServiceContractStatusSearch) Create(record *ServiceContractStatus) error {
    var db = slf.build()
    return db.Create(record).Error
}
func (slf *ServiceContractStatusSearch) Delete() error {
    var db = slf.build()
    return db.Delete(&ServiceContractStatus{}).Error
}
func (slf *ServiceContractStatusSearch) Update(record *ServiceContractStatus) error {
    var db = slf.build()
    return db.Updates(record).Error
}
func (slf *ServiceContractStatusSearch) Find() (*ServiceContractStatus, error) {
    var db = slf.build()
    var record = new(ServiceContractStatus)
    err := db.First(record).Error
    return record, err
}
func (slf *ServiceContractStatusSearch) FindAll() ([]*ServiceContractStatus, error) {
    var db = slf.build()
    var records = make([]*ServiceContractStatus, 0)
    err := db.Find(&records).Error
    return records, err
}
func (slf *ServiceContractStatusSearch) SetId(id int) *ServiceContractStatusSearch {
    slf.Id = id
    return slf
}
func (slf *ServiceContractStatusSearch) SetName(name string) *ServiceContractStatusSearch {
    slf.Name = name
    return slf
}
func (slf *ServiceContractStatusSearch) Updates(data map[string]interface{}) error {
    var db = slf.build()
    return db.Updates(data).Error
}
model/serviceContracts.go
@@ -8,24 +8,24 @@
type (
    ServiceContract struct {
        Id           int       `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
        ClientId     int       `json:"clientId" gorm:"column:client_id;type:int;comment:客户id"`
        Number       string    `json:"number" gorm:"column:number;type:varchar(255);comment:合同编号"`
        MemberId     int       `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"`
        ContactId    int       `json:"contactId" gorm:"column:contact_id;type:int;comment:联系人id"`
        SaleChanceId int       `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:销售机会id"`
        ContractId   int       `json:"contractId" gorm:"column:contract_id;type:int;comment:合同id"`
        QuotationId  int       `json:"quotationId" gorm:"column:quotation_id;type:int;comment:报价单id"`
        TypeId       int       `json:"typeId" gorm:"column:type_id;type:int;comment:合同类型id"`
        SignTime     time.Time `json:"signTime" gorm:"column:sign_time;type:datetime;comment:签约时间"`
        StartTime    time.Time `json:"startTime" gorm:"column:start_time;type:datetime;comment:开始时间"`
        EndTime      time.Time `json:"endTime" gorm:"column:end_time;type:datetime;comment:结束时间"`
        StatusId     int       `json:"statusId" gorm:"column:status_id;type:int;comment:合同状态id"`
        ServiceTimes int       `json:"serviceTimes" gorm:"column:service_times;type:int;comment:服务次数"`
        Terms        string    `json:"terms" gorm:"column:terms;type:text;comment:条款"`
        Remark       string    `json:"remark" gorm:"column:remark;type:text;comment:备注"`
        Products     []Product `json:"products" gorm:"many2many:serviceContract_product;"`
        gorm.Model   `json:"-"`
        Id                      int       `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
        ClientId                int       `json:"clientId" gorm:"column:client_id;type:int;comment:客户id"`
        Number                  string    `json:"number" gorm:"column:number;type:varchar(255);comment:合同编号"`
        MemberId                int       `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"`
        ContactId               int       `json:"contactId" gorm:"column:contact_id;type:int;comment:联系人id"`
        SaleChanceId            int       `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:销售机会id"`
        ContractId              int       `json:"contractId" gorm:"column:contract_id;type:int;comment:合同id"`
        QuotationId             int       `json:"quotationId" gorm:"column:quotation_id;type:int;comment:报价单id"`
        TypeId                  int       `json:"typeId" gorm:"column:type_id;type:int;comment:合同类型id"`
        SignTime                time.Time `json:"signTime" gorm:"column:sign_time;type:datetime;comment:签约时间"`
        StartTime               time.Time `json:"startTime" gorm:"column:start_time;type:datetime;comment:开始时间"`
        EndTime                 time.Time `json:"endTime" gorm:"column:end_time;type:datetime;comment:结束时间"`
        ServiceContractStatusId int       `json:"serviceContractStatusId" gorm:"column:service_contract_status_id;type:int;comment:合同状态id"`
        ServiceTimes            int       `json:"serviceTimes" gorm:"column:service_times;type:int;comment:服务次数"`
        Terms                   string    `json:"terms" gorm:"column:terms;type:text;comment:条款"`
        Remark                  string    `json:"remark" gorm:"column:remark;type:text;comment:备注"`
        Products                []Product `json:"products" gorm:"many2many:serviceContract_product;"`
        gorm.Model              `json:"-"`
    }
    ServiceContractSearch struct {
model/serviceFollowup.go
@@ -85,7 +85,6 @@
    return slf
}
// 工单类型 报修来源(工单管理)
// 合同类型 合同状态(服务合同)
// 付款方式 是否开票 账户(销售退款单)
// 退入仓库 状态(销售退货单)
pkg/ecode/code.go
@@ -328,4 +328,11 @@
    OrderTypeSetErr    = 4700004 // 设置工单类型失败
    OrderTypeUpdateErr = 4700005 // 更新工单类型失败
)
    ServiceContractStatusExist     = 4400001 // 服务合同状态已存在
    ServiceContractStatusNotExist  = 4400002 // 服务合同状态不存在
    ServiceContractStatusListErr   = 4400003 // 获取服务合同状态列表失败
    ServiceContractStatusSetErr    = 4400004 // 设置服务合同状态失败
    ServiceContractStatusUpdateErr = 4400005 // 更新服务合同状态失败
)
router/index.go
@@ -11,6 +11,7 @@
)
type Group struct {
    ServiceContractStatusRouter
    OrderTypeRouter
    ReportSourceRouter
    IsVisitRouter
@@ -139,6 +140,7 @@
        routerGroup.InitIsVisitRouter(PrivateGroup)
        routerGroup.InitReportSourceRouter(PrivateGroup)
        routerGroup.InitOrderTypeRouter(PrivateGroup)
        routerGroup.InitServiceContractStatusRouter(PrivateGroup)
    }
    return Router
}
router/serviceContractStatus.go
New file
@@ -0,0 +1,20 @@
package router
import (
    v1 "aps_crm/api/v1"
    "github.com/gin-gonic/gin"
)
type ServiceContractStatusRouter struct{}
func (s *ServiceContractStatusRouter) InitServiceContractStatusRouter(router *gin.RouterGroup) {
    serviceContractStatusRouter := router.Group("serviceContractStatus")
    serviceContractStatusApi := v1.ApiGroup.ServiceContractStatusApi
    {
        serviceContractStatusRouter.POST("add", serviceContractStatusApi.Add)             // 添加$CName$
        serviceContractStatusRouter.DELETE("delete/:id", serviceContractStatusApi.Delete) // 删除$CName$
        serviceContractStatusRouter.PUT("update", serviceContractStatusApi.Update)        // 更新$CName$
        serviceContractStatusRouter.GET("list", serviceContractStatusApi.List)            // 获取$CName$列表
    }
}
service/dataServer.go
@@ -106,6 +106,11 @@
    data.OrderType = orderTypeList
    // get ServiceContractStatus list
    serviceContractStatusList, _ := ServiceGroup.GetServiceContractStatusList()
    data.ServiceContractStatus = serviceContractStatusList
    errCode = ecode.OK
    return
service/index.go
@@ -51,6 +51,7 @@
    IsVisitService
    ReportSourceService
    OrderTypeService
    ServiceContractStatusService
}
var ServiceGroup = new(Group)
service/serviceContractStatus.go
New file
@@ -0,0 +1,69 @@
package service
import (
    "aps_crm/model"
    "aps_crm/model/request"
    "aps_crm/pkg/ecode"
)
type ServiceContractStatusService struct{}
func (ServiceContractStatusService) AddServiceContractStatus(serviceContractStatus *model.ServiceContractStatus) int {
    err := model.NewServiceContractStatusSearch().Create(serviceContractStatus)
    if err != nil {
        return ecode.ServiceContractStatusExist
    }
    return ecode.OK
}
func (ServiceContractStatusService) DeleteServiceContractStatus(id int) int {
    _, err := model.NewServiceContractStatusSearch().SetId(id).Find()
    if err != nil {
        return ecode.ServiceContractStatusNotExist
    }
    err = model.NewServiceContractStatusSearch().SetId(id).Delete()
    if err != nil {
        return ecode.ServiceContractStatusNotExist
    }
    return ecode.OK
}
func (ServiceContractStatusService) GetServiceContractStatusList() ([]*model.ServiceContractStatus, int) {
    list, err := model.NewServiceContractStatusSearch().FindAll()
    if err != nil {
        return nil, ecode.ServiceContractStatusListErr
    }
    return list, ecode.OK
}
func (ServiceContractStatusService) UpdateServiceContractStatus(serviceContractStatuss []*request.UpdateServiceContractStatus) int {
    for _, v := range serviceContractStatuss {
        // check serviceContractStatus exist
        _, err := model.NewServiceContractStatusSearch().SetId(v.Id).Find()
        if err != nil {
            return ecode.ServiceContractStatusNotExist
        }
        err = model.NewServiceContractStatusSearch().SetId(v.Id).Updates(map[string]interface{}{
            "name": v.Name,
        })
        if err != nil {
            return ecode.ServiceContractStatusSetErr
        }
    }
    return ecode.OK
}
func (ServiceContractStatusService) GetServiceContractStatusDetail(id int) (*model.ServiceContractStatus, int) {
    serviceContractStatus, err := model.NewServiceContractStatusSearch().SetId(id).Find()
    if err != nil {
        return nil, ecode.ServiceContractStatusNotExist
    }
    return serviceContractStatus, ecode.OK
}