Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop

This commit is contained in:
eson
2023-07-20 16:34:08 +08:00
6 changed files with 25 additions and 26 deletions

View File

@@ -75,7 +75,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
{
Method: http.MethodGet,
Path: "/api/user/order-list",
Handler: GetUserOrderListHandler(serverCtx),
Handler: UserOrderListHandler(serverCtx),
},
{
Method: http.MethodGet,

View File

@@ -4,20 +4,19 @@ import (
"errors"
"net/http"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/server/home-user-auth/internal/logic"
"fusenapi/server/home-user-auth/internal/svc"
"fusenapi/server/home-user-auth/internal/types"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
)
func GetUserOrderListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
func UserOrderListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var (
// 定义错误变量
err error
@@ -53,7 +52,7 @@ func GetUserOrderListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
userinfo = &auth.UserInfo{UserId: 0, GuestId: 0}
}
var req types.GetUserOrderListReq
var req types.UserOrderListReq
// 如果端点有请求结构体则使用httpx.Parse方法从HTTP请求体中解析请求数据
if err := httpx.Parse(r, &req); err != nil {
httpx.OkJsonCtx(r.Context(), w, &basic.Response{
@@ -64,8 +63,8 @@ func GetUserOrderListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetUserOrderListLogic(r.Context(), svcCtx)
resp := l.GetUserOrderList(&req, userinfo)
l := logic.NewUserOrderListLogic(r.Context(), svcCtx)
resp := l.UserOrderList(&req, userinfo)
// 如果响应不为nil则使用httpx.OkJsonCtx方法返回JSON响应;
if resp != nil {
httpx.OkJsonCtx(r.Context(), w, resp)