代码重构-基于gin,gorm

This commit is contained in:
meilin.huang
2021-04-16 15:10:07 +08:00
parent a1141a405a
commit ec1001d88b
84 changed files with 1445 additions and 1424 deletions

View File

@@ -21,3 +21,24 @@ func GetInt4Map(m map[string]interface{}, key string) int {
}
return 0
}
// map构造器
type mapBuilder struct {
m map[string]interface{}
}
func MapBuilder(key string, value interface{}) *mapBuilder {
mb := new(mapBuilder)
mb.m = make(map[string]interface{}, 4)
mb.m[key] = value
return mb
}
func (mb *mapBuilder) Put(key string, value interface{}) *mapBuilder {
mb.m[key] = value
return mb
}
func (mb *mapBuilder) ToMap() map[string]interface{} {
return mb.m
}