helpers

package
v0.0.0-...-b3d6e89 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2020 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Between

func Between(lang string, number string) string

func Bool

func Bool(lang string) string

func CheckFile

func CheckFile(r *http.Request) *govalidator.Validator

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

* * check if password is valid

func ClearText

func ClearText(text string) string

** * trim text

func ConvertImageToBase

func ConvertImageToBase(g *gin.Context, filepath string) (bool, string)

* * convert image to to base 64

func DbTruncate

func DbTruncate(tableName ...string)

** * truncate tables

func DecodeAndReturn

func DecodeAndReturn(req *http.Request, structBind interface{}) (interface{}, error)

* * decode body then return interface

func DecodeImage

func DecodeImage(g *gin.Context, filename string) (bool, string)

* * Decode Image and save it on path

func Digits

func Digits(lang string) string

func DoneActivate

func DoneActivate(g *gin.Context) string

func DoneActivationPack

func DoneActivationPack(g *gin.Context, activateCount int, deactivateCount int) string

func DoneCreateItem

func DoneCreateItem(g *gin.Context) string

func DoneDeactivate

func DoneDeactivate(g *gin.Context) string

func DoneDelete

func DoneDelete(g *gin.Context) string

func DoneGetAllItems

func DoneGetAllItems(g *gin.Context) string

func DoneGetItem

func DoneGetItem(g *gin.Context) string

func DoneTrash

func DoneTrash(g *gin.Context) string

func DoneUpdate

func DoneUpdate(g *gin.Context) string

func Email

func Email(lang string) string

func Ext

func Ext(lang string, extentions string) string

func GenerateToken

func GenerateToken(stringToHash string) (string, error)

* * generate token based on user data

func GetCurrentLang

func GetCurrentLang(g *gin.Context) string

func GetCurrentLangFromHttp

func GetCurrentLangFromHttp(r *http.Request) string

func HashPassword

func HashPassword(password string) (string, error)

* * hash passwords

func In

func In(lang string, ableStrings ...string) string

func IntSlice

func IntSlice(lang string) string

func ItemNotFound

func ItemNotFound(g *gin.Context) string

func LangHeader

func LangHeader(g *gin.Context) string

* * get lang header

func Limit

func Limit(g *gin.Context) int

func Max

func Max(lang string, number string) string

func Mime

func Mime(lang string, extentions string) string

func Min

func Min(lang string, number string) string

func MultiDecodeImage

func MultiDecodeImage(g *gin.Context, images []string) []string

func MultiUploadError

func MultiUploadError(g *gin.Context)

* * multi upload error

func NotValidExt

func NotValidExt(lang string) string

func Numeric

func Numeric(lang string) string

func OkResponse

func OkResponse(g *gin.Context, msg string, data interface{})

* * ok response with data

func OkResponseWithOutData

func OkResponseWithOutData(g *gin.Context, msg string)

* * ok response without data

func OkResponseWithPaging

func OkResponseWithPaging(g *gin.Context, msg string, data *Paginator)

* * ok with paging

func Order

func Order(g *gin.Context, order ...string) []string

func Page

func Page(g *gin.Context) int

func PreloadD

func PreloadD(db *gorm.DB, preload []string) *gorm.DB

* * add preload dynamic * this will allow to add more than one preload

func RandomString

func RandomString(n int) string

* * generate random string

func ReadAllFiles

func ReadAllFiles(root string) []string

* * return with []strings that contains * files names inside path what you set

func Required

func Required(lang string) string

func ReturnBadRequest

func ReturnBadRequest(g *gin.Context)

* * conflict

func ReturnDuplicateData

func ReturnDuplicateData(g *gin.Context, inputName string)

* * Duplicate data

func ReturnForbidden

func ReturnForbidden(g *gin.Context, msg string)

* * Forbidden response

func ReturnNotFound

func ReturnNotFound(g *gin.Context, msg string)

* * NotFound response

func ReturnNotValidFile

func ReturnNotValidFile(err error, g *gin.Context)

* * NotValidRequest file

func ReturnNotValidRequest

func ReturnNotValidRequest(error *govalidator.Validator, g *gin.Context) bool

* * NotValidRequest response

func ReturnNotValidRequestFile

func ReturnNotValidRequestFile(error *govalidator.Validator, g *gin.Context) bool

* * NotValidFile response

func ReturnNotValidRequestFormData

func ReturnNotValidRequestFormData(error *govalidator.Validator, g *gin.Context) bool

* * NotValidRequest response

func ReturnResponseWithMessageAndStatus

func ReturnResponseWithMessageAndStatus(g *gin.Context, statusHttp int, message string, status bool)

* * global response

func ReturnYouAreNotAuthorize

func ReturnYouAreNotAuthorize(g *gin.Context)

* * Not Authorize

func SendMail

func SendMail(email string, subject string, content string)

* * function to send email with subject and content

func Size

func Size(lang string, size string) string

func StringsSlice

func StringsSlice(lang string) string

func T

func T(g *gin.Context, key ...string) string

func ToSnakeCase

func ToSnakeCase(str string) string

func Unique

func Unique(lang string, key ...string) string

func UpdateOnlyAllowColumns

func UpdateOnlyAllowColumns(structNeedToMap interface{}, fillAble []string) interface{}

* * this function get struct and return with only * Available column that allow to updated depend on FillAbleColumn function * this for security * map struct to update

func UploadError

func UploadError(g *gin.Context)

* * upload error

func UploadImage

func UploadImage(g *gin.Context, fileString string) (bool, string)

** * upload file with input name * if there are resize width height * it will resize image with this sizes

func UploadImages

func UploadImages(g *gin.Context, fileString string) (bool, []string)

** * upload file with input name * if there are resize width height * it will resize image with this sizes

func Url

func Url(lang string) string

func ValidCsvFile

func ValidCsvFile(g *gin.Context) string

func Wrong

func Wrong(g *gin.Context) string

Types

type Paginator

type Paginator struct {
	TotalRecord int         `json:"total_record"`
	TotalPage   int         `json:"total_page"`
	Records     interface{} `json:"records"`
	Offset      int         `json:"offset"`
	Limit       int         `json:"limit"`
	Page        int         `json:"page"`
	PrevPage    int         `json:"prev_page"`
	NextPage    int         `json:"next_page"`
}

Paginator 分页返回

func Paging

func Paging(p *Param, result interface{}) *Paginator

Paging 分页

type Param

type Param struct {
	DB      *gorm.DB
	Page    int
	Limit   int
	OrderBy []string
	Filters []string
	Preload []string
	ShowSQL bool
}

Param 分页参数

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL