Skip to content

Commit

Permalink
feat(mgm): api create rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Matrix-X committed Oct 5, 2023
1 parent 87883f2 commit a13205c
Show file tree
Hide file tree
Showing 22 changed files with 755 additions and 48 deletions.
1 change: 1 addition & 0 deletions api/admin.crm.api
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "admin/crm/customerdomain/lead.api"
import "admin/crm/customerdomain/customer.api"
import "admin/crm/market/media.api"
import "admin/crm/market/store.api"
import "admin/crm/market/mgm.api"
import "admin/crm/business/opportunity.api"
import "admin/crm/product/pricebook.api"
import "admin/crm/product/product.api"
Expand Down
94 changes: 46 additions & 48 deletions api/admin/crm/market/mgm.api
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
syntax = "v1"

info(
title: "MGM管理"
desc: "MGM管理"
title: "MGMRule管理"
desc: "MGMRule管理"
author: "MichaelHu"
email: "[email protected]"
version: "v1"
Expand All @@ -15,92 +15,90 @@ info(
)

service PowerX {
@doc "查询MGM列表"
@handler ListMGMsPage
get /mgms/page-list (ListMGMsPageRequest) returns (ListMGMsPageReply)
@doc "请求MGM上传链接"
@handler CreateMGM
post /mgms (CreateMGMRequest) returns (CreateMGMReply)

@doc "创建或更新MGM"
@handler UpdateMGM
put /mgms/:id (UpdateMGMRequest) returns (UpdateMGMReply)

@doc "根据获取MGM"
@handler GetMGM
get /mgms/:id (GetMGMRequest) returns (GetMGMReply)

@doc "删除MGM"
@handler DeleteMGM
delete /mgms/:id (DeleteMGMRequest) returns (DeleteMGMReply)
@doc "查询MGMRule列表"
@handler ListMGMRulesPage
get /mgms/page-list (ListMGMRulesPageRequest) returns (ListMGMRulesPageReply)
@doc "请求MGMRule上传链接"
@handler CreateMGMRule
post /mgms (CreateMGMRuleRequest) returns (CreateMGMRuleReply)

@doc "创建或更新MGMRule"
@handler UpdateMGMRule
put /mgms/:id (UpdateMGMRuleRequest) returns (UpdateMGMRuleReply)

@doc "根据获取MGMRule"
@handler GetMGMRule
get /mgms/:id (GetMGMRuleRequest) returns (GetMGMRuleReply)

@doc "删除MGMRule"
@handler DeleteMGMRule
delete /mgms/:id (DeleteMGMRuleRequest) returns (DeleteMGMRuleReply)
}

type (
ListMGMsPageRequest struct {
MGMTypes []int8 `form:"mgmTypes,optional"`
ListMGMRulesPageRequest struct {
MGMRuleTypes []int8 `form:"mgmTypes,optional"`
Keys []string `form:"keys,optional"`
OrderBy string `form:"orderBy,optional"`
PageIndex int `form:"pageIndex,optional"`
PageSize int `form:"pageSize,optional"`
}

MGM struct {
MGMRule struct {
Id int64 `json:"id,optional"`

Title string `json:"title,optional"`
SubTitle string `json:"subTitle,optional"`
CoverImageId int64 `json:"coverImageId,optional"`
ResourceUrl string `json:"resourceUrl,optional"`
CommissionRate1 float32 `json:"commissionRate1,optional"`
CommissionRate2 float32 `json:"commissionRate2,optional"`
Scene int `json:"scene,optional"`
Description string `json:"description,optional"`
MGMType int `json:"mgmType,optional"`
ViewedCount int `json:"viewedCount,optional"`

}

ListMGMsPageReply struct {
List []*MGM `json:"list"`
ListMGMRulesPageReply struct {
List []*MGMRule `json:"list"`
PageIndex int `json:"pageIndex"`
PageSize int `json:"pageSize"`
Total int64 `json:"total"`
}
)

type (
CreateMGMRequest struct {
MGM
CreateMGMRuleRequest struct {
MGMRule
}

CreateMGMReply struct {
MGMId int64 `json:"id"`
CreateMGMRuleReply struct {
MGMRuleId int64 `json:"id"`
}
)

type (
UpdateMGMRequest struct {
MGMId int64 `path:"id"`
MGM
UpdateMGMRuleRequest struct {
MGMRuleId int64 `path:"id"`
MGMRule
}

UpdateMGMReply struct {
MGMId int64 `json:"id"`
UpdateMGMRuleReply struct {
MGMRuleId int64 `json:"id"`
}
)

type (
GetMGMRequest struct {
MGMId int64 `path:"id"`
GetMGMRuleRequest struct {
MGMRuleId int64 `path:"id"`
}

GetMGMReply struct {
*MGM
GetMGMRuleReply struct {
*MGMRule
}
)

type (
DeleteMGMRequest struct {
MGMId int64 `path:"id"`
DeleteMGMRuleRequest struct {
MGMRuleId int64 `path:"id"`
}

DeleteMGMReply struct {
MGMId int64 `json:"id"`
DeleteMGMRuleReply struct {
MGMRuleId int64 `json:"id"`
}
)
28 changes: 28 additions & 0 deletions internal/handler/admin/crm/market/mgm/createmgmhandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mgm

import (
"net/http"

"PowerX/internal/logic/admin/crm/market/mgm"
"PowerX/internal/svc"
"PowerX/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)

func CreateMGMHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CreateMGMRuleRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := mgm.NewCreateMGMRuleLogic(r.Context(), svcCtx)
resp, err := l.CreateMGMRule(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
28 changes: 28 additions & 0 deletions internal/handler/admin/crm/market/mgm/createmgmrulehandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mgm

import (
"net/http"

"PowerX/internal/logic/admin/crm/market/mgm"
"PowerX/internal/svc"
"PowerX/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)

func CreateMGMRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CreateMGMRuleRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := mgm.NewCreateMGMRuleLogic(r.Context(), svcCtx)
resp, err := l.CreateMGMRule(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
28 changes: 28 additions & 0 deletions internal/handler/admin/crm/market/mgm/deletemgmhandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mgm

import (
"net/http"

"PowerX/internal/logic/admin/crm/market/mgm"
"PowerX/internal/svc"
"PowerX/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)

func DeleteMGMHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DeleteMGMRuleRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := mgm.NewDeleteMGMRuleLogic(r.Context(), svcCtx)
resp, err := l.DeleteMGMRule(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
28 changes: 28 additions & 0 deletions internal/handler/admin/crm/market/mgm/deletemgmrulehandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mgm

import (
"net/http"

"PowerX/internal/logic/admin/crm/market/mgm"
"PowerX/internal/svc"
"PowerX/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)

func DeleteMGMRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DeleteMGMRuleRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := mgm.NewDeleteMGMRuleLogic(r.Context(), svcCtx)
resp, err := l.DeleteMGMRule(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
28 changes: 28 additions & 0 deletions internal/handler/admin/crm/market/mgm/getmgmhandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mgm

import (
"net/http"

"PowerX/internal/logic/admin/crm/market/mgm"
"PowerX/internal/svc"
"PowerX/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)

func GetMGMHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetMGMRuleRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := mgm.NewGetMGMRuleLogic(r.Context(), svcCtx)
resp, err := l.GetMGMRule(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
28 changes: 28 additions & 0 deletions internal/handler/admin/crm/market/mgm/getmgmrulehandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mgm

import (
"net/http"

"PowerX/internal/logic/admin/crm/market/mgm"
"PowerX/internal/svc"
"PowerX/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)

func GetMGMRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetMGMRuleRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := mgm.NewGetMGMRuleLogic(r.Context(), svcCtx)
resp, err := l.GetMGMRule(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
28 changes: 28 additions & 0 deletions internal/handler/admin/crm/market/mgm/listmgmrulespagehandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mgm

import (
"net/http"

"PowerX/internal/logic/admin/crm/market/mgm"
"PowerX/internal/svc"
"PowerX/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)

func ListMGMRulesPageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ListMGMRulesPageRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := mgm.NewListMGMRulesPageLogic(r.Context(), svcCtx)
resp, err := l.ListMGMRulesPage(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
28 changes: 28 additions & 0 deletions internal/handler/admin/crm/market/mgm/listmgmspagehandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mgm

import (
"net/http"

"PowerX/internal/logic/admin/crm/market/mgm"
"PowerX/internal/svc"
"PowerX/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)

func ListMGMsPageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ListMGMRulesPageRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := mgm.NewListMGMRulesPageLogic(r.Context(), svcCtx)
resp, err := l.ListMGMRulesPage(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
Loading

0 comments on commit a13205c

Please sign in to comment.