model

package
v0.0.0-...-5979347 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2017 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const IPCNT = 5

Variables

View Source
var (
	//数据库打开错误
	DBErr = errors.New("DB Open Error")

	//函数参数错误
	ArgsErr = errors.New("Args Error")

	//没有查询到指定数据
	NotFoundErr = errors.New("Not Found")

	//更新错误
	OpErr = errors.New("Operate Error")

	//ID生成错误
	IDErr = errors.New("Get ID Error")

	//查询或查询参数错误
	QueryErr = errors.New("Query Error")

	//密码加密错误
	EncryptErr = errors.New("Encrypt Error")

	ExistErr = errors.New("Id has existed")
)

Functions

func Migrate_2015_07_09

func Migrate_2015_07_09()

Types

type Contest

type Contest struct {
	Cid      int         `json:"cid"bson:"cid"`
	Title    string      `json:"title"bson:"title"`
	Encrypt  int         `json:"encrypt"bson:"encrypt"`
	Argument interface{} `json:"argument"bson:"argument"`
	Creator  string      `json:"creator"bson:"creator"` //who creates the contest

	Start int64 `json:"start"bson:"start"`
	End   int64 `json:"end"bson:"end"`

	Status int    `json:"status"bson:"status"`
	Create string `'json:"create"bson:"create"`

	List []int `json:"list"bson:"list"` //problem list
}

type ContestModel

type ContestModel struct {
	class.Model
}

func (*ContestModel) CheckQuery

func (this *ContestModel) CheckQuery(args map[string]string) (query bson.M, err error)

检查参数args,返回一个query和一个error

func (*ContestModel) Delete

func (this *ContestModel) Delete(cid int) error

删除指定cid的contest

func (*ContestModel) Detail

func (this *ContestModel) Detail(cid int) (*Contest, error)

参数cid,返回指定cid的contest

func (*ContestModel) Insert

func (this *ContestModel) Insert(one Contest) error

插入新的contest,不能指定cid,statu,和create

func (*ContestModel) List

func (this *ContestModel) List(args map[string]string) ([]*Contest, error)

列出由参数args指定所有问题,参数args应该包括offset:<offset>,limit:<limit>,pid:<pid>,title:<title>之一

func (*ContestModel) Push

func (this *ContestModel) Push(cid int, list []int) error

更新指定cid的contest的问题列表

func (*ContestModel) Status

func (this *ContestModel) Status(cid, status int) error

更新指定cid的contest的状态,更新状态由参数status指定

func (*ContestModel) Update

func (this *ContestModel) Update(cid int, ori Contest) error

更新指定cid的contest

type Migrator

type Migrator func()

type News

type News struct {
	Nid     int           `json:"nid"bson:"nid"`
	Title   string        `json:"title"bson:"title"`
	Content template.HTML `json:"content"bson:"content"`

	Status int    `json:"status"bson:"status"`
	Create string `json:"create"bson:'create'`
}

type NewsModel

type NewsModel struct {
	class.Model
}

func (*NewsModel) Delete

func (this *NewsModel) Delete(nid int) error

删除指定nid的news

func (*NewsModel) Detail

func (this *NewsModel) Detail(nid int) (*News, error)

获取指定nid的news

func (*NewsModel) Insert

func (this *NewsModel) Insert(one News) error

插入一个新的news,不能指定status和create

func (*NewsModel) List

func (this *NewsModel) List(offset, limit int) ([]*News, error)

列出由offset,limit指定的news

func (*NewsModel) Status

func (this *NewsModel) Status(nid, status int) error

更新指定的news的status

func (*NewsModel) Update

func (this *NewsModel) Update(nid int, ori News) error

更新指定nid的news

type OJModel

type OJModel struct {
	class.Model
}

func (*OJModel) List

func (o *OJModel) List() ([]*OJStatus, error)

func (*OJModel) Update

func (o *OJModel) Update(status *OJStatus) error

type OJStatus

type OJStatus struct {
	Name   string `json:"name"bson:"name"`
	Status int    `json:"status"bson:"status"`
}

type Problem

