Ai
1 Star 0 Fork 0

rio/mouse-core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
srv.go 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
duanbin 提交于 2021-09-03 15:46 +08:00 . update time condition ...
package core
import (
"gitee.com/rio-studio/mouse-core/util"
"strings"
)
type Service struct{}
func (p *Service) ParseSort(sort string) string {
var order string
if sort != "" {
var sortType string
var sortField string
if strings.HasPrefix(sort, "+") {
sortType = "ASC"
sortField = strings.Replace(sort, "+", "", 1)
} else if strings.HasPrefix(sort, "-") {
sortType = "DESC"
sortField = strings.Replace(sort, "-", "", 1)
} else {
sortType = "DESC"
sortField = "id"
}
order = "`" + sortField + "` " + sortType
}
return order
}
func (p *Service) ParseSearchText(searchText string, fields *[]string, whereAnd map[string]interface{}, isOr bool) map[string]interface{} {
link := " And "
if isOr {
link = " OR "
}
if searchText != "" {
var arr []string
var str string
for _, field := range *fields {
str += " " + field + " LIKE ? " + link
arr = append(arr, "%"+searchText+"%")
}
whereAnd[str[:(len(str)-len(link))]] = arr
}
return whereAnd
}
func (p *Service) ParseDateTime(startTime, endTime int, timeField string, whereAnd map[string]interface{}) map[string]interface{} {
timeCondition := &util.TimeCondition{}
timeCondition.StartTime = startTime
timeCondition.EndTime = endTime
return util.ParseStrTimeCondition(timeCondition, timeField, whereAnd)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rio-studio/mouse-core.git
git@gitee.com:rio-studio/mouse-core.git
rio-studio
mouse-core
mouse-core
v0.0.11

搜索帮助