zhangqian
2023-08-15 e7f3f86e85a46c7962e4701115571a2274631a84
服务合同批量删除接口
8个文件已修改
160 ■■■■ 已修改文件
api/v1/serviceContract.go 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/serviceOrder.go 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceContract.go 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/serviceContract.go 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/serviceContract.go 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/serviceContract.go
@@ -42,22 +42,45 @@
    ctx.Ok()
}
// Delete
//// Delete
////
////    @Tags        ServiceContract
////    @Summary    删除服务合同
////    @Produce    application/json
////    @Param        object    body        request.DeleteServiceContract true    "查询参数"
////    @Success    200    {object}    contextx.Response{}
////    @Router        /api/serviceContract/delete [delete]
//func (s *ServiceContractApi) Delete(c *gin.Context) {
//    var params request.DeleteServiceContract
//    ctx, ok := contextx.NewContext(c, &params)
//    if !ok {
//        return
//    }
//
//    @Tags        ServiceContract
//    @Summary    删除服务合同
//    @Produce    application/json
//    @Param        object    body        request.DeleteServiceContract true    "查询参数"
//    @Success    200    {object}    contextx.Response{}
//    @Router        /api/serviceContract/delete [delete]
func (s *ServiceContractApi) Delete(c *gin.Context) {
    var params request.DeleteServiceContract
//    errCode := serviceContractService.DeleteServiceContract(params.Ids)
//    if errCode != ecode.OK {
//        ctx.Fail(errCode)
//        return
//    }
//
//    ctx.Ok()
//}
// BatchDelete
// @Tags    ServiceContract
// @Summary    批量删除服务合同
// @Produce    application/json
// @Param    object    body request.CommonIds    true "参数"
// @Success    200    {object}    contextx.Response{}
// @Router        /api/serviceContract/delete [delete]
func (s *ServiceContractApi) BatchDelete(c *gin.Context) {
    var params request.CommonIds
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    errCode := serviceContractService.DeleteServiceContract(params.Ids)
    errCode := serviceContractService.BatchDeleteServiceContract(params.Ids)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
api/v1/serviceOrder.go
@@ -67,10 +67,10 @@
}
// BatchDelete
// @Tags        服务单管理
// @Summary     批量删除服务单
// @Tags        服务单
// @Summary    批量删除服务单
// @Produce    application/json
// @Param        object    body        request.CommonIds    true    "参数"
// @Param    object    body request.CommonIds    true "参数"
// @Success    200    {object}    contextx.Response{}
// @Router        /api/serviceOrder/delete [delete]
func (s *ServiceOrderApi) BatchDelete(c *gin.Context) {
docs/docs.go
@@ -7763,15 +7763,15 @@
                "tags": [
                    "ServiceContract"
                ],
                "summary": "删除服务合同",
                "summary": "批量删除服务合同",
                "parameters": [
                    {
                        "description": "查询参数",
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.DeleteServiceContract"
                            "$ref": "#/definitions/request.CommonIds"
                        }
                    }
                ],
@@ -8395,12 +8395,12 @@
                    "application/json"
                ],
                "tags": [
                    "服务单管理"
                    "服务单"
                ],
                "summary": "批量删除服务单",
                "parameters": [
                    {
                        "description": "查询参数",
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
@@ -14676,17 +14676,6 @@
            }
        },
        "request.DeleteSalesLeads": {
            "type": "object",
            "properties": {
                "ids": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                }
            }
        },
        "request.DeleteServiceContract": {
            "type": "object",
            "properties": {
                "ids": {
docs/swagger.json
@@ -7751,15 +7751,15 @@
                "tags": [
                    "ServiceContract"
                ],
                "summary": "删除服务合同",
                "summary": "批量删除服务合同",
                "parameters": [
                    {
                        "description": "查询参数",
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.DeleteServiceContract"
                            "$ref": "#/definitions/request.CommonIds"
                        }
                    }
                ],
@@ -8383,12 +8383,12 @@
                    "application/json"
                ],
                "tags": [
                    "服务单管理"
                    "服务单"
                ],
                "summary": "批量删除服务单",
                "parameters": [
                    {
                        "description": "查询参数",
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
@@ -14664,17 +14664,6 @@
            }
        },
        "request.DeleteSalesLeads": {
            "type": "object",
            "properties": {
                "ids": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                }
            }
        },
        "request.DeleteServiceContract": {
            "type": "object",
            "properties": {
                "ids": {
docs/swagger.yaml
@@ -3200,13 +3200,6 @@
          type: integer
        type: array
    type: object
  request.DeleteServiceContract:
    properties:
      ids:
        items:
          type: integer
        type: array
    type: object
  request.DeleteServiceFeeManage:
    properties:
      ids:
@@ -10661,12 +10654,12 @@
  /api/serviceContract/delete:
    delete:
      parameters:
      - description: 查询参数
      - description: 参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.DeleteServiceContract'
          $ref: '#/definitions/request.CommonIds'
      produces:
      - application/json
      responses:
@@ -10674,7 +10667,7 @@
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 删除服务合同
      summary: 批量删除服务合同
      tags:
      - ServiceContract
  /api/serviceContract/list:
@@ -11050,7 +11043,7 @@
  /api/serviceOrder/delete:
    delete:
      parameters:
      - description: 查询参数
      - description: 参数
        in: body
        name: object
        required: true
@@ -11065,7 +11058,7 @@
            $ref: '#/definitions/contextx.Response'
      summary: 批量删除服务单
      tags:
      - 服务单管理
      - 服务单
  /api/serviceOrder/delete/{id}:
    delete:
      parameters:
model/serviceContract.go
@@ -139,6 +139,12 @@
    return db.Delete(&ServiceContract{}).Error
}
func (slf *ServiceContractSearch) DeleteByIds(ids []int) error {
    var db = slf.build()
    db = db.Where("id in ?", ids)
    return db.Delete(&ServiceContract{}).Error
}
func (slf *ServiceContractSearch) Find() ([]*ServiceContract, int64, error) {
    var db = slf.build()
    var records = make([]*ServiceContract, 0)
router/serviceContract.go
@@ -1,19 +1,19 @@
package router
import (
    v1 "aps_crm/api/v1"
    "github.com/gin-gonic/gin"
)
type ServiceContractRouter struct{}
func (s *ServiceContractRouter) InitServiceContractRouter(router *gin.RouterGroup) {
    serviceContractRouter := router.Group("serviceContract")
    serviceContractApi := v1.ApiGroup.ServiceContractApi
    {
        serviceContractRouter.POST("add", serviceContractApi.Add)             // 添加服务合同
        serviceContractRouter.DELETE("delete", serviceContractApi.Delete)     // 删除服务合同
        serviceContractRouter.PUT("update", serviceContractApi.Update)        // 更新服务合同
        serviceContractRouter.POST("list", serviceContractApi.List)           // 获取服务合同列表
    }
}
package router
import (
    v1 "aps_crm/api/v1"
    "github.com/gin-gonic/gin"
)
type ServiceContractRouter struct{}
func (s *ServiceContractRouter) InitServiceContractRouter(router *gin.RouterGroup) {
    serviceContractRouter := router.Group("serviceContract")
    serviceContractApi := v1.ApiGroup.ServiceContractApi
    {
        serviceContractRouter.POST("add", serviceContractApi.Add)              // 添加服务合同
        serviceContractRouter.DELETE("delete", serviceContractApi.BatchDelete) // 删除服务合同
        serviceContractRouter.PUT("update", serviceContractApi.Update)         // 更新服务合同
        serviceContractRouter.POST("list", serviceContractApi.List)            // 获取服务合同列表
    }
}
service/serviceContract.go
@@ -77,6 +77,14 @@
    return ecode.OK
}
func (SContractService) BatchDeleteServiceContract(ids []int) int {
    err := model.NewServiceContractSearch().DeleteByIds(ids)
    if err != nil {
        return ecode.DBErr
    }
    return ecode.OK
}
func (SContractService) GetServiceContractList(page, pageSize int, queryClass constvar.ServiceContractQueryClass, keywordType constvar.ServiceContractKeywordType, keyword string) ([]*model.ServiceContract, int64, int) {
    // get contact list
    contacts, total, err := model.NewServiceContractSearch().