web

package
v0.0.0-...-4953d41 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthJson

func AuthJson(context martini.Context, session sessions.Session,
	r render.Render, req *http.Request)

json身份认证

func Authorize

func Authorize(context martini.Context, session sessions.Session,
	r render.Render, req *http.Request)

身份认证

func CaptchaCheck

func CaptchaCheck(c Captcha, r render.Render)

图片验证

func CaptchaImage

func CaptchaImage(params martini.Params, w http.ResponseWriter)

验证图片

func CaptchaReload

func CaptchaReload(params martini.Params, w http.ResponseWriter)

更换图片

func CsPath

func CsPath(m *martini.ClassicMartini, p string)

客服网址

func LogList

func LogList(p martini.Params, params base.Params, r render.Render)

日志列表

func LogNew

func LogNew(work string) martini.Handler

创建日志

func LogQuery

func LogQuery(session Session, params base.Params, r render.Render)

查询日志

func ManagerJson

func ManagerJson(context martini.Context, session sessions.Session,
	r render.Render, req *http.Request)

管理员json身份认证

func Path

func Path(m *martini.ClassicMartini, p string)

网址设置

func PostNew

func PostNew(l Log, s Session, p Post, r render.Render)

新增帖子

func PostQuery

func PostQuery(params base.Params, r render.Render)

查询帖子

func PostQuery2

func PostQuery2(session Session, params base.Params, r render.Render)

查询用户帖子

func PostRead

func PostRead(l Log, params martini.Params, r render.Render)

帖子阅读

func PostRemove

func PostRemove(l Log, params martini.Params, r render.Render)

帖子删除

func PostUpdate

func PostUpdate(l Log, p Post, r render.Render)

修改帖子

func SessionQuery

func SessionQuery(params base.Params, r render.Render)

查询会话

func SessionRemove

func SessionRemove(params martini.Params, r render.Render)

删除会话

func UserGet

func UserGet(s Session, r render.Render)

获取用户信息

func UserLogin

func UserLogin(session sessions.Session, user Captcha,
	r render.Render, req *http.Request)

用户登录

func UserLogout

func UserLogout(s Session, session sessions.Session, r render.Render)

用户登出

func UserPassword

func UserPassword(p Password, s Session, r render.Render)

修改密码

func UserQuery

func UserQuery(params base.Params, r render.Render)

查询用户

func UserRegister

func UserRegister(session sessions.Session, user Captcha,
	r render.Render, req *http.Request)

用户注册

Types

type Captcha

type Captcha struct {
	User
	// ID
	CaptchaId string
	// 验证码
	Solution string
	Password string `form:"password" binding:"required"`
}

验证码

type Log

type Log struct {
	Id bson.ObjectId `bson:"_id,omitempty" json:"-" table:"log"`
	// 对象ID
	Oid bson.ObjectId `bson:"oid,omitempty" json:"-"`
	// 姓名
	Work string `bson:"work,omitempty" json:"work"`
	// IP
	Ip string `bson:"ip,omitempty" json:"ip"`
	// 用户ID
	Uid bson.ObjectId `bson:"uid,omitempty" json:"-"`
	// 用户
	User User `bson:",omitempty" json:"user"`
	// 创建时间
	Ca time.Time `bson:"ca,omitempty" json:"ca"`
}

日志

func (*Log) Log

func (l *Log) Log(oid bson.ObjectId, msg string) error

生成日志

func (*Log) New

func (l *Log) New() error

创建日志

func (*Log) Query

func (l *Log) Query(p base.Params) (logs []Log, count int, err error)

查询

func (*Log) Read

func (l *Log) Read() (err error)

读取用户

func (*Log) Save

func (l *Log) Save() error

保存

type Msg

type Msg struct {
	// 是否成功
	Ok bool `json:"ok"`
	// 错误信息
	Err string `json:"err,omitempty"`
	// 传输数据
	Data interface{} `json:"data,omitempty"`
	// 总数
	Count int `json:"count,omitempty"`
	// 验证码ID
	Cid string `json:"cid,omitempty"`
}

