字段中的blob和JSON类型映射为[]byte和dbs.JSON

This commit is contained in:
GoEdgeLab
2022-03-21 21:39:36 +08:00
parent a2cf2e5b03
commit 31599bee13
105 changed files with 1537 additions and 1156 deletions

View File

@@ -5,10 +5,10 @@ import (
"sync"
)
// 缓存专用Locker
// SharedCacheLocker 缓存专用Locker
var SharedCacheLocker = sync.RWMutex{}
// 处理JSON字节Slice
// JSONBytes 处理JSON字节Slice
func JSONBytes(data []byte) []byte {
if len(data) == 0 {
return []byte("null")
@@ -16,12 +16,18 @@ func JSONBytes(data []byte) []byte {
return data
}
// 判断JSON是否不为空
func IsNotNull(data string) bool {
return len(data) > 0 && data != "null"
// IsNotNull 判断JSON是否不为空
func IsNotNull(data []byte) bool {
if len(data) == 0 {
return false
}
if len(data) == 4 && string(data) == "null" {
return false
}
return true
}
// 构造Query
// NewQuery 构造Query
func NewQuery(tx *dbs.Tx, dao dbs.DAOWrapper, adminId int64, userId int64) *dbs.Query {
query := dao.Object().Query(tx)
if adminId > 0 {