Code Monkey home page Code Monkey logo

beegohelper's Introduction

beegoHelper

创建beego控制器时候的一个辅助控制器,方便开发.

使用方法: 直接嵌入即可,即

import (
	"github.com/doomsplayer/beegoHelper"
)

type MainController struct {
	beegoHelper.Base
}

func (this *MainController) Get() {
	.........
}

内容包括: Parse 系列:

this.GetInts 函数, 返回一个[]int

this.ParseJson 直接将body当成一个json,parse到对象中。方便api交互(尤其是angular)

this.GetParamString, this.GetParamIntthis.Ctx.Input.Param() 的缩短版

this.ParseFormAndValid, 直接解析内容到结构体,并且按照valid的tag来验证struct,详细请查看beego文档form验证一节

this.ParseQuery, 实验函数,解析query直接返回一个orm的Cond

Paginator系列:分页器 使用以后会在url最后加一个?p=xxx表示页码

this.Paginator(每页几个元素,一共有几个元素) 生成一个分页器,方便数据库查询以及分页,有以下方法:

Pages() []int 返回页码数组

PageLink(page int) string 根据页码生成某一页的链接

PageLinkPrev() (link string)

PageLinkLast() (link string)

HasPrev() bool

HasNext() bool

IsActive(page int) bool

Offset() int

HasPages() bool

End() int

Auth系列:HTTPBaseAuth

CheckBaseAuth(cred string) bool cred是验证字符串,格式 用户名:密码 只要使用了这个函数会自动加载authorization的头.

Check,Ok 系列 to be continue

beegohelper's People

Contributors

dovahcrow avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.