feat: 标签路径展示优化,新增提示

This commit is contained in:
meilin.huang
2023-02-14 18:24:39 +08:00
parent 11eebdfcf0
commit 8c501c90cd
13 changed files with 174 additions and 47 deletions

View File

@@ -7,6 +7,7 @@ import (
"mayfly-go/internal/tag/domain/entity"
"mayfly-go/pkg/ginx"
"mayfly-go/pkg/req"
"strings"
)
type TagTree struct {
@@ -31,6 +32,15 @@ func (p *TagTree) GetTagTree(rc *req.Ctx) {
rc.ResData = tagTrees.ToTrees(0)
}
func (p *TagTree) ListByQuery(rc *req.Ctx) {
cond := new(entity.TagTreeQuery)
tagPaths := rc.GinCtx.Query("tagPaths")
cond.CodePaths = strings.Split(tagPaths, ",")
var tagTrees vo.TagTreeVOS
p.TagTreeApp.ListByQuery(cond, &tagTrees)
rc.ResData = tagTrees
}
func (p *TagTree) SaveTagTree(rc *req.Ctx) {
projectTree := &entity.TagTree{}
ginx.BindJsonAndValid(rc.GinCtx, projectTree)

View File

@@ -5,11 +5,11 @@ import "mayfly-go/pkg/model"
type TagTreeQuery struct {
model.Model
Pid uint64
Code string `json:"code"` // 标识
CodePath string `json:"codePath"` // 标识路径
Name string `json:"name"` // 名称
Pid uint64
Code string `json:"code"` // 标识
CodePath string `json:"codePath"` // 标识路径
CodePaths []string
Name string `json:"name"` // 名称
CodePathLike string // 标识符路径模糊查询
CodePathLikes []string
}

View File

@@ -6,6 +6,7 @@ import (
"mayfly-go/internal/tag/domain/repository"
"mayfly-go/pkg/biz"
"mayfly-go/pkg/model"
"strings"
)
type tagTreeRepoImpl struct{}
@@ -22,6 +23,14 @@ func (p *tagTreeRepoImpl) SelectByCondition(condition *entity.TagTreeQuery, toEn
if condition.CodePath != "" {
sql = fmt.Sprintf("%s AND p.code_path = '%s'", sql, condition.CodePath)
}
if len(condition.CodePaths) > 0 {
strCodePaths := make([]string, 0)
// 将字符串用''包裹
for _, v := range condition.CodePaths {
strCodePaths = append(strCodePaths, fmt.Sprintf("'%s'", v))
}
sql = fmt.Sprintf("%s AND p.code_path IN (%s)", sql, strings.Join(strCodePaths, ","))
}
if condition.CodePathLike != "" {
sql = fmt.Sprintf("%s AND p.code_path LIKE '%s'", sql, condition.CodePathLike+"%")
}

View File

@@ -20,6 +20,11 @@ func InitTagTreeRouter(router *gin.RouterGroup) {
req.NewCtxWithGin(c).Handle(m.GetTagTree)
})
// 根据条件获取标签
project.GET("query", func(c *gin.Context) {
req.NewCtxWithGin(c).Handle(m.ListByQuery)
})
// 获取登录账号拥有的标签信息
project.GET("account-has", func(c *gin.Context) {
req.NewCtxWithGin(c).Handle(m.GetAccountTags)