fix
wangpengfei
2023-08-28 c5a0eb549cba2cd358a2d0496c44f3a289f15d9c
api/v1/contract.go
@@ -7,7 +7,6 @@
   "aps_crm/pkg/contextx"
   "aps_crm/pkg/ecode"
   "github.com/gin-gonic/gin"
   "strconv"
)
type ContractApi struct{}
@@ -47,17 +46,17 @@
//   @Tags      Contract
//   @Summary   删除合同
//   @Produce   application/json
//   @Param      id   path      int   true   "查询参数"
//   @Param      object   body      request.DeleteContract true   "查询参数"
//   @Success   200   {object}   contextx.Response{}
//   @Router      /api/contract/delete/{id} [delete]
//   @Router      /api/contract/delete [delete]
func (s *ContractApi) Delete(c *gin.Context) {
   ctx, ok := contextx.NewContext(c, nil)
   var params request.DeleteContract
   ctx, ok := contextx.NewContext(c, &params)
   if !ok {
      return
   }
   id, _ := strconv.Atoi(c.Param("id"))
   errCode := contractService.DeleteContract(id)
   errCode := contractService.DeleteContract(params.Ids)
   if errCode != ecode.OK {
      ctx.Fail(errCode)
      return
@@ -87,6 +86,8 @@
      return
   }
   contract.Id = params.Id
   errCode = contractService.UpdateContract(&contract)
   if errCode != ecode.OK {
      ctx.Fail(errCode)
@@ -96,38 +97,14 @@
   ctx.Ok()
}
// List
//
//   @Tags      Contract
//   @Summary   获取合同列表
//   @Produce   application/json
//   @Success   200   {object}   contextx.Response{data=response.ContractResponse}
//   @Router      /api/contract/list [get]
func (s *ContractApi) List(c *gin.Context) {
   ctx, ok := contextx.NewContext(c, nil)
   if !ok {
      return
   }
   contractList, errCode := contractService.GetContractList()
   if errCode != ecode.OK {
      ctx.Fail(errCode)
      return
   }
   ctx.OkWithDetailed(response.ContractResponse{
      List: contractList,
   })
}
func checkContractParams(contract request.Contract) (errCode int, contractModel model.Contract) {
   if contract.Number == "" {
      return ecode.InvalidParams, contractModel
   }
   //if contract.Number == "" {
   //   return ecode.InvalidParams, contractModel
   //}
   if contract.MemberId == 0 {
      return ecode.InvalidParams, contractModel
   }
   //if contract.MemberId == 0 {
   //   return ecode.InvalidParams, contractModel
   //}
   contractModel = model.Contract{
      ClientId:    contract.ClientId,
@@ -140,3 +117,30 @@
   return ecode.OK, contractModel
}
// List
//
//   @Tags      Contract
//   @Summary   销售合同列表
//   @Produce   application/json
//   @Param      object   body      request.GetContractList   true   "参数"
//   @Success   200      {object}   contextx.Response{data=response.ContractResponse}
//   @Router      /api/contract/list [post]
func (con *ContractApi) List(c *gin.Context) {
   var params request.GetContractList
   ctx, ok := contextx.NewContext(c, &params)
   if !ok {
      return
   }
   contracts, total, errCode := contractService.GetContractList(params.Page, params.PageSize, params.SearchMap)
   if errCode != ecode.OK {
      ctx.Fail(errCode)
      return
   }
   ctx.OkWithDetailed(response.ContractResponse{
      List:  contracts,
      Count: int(total),
   })
}