所有序列化, 都加入 BeforeLogic AfterLogic方法. 便于处理 w r的传递的参数

This commit is contained in:
eson
2023-07-21 15:20:18 +08:00
parent 373d5dca45
commit 2825f8ae54
100 changed files with 1499 additions and 454 deletions

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func DesignGatherHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DesignGatherReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewDesignGatherLogic(r.Context(), svcCtx)
resp := l.DesignGather(&req, userinfo, r)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.DesignGather(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetFittingByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetFittingByPidReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetFittingByPidLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetFittingByPid(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetLastProductDesignHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.Request
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetLastProductDesignLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetLastProductDesign(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetLightByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetLightByPidReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetLightByPidLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetLightByPid(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetModelByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetModelByPidReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetModelByPidLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetModelByPid(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetPriceByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetPriceByPidReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetPriceByPidLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetPriceByPid(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetProductDesignHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetProductDesignReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetProductDesignLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetProductDesign(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetProductInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetProductInfoReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetProductInfoLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetProductInfo(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetProductListReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetProductListLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetProductList(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetRecommandProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetRecommandProductListReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetRecommandProductListLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetRecommandProductList(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetRenderDesignHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetRenderDesignReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetRenderDesignLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetRenderDesign(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetRenderSettingByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetRenderSettingByPidReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetRenderSettingByPidLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetRenderSettingByPid(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetSizeByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetSizeByPidReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetSizeByPidLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetSizeByPid(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,16 +2,34 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
"fusenapi/server/product/internal/types"
)
func GetSizeByProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
l := logic.NewGetSizeByProductLogic(r.Context(), svcCtx)
resp := l.GetSizeByProduct(userinfo)
var req types.Request
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetSizeByProductLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetSizeByProduct(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetSuccessRecommandHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetSuccessRecommandReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetSuccessRecommandLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetSuccessRecommand(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetTagProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetTagProductListReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetTagProductListLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetTagProductList(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func GetTemplateByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetTemplateByPidReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetTemplateByPidLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetTemplateByPid(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -1,21 +1,35 @@
package handler
import (
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/types"
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
"fusenapi/server/product/internal/types"
)
func HomePageRecommendProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.HomePageRecommendProductListReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewHomePageRecommendProductListLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.HomePageRecommendProductList(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func OtherProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.OtherProductListReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewOtherProductListLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.OtherProductList(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -2,6 +2,9 @@ package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
@@ -12,10 +15,21 @@ func SaveDesignHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SaveDesignReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewSaveDesignLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.SaveDesign(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
basic.NormalAfterLogic(w, r, resp)
}
}
}