fix(节点模型): 修正标签查询字段名从'tag'到'tags'
Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 22s
Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 22s
修复在CountNodesByIdsAndTags方法中标签查询字段名错误的问题,将'tag'改为'tags'以匹配实际数据库字段
This commit is contained in:
parent
f4ecf912e0
commit
7731384ccb
@ -202,17 +202,19 @@ func (m *customServerModel) CountNodesByIdsAndTags(ctx context.Context, nodeIds
|
|||||||
|
|
||||||
if len(nodeIds) > 0 && len(tags) > 0 {
|
if len(nodeIds) > 0 && len(tags) > 0 {
|
||||||
// 节点ID和标签都存在时,使用OR条件
|
// 节点ID和标签都存在时,使用OR条件
|
||||||
subQuery = subQuery.Where("id IN ? OR ?", nodeIds, InSet("tag", tags))
|
subQuery = subQuery.Where("id IN ? OR ?", nodeIds, InSet("tags", tags))
|
||||||
} else if len(nodeIds) > 0 {
|
} else if len(nodeIds) > 0 {
|
||||||
// 只有节点ID
|
// 只有节点ID
|
||||||
subQuery = subQuery.Where("id IN ?", nodeIds)
|
subQuery = subQuery.Where("id IN ?", nodeIds)
|
||||||
} else {
|
} else {
|
||||||
// 只有标签
|
// 只有标签
|
||||||
subQuery = subQuery.Scopes(InSet("tag", tags))
|
subQuery = subQuery.Scopes(InSet("tags", tags))
|
||||||
}
|
}
|
||||||
|
|
||||||
query = subQuery
|
query = subQuery
|
||||||
}
|
}
|
||||||
|
// 打印sql
|
||||||
|
fmt.Println(query.ToSQL(func(tx *gorm.DB) *gorm.DB { return tx }))
|
||||||
|
|
||||||
err := query.Count(&count).Error
|
err := query.Count(&count).Error
|
||||||
return count, err
|
return count, err
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user