新版本,代理功能上线

This commit is contained in:
2025-03-07 03:48:59 +08:00
parent 8ead7a7a67
commit b2d9d828e3
130 changed files with 11004 additions and 2209 deletions

View File

@@ -0,0 +1,29 @@
package agent
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tydata-server/app/user/cmd/api/internal/logic/agent"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/app/user/cmd/api/internal/types"
"tydata-server/common/result"
"tydata-server/pkg/lzkit/validator"
)
func ActivateAgentMembershipHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.AgentActivateMembershipReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err := validator.Validate(req); err != nil {
result.ParamValidateErrorResult(r, w, err)
return
}
l := agent.NewActivateAgentMembershipLogic(r.Context(), svcCtx)
resp, err := l.ActivateAgentMembership(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -1,19 +1,19 @@
package query
package agent
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tydata-server/app/user/cmd/api/internal/logic/query"
"tydata-server/app/user/cmd/api/internal/logic/agent"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/app/user/cmd/api/internal/types"
"tydata-server/common/result"
"tydata-server/pkg/lzkit/validator"
)
func RentalInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
func ApplyForAgentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.QueryReq
var req types.AgentApplyReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
@@ -22,8 +22,8 @@ func RentalInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
result.ParamValidateErrorResult(r, w, err)
return
}
l := query.NewRentalInfoLogic(r.Context(), svcCtx)
resp, err := l.RentalInfo(&req)
l := agent.NewApplyForAgentLogic(r.Context(), svcCtx)
resp, err := l.ApplyForAgent(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -1,19 +1,19 @@
package query
package agent
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tydata-server/app/user/cmd/api/internal/logic/query"
"tydata-server/app/user/cmd/api/internal/logic/agent"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/app/user/cmd/api/internal/types"
"tydata-server/common/result"
"tydata-server/pkg/lzkit/validator"
)
func RiskAssessmentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
func GeneratingLinkHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.QueryReq
var req types.AgentGeneratingLinkReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
@@ -22,8 +22,8 @@ func RiskAssessmentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
result.ParamValidateErrorResult(r, w, err)
return
}
l := query.NewRiskAssessmentLogic(r.Context(), svcCtx)
resp, err := l.RiskAssessment(&req)
l := agent.NewGeneratingLinkLogic(r.Context(), svcCtx)
resp, err := l.GeneratingLink(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -0,0 +1,17 @@
package agent
import (
"net/http"
"tydata-server/app/user/cmd/api/internal/logic/agent"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/common/result"
)
func GetAgentAuditStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
l := agent.NewGetAgentAuditStatusLogic(r.Context(), svcCtx)
resp, err := l.GetAgentAuditStatus()
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -0,0 +1,17 @@
package agent
import (
"net/http"
"tydata-server/app/user/cmd/api/internal/logic/agent"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/common/result"
)
func GetAgentInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
l := agent.NewGetAgentInfoLogic(r.Context(), svcCtx)
resp, err := l.GetAgentInfo()
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -0,0 +1,29 @@
package agent
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tydata-server/app/user/cmd/api/internal/logic/agent"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/app/user/cmd/api/internal/types"
"tydata-server/common/result"
"tydata-server/pkg/lzkit/validator"
)
func GetAgentMembershipProductConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.AgentMembershipProductConfigReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err := validator.Validate(req); err != nil {
result.ParamValidateErrorResult(r, w, err)
return
}
l := agent.NewGetAgentMembershipProductConfigLogic(r.Context(), svcCtx)
resp, err := l.GetAgentMembershipProductConfig(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -0,0 +1,17 @@
package agent
import (
"net/http"
"tydata-server/app/user/cmd/api/internal/logic/agent"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/common/result"
)
func GetAgentProductConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
l := agent.NewGetAgentProductConfigLogic(r.Context(), svcCtx)
resp, err := l.GetAgentProductConfig()
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -0,0 +1,29 @@
package agent
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tydata-server/app/user/cmd/api/internal/logic/agent"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/app/user/cmd/api/internal/types"
"tydata-server/common/result"
"tydata-server/pkg/lzkit/validator"
)
func GetAgentRevenueInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetAgentRevenueInfoReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err := validator.Validate(req); err != nil {
result.ParamValidateErrorResult(r, w, err)
return
}
l := agent.NewGetAgentRevenueInfoLogic(r.Context(), svcCtx)
resp, err := l.GetAgentRevenueInfo(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -1,19 +1,19 @@
package query
package agent
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tydata-server/app/user/cmd/api/internal/logic/query"
"tydata-server/app/user/cmd/api/internal/logic/agent"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/app/user/cmd/api/internal/types"
"tydata-server/common/result"
"tydata-server/pkg/lzkit/validator"
)
func CompanyInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
func GetLinkDataHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.QueryReq
var req types.GetLinkDataReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
@@ -22,8 +22,8 @@ func CompanyInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
result.ParamValidateErrorResult(r, w, err)
return
}
l := query.NewCompanyInfoLogic(r.Context(), svcCtx)
resp, err := l.CompanyInfo(&req)
l := agent.NewGetLinkDataLogic(r.Context(), svcCtx)
resp, err := l.GetLinkData(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -0,0 +1,29 @@
package agent
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tydata-server/app/user/cmd/api/internal/logic/agent"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/app/user/cmd/api/internal/types"
"tydata-server/common/result"
"tydata-server/pkg/lzkit/validator"
)
func SaveAgentMembershipUserConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SaveAgentMembershipUserConfigReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err := validator.Validate(req); err != nil {
result.ParamValidateErrorResult(r, w, err)
return
}
l := agent.NewSaveAgentMembershipUserConfigLogic(r.Context(), svcCtx)
err := l.SaveAgentMembershipUserConfig(&req)
result.HttpResult(r, w, nil, err)
}
}

