Documentation ¶
Index ¶
- func BindJSONIntoMap(context *gin.Context, obj map[string]interface{}) error
- func CheckPathAndCreate(path string) error
- func GetFileExt(file *multipart.FileHeader) string
- func GetFileMimeTypeByExt(ext string) string
- func GetFileType(mimeType string) string
- func GetFormatDeletedAtTime(d *gorm.DeletedAt, layout string) string
- func GetFormatNullTime(t *sql.NullTime, layout string) string
- func GetFormatTime(t *time.Time, layout string) string
- func GetReqID(c *gin.Context) string
- func JSON2Map(j []byte, m *map[string]interface{}) error
- func Map2JSON(m interface{}) ([]byte, error)
- func PathExists(path string) (bool, error)
- func SliceDiff(slice1, slice2 []interface{}) (diffslice []interface{})
- func SliceDiffUint64(slice1, slice2 []uint64) (diffslice []uint64)
- func SliceHas(v interface{}, sl []interface{}) bool
- func SliceIntersect(slice1, slice2 []interface{}) (diffslice []interface{})
- func SliceMerge(slice1, slice2 []interface{}) (c []interface{})
- func StringToNullTime(layout string, timeString string) sql.NullTime
- func StringToTime(layout string, timeString string) time.Time
- func SubNullTimeUnitlNowAsDay(t time.Time) float64
- type Page
- type Pagination
- type StrTo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindJSONIntoMap ¶
BindJSONIntoMap decodes json body to map, skips fields which are not in allowedFields Example usage: u.Params = make(map[string]interface{}) err := utils.BindJSONIntoMap(c, u.Params)
func CheckPathAndCreate ¶
CheckPathAndCreate check path if exist, fi not exist, make the path dir
func GetFileExt ¶
func GetFileExt(file *multipart.FileHeader) string
GetFileExt returns the file name extension The extension is the suffix beginning at the final dot
func GetFileMimeTypeByExt ¶
GetFileMimeTypeByExt returns the file mine-type by ext
func GetFileType ¶
GetFileType returns file type in word that defined
func GetFormatDeletedAtTime ¶
GetFormatDeletedAtTime get format time from grom(v2) DeletedAt
func GetFormatNullTime ¶
GetFormatNullTime get format time which could be NULL it returns empty string if the time is NULL
func GetFormatTime ¶
GetFormatTime get format time include nil value
func SliceDiff ¶
func SliceDiff(slice1, slice2 []interface{}) (diffslice []interface{})
SliceDiff returns diff slice of slice1 - slice2.
func SliceDiffUint64 ¶
SliceDiffUint64 returns diff slice of slice1 - slice2. for uint64
func SliceHas ¶
func SliceHas(v interface{}, sl []interface{}) bool
SliceHas checks given interface if in the interface slice.
func SliceIntersect ¶
func SliceIntersect(slice1, slice2 []interface{}) (diffslice []interface{})
SliceIntersect returns the intersection of slice1 and slice2.
func SliceMerge ¶
func SliceMerge(slice1, slice2 []interface{}) (c []interface{})
SliceMerge merges interface slices to one slice.
func StringToNullTime ¶
StringToNullTime changesfer a time string to mysql.NullTime
func StringToTime ¶
StringToTime changesfer a time string to time.Time
func SubNullTimeUnitlNowAsDay ¶
SubNullTimeUnitlNowAsDay calculate the diff day until now
Types ¶
type Page ¶
type Page struct { ShowSize int `json:"showSize"` PageSize int `json:"pageSize"` CurrentPage int `json:"currentPage"` TotalPage int `json:"totalPage"` TotalRecord int `json:"totalRecord"` NextPageNum int `json:"nextPageNum"` PreviousPageNum int `json:"previousPageNum"` FirstPageNum int `josn:"firstPageNum"` LastPageNum int `json:"lastPageNum"` PageNums []int `json:"pageNums"` }
Page pagination
type Pagination ¶
Pagination include page and page url
func GetPagination ¶
func GetPagination(totalRecord, currentPage, pageSizeIn, showSizeIn int) *Pagination
GetPagination return pagiantion and default page pre url
func (*Pagination) SetPageURL ¶
func (p *Pagination) SetPageURL(url string)
SetPageURL set page url, default is empty string
type StrTo ¶
type StrTo string
func (StrTo) MustUInt32 ¶
MustUInt32 convert string to uint32 without error
func (StrTo) MustUInt64 ¶
MustUInt32 convert string to uint32 without error