type Problem struct {
	Pid  int    `json:"pid"bson:"pid"`
	RPid int    `json:"rpid"bson:"rpid"` //remote problem id
	ROJ  string `json:"roj"bson:"roj"`
	Flag uint8  `json:"-"`

	Time    int    `json:"time"bson:"time"xml:"time_limit"`
	Memory  int    `json:"memory"bson:"memory"xml:"memory_limit"`
	Special int    `json:"special"bson:"special"`
	Expire  string `json:"expire"bson:"expire"`

	Title       string        `json:"title"bson:"title"xml:"title"`
	Description template.HTML `json:"description"bson:"description"xml:"description"`
	Input       template.HTML `json:"input"bson:"input"xml:"input"`
	Output      template.HTML `json:"output"bson:"output"xml:"output"`
	Source      string        `json:"source"bson:"source"xml:"source"`
	Hint        template.HTML `json:"hint"bson:"hint"xml:"hint"`

	In  string `json:"in"bson:"in"xml:"sample_input"`
	Out string `json:"out"bson:"out"xml:"sample_output"`

	Solve  int `json:"solve"bson:"solve"`
	Submit int `json:"submit"bson:"submit"`

	Status int    `json:"status"bson:"status"`
	Create string `json:"create"bson:"create"`
}

type ProblemModel

type ProblemModel struct {
	class.Model
}

func (*ProblemModel) CheckQuery

func (this *ProblemModel) CheckQuery(args map[string]string) (query bson.M, err error)

检查查询参数args,成功则返回一个query

func (*ProblemModel) Count

func (this *ProblemModel) Count(args map[string]string) (int, error)

计数符合参数args的problem的个数,title:<title>,source:<source>,status:<status>

func (*ProblemModel) Delete

func (this *ProblemModel) Delete(pid int) error

删除指定pid的problem

func (*ProblemModel) Detail

func (this *ProblemModel) Detail(pid int) (*Problem, error)

查询指定pid的problem的详细信息

func (*ProblemModel) Expire

func (this *ProblemModel) Expire(pid int, expire string) error

修改指定pid的problem的 expire 值

func (*ProblemModel) Insert

func (this *ProblemModel) Insert(one Problem) (int, error)

插入一个新的problem,不可指定solve,submit,status,create,exprie和pid参数, 成功则返回新的pid

func (*ProblemModel) List

func (this *ProblemModel) List(args map[string]string) ([]*Problem, error)

列出符合参数args的所有problem,offset?<offset>/limit?<limit>/pid?<pid>/title?<title>/source?<source>

func (*ProblemModel) Record

func (this *ProblemModel) Record(pid int, solve int, submit int) error

记录problem的solve和submit,每次记录时submit值总会加1,而solve则由action指定是否记录

func (*ProblemModel) Status

func (this *ProblemModel) Status(pid, status int) error

更新指定pid的problem的状态,状态值由status指定

func (*ProblemModel) Update

func (this *ProblemModel) Update(pid int, ori Problem) error

更新指定pid的problem

type Solution

type Solution struct {
	Sid int `json:"sid"bson:"sid"`

	Pid      int    `json:"pid"bson:"pid"`
	Uid      string `json:"uid"bson:"uid"`
	Judge    int    `json:"judge"bson:"judge"`
	Time     int    `json:"time"bson:"time"`
	Memory   int    `json:"memory"bson:"memory"`
	Length   int    `json:"length"bson:"length"`
	Language int    `json:"language"bson:"language"`

	//module指定solution提交类型,有problem,contest,exercise三种类型
	Module int `json:"module"bson:"module"`
	Mid    int `json:"mid"bson:"mid"`

	Code  string `json:"code"bson:"code"`
	Error string `json:"error"bson:"error"` //compiler error info

	Share     bool  `json:"share"bson:"share"` //share code
	Status    int   `json:"status"bson:"status"`
	Create    int64 `json:"create"bson:"create"`
	Sim       int   `json:"sim"bson:"sim"`
	Sim_s_id  int   `json:"sim_s_id"bson:"sim_s_id"`
	IsViewSim bool  `json:"isviewsim"bson:"isviewsim"`
}

type SolutionModel

type SolutionModel struct {
	class.Model
}

func (*SolutionModel) Achieve

func (this *SolutionModel) Achieve(uid string, module int, mid int) ([]int, error)

获取指定uid,judge状态为AC的solutions的相异的pid

func (*SolutionModel) CheckQuery

func (this *SolutionModel) CheckQuery(args map[string]string) (query bson.M, err error)

func (*SolutionModel) Count

