Documentation ¶
Index ¶
- Constants
- Variables
- func AbsoluteURL(u string, baseURL, URL string) (string, error)
- func AppendLine(path string, content string) error
- func CloseDB()
- func Contains(search interface{}, target interface{}) bool
- func ContainsIgnoreCase(search string, target []string) bool
- func Decode62(str string) int64
- func Encode62(number int64) string
- func EncodePassword(rawPassword string) string
- func FormValue(ctx *context.Context, name string) string
- func FormValueBool(ctx *context.Context, name string) (bool, error)
- func FormValueDefault(ctx *context.Context, name, def string) string
- func FormValueInt(ctx *context.Context, name string) (int, error)
- func FormValueInt64(ctx *context.Context, name string) (int64, error)
- func FormValueInt64Array(ctx *context.Context, name string) []int64
- func FormValueInt64Default(ctx *context.Context, name string, def int64) int64
- func FormValueIntDefault(ctx *context.Context, name string, def int) int
- func FormValueRequired(ctx *context.Context, name string) (string, error)
- func FormValueStringArray(ctx *context.Context, name string) []string
- func FormatJson(obj interface{}) (str string, err error)
- func Generate(baseDir, pkgName string, models ...GenerateStruct)
- func GetDB() *gorm.DB
- func GetDay(time time.Time) int
- func GetHtmlText(html string) string
- func GetSummary(s string, length int) string
- func IsEmpty(a interface{}) bool
- func MD5(str string) string
- func MD5Bytes(data []byte) string
- func MapToStruct(obj interface{}, data map[string]interface{}) error
- func NowTimestamp() int64
- func NowUnix() int64
- func OpenDB(conf *DBConfiguration) *gorm.DB
- func ParseJson(str string, t interface{}) error
- func PathExists(path string) (bool, error)
- func PrettyTime(timestamp int64) string
- func RuneLen(s string) int
- func StructFields(s interface{}) []reflect.StructField
- func StructName(s interface{}) string
- func StructToMap(obj interface{}, excludes ...string) map[string]interface{}
- func StructTypeOf(s interface{}) reflect.Type
- func Substr(s string, start, length int) string
- func TimeFormat(time time.Time, layout string) string
- func TimeFromTimestamp(timestamp int64) time.Time
- func TimeFromUnix(unix int64) time.Time
- func TimeParse(timeStr, layout string) (time.Time, error)
- func Timestamp(t time.Time) int64
- func Tx(db *gorm.DB, txFunc func(tx *gorm.DB) error) (err error)
- func ValidatePassword(encodePassword, inputPassword string) bool
- func WithTimeAsStartOfDay(t time.Time) time.Time
- func WriteString(path string, content string, append bool) error
- type CodeError
- type DBConfiguration
- type GenerateField
- type GenerateStruct
- type GormModel
- type InputData
- type JsonResult
- type MdOption
- type MdResult
- type OrderByCol
- type PageResult
- type Paging
- type ParamQueries
- func (o *ParamQueries) Asc(column string) *ParamQueries
- func (o *ParamQueries) Desc(column string) *ParamQueries
- func (o *ParamQueries) Eq(column string, args ...interface{}) *ParamQueries
- func (o *ParamQueries) EqAuto(column string) *ParamQueries
- func (o *ParamQueries) Gt(column string, args ...interface{}) *ParamQueries
- func (o *ParamQueries) GtAuto(column string) *ParamQueries
- func (o *ParamQueries) Gte(column string, args ...interface{}) *ParamQueries
- func (o *ParamQueries) GteAuto(column string) *ParamQueries
- func (o *ParamQueries) Like(column string, str string) *ParamQueries
- func (o *ParamQueries) LikeAuto(column string) *ParamQueries
- func (o *ParamQueries) Limit(limit int) *ParamQueries
- func (o *ParamQueries) Lt(column string, args ...interface{}) *ParamQueries
- func (o *ParamQueries) LtAuto(column string) *ParamQueries
- func (o *ParamQueries) Lte(column string, args ...interface{}) *ParamQueries
- func (o *ParamQueries) LteAuto(column string) *ParamQueries
- func (o *ParamQueries) NotEq(column string, args ...interface{}) *ParamQueries
- func (o *ParamQueries) NotEqAuto(column string) *ParamQueries
- func (o *ParamQueries) OrderBy(column string, asc bool) *ParamQueries
- func (o *ParamQueries) Page(page, limit int) *ParamQueries
- func (o *ParamQueries) PageAuto() *ParamQueries
- func (o *ParamQueries) StartCount(db *gorm.DB) *gorm.DB
- func (o *ParamQueries) StartQuery(db *gorm.DB) *gorm.DB
- func (o *ParamQueries) Where(query string, args ...interface{}) *ParamQueries
- type QueryCnd
- type RspBuilder
- type SimpleMd
Constants ¶
View Source
const ( FMT_DATE_TIME = "2006-01-02 15:04:05" FMT_DATE = "2006-01-02" FMT_TIME = "15:04:05" FMT_DATE_TIME_CN = "2006年01月02日 15时04分05秒" FMT_DATE_CN = "2006年01月02日" FMT_TIME_CN = "15时04分05秒" )
View Source
const CODE62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
View Source
const CodeLength = 62
Variables ¶
View Source
var CodeMap = map[string]int64{"0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, "a": 10,
"b": 11, "c": 12, "d": 13, "e": 14, "f": 15, "g": 16, "h": 17, "i": 18, "j": 19, "k": 20, "l": 21, "m": 22,
"n": 23, "o": 24, "p": 25, "q": 26, "r": 27, "s": 28, "t": 29, "u": 30, "v": 31, "w": 32, "x": 33, "y": 34,
"z": 35, "A": 36, "B": 37, "C": 38, "D": 39, "E": 40, "F": 41, "G": 42, "H": 43, "I": 44, "J": 45, "K": 46,
"L": 47, "M": 48, "N": 49, "O": 50, "P": 51, "Q": 52, "R": 53, "S": 54, "T": 55, "U": 56, "V": 57, "W": 58,
"X": 59, "Y": 60, "Z": 61}
View Source
var (
ErrorNotLogin = NewError(1, "请先登录")
)
Functions ¶
func AbsoluteURL ¶
AbsoluteURL u : /1/2/3 ... baseURL : www.baidu.com Url : www.baidu.com/a/b/c
func AppendLine ¶
func ContainsIgnoreCase ¶
func EncodePassword ¶
func FormValueInt64Default ¶
func FormatJson ¶
func Generate ¶
func Generate(baseDir, pkgName string, models ...GenerateStruct)
func MapToStruct ¶
func PathExists ¶
func PrettyTime ¶
*
- 将时间格式换成 xx秒前,xx分钟前...
- 规则:
- 59秒--->刚刚
- 1-59分钟--->x分钟前(23分钟前)
- 1-24小时--->x小时前(5小时前)
- 昨天--->昨天 hh:mm(昨天 16:15)
- 前天--->前天 hh:mm(前天 16:15)
- 前天以后--->mm-dd(2月18日)
func StructToMap ¶
func StructTypeOf ¶
func ValidatePassword ¶
Types ¶
type CodeError ¶
errorString is a trivial implementation of error.
func NewErrorMsg ¶
type DBConfiguration ¶
type GenerateField ¶
type GenerateField struct { CamelName string NativeField reflect.StructField }
type GenerateStruct ¶
type GenerateStruct struct { Name string Fields []GenerateField }
func GetGenerateStruct ¶
func GetGenerateStruct(s interface{}) GenerateStruct
type InputData ¶
type InputData struct { PkgName string Name string // FuckShit CamelName string // fuckShit KebabName string // FuckShit -> fuck-shit Fields []GenerateField }
type JsonResult ¶
type JsonResult struct { ErrorCode int `json:"errorCode"` Message string `json:"message"` Data interface{} `json:"data"` Success bool `json:"success"` }
func Error ¶
func Error(err *CodeError) *JsonResult
func ErrorCode ¶
func ErrorCode(code int, message string) *JsonResult
func ErrorMsg ¶
func ErrorMsg(message string) *JsonResult
func JsonData ¶
func JsonData(data interface{}) *JsonResult
func Success ¶
func Success() *JsonResult
type PageResult ¶
type PageResult struct { Page *Paging `json:"page"` // 分页信息 Results interface{} `json:"results"` // 数据 }
分页返回数据
type Paging ¶
type Paging struct { Page int `json:"page"` // 页码 Limit int `json:"limit"` // 每页条数 Total int `json:"total"` // 总数据条数 }
分页请求数据
type ParamQueries ¶
type ParamQueries struct { Ctx *context.Context Queries []queryPair // 条件 OrderByCols []OrderByCol // 排序 Paging *Paging // 分页 }
func NewParamQueries ¶
func NewParamQueries(ctx *context.Context) *ParamQueries
func (*ParamQueries) Asc ¶
func (o *ParamQueries) Asc(column string) *ParamQueries
func (*ParamQueries) Desc ¶
func (o *ParamQueries) Desc(column string) *ParamQueries
func (*ParamQueries) Eq ¶
func (o *ParamQueries) Eq(column string, args ...interface{}) *ParamQueries
func (*ParamQueries) EqAuto ¶
func (o *ParamQueries) EqAuto(column string) *ParamQueries
func (*ParamQueries) Gt ¶
func (o *ParamQueries) Gt(column string, args ...interface{}) *ParamQueries
func (*ParamQueries) GtAuto ¶
func (o *ParamQueries) GtAuto(column string) *ParamQueries
func (*ParamQueries) Gte ¶
func (o *ParamQueries) Gte(column string, args ...interface{}) *ParamQueries
func (*ParamQueries) GteAuto ¶
func (o *ParamQueries) GteAuto(column string) *ParamQueries
func (*ParamQueries) Like ¶
func (o *ParamQueries) Like(column string, str string) *ParamQueries
func (*ParamQueries) LikeAuto ¶
func (o *ParamQueries) LikeAuto(column string) *ParamQueries
func (*ParamQueries) Limit ¶
func (o *ParamQueries) Limit(limit int) *ParamQueries
func (*ParamQueries) Lt ¶
func (o *ParamQueries) Lt(column string, args ...interface{}) *ParamQueries
func (*ParamQueries) LtAuto ¶
func (o *ParamQueries) LtAuto(column string) *ParamQueries
func (*ParamQueries) Lte ¶
func (o *ParamQueries) Lte(column string, args ...interface{}) *ParamQueries
func (*ParamQueries) LteAuto ¶
func (o *ParamQueries) LteAuto(column string) *ParamQueries
func (*ParamQueries) NotEq ¶
func (o *ParamQueries) NotEq(column string, args ...interface{}) *ParamQueries
func (*ParamQueries) NotEqAuto ¶
func (o *ParamQueries) NotEqAuto(column string) *ParamQueries
func (*ParamQueries) OrderBy ¶
func (o *ParamQueries) OrderBy(column string, asc bool) *ParamQueries
func (*ParamQueries) Page ¶
func (o *ParamQueries) Page(page, limit int) *ParamQueries
func (*ParamQueries) PageAuto ¶
func (o *ParamQueries) PageAuto() *ParamQueries
func (*ParamQueries) StartCount ¶
func (o *ParamQueries) StartCount(db *gorm.DB) *gorm.DB
func (*ParamQueries) StartQuery ¶
func (o *ParamQueries) StartQuery(db *gorm.DB) *gorm.DB
func (*ParamQueries) Where ¶
func (o *ParamQueries) Where(query string, args ...interface{}) *ParamQueries
type QueryCnd ¶
func NewQueryCnd ¶
type RspBuilder ¶
type RspBuilder struct {
Data map[string]interface{}
}
func NewEmptyRspBuilder ¶
func NewEmptyRspBuilder() *RspBuilder
func NewRspBuilder ¶
func NewRspBuilder(obj interface{}) *RspBuilder
func NewRspBuilderExcludes ¶
func NewRspBuilderExcludes(obj interface{}, excludes ...string) *RspBuilder
func (*RspBuilder) Build ¶
func (this *RspBuilder) Build() map[string]interface{}
func (*RspBuilder) JsonResult ¶
func (this *RspBuilder) JsonResult() *JsonResult
func (*RspBuilder) Put ¶
func (this *RspBuilder) Put(key string, value interface{}) *RspBuilder
Source Files ¶
Click to show internal directories.
Click to hide internal directories.