icole 4 лет назад
Родитель
Сommit
76ff31701d

+ 8 - 2
i2bill.api

@@ -171,6 +171,12 @@ service i2bill-api {
 	@handler PunchClock
 	post /api/user/punchClock(punchClockRequest) returns(Response)
 	
+	@handler PunchClockPage
+	get /api/user/punchClock/page returns(Response)
+	
+	@handler PunchClockGet
+	get /api/user/punchClock/get_to_day returns(Response)
+	
 }
 
 // 兼职模块
@@ -207,10 +213,10 @@ service i2bill-api {
 
 service i2bill-api{
 	@handler AcquirerStudentPage
-	post /api/acquirer_student/enroll/page() returns(Response)
+	post /api/v1/acquirer_student/page() returns(Response)
 	
 	@handler AcquirerStudentTotal
-	get  /api/acquirer/acquirer_student/total returns(Response)
+	get  /api/v1/acquirer_student/total returns(Response)
 }
 
 @server(

+ 12 - 2
internal/handler/routes.go

@@ -55,6 +55,16 @@ func RegisterHandlers(engine *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/api/user/punchClock",
 				Handler: user.PunchClockHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodGet,
+				Path:    "/api/user/punchClock/page",
+				Handler: user.PunchClockPageHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodGet,
+				Path:    "/api/user/punchClock/get_to_day",
+				Handler: user.PunchClockGetHandler(serverCtx),
+			},
 		},
 		rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret),
 	)
