diff --git a/api/admin.wechat.offiaccount.api b/api/admin.wechat.offiaccount.api index 7970b202..68c7c4e4 100644 --- a/api/admin.wechat.offiaccount.api +++ b/api/admin.wechat.offiaccount.api @@ -1,2 +1,3 @@ import "admin/wechat/officialaccount/menu.api" +import "admin/wechat/officialaccount/media.api" diff --git a/api/admin/wechat/officialaccount/media.api b/api/admin/wechat/officialaccount/media.api new file mode 100644 index 00000000..93df269c --- /dev/null +++ b/api/admin/wechat/officialaccount/media.api @@ -0,0 +1,89 @@ +syntax = "v1" + +info( + title: "菜单管理" + desc: "菜单管理" + author: "MichaelHu" + email: "matrix-x@artisan-cloud.com" + version: "v1" +) + +@server( + group: admin/wechat/officialaccount/media + prefix: /api/v1/admin/wechat/official-account + middleware: EmployeeJWTAuth +) + +service PowerX { + @doc "查询菜单列表" + @handler GetMediaList + post /medias/page-list (GetOAMediaListRequest) returns (GetOAMediaListReply) + + @doc "查询菜单列表" + @handler GetOAMediaNewsList + get /media/news/list returns (GetOAMediaNewsListReply) + + @doc "请求菜单上传链接" + @handler GetOAMedia + post /medias/:mediaId (GetOAMediaRequest) returns (GetOAMediaReply) + + + @doc "创建菜单" + @handler CreateOAMedia + post /medias (CreateOAMediaRequest) returns (CreateOAMediaReply) + + @doc "删除菜单" + @handler DeleteOAMedia + delete /medias/:mediaId (DeleteOAMediaRequest) returns (DeleteOAMediaReply) +} + + +type ( + GetOAMediaListRequest struct { + Offset int64 `json:"offset,optional"` + Count int64 `json:"count,optional"` + MediaType string `json:"type"` + } + GetOAMediaListReply struct { + TotalCount interface{} `json:"total_count"` + ItemCount interface{} `json:"item_count"` + Item interface{} `json:"item"` + } + + GetOAMediaNewsListReply struct { + NewsItem interface{} `json:"news_item"` + } +) + +type ( + CreateOAMediaRequest struct { + OAMedia interface{} `json:"media"` + } + + CreateOAMediaReply struct { + Success bool `json:"success,optional"` + Data interface{} `json:"data"` + } +) + +type ( + GetOAMediaRequest struct { + MediaId string `path:"mediaId"` + } + + GetOAMediaReply struct { + OAMedia interface{} `json:"media"` + } +) + + +type ( + DeleteOAMediaRequest struct { + MediaId string `path:"mediaId"` + } + + DeleteOAMediaReply struct { + Success bool `json:"success"` + Data interface{} `json:"data"` + } +) \ No newline at end of file diff --git a/internal/handler/admin/wechat/officialaccount/media/createoamediahandler.go b/internal/handler/admin/wechat/officialaccount/media/createoamediahandler.go new file mode 100644 index 00000000..9cb704f5 --- /dev/null +++ b/internal/handler/admin/wechat/officialaccount/media/createoamediahandler.go @@ -0,0 +1,28 @@ +package media + +import ( + "net/http" + + "PowerX/internal/logic/admin/wechat/officialaccount/media" + "PowerX/internal/svc" + "PowerX/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func CreateOAMediaHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateOAMediaRequest + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := media.NewCreateOAMediaLogic(r.Context(), svcCtx) + resp, err := l.CreateOAMedia(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/admin/wechat/officialaccount/media/deleteoamediahandler.go b/internal/handler/admin/wechat/officialaccount/media/deleteoamediahandler.go new file mode 100644 index 00000000..cf0aaab3 --- /dev/null +++ b/internal/handler/admin/wechat/officialaccount/media/deleteoamediahandler.go @@ -0,0 +1,28 @@ +package media + +import ( + "net/http" + + "PowerX/internal/logic/admin/wechat/officialaccount/media" + "PowerX/internal/svc" + "PowerX/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func DeleteOAMediaHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteOAMediaRequest + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := media.NewDeleteOAMediaLogic(r.Context(), svcCtx) + resp, err := l.DeleteOAMedia(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/admin/wechat/officialaccount/media/getmedialisthandler.go b/internal/handler/admin/wechat/officialaccount/media/getmedialisthandler.go new file mode 100644 index 00000000..7abaee2f --- /dev/null +++ b/internal/handler/admin/wechat/officialaccount/media/getmedialisthandler.go @@ -0,0 +1,28 @@ +package media + +import ( + "net/http" + + "PowerX/internal/logic/admin/wechat/officialaccount/media" + "PowerX/internal/svc" + "PowerX/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func GetMediaListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetOAMediaListRequest + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := media.NewGetMediaListLogic(r.Context(), svcCtx) + resp, err := l.GetMediaList(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/admin/wechat/officialaccount/media/getoamediahandler.go b/internal/handler/admin/wechat/officialaccount/media/getoamediahandler.go new file mode 100644 index 00000000..5778b993 --- /dev/null +++ b/internal/handler/admin/wechat/officialaccount/media/getoamediahandler.go @@ -0,0 +1,28 @@ +package media + +import ( + "net/http" + + "PowerX/internal/logic/admin/wechat/officialaccount/media" + "PowerX/internal/svc" + "PowerX/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func GetOAMediaHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetOAMediaRequest + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := media.NewGetOAMediaLogic(r.Context(), svcCtx) + resp, err := l.GetOAMedia(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/admin/wechat/officialaccount/media/getoamedianewslisthandler.go b/internal/handler/admin/wechat/officialaccount/media/getoamedianewslisthandler.go new file mode 100644 index 00000000..ec53828f --- /dev/null +++ b/internal/handler/admin/wechat/officialaccount/media/getoamedianewslisthandler.go @@ -0,0 +1,21 @@ +package media + +import ( + "net/http" + + "PowerX/internal/logic/admin/wechat/officialaccount/media" + "PowerX/internal/svc" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func GetOAMediaNewsListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := media.NewGetOAMediaNewsListLogic(r.Context(), svcCtx) + resp, err := l.GetOAMediaNewsList() + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/routes.go b/internal/handler/routes.go index 31a75d34..2e97b5ca 100644 --- a/internal/handler/routes.go +++ b/internal/handler/routes.go @@ -44,6 +44,7 @@ import ( adminscrmtag "PowerX/internal/handler/admin/scrm/tag" admintag "PowerX/internal/handler/admin/tag" adminuserinfo "PowerX/internal/handler/admin/userinfo" + adminwechatofficialaccountmedia "PowerX/internal/handler/admin/wechat/officialaccount/media" adminwechatofficialaccountmenu "PowerX/internal/handler/admin/wechat/officialaccount/menu" mpcrmcustomerauth "PowerX/internal/handler/mp/crm/customer/auth" mpcrmmarketmedia "PowerX/internal/handler/mp/crm/market/media" @@ -1525,6 +1526,40 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { rest.WithPrefix("/api/v1/admin/wechat/official-account"), ) + server.AddRoutes( + rest.WithMiddlewares( + []rest.Middleware{serverCtx.EmployeeJWTAuth}, + []rest.Route{ + { + Method: http.MethodPost, + Path: "/medias/page-list", + Handler: adminwechatofficialaccountmedia.GetMediaListHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/media/news/list", + Handler: adminwechatofficialaccountmedia.GetOAMediaNewsListHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/medias/:mediaId", + Handler: adminwechatofficialaccountmedia.GetOAMediaHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/medias", + Handler: adminwechatofficialaccountmedia.CreateOAMediaHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/medias/:mediaId", + Handler: adminwechatofficialaccountmedia.DeleteOAMediaHandler(serverCtx), + }, + }..., + ), + rest.WithPrefix("/api/v1/admin/wechat/official-account"), + ) + server.AddRoutes( []rest.Route{ { diff --git a/internal/logic/admin/wechat/officialaccount/media/createoamedialogic.go b/internal/logic/admin/wechat/officialaccount/media/createoamedialogic.go new file mode 100644 index 00000000..493e7b1f --- /dev/null +++ b/internal/logic/admin/wechat/officialaccount/media/createoamedialogic.go @@ -0,0 +1,30 @@ +package media + +import ( + "context" + + "PowerX/internal/svc" + "PowerX/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateOAMediaLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateOAMediaLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateOAMediaLogic { + return &CreateOAMediaLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateOAMediaLogic) CreateOAMedia(req *types.CreateOAMediaRequest) (resp *types.CreateOAMediaReply, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/admin/wechat/officialaccount/media/deleteoamedialogic.go b/internal/logic/admin/wechat/officialaccount/media/deleteoamedialogic.go new file mode 100644 index 00000000..7e817c94 --- /dev/null +++ b/internal/logic/admin/wechat/officialaccount/media/deleteoamedialogic.go @@ -0,0 +1,30 @@ +package media + +import ( + "context" + + "PowerX/internal/svc" + "PowerX/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteOAMediaLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteOAMediaLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteOAMediaLogic { + return &DeleteOAMediaLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteOAMediaLogic) DeleteOAMedia(req *types.DeleteOAMediaRequest) (resp *types.DeleteOAMediaReply, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/admin/wechat/officialaccount/media/getmedialistlogic.go b/internal/logic/admin/wechat/officialaccount/media/getmedialistlogic.go new file mode 100644 index 00000000..6767a68b --- /dev/null +++ b/internal/logic/admin/wechat/officialaccount/media/getmedialistlogic.go @@ -0,0 +1,49 @@ +package media + +import ( + "PowerX/internal/svc" + "PowerX/internal/types" + "PowerX/internal/types/errorx" + "context" + "github.com/ArtisanCloud/PowerWeChat/v3/src/officialAccount/material/request" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetMediaListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetMediaListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMediaListLogic { + return &GetMediaListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetMediaListLogic) GetMediaList(req *types.GetOAMediaListRequest) (resp *types.GetOAMediaListReply, err error) { + + if req.Count <= 0 { + req.Count = 10 + } + res, err := l.svcCtx.PowerX.WechatOA.App.Material.List(l.ctx, &request.RequestMaterialBatchGetMaterial{ + Type: req.MediaType, + Offset: req.Offset, + Count: req.Count, + }) + if err != nil { + return nil, err + } + if res.ErrCode != 0 { + return nil, errorx.WithCause(errorx.ErrNotFoundObject, res.ErrMsg) + } + + return &types.GetOAMediaListReply{ + TotalCount: res.TotalCount, + ItemCount: res.ItemCount, + Item: res.Item, + }, nil +} diff --git a/internal/logic/admin/wechat/officialaccount/media/getoamedialogic.go b/internal/logic/admin/wechat/officialaccount/media/getoamedialogic.go new file mode 100644 index 00000000..c31df024 --- /dev/null +++ b/internal/logic/admin/wechat/officialaccount/media/getoamedialogic.go @@ -0,0 +1,30 @@ +package media + +import ( + "context" + + "PowerX/internal/svc" + "PowerX/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetOAMediaLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetOAMediaLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOAMediaLogic { + return &GetOAMediaLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetOAMediaLogic) GetOAMedia(req *types.GetOAMediaRequest) (resp *types.GetOAMediaReply, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/admin/wechat/officialaccount/media/getoamedianewslistlogic.go b/internal/logic/admin/wechat/officialaccount/media/getoamedianewslistlogic.go new file mode 100644 index 00000000..f7a8a910 --- /dev/null +++ b/internal/logic/admin/wechat/officialaccount/media/getoamedianewslistlogic.go @@ -0,0 +1,30 @@ +package media + +import ( + "context" + + "PowerX/internal/svc" + "PowerX/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetOAMediaNewsListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetOAMediaNewsListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOAMediaNewsListLogic { + return &GetOAMediaNewsListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetOAMediaNewsListLogic) GetOAMediaNewsList() (resp *types.GetOAMediaNewsListReply, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/model/crm/customerdomain/customer.go b/internal/model/crm/customerdomain/customer.go index c54a29ca..1038a12c 100644 --- a/internal/model/crm/customerdomain/customer.go +++ b/internal/model/crm/customerdomain/customer.go @@ -23,6 +23,7 @@ type Customer struct { InviterId int64 `gorm:"comment:邀请方" json:"inviterId"` MgmId int `gorm:"comment:MGM Id" json:"mgmId"` Source int `gorm:"comment:注册来源" json:"source"` + Uuid string `gorm:"comment:识别码;index" json:"uuid"` Type int `gorm:"comment:类型:个人,企业" json:"type"` IsActivated bool `gorm:"comment:激活状态" json:"isActivated"` ExternalId diff --git a/internal/model/crm/market/mgm.go b/internal/model/crm/market/mgm.go index 51eec89e..6832be48 100644 --- a/internal/model/crm/market/mgm.go +++ b/internal/model/crm/market/mgm.go @@ -35,6 +35,14 @@ const ( MGMSceneVIPMemberReward = "_vip_member_reward" // "VIP会员奖励", ) +type CustomerChannel struct { + powermodel.PowerModel + + CustomerID int64 `gorm:"comment:客户ID" json:"customerId"` + ChannelID int `gorm:"comment:渠道ID" json:"channelId"` + Code string `gorm:"comment:渠道码" json:"code"` +} + // InviteRecord 表示会员邀请记录 type InviteRecord struct { powermodel.PowerModel diff --git a/internal/types/types.go b/internal/types/types.go index a3ec1544..d7de0852 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -2902,6 +2902,48 @@ type DeleteMenuReply struct { Data interface{} `json:"data"` } +type GetOAMediaListRequest struct { + Offset int64 `json:"offset,optional"` + Count int64 `json:"count,optional"` + MediaType string `json:"type"` +} + +type GetOAMediaListReply struct { + TotalCount interface{} `json:"total_count"` + ItemCount interface{} `json:"item_count"` + Item interface{} `json:"item"` +} + +type GetOAMediaNewsListReply struct { + NewsItem interface{} `json:"news_item"` +} + +type CreateOAMediaRequest struct { + OAMedia interface{} `json:"media"` +} + +type CreateOAMediaReply struct { + Success bool `json:"success,optional"` + Data interface{} `json:"data"` +} + +type GetOAMediaRequest struct { + MediaId string `path:"mediaId"` +} + +type GetOAMediaReply struct { + OAMedia interface{} `json:"media"` +} + +type DeleteOAMediaRequest struct { + MediaId string `path:"mediaId"` +} + +type DeleteOAMediaReply struct { + Success bool `json:"success"` + Data interface{} `json:"data"` +} + type MPCustomerLoginRequest struct { Code string `json:"code"` }