|
@@ -2,9 +2,11 @@ package tags |
|
@@ -2,9 +2,11 @@ package tags |
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
4
|
"context"
|
4
|
"context"
|
|
|
5
|
+ "fmt"
|
5
|
|
6
|
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
|
|
|
9
|
+ "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
|
8
|
|
10
|
|
9
|
"github.com/zeromicro/go-zero/core/logx"
|
11
|
"github.com/zeromicro/go-zero/core/logx"
|
10
|
)
|
12
|
)
|
|
@@ -25,6 +27,18 @@ func NewCreateTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateT |
|
@@ -25,6 +27,18 @@ func NewCreateTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateT |
25
|
|
27
|
|
26
|
func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.TagCreateResponse, err error) {
|
28
|
func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.TagCreateResponse, err error) {
|
27
|
// todo: add your logic here and delete this line
|
29
|
// todo: add your logic here and delete this line
|
28
|
-
|
30
|
+ var conn = l.svcCtx.DefaultDBConn()
|
|
|
31
|
+ //检查重复
|
|
|
32
|
+ cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, map[string]interface{}{
|
|
|
33
|
+ "name": req.Name,
|
|
|
34
|
+ "group": req.Group,
|
|
|
35
|
+ "countOnly": true,
|
|
|
36
|
+ })
|
|
|
37
|
+ if err != nil {
|
|
|
38
|
+ return nil, xerr.NewErrMsgErr("添加标签失败", err)
|
|
|
39
|
+ }
|
|
|
40
|
+ if cnt > 0 {
|
|
|
41
|
+ return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Group, req.Name))
|
|
|
42
|
+ }
|
29
|
return
|
43
|
return
|
30
|
} |
44
|
} |