@@ -95,12 +105,12 @@ func RegisterHandlers(engine *rest.Server, serverCtx *svc.ServiceContext) {
 		[]rest.Route{
 			{
 				Method:  http.MethodPost,
-				Path:    "/api/acquirer_student/enroll/page",
+				Path:    "/api/v1/acquirer_student/page",
 				Handler: acquirer_student.AcquirerStudentPageHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodGet,
-				Path:    "/api/acquirer/acquirer_student/total",
+				Path:    "/api/v1/acquirer_student/total",
 				Handler: acquirer_student.AcquirerStudentTotalHandler(serverCtx),
 			},
 		},

+ 22 - 0
internal/handler/user/punch_clock_get_handler.go

@@ -0,0 +1,22 @@
+package user
+
+import (
+	"net/http"
+
+	"git.i2edu.net/i2/go-zero/rest/httpx"
+	userLogic "git.i2edu.net/i2/i2-bill-api/internal/logic/user"
+	"git.i2edu.net/i2/i2-bill-api/internal/svc"
+)
+
+func PunchClockGetHandler(ctx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+
+		l := userLogic.NewPunchClockGetLogic(r.Context(), ctx)
+		resp, err := l.PunchClockGet(r)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 22 - 0
internal/handler/user/punch_clock_page_handler.go

@@ -0,0 +1,22 @@
+package user
+
+import (
+	"net/http"
+
+	"git.i2edu.net/i2/go-zero/rest/httpx"
+	userLogic "git.i2edu.net/i2/i2-bill-api/internal/logic/user"
+	"git.i2edu.net/i2/i2-bill-api/internal/svc"
+)
+
+func PunchClockPageHandler(ctx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+
+		l := userLogic.NewPunchClockPageLogic(r.Context(), ctx)
+		resp, err := l.PunchClockPage(r)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 1 - 1
internal/logic/acquirer_student/acquirer_student_page_logic.go

@@ -57,7 +57,7 @@ func (l *AcquirerStudentPageLogic) AcquirerStudentPage(r *http.Request) (*types.
 		"check_state":     check_state,
 		"__sort__":        sort,
 	}
-	res, err := utils.PageSearch(l.svcCtx.DB, "i2bill_mkt_part_time_user", "page", "", paramMap_i_t)
+	res, err := utils.PageSearch(l.svcCtx.DB, "i2bill_acquirer_student", "page", "i2bill_acquirer_student", paramMap_i_t)
 	if err != nil {
 		return &types.Response{500, err.Error(), res}, nil
 	}

+ 35 - 0
internal/logic/user/punch_clock_get_logic.go

@@ -0,0 +1,35 @@
+package user
+
+import (
+	"context"
+	"net/http"
+	"time"
+
+	"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 PunchClockGetLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewPunchClockGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) PunchClockGetLogic {
+	return PunchClockGetLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *PunchClockGetLogic) PunchClockGet(r *http.Request) (*types.Response, error) {
+	// todo: add your logic here and delete this line
+	res, err := l.svcCtx.DB.SQL("select * from i2bill_acquirer_attendance_record where del_flag = 0 and user_id = ? and  DATE_FORMAT(create_time,'%Y-%m-%d') = ? order by id desc limit 0,1", l.svcCtx.GetUserIdByJwt(l.ctx), time.Now().Format("2006-01-02")).Query().List()
+	if err != nil {
+		return &types.Response{500, err.Error(), nil}, nil
+	}
+	return &types.Response{200, "", res}, nil
+}

+ 65 - 0
internal/logic/user/punch_clock_page_logic.go

@@ -0,0 +1,65 @@
+package user
+
+import (
+	"context"
+	"fmt"
+	"git.i2edu.net/i2/i2-bill-api/internal/utils"
+	"net/http"
+	"strconv"
+	"time"
+
+	"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 PunchClockPageLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewPunchClockPageLogic(ctx context.Context, svcCtx *svc.ServiceContext) PunchClockPageLogic {
+	return PunchClockPageLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *PunchClockPageLogic) PunchClockPage(r *http.Request) (*types.Response, error) {
+	// todo: add your logic here and delete this line
+	r.ParseForm()
+	create_time_sta := r.Form.Get("create_time_sta")
+	create_time_end := r.Form.Get("create_time_end")
+	page, _ := strconv.Atoi(r.Form.Get("page"))
+	rows, _ := strconv.Atoi(r.Form.Get("rows"))
+	sort := r.Form.Get("__sort__")
+	userId := fmt.Sprintf("%d", l.svcCtx.GetUserIdByJwt(l.ctx))
+	if create_time_end != "" {
+		end, err := time.Parse("2006-01-02", create_time_end)
+		if err != nil {
+			return &types.Response{500, err.Error(), nil}, nil
+		}
+		create_time_end = end.Add(time.Second*24*60*60 - 1*time.Second).Format("2006-01-02 15:04:05")
+
+	}
+	if sort == "" {
+		sort = "id desc"
+	}
+	paramMap_i_t := map[string]interface{}{
+		"page":            page,
+		"rows":            rows,
+		"create_time_sta": create_time_sta,
+		"create_time_end": create_time_end,
+		"user_id":         userId,
+		"__sort__":        sort,
+	}
+
+	res, err := utils.PageSearch(l.svcCtx.DB, "i2bill_acquirer_attendance_record", "page", "i2bill_acquirer_attendance_record", paramMap_i_t)
+	if err != nil {
+		return &types.Response{500, err.Error(), nil}, nil
+	}
+	return &types.Response{200, "", res}, nil
+}

+ 1 - 1
sqlconfig/i2bill_mkt_part_time_user/i2bill_mkt_part_time_user_page_select.tpl → sqlconfig/i2bill_acquirer_student/i2bill_acquirer_student_page_select.tpl

@@ -1,7 +1,7 @@
 SELECT
     *
 FROM
-    i2bill_mkt_part_time_user
+    i2bill_acquirer_student
 WHERE
 del_flag = 0
 {{if ne .user_id ""}}

+ 1 - 1
sqlconfig/i2bill_mkt_part_time_user/i2bill_mkt_part_time_user_page_count.tpl → sqlconfig/i2bill_acquirer_student/i2bill_acquirer_studentr_page_count.tpl

@@ -1,7 +1,7 @@
 SELECT
     count(*) records
 FROM
-    i2bill_mkt_part_time_user
+    i2bill_acquirer_student
 WHERE
     del_flag = 0
 {{if ne .user_id ""}}