Prechádzať zdrojové kódy

faet:新增是否可以创建接口

zhangxinlei1996 1 rok pred
rodič
commit
5941f755f6

+ 17 - 0
api/application.api

@@ -165,6 +165,20 @@ type (
 		MobileHref string  `json:"mobileHref"`    //移动端跳转地址
 		User       []int64 `json:"user,optional"` //企业用户id
 	}
+
+	CanAddReq {
+		AppId          string `header:"appId,default=10000"`
+		BaseUserId     int64  `header:"newUserId"`
+		PositionId     int64  `header:"positionId,optional"`
+		EntUserId      int64  `header:"entUserId,optional"`
+		EntId          int64  `header:"entId,optional"`
+		AccountId      int64  `header:"accountId,optional"`
+		EntDeptId      int64  `header:"entDeptId,optional"`
+		EmployInfoId   int64  `json:"employInfoId"`            //资讯收录id
+		EmployCustomId int64  `json:"employCustomId,optional"` //客户收录id
+		Key            string `json:"key"`                     //创建线索:more_create_clue 创建机会:more_create_chance 创建客户:more_create_custom
+
+	}
 )
 
 service crmApplication {
@@ -201,4 +215,7 @@ service crmApplication {
 	@doc "消息推送"
 	@handler pushMsg
 	post /crmApplication/info/push(PushMsgReq) returns (Reply)
+	@doc "是否可以创建"
+	@handler canAddReq
+	post /crmApplication/info/canAdd(CanAddReq) returns (Reply)
 }

+ 28 - 0
api/internal/handler/canaddreqhandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/logic"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func canAddReqHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.CanAddReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewCanAddReqLogic(r.Context(), svcCtx)
+		resp, err := l.CanAddReq(&req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 5 - 0
api/internal/handler/routes.go

@@ -67,6 +67,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/crmApplication/info/push",
 				Handler: pushMsgHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/crmApplication/info/canAdd",
+				Handler: canAddReqHandler(serverCtx),
+			},
 		},
 	)
 }

+ 42 - 0
api/internal/logic/canaddreqlogic.go

@@ -0,0 +1,42 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+	"bp.jydev.jianyu360.cn/CRM/application/service"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type CanAddReqLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewCanAddReqLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CanAddReqLogic {
+	return &CanAddReqLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *CanAddReqLogic) CanAddReq(req *types.CanAddReq) (resp *types.Reply, err error) {
+
+	// todo: add your logic here and delete this line
+
+	resp = &types.Reply{}
+
+	status, error_msg := service.CanAdd(req.EntId, req.Key, req.EmployInfoId, req.EmployCustomId, req.PositionId)
+
+	resp.Error_code = status
+	resp.Error_msg = error_msg
+	resp.Data = map[string]interface{}{
+		"status": status,
+	}
+
+	return
+}

+ 13 - 0
api/internal/types/types.go

@@ -168,3 +168,16 @@ type PushMsgReq struct {
 	MobileHref string  `json:"mobileHref"`    //移动端跳转地址
 	User       []int64 `json:"user,optional"` //企业用户id
 }
+
+type CanAddReq struct {
+	AppId          string `header:"appId,default=10000"`
+	BaseUserId     int64  `header:"newUserId"`
+	PositionId     int64  `header:"positionId,optional"`
+	EntUserId      int64  `header:"entUserId,optional"`
+	EntId          int64  `header:"entId,optional"`
+	AccountId      int64  `header:"accountId,optional"`
+	EntDeptId      int64  `header:"entDeptId,optional"`
+	EmployInfoId   int64  `json:"employInfoId"`            //资讯收录id
+	EmployCustomId int64  `json:"employCustomId,optional"` //客户收录id
+	Key            string `json:"key"`                     //创建线索:more_create_clue 创建机会:more_create_chance 创建客户:more_create_custom
+}