Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrCircleQuery = errors.New("circle query with other fields")
)
Functions ¶
func GenModel ¶
func GenModel(table *InnerTable) (string, error)
Types ¶
type InnerField ¶
type InnerField struct {
IsPrimaryKey bool
InnerWithField
DataBaseType string // 数据库中字段类型
Tag string // 标签,格式:`db:"xxx"`
Comment string // 注释,以"// 开头"
Cache bool // 是否缓存模式
QueryType QueryType
WithFields []InnerWithField
Sort []InnerSort
}
type InnerTable ¶
type InnerTable struct {
Case
ContainsCache bool
CreateNotFound bool
PrimaryField *InnerField
Fields []*InnerField
CacheKey map[string]Key // key-数据库字段
}
func TableConvert ¶
func TableConvert(outerTable OuterTable) (*InnerTable, error)
type InnerWithField ¶
type Key ¶
type Key struct {
Define string // cacheKey define,如:cacheUserUserIdPrefix
Value string // cacheKey value expression,如:cache#user#userId#
Expression string // cacheKey expression,如:cacheUserUserIdPrefix="cache#user#userId#"
KeyVariable string // cacheKey 声明变量,如:userIdKey
Key string // 缓存key的代码,如 userIdKey:=fmt.Sprintf("%s%v", cacheUserUserIdPrefix, userId)
DataKey string // 缓存key的代码,如 userIdKey:=fmt.Sprintf("%s%v", cacheUserUserIdPrefix, data.userId)
RespKey string // 缓存key的代码,如 userIdKey:=fmt.Sprintf("%s%v", cacheUserUserIdPrefix, resp.userId)
}
type OuterFiled ¶
type OuterFiled struct {
IsPrimaryKey bool `json:"isPrimaryKey,optional"`
Name string `json:"name"`
DataBaseType string `json:"dataBaseType"`
Comment string `json:"comment"`
Cache bool `json:"cache,optional"`
// if IsPrimaryKey==false下面字段有效
QueryType QueryType `json:"queryType"` // 查找类型
WithFields []OuterWithField `json:"withFields,optional"` // 其他字段联合组成条件的字段列表
OuterSort []OuterSort `json:"sort,optional"`
}
type OuterTable ¶
type OuterTable struct {
Table string `json:"table"`
CreateNotFound bool `json:"createNotFound,optional"`
Fields []*OuterFiled `json:"fields"`
}
type OuterWithField ¶
Click to show internal directories.
Click to hide internal directories.