Skip to content

Commit

Permalink
feat(mgm): api delete put list
Browse files Browse the repository at this point in the history
  • Loading branch information
Matrix-X committed Oct 6, 2023
1 parent a13205c commit 73710b4
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
9 changes: 7 additions & 2 deletions internal/logic/admin/crm/market/mgm/deletemgmrulelogic.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ func NewDeleteMGMRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Del
}

func (l *DeleteMGMRuleLogic) DeleteMGMRule(req *types.DeleteMGMRuleRequest) (resp *types.DeleteMGMRuleReply, err error) {
// todo: add your logic here and delete this line
err = l.svcCtx.PowerX.MGM.DeleteMGMRule(l.ctx, req.MGMRuleId)
if err != nil {
return nil, err
}

return
return &types.DeleteMGMRuleReply{
MGMRuleId: req.MGMRuleId,
}, nil
}
11 changes: 11 additions & 0 deletions internal/logic/admin/crm/market/mgm/getmgmrulelogic.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mgm

import (
"PowerX/internal/model/crm/market"
"context"

"PowerX/internal/svc"
Expand Down Expand Up @@ -28,3 +29,13 @@ func (l *GetMGMRuleLogic) GetMGMRule(req *types.GetMGMRuleRequest) (resp *types.

return
}

func TransformMGMRuleToReply(mdlMGMRule *market.MGMRule) (mediaReply *types.MGMRule) {
return &types.MGMRule{
Id: mdlMGMRule.Id,
CommissionRate1: mdlMGMRule.CommissionRate1,
CommissionRate2: mdlMGMRule.CommissionRate2,
Scene: mdlMGMRule.Scene,
Description: mdlMGMRule.Description,
}
}
31 changes: 29 additions & 2 deletions internal/logic/admin/crm/market/mgm/listmgmrulespagelogic.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package mgm

import (
market2 "PowerX/internal/model/crm/market"
"PowerX/internal/uc/powerx/crm/market"
"context"

"PowerX/internal/svc"
Expand All @@ -24,7 +26,32 @@ func NewListMGMRulesPageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
}

func (l *ListMGMsPageLogic) ListMGMRulesPage(req *types.ListMGMRulesPageRequest) (resp *types.ListMGMRulesPageReply, err error) {
// todo: add your logic here and delete this line
page, err := l.svcCtx.PowerX.MGM.FindManyMGMRules(l.ctx, &market.FindManyMGMRulesOption{
PageEmbedOption: types.PageEmbedOption{
PageIndex: req.PageIndex,
PageSize: req.PageSize,
},
})
if err != nil {
return nil, err
}

// list
list := TransformMGMRulesToReply(page.List)
return &types.ListMGMRulesPageReply{
List: list,
PageIndex: page.PageIndex,
PageSize: page.PageSize,
Total: page.Total,
}, nil
}

func TransformMGMRulesToReply(medias []*market2.MGMRule) (mediasReply []*types.MGMRule) {
mediasReply = []*types.MGMRule{}
for _, media := range medias {
mediaReply := TransformMGMRuleToReply(media)
mediasReply = append(mediasReply, mediaReply)
}
return mediasReply

return
}
13 changes: 11 additions & 2 deletions internal/logic/admin/crm/market/mgm/updatemgmrulelogic.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ func NewUpdateMGMRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upd
}

func (l *UpdateMGMRuleLogic) UpdateMGMRule(req *types.UpdateMGMRuleRequest) (resp *types.UpdateMGMRuleReply, err error) {
// todo: add your logic here and delete this line
mdlMGMRule := TransformRequestToMGMRule(&(req.MGMRule))
mdlMGMRule.Id = req.MGMRuleId

return
// 更新MGM对象
mdlMGMRule, err = l.svcCtx.PowerX.MGM.UpsertMGMRule(l.ctx, mdlMGMRule)
if err != nil {
return nil, err
}

return &types.UpdateMGMRuleReply{
MGMRuleId: mdlMGMRule.Id,
}, nil
}

0 comments on commit 73710b4

Please sign in to comment.