From b45b8ce8051e2ad9c80aafa42d1a5892f6a36bce Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期二, 17 十月 2023 15:27:44 +0800 Subject: [PATCH] 初始化一些表shuju --- api/v1/serviceContract.go | 68 ++++++++++++++++++++++++++++----- 1 files changed, 57 insertions(+), 11 deletions(-) diff --git a/api/v1/serviceContract.go b/api/v1/serviceContract.go index 7cf4b9d..d6b13c1 100644 --- a/api/v1/serviceContract.go +++ b/api/v1/serviceContract.go @@ -1,12 +1,14 @@ package v1 import ( + "aps_crm/constvar" "aps_crm/model" "aps_crm/model/request" "aps_crm/model/response" "aps_crm/pkg/contextx" "aps_crm/pkg/ecode" "aps_crm/pkg/structx" + "aps_crm/utils" "github.com/gin-gonic/gin" ) @@ -33,31 +35,69 @@ return } + if params.MemberId == 0 { + userInfo := utils.GetUserInfo(c) + if userInfo.UserType == constvar.UserTypeSub { + params.MemberId = userInfo.CrmUserId + } + } + errCode := serviceContractService.AddServiceContract(serviceContract) if errCode != ecode.OK { ctx.Fail(errCode) 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 +//// 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 +// } // -// @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, ¶ms) if !ok { return } - errCode := serviceContractService.DeleteServiceContract(params.Ids) + errCode := serviceContractService.BatchDeleteServiceContract(params.Ids) if errCode != ecode.OK { ctx.Fail(errCode) return @@ -113,7 +153,13 @@ return } - serviceContracts, total, errCode := serviceContractService.GetServiceContractList(params.Page, params.PageSize, params.QueryClass, params.KeywordType, params.Keyword) + var memberIds []int + userInfo := utils.GetUserInfo(c) + if userInfo.UserType == constvar.UserTypeSub { + memberIds = []int{userInfo.CrmUserId} + } + + serviceContracts, total, errCode := serviceContractService.GetServiceContractList(params, memberIds) if errCode != ecode.OK { ctx.Fail(errCode) return -- Gitblit v1.8.0