func (this *SolutionModel) Count(args map[string]string) (int, error)

计数由参数args指定的solution个数,参数包括pid、uid、module、mid、action

func (*SolutionModel) Delete

func (this *SolutionModel) Delete(sid int) error

删除指定sid的solution

func (*SolutionModel) Detail

func (this *SolutionModel) Detail(sid int) (*Solution, error)

查询指定sid的solution的所有详细信息

func (*SolutionModel) Insert

func (this *SolutionModel) Insert(one Solution) (int, error)

插入一个新的solution,不能指定create和sid

func (*SolutionModel) List

func (this *SolutionModel) List(args map[string]string) ([]*Solution, error)

列出符合参数args的Solution,参数包括offset、limit、sid、pid、uid、language、judge、module、mid、from、sort 默认按sid从大到小排,sort参数设为resort可以设置为从小到大

func (*SolutionModel) Status

func (this *SolutionModel) Status(sid, status int) error

更新指定sid的solution状态,状态值由status指定

func (*SolutionModel) Update

func (this *SolutionModel) Update(sid int, ori Solution) error

更新指定sid的solution,可更新参数包括judge、time、memory三个

type User

type User struct {
	Uid string `json:"uid"bson:"uid"`
	Pwd string `json:"pwd"bson:"pwd"`

	Nick   string `json:"nick"bson:"nick"`
	Mail   string `json:"mail"bson:"mail"`
	School string `json:"school"bson:"school"`
	Motto  string `json:"motto"bson:"motto"`

	Privilege int `json:"privilege"bson:"privilege"`
	//module指定user类型,有普通normal(0),比赛用team(1)两种类型
	Module int `json:"module"bson:"module"`

	Solve  int `json:"solve"bson:"solve"`
	Submit int `json:"submit"bson:"submit"`

	ShareCode  bool          `json:"share_code"bson:"share_code"`
	Status     int           `json:"status"bson:"status"`
	Create     string        `json:"create"bson:"create"`
	IPRecord   [IPCNT]string `json:"iprecord"bson:"iprecord"` //记录ip地址
	TimeRecord [IPCNT]int64  `json:"timerecord"bson:"timerecord"`
}

type UserModel

type UserModel struct {
	class.Model
}

func (*UserModel) CheckQuery

func (this *UserModel) CheckQuery(args map[string]string) (query bson.M, err error)

func (*UserModel) Delete

func (this *UserModel) Delete(uid string) error

删除指定uid用户

func (*UserModel) Detail

func (this *UserModel) Detail(uid string) (*User, error)

获得指定uid用户的所有信息

func (*UserModel) Insert

func (this *UserModel) Insert(one User) error

插入一个新的user

func (*UserModel) List

func (this *UserModel) List(args map[string]string) ([]*User, error)

列出用户 offset:<offset>,limit:<limit>,uid:<uid>,nick:<nick>

func (*UserModel) Login

func (this *UserModel) Login(uid, pwd string) (*User, error)

用户登入验证,需要提供uid和pwd两个参数, 如果用户存在并且uid和pwd匹配,则返回一个user

func (*UserModel) Logout

func (this *UserModel) Logout()

这个函数貌似没干什么事啊==

func (*UserModel) Password

func (this *UserModel) Password(uid, pwd string) error

设定用户密码,需提供uid和pwd

func (*UserModel) Privilege

func (this *UserModel) Privilege(uid string, privilege int) error

设定指定uid用户的权限

func (*UserModel) Record

func (this *UserModel) Record(uid string, solve int, submit int) error

用户做题记录,uid:<uid>,action:<solve/submit>

func (*UserModel) RecordIP

func (this *UserModel) RecordIP(uid, IP string, time int64) error

func (*UserModel) Status

func (this *UserModel) Status(uid string) error

更新用户状态

func (*UserModel) Update

func (this *UserModel) Update(uid string, ori User) error

更新用户信息(nick,mail,scholl,motto)

type VIds

type VIds struct {
	Name string `json:"name"bson:"name"`
	Id   int    `json:"id"bson:"id"`
}

type VIdsModel

type VIdsModel struct {
	class.Model
}

func (*VIdsModel) GetLastID

func (v *VIdsModel) GetLastID(c string) (id int, err error)

func (*VIdsModel) SetLastID

func (v *VIdsModel) SetLastID(c string, id int) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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