67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
|
package model
|
|||
|
|
|||
|
import (
|
|||
|
"github.com/codinl/go-logger"
|
|||
|
"time"
|
|||
|
)
|
|||
|
|
|||
|
//go:generate goqueryset -in task.go
|
|||
|
|
|||
|
// gen:qs
|
|||
|
//type Task struct {
|
|||
|
// Model
|
|||
|
//
|
|||
|
// Name string `json:"name" gorm:"comment:'任务名称'"`
|
|||
|
// NameKey string `json:"name_key" gorm:"comment:'任务名称key'"`
|
|||
|
// TaskType string `json:"task_type" gorm:"comment:'任务类型(1 活跃任务 2 日常任务 3 新手任务)'"` // 任务类型
|
|||
|
// IsOnline bool `json:"is_online" gorm:"comment:'是否上线(1 上线 2 不上线)'"` // 是否上线
|
|||
|
// Sort uint32 `json:"sort" gorm:"comment:'排序'"` // 排序
|
|||
|
//}
|
|||
|
|
|||
|
// gen:qs
|
|||
|
type UserAttendance struct {
|
|||
|
Model
|
|||
|
|
|||
|
Uid uint32 `json:"uid" gorm:"index"`
|
|||
|
LatestTime time.Time `json:"latest_time" gorm:"index"`
|
|||
|
ConsecutiveDays uint32 `json:"consecutive_days" gorm:"index"`
|
|||
|
IndexDay uint32 `json:"index_day"`
|
|||
|
// user_attendance
|
|||
|
}
|
|||
|
|
|||
|
// gen:qs
|
|||
|
type UserAttendanceRecord struct {
|
|||
|
Model
|
|||
|
|
|||
|
Uid uint32 `json:"uid" gorm:"index"`
|
|||
|
AttendanceTime time.Time `json:"attendance_time"`
|
|||
|
Vm uint32 `json:"vm"`
|
|||
|
AttendanceDate string `json:"attendance_date" gorm:"index"`
|
|||
|
// user_attendance_record
|
|||
|
}
|
|||
|
|
|||
|
func (m *UserAttendanceRecord) Add(event, describe string) error {
|
|||
|
err := UserVmUpdate(m.Uid, int(m.Vm), event, describe)
|
|||
|
if err != nil {
|
|||
|
logger.Error("update user vm err:", err)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
err = DB.Create(m).Error
|
|||
|
if err != nil {
|
|||
|
logger.Error("create user attendance record err:", err)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
return nil
|
|||
|
}
|
|||
|
|
|||
|
type AttendanceInfo struct {
|
|||
|
IndexDay uint32 `json:"index_day"`
|
|||
|
Date string `json:"date"`
|
|||
|
State uint32 `json:"state"` // 1-未签到 2-签到
|
|||
|
Vm uint32 `json:"vm"`
|
|||
|
}
|
|||
|
|
|||
|
// 2 4 6 8 10 12 14
|