...
|
...
|
@@ -3,6 +3,7 @@ package chart |
|
|
import (
|
|
|
"context"
|
|
|
"fmt"
|
|
|
"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/contextdata"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/xerr"
|
...
|
...
|
@@ -35,6 +36,7 @@ func (l *DeleteChartLogic) DeleteChart(req *types.ChartDeleteRequest) (resp *typ |
|
|
appPage *domain.AppPage
|
|
|
)
|
|
|
resp = &types.ChartDeleteResponse{}
|
|
|
|
|
|
if chart, err = l.svcCtx.ChartRepository.FindOne(l.ctx, conn, req.Id); err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("不存在", err)
|
|
|
}
|
...
|
...
|
@@ -48,9 +50,23 @@ func (l *DeleteChartLogic) DeleteChart(req *types.ChartDeleteRequest) (resp *typ |
|
|
if appPage.Identify() != nil {
|
|
|
return nil, xerr.NewErrMsgErr(fmt.Sprintf("该图表已被页面\"%v\"引用", appPage.Name), err)
|
|
|
}
|
|
|
|
|
|
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
|
|
|
if chart, err = l.svcCtx.ChartRepository.Delete(l.ctx, conn, chart); err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("删除失败", err)
|
|
|
return xerr.NewErrMsgErr("删除失败", err)
|
|
|
}
|
|
|
//删除数据源
|
|
|
chartSetting, err := l.svcCtx.ChartSettingRepository.FindOne(l.ctx, conn, chart.Id)
|
|
|
if err == nil && len(chartSetting.DataSourceIds) > 0 {
|
|
|
for _, sourceId := range chartSetting.DataSourceIds {
|
|
|
err = DeleteObjectTable(l.ctx, l.svcCtx, conn, int(sourceId))
|
|
|
if err != nil {
|
|
|
return xerr.NewErrMsg("删除失败")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
|
}, true)
|
|
|
|
|
|
resp = &types.ChartDeleteResponse{}
|
|
|
return
|
...
|
...
|
|