common

package
v0.0.0-...-ad2cf94 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Addslashes

func Addslashes(str string) string

Addslashes 函数返回在预定义字符之前添加反斜杠的字符串。 预定义字符是: 单引号(') 双引号(") 反斜杠(\)

func ClientIP

func ClientIP(request *http.Request) string

ClientIP 得到客户端IP地址

func ConvertCookie

func ConvertCookie(admUser *models.Member) *viewsmodels.MemberCookie

ConvertCookie 转换

func ConvertSession

func ConvertSession(admUser *models.Admin) *viewsmodels.AdminSession

ConvertSession 转换

func CreateSign

func CreateSign(str string) string

CreateSign 对字符串进行签名

func FormatFromUnixTime

func FormatFromUnixTime(t int64) string

FormatFromUnixTime 将unix时间戳格式化为yyyymmdd H:i:s格式字符串

func FormatFromUnixTimeShort

func FormatFromUnixTimeShort(t int64) string

FormatFromUnixTimeShort 将unix时间戳格式化为yyyymmdd格式字符串

func GetInt64

func GetInt64(i interface{}, d int64) int64

从接口类型安全获取到int64

func GetInt64FromMap

func GetInt64FromMap(dm map[string]interface{}, key string, dft int64) int64

从map中得到指定的key

func GetInt64FromStringMap

func GetInt64FromStringMap(dm map[string]string, key string, dft int64) int64

从map中得到指定的key

func GetLoginUser

func GetLoginUser(request *http.Request) *viewsmodels.MemberCookie

GetLoginUser 从cookie中得到当前登录的用户

func GetString

func GetString(str interface{}, d string) string

从接口类型安全获取到字符串类型

func GetStringFromMap

func GetStringFromMap(dm map[string]interface{}, key string, dft string) string

从map中得到指定的key

func GetStringFromStringMap

func GetStringFromStringMap(dm map[string]string, key string, dft string) string

从map中得到指定的key

func H

func H(po *PageOptions) string

最后 组装分页标签

func Ip4toInt

func Ip4toInt(ip string) int64

将字符串的IP转化为数字

func IsDir

func IsDir(path string) bool

IsDir 判断所给路径是否为文件夹 tf = isdir('A') 如果A是一个文件夹,返回逻辑1(true),否则返回0(false)

func LoginSessionGet

func LoginSessionGet(c iris.Context, sessionname string) (bool, *viewsmodels.AdminSession, error)

LoginSessionGet 获取

func LoginSessionSet

func LoginSessionSet(c iris.Context, sessionname string, sessionvalue *viewsmodels.AdminSession)

LoginSessionSet 用户登录 session 填充

func Mobile

func Mobile(r *http.Request) bool

func MuBanLayout

func MuBanLayout(r *http.Request, cookieMobile string, indexOrAdmin string, pathModel string) string

func MuBanPath

func MuBanPath(r *http.Request, cookieMobile string, indexOrAdmin string, pathModel string, page string) string

func MuBanPaths

func MuBanPaths(r *http.Request, cookieMobile string, indexOrAdmin string, pathModel string, page string) (pages string, layout string)

func NextDayDuration

func NextDayDuration() time.Duration

得到当前时间到下一天零点的延时

func NowUnix

func NowUnix() int

NowUnix 当前时间的时间戳

func ParseTime

func ParseTime(str string) (time.Time, error)

ParseTime 将字符串转成时间

func PasswordSalt

func PasswordSalt(pass, salt string) string

加密密码

func PasswordVerify

func PasswordVerify(password, pass, salt string) bool

验证

func PathExists

func PathExists(path string) bool

PathExists 判断文件或文件夹是否存在 存在为true

如果返回的错误为nil,说明文件或文件夹存在
如果返回的错误类型使用os.IsNotExist()判断为true,说明文件或文件夹不存在
                 使用os.IsExist()判断为true,说明文件或文件夹存在
如果返回的错误为其它类型,则不确定是否在存在

func QQLevePic

func QQLevePic(leve *QQSeveralPic) string

func RandErPaths

func RandErPaths() string

func Random

func Random(max int) int

Random 得到一个随机数

func Redirect

func Redirect(writer http.ResponseWriter, url string)

Redirect 跳转URL

func SessionDel

func SessionDel(c iris.Context, sessionname string)

SessionDel 删除

func SetLoginuser

func SetLoginuser(writer http.ResponseWriter, loginuser *viewsmodels.MemberCookie)

SetLoginuser 将登录的用户信息设置到cookie中

func Stripslashes

func Stripslashes(str string) string

stripslashes() 函数删除由 addslashes() 函数添加的反斜杠。

func ViewsPathCookie

func ViewsPathCookie(r *http.Request, cookieMobile string, indexOrAdmin string, pathModel string) string

http.Request cookie设备信息 前台或者后台 模块路径

func YYLevePic

func YYLevePic(leve *YYSeveralPic) string

Types

type Error

type Error struct {
	Msg string
}

错误基类

func NewError

func NewError(msg string) *Error

func (*Error) Error

func (e *Error) Error() string

type PageOptions

type PageOptions struct {
	FirstPageText string //首页文字  默认"首页"
	LastPageText  string //尾页文字  默认"尾页"

	PrePageText  string //上一页文字 默认"上一页"
	NextPageText string //下一页文字 默认"下一页"
	Currentpage  int64  //当前页 ,默认1 每次分页,必须在前台设置新的页数,不设置始终默认1.在控制器中使用方式:cp, _ := this.GetInt("pno")   po.Currentpage = int(cp)

	LinkItemCount int64  //生成A标签的个数 默认10个
	PageSize      int64  //页面大小,默认20
	TotalPage     int64  //总页码
	ParamName     string //参数名称  默认是page

	Href string //A标签的链接地址  ---------[不需要设置]

	EnableFirstLastLink bool //是否启用首尾连接 默认false 建议开启
	EnablePreNexLink    bool //是否启用上一页,下一页连接 默认false 建议开启
}

分页标签信息

func DealUri

func DealUri(po *PageOptions, uri string) *PageOptions

*

  • 处理url,目的是保存参数
  • ParamName string //参数名称 默认是pno

第二步 处理 PageOptions.Href A标签的链接地址

func GetPages

func GetPages(sqlwhere *SqlWhere, totalCount int64) (po *PageOptions)

第一步 传入总条数 totalCount 返回分页标签信息 *PageOptions

func SetDefault

func SetDefault(po *PageOptions) *PageOptions

设置默认值

type QQSeveralPic

type QQSeveralPic struct {
	Huangguan int64
	Sun       int64
	Moon      int64
	Star      int64
}

func QQLeveToSeveral

func QQLeveToSeveral(leve int64) *QQSeveralPic

获取图标个数

type SqlReturn

type SqlReturn struct {
	Page       int64         //当前页		`json:"page"`
	PageSize   int64         //每页条数
	TotalCount int64         //总条数
	TotalPage  int64         //总页码
	Data       []interface{} `json:"data"` //数据
	Href       string        //A标签的链接地址  ---------[不需要设置]
	Str        template.HTML //分页
}

GetAll 列表查询返回的结构体 返回总记录条数,总页数,以及当前请求的数据RawSeter

type SqlWhere

type SqlWhere struct {
	TableName   string                 //表名  -----------------[必填]
	Conditions  map[string]interface{} //条件
	Fields      []string               //字段
	OrderBy     string                 //排序
	Currentpage int64                  //当前页 ,默认1 每次分页,必须在前台设置新的页数,不设置始终默认1.在控制器中使用方式:cp, _ := this.GetInt("pno")   po.Currentpage = int(cp)
	PageSize    int64                  //页面大小,默认20
	Uri         string
}

GetAll 列表查询传入的结构体

type YYSeveralPic

type YYSeveralPic struct {
	Quanzhang int64
	Denglong  int64
	Huangguan int64
	Dunpai    int64
	Zhuanshi  int64
	Shuye     int64
}

func YYLeveToSeveral

func YYLeveToSeveral(leve int64) *YYSeveralPic

获取图标个数

Jump to

Keyboard shortcuts

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