2637309949 4 lat temu
rodzic
commit
e6605e0d75

+ 30 - 3
i2bill.api

@@ -102,23 +102,32 @@ type punchClockRequest {
 	Type    int64  `json:"type"`
 }
 
+type enrollRequest {
+	Name        string `json:"name"`
+	Sex         int64  `json:"sex"`
+	IponeNumber string `json:"ipone_number"`
+	Target      int64  `json:"target"`
+}
+
 type Response {
 	Code int         `json:"code"`
 	Msg  string      `json:"msg"`
 	Data interface{} `json:"data"`
 }
 
+// 认证模块
 @server(
 	group: auth
 )
 service i2bill-api {
 	@handler Hello
 	get /api/hello
-
+	
 	@handler LoginByWeixin
 	post /api/auth/loginByWeixin(loginByWeixinRequest) returns(loginByWeixinResponse)
 }
 
+// 用户模块
 @server(
 	jwt: JwtAuth
 	group: user
@@ -136,10 +145,28 @@ service i2bill-api {
 	@handler PunchClock
 	post /api/user/punchClock(punchClockRequest) returns(Response)
 
-	@handler  PartTimeUserAd
+}
+
+// 兼职模块
+@server(
+	jwt: JwtAuth
+	group: part_time_user
+)
+service i2bill-api {
 	@handler  PartTimeUserAdd
 	post /api/v1/part_time_user/add (partTimeUserAddRequest) returns(Response)
-
+	
 	@handler  PartTimeUserUpdate
 	post /api/v1/part_time_user/update (partTimeUserAddRequest) returns(Response)
+}
+
+
+// 收单模块
+@server(
+	jwt: JwtAuth
+	group: acquirer
+)
+service i2bill-api {
+	@handler Enroll
+	post /api/acquirer/enroll(enrollRequest) returns(Response)
 }

+ 29 - 0
internal/handler/acquirer/enrollhandler.go

@@ -0,0 +1,29 @@
+package acquirer
+
+import (
+	"net/http"
+
+	"git.i2edu.net/i2/i2-bill-api/internal/logic/acquirer"
+	"git.i2edu.net/i2/i2-bill-api/internal/svc"
+	"git.i2edu.net/i2/i2-bill-api/internal/types"
+
+	"git.i2edu.net/i2/go-zero/rest/httpx"
+)
+
+func EnrollHandler(ctx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.EnrollRequest
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := acquirer.NewEnrollLogic(r.Context(), ctx)
+		resp, err := l.Enroll(req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 13 - 1
internal/handler/routes.go

@@ -2,10 +2,11 @@
 package handler
 
 import (
-	"git.i2edu.net/i2/i2-bill-api/internal/handler/part_time_user"
 	"net/http"
 
+	acquirer "git.i2edu.net/i2/i2-bill-api/internal/handler/acquirer"
 	auth "git.i2edu.net/i2/i2-bill-api/internal/handler/auth"
+	part_time_user "git.i2edu.net/i2/i2-bill-api/internal/handler/part_time_user"
 	user "git.i2edu.net/i2/i2-bill-api/internal/handler/user"
 	"git.i2edu.net/i2/i2-bill-api/internal/svc"
 
@@ -63,4 +64,15 @@ func RegisterHandlers(engine *rest.Server, serverCtx *svc.ServiceContext) {
 		},
 		rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret),
 	)
+
+	engine.AddRoutes(
+		[]rest.Route{
+			{
+				Method:  http.MethodPost,
+				Path:    "/api/acquirer/enroll",
+				Handler: acquirer.EnrollHandler(serverCtx),
+			},
+		},
+		rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret),
+	)
 }

+ 30 - 0
internal/logic/acquirer/enrolllogic.go

@@ -0,0 +1,30 @@
+package acquirer
+
+import (
+	"context"
+
+	"git.i2edu.net/i2/i2-bill-api/internal/svc"
+	"git.i2edu.net/i2/i2-bill-api/internal/types"
+
+	"git.i2edu.net/i2/go-zero/core/logx"
+)
+
+type EnrollLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewEnrollLogic(ctx context.Context, svcCtx *svc.ServiceContext) EnrollLogic {
+	return EnrollLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *EnrollLogic) Enroll(req types.EnrollRequest) (*types.Response, error) {
+	// todo: add your logic here and delete this line
+
+	return &types.Response{}, nil
+}

+ 7 - 0
internal/types/types.go

@@ -95,6 +95,13 @@ type PunchClockRequest struct {
 	Type    int64  `json:"type"`
 }
 
+type EnrollRequest struct {
+	Name        string `json:"name"`
+	Sex         int64  `json:"sex"`
+	IponeNumber string `json:"ipone_number"`
+	Target      int64  `json:"target"`
+}
+
 type Response struct {
 	Code int         `json:"code"`
 	Msg  string      `json:"msg"`