common

package
v0.0.0-...-3f42f3c Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Sess = sessions.New(sessions.Config{Cookie: cookieNameForSessionID})
)

Functions

func Addslashes

func Addslashes(str string) string

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

func BlogKeyWord

func BlogKeyWord(s string) string

博客文章关键检索

func ClientIP

func ClientIP(request *http.Request) string

ClientIP 得到客户端IP地址

func CreateSign

func CreateSign(str string) string

CreateSign 对字符串进行签名

func Delete_extra_space

func Delete_extra_space(s string) string

函数名:delete_extra_space(s string) string 功 能:删除字符串中多余的空格(含tab),有多个空格时,仅保留一个空格,同时将字符串中的tab换为空格 参 数:s string:原始字符串 返回值:string:删除多余空格后的字符串 创建时间:2018年12月3日 修订信息:

func Exists

func Exists(path string) bool

简化版 直接用os.IsNotExist(err)

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.ObjLoginuser

从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 IsHuBuLaOSS

func IsHuBuLaOSS() bool

func IsMobile

func IsMobile(header *http.Request) (isMobile bool)

IsMobile 判断是否手机登录

func LoginSession

func LoginSession(c iris.Context) *viewsmodels.AdminSession

获取

func LoginSessionGet

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

获取

func LoginSessionSet

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

用户登录 session 填充

func Mobile

func Mobile(r *http.Request) bool

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

encrypt password 加密密码

func PasswordVerify

func PasswordVerify(password, pass, salt string) bool

验证

func PathAutoOrMobile

func PathAutoOrMobile(r *http.Request, b bool, cookieMobile string, indexoradmin string, model string) string

http.Request 是否启用自适应方式默认flase cookie设备信息 前台或者后台 模块路径

func PathExists

func PathExists(path string) bool

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

使用os.IsExist()判断为true,说明文件或文件夹存在

如果返回的错误为其它类型,则不确定是否在存在

func PathMobile

func PathMobile(r *http.Request, indexoradmin string, model string) string

判断pc还是移动设备,进行模板路径拼接,不考虑自适应模板

func PrintKeyWord

func PrintKeyWord(ch <-chan string) string

字符串【搜索引擎模式】分词

func QQLevePic

func QQLevePic(leve *QQSeveralPic) string

func Random

func Random(max int) int

Random 得到一个随机数

func Redirect

func Redirect(writer http.ResponseWriter, url string)

Redirect 跳转URL

func SessionSet

func SessionSet(c iris.Context, sessionname string, sessionvalue interface{})

通用 session 填充

func SetLoginuser

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

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

func SqlBuHan

func SqlBuHan(buhan string) (v map[string]string)

不含

func SqlHaoduan400

func SqlHaoduan400(haoduan string) (v map[string]string)

400号段

func SqlHaoduanSJH

func SqlHaoduanSJH(haoduan string) (v map[string]string)

手机号段 匹配前三个

func SqlJiLiHao

func SqlJiLiHao(jilihao string) (v map[string]string)

吉利号码

func SqlJiaGe

func SqlJiaGe(jiage string) (v map[string]string)

价格

func SqlJiaoDuo

func SqlJiaoDuo(jiaoduo string) (v map[string]string)

较多 直接匹配到至少4个

func SqlNianDai

func SqlNianDai(niandai string) (v map[string]string)

年代 末尾四位

func SqlOrder

func SqlOrder(order string) (v map[string]string)

排序

func SqlShengRi

func SqlShengRi(shengri string) (v map[string]string)

生日 只能匹配末尾四位

func SqlTeZheng

func SqlTeZheng(tezheng string) (v map[string]string)

号码特征 末尾匹配

func Sqlyuju

func Sqlyuju(biaoming string, keyValue string) string

func Stripslashes

func Stripslashes(str string) string

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

func Tree

func Tree(list []*models.ADemo) string

树形结构

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