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