mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-03 16:00:25 +08:00
feat: 标签路径展示优化,新增提示
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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+"%")
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user