| | |
| | | return |
| | | } |
| | | |
| | | count, err := model.NewServiceContractSearch().SetNumber(params.Number).Count() |
| | | if err != nil { |
| | | ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败") |
| | | return |
| | | } |
| | | if count > 0 { |
| | | ctx.FailWithMsg(ecode.UnknownErr, "编码已存在") |
| | | return |
| | | } |
| | | |
| | | if params.MemberId == 0 { |
| | | userInfo := utils.GetUserInfo(c) |
| | | if userInfo.UserType == constvar.UserTypeSub { |
| | |
| | | return |
| | | } |
| | | |
| | | if params.CodeRule.Method == 1 { |
| | | autoCode := model.GetAutoCode(serviceContract.Id, ¶ms.CodeRule) |
| | | m := map[string]interface{}{ |
| | | "number": autoCode, |
| | | } |
| | | _ = model.NewServiceContractSearch().SetId(serviceContract.Id).UpdateByMap(m) |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | //// 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, ¶ms) |
| | | // if !ok { |
| | | // return |
| | | // } |
| | | // |
| | | // errCode := serviceContractService.DeleteServiceContract(params.Ids) |
| | | // if errCode != ecode.OK { |
| | | // ctx.Fail(errCode) |
| | | // return |
| | | // } |
| | | // |
| | | // ctx.Ok() |
| | | //} |
| | | |
| | | // BatchDelete |
| | | // @Tags ServiceContract |