utils

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2017 License: Apache-2.0, Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KC_RAND_KIND_NUM   = 0 // 纯数字
	KC_RAND_KIND_LOWER = 1 // 小写字母
	KC_RAND_KIND_UPPER = 2 // 大写字母
	KC_RAND_KIND_ALL   = 3 // 数字、大小写字母
)

Variables

This section is empty.

Functions

func AbsolutePath

func AbsolutePath(p string) (string, error)

func AddMember added in v0.5.1

func AddMember(account, password string) error

func Asset added in v0.5.1

func Asset(p string, cdn string) string

func CopyFile added in v0.5.1

func CopyFile(dstName, srcName string) (written int64, err error)

func DealUri

func DealUri(po *PageOptions, requestURI string)

*

  • 处理url,目的是保存参数

func Decode

func Decode(value string, r interface{}) error

解码

func Encode

func Encode(value interface{}) (string, error)

编码

func FileExists added in v0.5.1

func FileExists(name string) bool

FileExists reports whether the named file or directory exists.

func FormatBytes added in v0.5.1

func FormatBytes(size int64) string

func GetPagerHtml

func GetPagerHtml(requestURI string, pageIndex, pageSize, totalCount int) html.HTML
func GetPagerLinks(po *PageOptions, requestURI string) (int, int, orm.RawSeter, html.HTML)

*

  • 返回总记录条数,总页数,当前页面数据,分页html
  • 根据分页选项,生成分页连接 下面是一个实例: func (this *MainController) Test() { var po util.PageOptions po.EnablePreNexLink = true po.EnableFirstLastLink = true po.LinkItemCount = 7 po.TableName = "help_topic" cp, _ := this.GetInt("pno") po.CurrentPage = int(cp) _,_,_ pager := util.GetPagerLinks(&po, this.Ctx) this.Data["Email"] = html.HTML(pager) this.TplName = "test.html" }

func GetPagesInfo

func GetPagesInfo(tableName string, currentpage int, pagesize int, conditions string) (int, int, orm.RawSeter)

*

  • 分页函数,适用任何表
  • 返回 总记录条数,总页数,以及当前请求的数据RawSeter,调用中需要"rs.QueryRows(&tblog)"就行了 --tblog是一个Tb_log对象
  • 参数:表名,当前页数,页面大小,条件(查询条件,格式为 " and name='zhifeiya' and age=12 ")

func JoinURI added in v0.5.1

func JoinURI(elem ...string) string

func Krand

func Krand(size int, kind int) []byte

随机字符串

func ModifyPassword added in v0.5.1

func ModifyPassword(account, old_password, new_password string) error

func PasswordHash

func PasswordHash(pass string) (string, error)

加密密码

func PasswordVerify

func PasswordVerify(hashing string, pass string) (bool, error)

校验密码是否有效

func Round added in v0.5.1

func Round(val float64, places int) float64

func ValidLDAPLogin added in v0.5.1

func ValidLDAPLogin(password string) (result bool, err error)

Types

type PageOptions

type PageOptions struct {
	TableName           string //表名  -----------------[必填]
	Conditions          string //条件
	CurrentPage         int    //当前页 ,默认1 每次分页,必须在前台设置新的页数,不设置始终默认1.在控制器中使用方式:cp, _ := this.GetInt("pno")   po.CurrentPage = int(cp)
	PageSize            int    //页面大小,默认20
	LinkItemCount       int    //生成A标签的个数 默认10个
	Href                string //A标签的链接地址  ---------[不需要设置]
	ParamName           string //参数名称  默认是pno
	FirstPageText       string //首页文字  默认"首页"
	LastPageText        string //尾页文字  默认"尾页"
	PrePageText         string //上一页文字 默认"上一页"
	NextPageText        string //下一页文字 默认"下一页"
	EnableFirstLastLink bool   //是否启用首尾连接 默认false 建议开启
	EnablePreNexLink    bool   //是否启用上一页,下一页连接 默认false 建议开启
}

Directories

Path Synopsis
Package wkhtmltopdf contains wrappers around the wkhtmltopdf commandline tool
Package wkhtmltopdf contains wrappers around the wkhtmltopdf commandline tool

Jump to

Keyboard shortcuts

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