Documentation
¶
Index ¶
- Constants
- func Connect(dsn string) (err error)
- func GetPagingParams(c *gin.Context) (page int, size int)
- func GetParamsTryInt(val string, defaults int) int
- type FavoriteProjectModel
- type GormDB
- type Middleware
- type Model
- type ModelType
- type Objects
- type Page
- type Pagination
- type ProjectLogModel
- type ProjectModel
- type ProjectTodoModel
- type Result
- type UserModel
Constants ¶
View Source
const ( //ProjectTodoWait 等待处理 ProjectTodoWait int = iota + 1 // ProjectTodoWorking 工作中 ProjectTodoWorking // ProjectTodoDone 完成 ProjectTodoDone )
Variables ¶
This section is empty.
Functions ¶
func GetPagingParams ¶
GetPagingParams 获取分页参数
Types ¶
type FavoriteProjectModel ¶
type FavoriteProjectModel struct { Model UserID uint `json:"user_id"` ProjectID uint `json:"project_id"` }
FavoriteProjectModel 收藏的项目
func (*FavoriteProjectModel) TableName ¶
func (f *FavoriteProjectModel) TableName() string
TableName 表名
func (*FavoriteProjectModel) Validator ¶
func (f *FavoriteProjectModel) Validator() (err error)
Validator Validator
type GormDB ¶
GormDB 自定义方法
func (*GormDB) ConnectMysql ¶
ConnectMysql 链接mysql
func (*GormDB) GetObjectOrNotFound ¶
func (g *GormDB) GetObjectOrNotFound(obj interface{}, query interface{}, midd ...Middleware) (err error)
GetObjectOrNotFound 获取某一条数据 gorm first查询接收空条件,在某些情况下会操作到错误到数据
func (*GormDB) GetObjectsOrEmpty ¶
func (g *GormDB) GetObjectsOrEmpty(obj interface{}, query interface{}, args ...Middleware) *Objects
GetObjectsOrEmpty 获取列表 \n 可选参数 middleware models.middleware 接收一个 *gorm.DB 返回 *gorm.DB
type Model ¶
type Model struct { ID uint `json:"id" gorm:"primarykey"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` }
Model Model
type ModelType ¶
type ModelType interface { //Validator 验证模型 //常用的非空验证 友好提示 Validator() (err error) //TableName //邀请数据模型必须提供tablename //gorm依次自动迁移建表 //查询数据比如join操作可以便捷拼接表名 TableName() string }
ModelType 数据库需要实现对应的便捷方法
type Objects ¶
type Objects struct { Obj interface{} Model *gorm.DB Pagination *Pagination Result *Result }
Objects List
type Pagination ¶
type Pagination struct { Page int `json:"page"` Size int `json:"size"` Total int `json:"total"` URLFormat string `json:"-"` }
Pagination 分页数据
func (*Pagination) SetURLFormat ¶
func (p *Pagination) SetURLFormat(url string) string
SetURLFormat 设置url
type ProjectLogModel ¶
type ProjectLogModel struct { Model ProjectID uint `json:"project_id"` Content string `json:"content"` PlusProgress int `json:"plus_progress"` }
ProjectLogModel 项目日志
type ProjectModel ¶
type ProjectModel struct { Model UserID uint `json:"user_id" gorm:"not null;"` Name string `json:"name" form:"name" gorm:"NOT NULL"` Describe string `json:"describe" form:"describe"` Start utils.JSONTime `json:"start" form:"start"` ExpectEnd utils.JSONTime `json:"expect_end" form:"expect_end"` ActualDeliveryDate utils.JSONTime `json:"actual_delivery_date" form:"actual_delivery_date"` Progress int `json:"progress" form:"progress"` Logs []ProjectLogModel `json:"logs" gorm:"foreignKey:project_id"` }
ProjectModel 项目模型
type ProjectTodoModel ¶
type ProjectTodoModel struct { Model ProjectID uint `json:"project_id" gorm:"comment:项目id"` UserID uint `json:"user_id" gorm:"comment:认领工作的用户"` Content string `json:"content"` Statuc int `json:"statuc" gorm:"comment:1-待认领,2-处理中,3-已完成"` DoneTime gorm.DeletedAt `json:"done_time"` Done bool `json:"done" gorm:"-"` }
ProjectTodoModel 待处理任务
func (*ProjectTodoModel) Validator ¶
func (p *ProjectTodoModel) Validator() (err error)
Validator 验证器
type UserModel ¶
type UserModel struct { Model Nick string `json:"nick" form:"nick" gorm:"index;not null;unique"` HeadPic string `json:"head_pic" form:"head_pic"` Email string `json:"email" form:"email" gorm:"index;"` Password string `json:"password" gorm:"not null"` }
UserModel 用户
func (*UserModel) VerifyRepeatEmail ¶
VerifyRepeatEmail 验证重复邮箱
func (*UserModel) VerifyRepeatNickName ¶
VerifyRepeatNickName 验证重复昵称
Click to show internal directories.
Click to hide internal directories.