Documentation
¶
Index ¶
- Constants
- Variables
- func AddOpen(record ReserveRecord) map[string]interface{}
- func AddWhiteList(uid uint64) error
- func DeleteOpen(uid string, openid int) map[string]interface{}
- func GetReserveCount(status int) int
- func GetUserCount() int
- func InitSelfDB() *gorm.DB
- func IsExistsReserveRecord(uid string, lid, day, time string) bool
- func IsWhiteList(id uint64) bool
- func Migrations(v ...interface{})
- func RemoveWhiteList(uid uint64) error
- func UpdateOpen(record ReserveRecord) map[string]interface{}
- type BaseModel
- type Database
- type Lab
- type LabClass
- type LabDetail
- type LabType
- type ReserveInfo
- type ReserveRecord
- func GetReserveRecord(id uint64) (*ReserveRecord, error)
- func GetReserveRecordWithOpenId(openid int) (*ReserveRecord, error)
- func GetReserveWithStatus(status, pageNum, pageLimit int) ([]*ReserveRecord, error)
- func GetUserReserve(uid string, pageNum, pageLimit int, params ...interface{}) ([]*ReserveRecord, error)
- func (oo *ReserveRecord) Create() error
- func (oo *ReserveRecord) Delete(syncNeu bool) error
- func (oo *ReserveRecord) DeleteDetail() error
- func (oo *ReserveRecord) Detail2Records()
- func (oo *ReserveRecord) GetDetail() []ReserveRecordDetail
- func (oo *ReserveRecord) GetLab()
- func (oo *ReserveRecord) Records2Detail()
- func (oo *ReserveRecord) Review(status int) error
- func (oo *ReserveRecord) SaveNoSafe(syncNeu bool) error
- type ReserveRecordDetail
- type Token
- type User
- type UserInfo
- type WhiteList
Constants ¶
const ( ReserveReviewPending = 0 ReserveReviewSuccess = 1 )
Variables ¶
Functions ¶
func AddOpen ¶
func AddOpen(record ReserveRecord) map[string]interface{}
SubmitOpenJob 向neu提交开放预约申请,有可能会失败,故使用Chan作为为队列 2019.08.31 废弃队列,改为事物,只提交一次,提交失败 就是失败
func AddWhiteList ¶
func DeleteOpen ¶
func GetReserveCount ¶
GetReserveCount return count of reserves
func GetUserCount ¶
func GetUserCount() int
func IsExistsReserveRecord ¶
func IsWhiteList ¶
func RemoveWhiteList ¶
func UpdateOpen ¶
func UpdateOpen(record ReserveRecord) map[string]interface{}
Types ¶
type Lab ¶
type Lab struct { CreatedAt time.Time `gorm:"column:createdAt" json:"-"` DeletedAt *time.Time `gorm:"column:deletedAt" sql:"index" json:"-"` LabID string `gorm:"primary_key;unique_index" uri:"labid" json:"lab_id"` LabName string `json:"lab_name"` SeatNum int `json:"seat_num"` LabTypeID int `json:"lab_type_id"` S int `json:"s"` Detail *LabDetail `json:"detail"` Userid string `json:"userid"` UserName string `json:"user_name"` Tel string `json:"tel"` DeviceNumber string `json:"device_number"` }
Lab S mean lock
func GetLabWithDoorId ¶
type LabClass ¶
type LabClass struct { Id uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"-"` LabID string Lab Lab Class string Day string `gorm:"type:char(10)"` Time string `gorm:"type:char(1)"` Teacher string Other string }
LabClass 归类于独占教室的目的,当有记录,此实验室这个时间段内不在开放预约
type LabDetail ¶
type LabDetail struct { LabID string `gorm:"primary_key;unique_index" uri:"labid" json:"-"` Context string `gorm:"type:text" json:"context"` ImagesString string `gorm:"type:text" json:"-"` Images []string `gorm:"-" json:"images"` Info string `json:"info"` }
func (*LabDetail) DeleteImage ¶
func (*LabDetail) GetNextImageFileName ¶
func (*LabDetail) InsertImage ¶
type LabType ¶
type LabType struct { Id int `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"id"` Name string `gorm:"type:varchar(30);unique_index" json:"name"` }
func GetOneLabType ¶
type ReserveInfo ¶
func GetLabClassInfo ¶
func GetLabClassInfo(labid, day string) ([]ReserveInfo, error)
GetLabClassInfo 返回某月某实验室的所有课程
func GetLabUserNumInfo ¶
func GetLabUserNumInfo(labid, day string) ([]ReserveInfo, error)
GetLabUserNumInfo 返回某月某实验室的所有预约座位数
func GetLabUserReserveInfo ¶
func GetLabUserReserveInfo(uid string, labid, day string) ([]ReserveInfo, error)
GetLabUserReserveInfo 返回某月某实验室某用户的所有的预约情况
type ReserveRecord ¶
type ReserveRecord struct { Id uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"id"` CreatedAt time.Time `gorm:"column:createdAt" json:"created_at"` UpdatedAt time.Time `gorm:"column:updatedAt" json:"updated_at"` DeletedAt *time.Time `gorm:"column:deletedAt" sql:"index" json:"-"` Uid string `gorm:"index" json:"uid"` // 2019-07-03 改为用户的userid LabID string `json:"lab_id"` Status int `gorm:"index;default:0" json:"status"` Content string `gorm:"type:varchar(100)" json:"content" binding:"exists"` // 项目名称 Explain string `gorm:"type:varchar(100)" json:"explain" binding:"exists"` // 项目说明 OpentypeID string `json:"opentype_id" binding:"required"` // 项目类型 UserNum int `json:"user_num" binding:"required"` // 人数 GuideTeacher string `gorm:"type:varchar(20)" json:"guide_teacher" binding:"exists"` // 指导教师 Remarks string `gorm:"type:varchar(255)" json:"remarks" binding:"exists"` // 备注 Expend int `json:"expend" binding:"exists"` // 是否需要消耗品 Mobile string `gorm:"type:varchar(11)" json:"mobile" binding:"required"` // 手机 OpenId int `gorm:"column:openid" json:"openid"` // neu返回的openid Note string `json:"note"` // neu 预约失败返回的字段 Details []ReserveRecordDetail `json:"-"` Lab *Lab `gorm:"-" json:"lab_info"` Records map[string][]int `gorm:"-" json:"records" binding:"required"` }
ReserveRecord : status : 0 pending review
1 success review 3 failed review
OpentypeID: 1 大创/竞赛项目 2 毕业设计项目 3 课程实验项目 4 教师科研项目 5 其他 TODO
func GetReserveRecord ¶
func GetReserveRecord(id uint64) (*ReserveRecord, error)
GetReserveRecord GetReserveRecord
func GetReserveRecordWithOpenId ¶
func GetReserveRecordWithOpenId(openid int) (*ReserveRecord, error)
GetReserveRecord GetReserveRecord
func GetReserveWithStatus ¶
func GetReserveWithStatus(status, pageNum, pageLimit int) ([]*ReserveRecord, error)
GetReserveWithStatus GetReserveWithStatus
func GetUserReserve ¶
func GetUserReserve(uid string, pageNum, pageLimit int, params ...interface{}) ([]*ReserveRecord, error)
func (*ReserveRecord) Delete ¶
func (oo *ReserveRecord) Delete(syncNeu bool) error
Delete will soft delete record and real delete detail
func (*ReserveRecord) DeleteDetail ¶
func (oo *ReserveRecord) DeleteDetail() error
DeleteDetail deleteDetail
func (*ReserveRecord) Detail2Records ¶
func (oo *ReserveRecord) Detail2Records()
Detail2Records convert detail to records
func (*ReserveRecord) GetDetail ¶
func (oo *ReserveRecord) GetDetail() []ReserveRecordDetail
GetDetail GetDetail
func (*ReserveRecord) Records2Detail ¶
func (oo *ReserveRecord) Records2Detail()
Records2Detail convert records to detail
func (*ReserveRecord) Review ¶
func (oo *ReserveRecord) Review(status int) error
Review the status code only support switch 0 -> 1 or 0 -> -1 or 1 > 0 or 1 > -1
func (*ReserveRecord) SaveNoSafe ¶
func (oo *ReserveRecord) SaveNoSafe(syncNeu bool) error
SaveNoSafe This method will delete all the original reserve info. Replace new apply info
type ReserveRecordDetail ¶
type ReserveRecordDetail struct { Id uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"-"` ReserveRecordID uint64 `gorm:"index" json:"-"` Day string `gorm:"type:char(10)"` Time string `gorm:"type:char(1)"` Uid string `json:"-"` // 2019-07-03 改为用户的userid Lid string `json:"-"` Effective int `gorm:"index" json:"-"` UserNum int `json:"-"` }
ReserveRecordDetail : `effective` is a special field, if its value is 1 means ReserveRecord success review, all sql statement where include `where effective = 1`. 在审核中或者审核成功时不能出现同一个时间同一实验室的预约记录, 审核不通过时可以出现 已有20190501 1 1 1 0/1,则 20190501 1 1 1 x x为任何值都不被允许
type User ¶
type User struct { Id uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"id"` CreatedAt time.Time `gorm:"column:createdAt" json:"created_at"` UpdatedAt time.Time `gorm:"column:updatedAt" json:"updated_at"` DeletedAt *time.Time `gorm:"column:deletedAt" sql:"index" json:"-"` Openid string `gorm:"unique_index" json:"openid"` Role uint `json:"role"` Un string `json:"-"` Pa string `json:"-"` Info *UserInfo `gorm:"-" json:"info"` }
func GetAllUser ¶
func GetUserWithId ¶
func (*User) GetStuInfo ¶
func (u *User) GetStuInfo()
type UserInfo ¶
type UserInfo struct { UserId string `gorm:"primary_key" json:"user_id"` UserPass string `gorm:"default:123456" json:"-"` UserName string `json:"user_name"` UserDepartment string `json:"user_department"` Consuserid string `json:"-"` UserRole string `json:"user_role"` Uid uint64 `gorm:"index" json:"uid"` }
func CheckPassStu ¶
func CheckPassStuV2 ¶
func GetAllStuInfo ¶
func GetAllUserInfo ¶
func GetAllUserInfo() []*UserInfo