View File

@@ -11,9 +11,9 @@ import (
"tydata-server/pkg/lzkit/validator"
)
func BackgroundCheckHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
func QueryServiceAgentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.QueryReq
var req types.QueryServiceReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
@@ -22,8 +22,8 @@ func BackgroundCheckHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
result.ParamValidateErrorResult(r, w, err)
return
}
l := query.NewBackgroundCheckLogic(r.Context(), svcCtx)
resp, err := l.BackgroundCheck(&req)
l := query.NewQueryServiceLogic(r.Context(), svcCtx)
resp, err := l.QueryService(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -4,6 +4,7 @@ package handler
import (
"net/http"
agent "tydata-server/app/user/cmd/api/internal/handler/agent"
auth "tydata-server/app/user/cmd/api/internal/handler/auth"
notification "tydata-server/app/user/cmd/api/internal/handler/notification"
pay "tydata-server/app/user/cmd/api/internal/handler/pay"
@@ -16,6 +17,89 @@ import (
)
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodGet,
Path: "/audit/status",
Handler: agent.GetAgentAuditStatusHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/commission",
Handler: agent.GetAgentCommissionHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/generating_link",
Handler: agent.GeneratingLinkHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/info",
Handler: agent.GetAgentInfoHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/membership/save_user_config",
Handler: agent.SaveAgentMembershipUserConfigHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/membership/user_config",
Handler: agent.GetAgentMembershipProductConfigHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/product_config",
Handler: agent.GetAgentProductConfigHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/revenue",
Handler: agent.GetAgentRevenueInfoHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/rewards",
Handler: agent.GetAgentRewardsHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/withdrawal",
Handler: agent.GetAgentWithdrawalHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/withdrawal",
Handler: agent.AgentWithdrawalHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret),
rest.WithPrefix("/api/v1/agent"),
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodPost,
Path: "/apply",
Handler: agent.ApplyForAgentHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/link",
Handler: agent.GetLinkDataHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/membership/activate",
Handler: agent.ActivateAgentMembershipHandler(serverCtx),
},
},
rest.WithPrefix("/api/v1/agent"),
)
server.AddRoutes(
[]rest.Route{
{
@@ -101,47 +185,17 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
server.AddRoutes(
[]rest.Route{
{
// query general background check
// query service agent
Method: http.MethodPost,
Path: "/query/backgroundCheck",
Handler: query.BackgroundCheckHandler(serverCtx),
},
{
// query company info
Method: http.MethodPost,
Path: "/query/companyInfo",
Handler: query.CompanyInfoHandler(serverCtx),
},
{
// query home service
Method: http.MethodPost,
Path: "/query/homeService",
Handler: query.HomeServiceHandler(serverCtx),
},
{
// query marriage
Method: http.MethodPost,
Path: "/query/marriage",
Handler: query.MarriageHandler(serverCtx),
},
{
// query pre-loan background check
Method: http.MethodPost,
Path: "/query/preLoanBackgroundCheck",
Handler: query.PreLoanBackgroundCheckHandler(serverCtx),
},
{
// query rental info
Method: http.MethodPost,
Path: "/query/rentalInfo",
Handler: query.RentalInfoHandler(serverCtx),
},
{
// query risk assessment
Method: http.MethodPost,
Path: "/query/riskAssessment",
Handler: query.RiskAssessmentHandler(serverCtx),
Path: "/query/service_agent/:product",
Handler: query.QueryServiceAgentHandler(serverCtx),
},
},
rest.WithPrefix("/api/v1"),
)
server.AddRoutes(
[]rest.Route{
{
// query service
Method: http.MethodPost,
@@ -204,6 +258,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
server.AddRoutes(
[]rest.Route{
{
// agent mobile code login
Method: http.MethodPost,
Path: "/user/agent_mobile_code_login",
Handler: user.AgentMobileCodeLoginHandler(serverCtx),
},
{
// mobile code login
Method: http.MethodPost,

View File

@@ -1,19 +1,19 @@
package query
package user
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tydata-server/app/user/cmd/api/internal/logic/query"
"tydata-server/app/user/cmd/api/internal/logic/user"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/app/user/cmd/api/internal/types"
"tydata-server/common/result"
"tydata-server/pkg/lzkit/validator"
)
func PreLoanBackgroundCheckHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
func AgentMobileCodeLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.QueryReq
var req types.MobileCodeLoginReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
@@ -22,8 +22,8 @@ func PreLoanBackgroundCheckHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
result.ParamValidateErrorResult(r, w, err)
return
}
l := query.NewPreLoanBackgroundCheckLogic(r.Context(), svcCtx)
resp, err := l.PreLoanBackgroundCheck(&req)
l := user.NewAgentMobileCodeLoginLogic(r.Context(), svcCtx)
resp, err := l.AgentMobileCodeLogin(&req)
result.HttpResult(r, w, resp, err)
}
}