delete_app_page_logic.go
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package page
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/xerr"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteAppPageLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewDeleteAppPageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAppPageLogic {
return &DeleteAppPageLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *DeleteAppPageLogic) DeleteAppPage(req *types.AppPageDeleteRequest) (resp *types.AppPageDeleteResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
appPage *domain.AppPage
)
if appPage, err = l.svcCtx.AppPageRepository.FindOne(l.ctx, conn, req.Id); err != nil {
return nil, xerr.NewErr(err)
}
resp = &types.AppPageDeleteResponse{}
if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
if appPage, err = l.svcCtx.AppPageRepository.Delete(l.ctx, conn, appPage); err != nil {
return err
}
return nil
}, true); err != nil {
return nil, xerr.NewErrMsgErr("删除页面失败", err)
}
return
}