消息

type Page

type Page struct {
	// 标题
	Title string
	// 验证码字符串
	Cid string
	// 是否是客服
	Cs bool
	// 数据
	Data interface{}
}

页面

func PageNew

func PageNew(title string, cs bool) (p Page)

新建页面对象

type Password

type Password struct {
	Password string `form:"password" binding:"required"`
	Old      string `form:"old" binding:"required"`
}

修改密码

type Post

type Post struct {
	Id bson.ObjectId `bson:"_id,omitempty" json:"id" table:"post"`
	// 标题
	Title string `bson:"title" json:"title"`
	// 分类
	Type string `bson:"type" json:"type"`
	// 状态
	Status int `bson:"status" json:"status"`
	// 内容
	Content string `bson:"content,omitempty" json:"content"`
	// 回复
	Rt string `bson:"rt,omitempty" json:"rt"`
	// 网址
	Url string `bson:"url,omitempty" json:"url"`
	// 是否阅读
	Read bool `bson:"read,omitempty" json:"read"`
	// 用户ID
	Uid bson.ObjectId `bson:"uid" json:"uid"`
	// 用户
	User User `bson:",omitempty" json:"user"`
	// 创建时间
	Ca time.Time `bson:"ca,omitempty" json:"ca"`
	// 创建时间
	Ua time.Time `bson:"ua,omitempty" json:"ua"`
}

帖子

func (*Post) Find

func (p *Post) Find() error

查找

func (*Post) New

func (p *Post) New() error

创建帖子

func (*Post) Query

func (i *Post) Query(p base.Params) (posts []Post, count int, err error)

查询

func (*Post) Remove

func (p *Post) Remove() error

查找

func (*Post) Save

func (p *Post) Save() error

保存

type Session

type Session struct {
	Id bson.ObjectId `bson:"_id,omitempty" json:"id" table:"session"`
	// IP
	Ip string `bson:"ip,omitempty" json:"ip"`
	// 当前用户
	Uid bson.ObjectId `bson:"uid,omitempty" json:"uid"`
	// 姓名
	Name string `bson:"name" json:"name"`
	// 手机
	Phone string `bson:"phone,omitempty" json:"phone"`
	// 是否是管理员
	Cs bool `bson:"cs" json:"cs"`
	// 用户信息
	User User `bson:",omitempty" json:"user"`
	// 创建时间
	Ca time.Time `bson:"ca,omitempty" json:"ca"`
	// 修改时间
	Ua time.Time `bson:"ua,omitempty" json:"ua"`
}

会话

func (*Session) Find

func (s *Session) Find() (err error)

会话查找

func (*Session) Logout

func (s *Session) Logout() error

登出

func (*Session) New

func (s *Session) New() error

创建会话

func (*Session) Query

func (s *Session) Query(p base.Params) (session []Session, count int, err error)

查询

func (*Session) Read

func (s *Session) Read() (err error)

读取用户

func (*Session) Save

func (s *Session) Save() error

保存

type User

type User struct {
	Id bson.ObjectId `bson:"_id,omitempty" json:"id" table:"user"`
	// 手机
	Phone string `bson:"phone" json:"phone"`
	// 姓名
	Name string `bson:"name" json:"name"`
	// 密码
	Password string `bson:"password" json:"-"`
	// 是否是客服
	Cs bool `bson:"cs" json:"cs"`
	// 创建时间
	Ca time.Time `bson:"ca,omitempty" json:"ca"`
	// 修改时间
	Ua time.Time `bson:"ua,omitempty" json:"ua"`
	// 有效标记
	En bool
}

用户

func (*User) Disable

func (u *User) Disable()

用户禁用

func (*User) Find

func (u *User) Find() error

查找用户

func (*User) New

func (u *User) New() (err error)

用户创建

func (*User) Query

func (u *User) Query(p base.Params) (users []User, count int, err error)

查询

func (*User) Save

func (u *User) Save() error

保存

func (*User) Sum

func (u *User) Sum() int

用户统计

Jump to

Keyboard shortcuts

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