mh_server/model/task.go
2022-04-26 14:28:41 +08:00

67 lines
1.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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