This commit is contained in:
Daniel 2023-08-15 16:32:13 +08:00
parent a169b3913a
commit 4b96ead36a
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 15 additions and 4 deletions

View file

@ -77,7 +77,7 @@ func GetAssetContent(id, query string, queryMethod int) (ret *AssetContent) {
// FullTextSearchAssetContent 搜索资源文件内容。
//
// method0关键字1查询语法2SQL3正则表达式
// orderBy: 0相关度默认1按更新时间升序2:按更新时间降序
// orderBy: 0按相关度降序1按相关度升序2按更新时间升序3:按更新时间降序
func FullTextSearchAssetContent(query string, types map[string]bool, method, orderBy, page, pageSize int) (ret []*AssetContent, matchedAssetCount, pageCount int) {
query = strings.TrimSpace(query)
beforeLen := 36
@ -238,11 +238,20 @@ func buildAssetContentTypeFilter(types map[string]bool) string {
var buf bytes.Buffer
buf.WriteString("(")
for k, _ := range types {
for k, enabled := range types {
if !enabled {
continue
}
buf.WriteString("'")
buf.WriteString(k)
buf.WriteString("',")
}
if 1 == buf.Len() {
buf.WriteString(")")
return buf.String()
}
buf.Truncate(buf.Len() - 1)
buf.WriteString(")")
return buf.String()
@ -253,8 +262,10 @@ func buildAssetContentOrderBy(orderBy int) string {
case 0:
return "ORDER BY rank DESC"
case 1:
return "ORDER BY updated ASC"
return "ORDER BY rank ASC"
case 2:
return "ORDER BY updated ASC"
case 3:
return "ORDER BY updated DESC"
default:
return "ORDER BY rank DESC"