You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.9 KiB
58 lines
1.9 KiB
package user
|
|
|
|
import (
|
|
"github.com/golangkit/formatime"
|
|
"recook/internal/v2/lib/db"
|
|
)
|
|
|
|
const (
|
|
RecookUserWelfareNoticeIsShowFalse = 0 // 未查看
|
|
RecookUserWelfareNoticeIsShowTrue = 1 // 已查看
|
|
|
|
RecookUserWelfareNoticeTypeExam = 1 // 考核退回
|
|
)
|
|
|
|
type RecookUserWelfareNoticeModel struct {
|
|
db.BaseModel
|
|
Id uint `gorm:"column:id" json:"id"`
|
|
UserId uint `json:"userId"`
|
|
Type uint `json:"type"`
|
|
IsLook uint `json:"isLook"`
|
|
Gold uint `json:"gold"`
|
|
Silver uint `json:"silver"`
|
|
UpdatedAt formatime.Second `json:"updatedAt"`
|
|
}
|
|
|
|
// TableName sets the insert table name for this struct type
|
|
func (r *RecookUserWelfareNoticeModel) TableName() string {
|
|
return "recook_user_welfare_notice"
|
|
}
|
|
|
|
// @Style 添加
|
|
func (r *RecookUserWelfareNoticeModel) Create(data *RecookUserWelfareNoticeModel) {
|
|
r.GetDb().Create(data)
|
|
}
|
|
|
|
// @Style 根据userId获取数据
|
|
func (r *RecookUserWelfareNoticeModel) FindByUserIdAndType(userId, noticeType uint) (result RecookUserWelfareNoticeModel) {
|
|
r.GetDb().Model(&RecookUserWelfareNoticeModel{}).First(&result, "user_id = ? and `type` = ?", userId, noticeType)
|
|
return
|
|
}
|
|
|
|
// @Style 根据userId获取数据
|
|
func (r *RecookUserWelfareNoticeModel) FindById(id uint) (result RecookUserWelfareNoticeModel) {
|
|
r.GetDb().Model(&RecookUserWelfareNoticeModel{}).First(&result, "id = ?", id)
|
|
return
|
|
}
|
|
|
|
// @Style 更新个人信息
|
|
func (r *RecookUserWelfareNoticeModel) UpdateById(id uint, data map[string]interface{}) error {
|
|
return r.GetDb().Model(&RecookUserWelfareNoticeModel{}).Where("id = ?", id).Updates(data).Error
|
|
}
|
|
|
|
// @Style 根据userId获取数据
|
|
func (r *RecookUserWelfareNoticeModel) FindByUserId(userId uint) (result []RecookUserWelfareNoticeModel) {
|
|
r.GetDb().Model(&RecookUserWelfareNoticeModel{}).Find(&result, "user_id = ? and is_look = ?", userId, RecookUserWelfareNoticeIsShowFalse)
|
|
return
|
|
}
|