Skip to content

Commit 1fb2905

Browse files
committed
refactor: 删除分类重构
1 parent 5e1d69d commit 1fb2905

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

internal/logic/article_grp/article_grp.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55

66
"github.com/oldme-git/oldme-api/internal/dao"
7+
"github.com/oldme-git/oldme-api/internal/logic/article"
78
"github.com/oldme-git/oldme-api/internal/model"
89
"github.com/oldme-git/oldme-api/internal/model/do"
910
"github.com/oldme-git/oldme-api/internal/model/entity"
@@ -43,16 +44,15 @@ func Upd(ctx context.Context, id model.Id, in *model.ArticleGrpInput) (err error
4344
// Del 删除文章分类
4445
func Del(ctx context.Context, id model.Id) (err error) {
4546
_, err = dao.ArticleGrp.Ctx(ctx).Where("id", id).Delete()
46-
// TODO 逻辑重新处理
4747
// 软删除掉该分类下的文章
48-
// var list []model.ArticleList
49-
// res, err := dao.Article.Ctx(ctx).Where("grp_id", id).All()
50-
// _ = res.Structs(&list)
51-
//
52-
//
53-
// for _, v := range list {
54-
// _ = article.Del(ctx, model.Id(v.Id), false)
55-
// }
48+
data, err := dao.Article.Ctx(ctx).Fields("id").Where("grp_id", id).All()
49+
if err != nil {
50+
return utility.Err.Sys(err)
51+
}
52+
53+
for _, v := range data {
54+
_ = article.Del(ctx, model.Id(v["id"].Uint()), false)
55+
}
5656
return
5757
}
5858

0 commit comments

Comments
 (0)