|
@@ -12,15 +12,17 @@ const (
|
|
|
)
|
|
|
|
|
|
type TemplateUser struct {
|
|
|
- Id int `gorm:"column:id;primaryKey;autoIncrement:'id'"`
|
|
|
- Username string `gorm:"column:username;type:varchar(20);comment:用户名"`
|
|
|
- Mobile string `gorm:"column:mobile;type:varchar(15);comment:手机号"`
|
|
|
- OpenId string `gorm:"column:open_id;type:varchar(50);comment:open_id"`
|
|
|
- GzhOpenId string `gorm:"column:gzh_open_id;type:varchar(255);comment:gzh_open_id"`
|
|
|
- UnionId string `gorm:"column:union_id;type:varchar(50);comment:union_id"`
|
|
|
- IsDeleted int `gorm:"column:is_deleted;type:int(11);comment:是否删除"`
|
|
|
- CreatedTime time.Time `gorm:"column:created_time;type:timestamps;comment:创建时间"`
|
|
|
- UpdatedTime time.Time `gorm:"column:updated_time;type:timestamps;comment:更新时间"`
|
|
|
+ Id int `gorm:"column:id;primaryKey;autoIncrement:'id'"`
|
|
|
+ Username string `gorm:"column:username;type:varchar(20);comment:用户名"`
|
|
|
+ Mobile string `gorm:"column:mobile;type:varchar(15);comment:手机号"`
|
|
|
+ OpenId string `gorm:"column:open_id;type:varchar(50);comment:open_id"`
|
|
|
+ GzhOpenId string `gorm:"column:gzh_open_id;type:varchar(255);comment:gzh_open_id"`
|
|
|
+ UnionId string `gorm:"column:union_id;type:varchar(50);comment:union_id"`
|
|
|
+ ReadCount int `gorm:"column:read_count;type:int(11);comment:阅读次数"`
|
|
|
+ LastReadTime time.Time `gorm:"column:last_read_time;type:timestamps;comment:最后阅读时间"`
|
|
|
+ IsDeleted int `gorm:"column:is_deleted;type:int(11);comment:是否删除"`
|
|
|
+ CreatedTime time.Time `gorm:"column:created_time;type:timestamps;comment:创建时间"`
|
|
|
+ UpdatedTime time.Time `gorm:"column:updated_time;type:timestamps;comment:更新时间"`
|
|
|
}
|
|
|
|
|
|
func (t *TemplateUser) BeforeCreate(tx *gorm.DB) (err error) {
|
|
@@ -32,6 +34,9 @@ func (t *TemplateUser) BeforeCreate(tx *gorm.DB) (err error) {
|
|
|
func GetUserByMobile(mobile string) (user TemplateUser, err error) {
|
|
|
return queryByColumn("mobile", mobile)
|
|
|
}
|
|
|
+func GetUserByIdAndCountReadTimes(userId int) (err error) {
|
|
|
+ return models.Main().Model(&TemplateUser{}).Where("id = ?", userId).Update("read_count", gorm.Expr("read_count + ?", 1)).Error
|
|
|
+}
|
|
|
|
|
|
func GetUserByOpenId(openId string) (user TemplateUser, err error) {
|
|
|
return queryByColumn("open_id", openId)
|