diff --git a/src/dao/user_dao.go b/src/dao/user_dao.go index fa65495..5065ea8 100644 --- a/src/dao/user_dao.go +++ b/src/dao/user_dao.go @@ -5,4 +5,5 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type UserDao interface { UserGetOneByParams(params map[string]interface{}) (*model.User, error) UserFindByParams(params map[string]interface{}) ([]model.User, error) + UserUpdate(id interface{}, user *model.User, forceColumns ...string) (int64, error) } diff --git a/src/dao/user_tag_dao.go b/src/dao/user_tag_dao.go new file mode 100644 index 0000000..25c6f98 --- /dev/null +++ b/src/dao/user_tag_dao.go @@ -0,0 +1,8 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type UserTagDao interface { + //TODO:: You can add specific method definitions here + UserTagAllByAsc() ([]*model.UserTag, error) +} diff --git a/src/dao/user_tag_records_dao.go b/src/dao/user_tag_records_dao.go new file mode 100644 index 0000000..cb944f7 --- /dev/null +++ b/src/dao/user_tag_records_dao.go @@ -0,0 +1,9 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type UserTagRecordsDao interface { + //TODO:: You can add specific method definitions here + UserTagRecordsGetOneByParams(params map[string]interface{}) (*model.UserTagRecords, error) + UserTagRecordsUpdate(uid interface{}, user *model.UserTagRecords, forceColumns ...string) (int64, error) +} diff --git a/src/implement/user_implement.go b/src/implement/user_implement.go index 3ee8896..c86997d 100644 --- a/src/implement/user_implement.go +++ b/src/implement/user_implement.go @@ -43,3 +43,19 @@ func (u UserDb) UserFindByParams(params map[string]interface{}) ([]model.User, e } return m, nil } + +func (u UserDb) UserUpdate(id interface{}, user *model.User, forceColumns ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColumns != nil { + affected, err = u.Db.Where("id=?", id).Cols(forceColumns...).Update(user) + } else { + affected, err = u.Db.Where("id=?", id).Update(user) + } + if err != nil { + return 0, err + } + return affected, nil +} diff --git a/src/implement/user_tag_implement.go b/src/implement/user_tag_implement.go new file mode 100644 index 0000000..c60d8e9 --- /dev/null +++ b/src/implement/user_tag_implement.go @@ -0,0 +1,25 @@ +package implement + +import ( + "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" + "xorm.io/xorm" +) + +func NewUserTagDb(engine *xorm.Engine) dao.UserTagDao { + return &UserTagDb{Db: engine} +} + +type UserTagDb struct { + Db *xorm.Engine +} + +func (u UserTagDb) UserTagAllByAsc() ([]*model.UserTag, error) { + var m []*model.UserTag + err := u.Db.Asc("id").Find(&m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + return m, nil +} diff --git a/src/implement/user_tag_records_implement.go b/src/implement/user_tag_records_implement.go new file mode 100644 index 0000000..af8969c --- /dev/null +++ b/src/implement/user_tag_records_implement.go @@ -0,0 +1,42 @@ +package implement + +import ( + "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" + "fmt" + "xorm.io/xorm" +) + +func NewUserTagRecordsDb(engine *xorm.Engine) dao.UserTagRecordsDao { + return &UserTagRecordsDb{Db: engine} +} + +type UserTagRecordsDb struct { + Db *xorm.Engine +} + +func (u UserTagRecordsDb) UserTagRecordsGetOneByParams(params map[string]interface{}) (*model.UserTagRecords, error) { + var m model.UserTagRecords + var query = fmt.Sprintf("%s = ?", params["key"]) + if has, err := u.Db.Where(query, params["value"]).Get(&m); err != nil || has == false { + return nil, zhios_order_relate_logx.Error(err) + } + return &m, nil +} + +func (u UserTagRecordsDb) UserTagRecordsUpdate(uid interface{}, user *model.UserTagRecords, forceColumns ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColumns != nil { + affected, err = u.Db.Where("uid=?", uid).Cols(forceColumns...).Update(user) + } else { + affected, err = u.Db.Where("uid=?", uid).Update(user) + } + if err != nil { + return 0, err + } + return affected, nil +} diff --git a/src/model/user.go b/src/model/user.go index 7df8a35..b6a07a9 100644 --- a/src/model/user.go +++ b/src/model/user.go @@ -1,23 +1,29 @@ package model +import ( + "time" +) + type User struct { - Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` - Phone string `json:"phone" xorm:"not null default '' comment('手机号') VARCHAR(255)"` - UnionId string `json:"union_id" xorm:"not null default '' comment('微信用户id') VARCHAR(255)"` - OpenId string `json:"open_id" xorm:"not null default '' comment('微信openid') VARCHAR(255)"` - Nickname string `json:"nickname" xorm:"not null default '' comment('昵称') VARCHAR(255)"` - Avatar string `json:"avatar" xorm:"not null default '' comment('头像') VARCHAR(255)"` - Password string `json:"password" xorm:"not null default '' comment('密码') CHAR(50)"` - Passcode string `json:"passcode" xorm:"not null default '' comment('支付密码') CHAR(50)"` - Level int `json:"level" xorm:"not null default 0 comment('用户等级id') INT(11)"` - InviteTotal int `json:"invite_total" xorm:"not null default 0 comment('直推邀请总人数') INT(11)"` - State int `json:"state" xorm:"not null default 1 comment('1正常,2冻结') TINYINT(1)"` - LastLoginIp string `json:"last_login_ip" xorm:"not null default '' comment('最后登录IP') CHAR(50)"` - Sex int `json:"sex" xorm:"not null default 0 comment('性别(0:未知 1:男 2:女)') TINYINT(1)"` - ParentUid int64 `json:"parent_uid" xorm:"not null default 0 comment('父级id') BIGINT(20)"` - SystemInviteCode string `json:"system_invite_code" xorm:"not null default '' comment('系统邀请码') CHAR(50)"` - CustomInviteCode string `json:"custom_invite_code" xorm:"not null default '' comment('自定义邀请码') CHAR(50)"` - Memo string `json:"memo" xorm:"not null default '' comment('备注信息') VARCHAR(244)"` - CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` - UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` + Phone string `json:"phone" xorm:"not null default '' comment('手机号') VARCHAR(255)"` + UnionId string `json:"union_id" xorm:"not null default '' comment('微信用户id') VARCHAR(255)"` + OpenId string `json:"open_id" xorm:"not null default '' comment('微信openid') VARCHAR(255)"` + Nickname string `json:"nickname" xorm:"not null default '' comment('昵称') VARCHAR(255)"` + Avatar string `json:"avatar" xorm:"not null default '' comment('头像') VARCHAR(255)"` + Password string `json:"password" xorm:"not null default '' comment('密码') CHAR(50)"` + Passcode string `json:"passcode" xorm:"not null default '' comment('支付密码') CHAR(50)"` + Level int `json:"level" xorm:"not null default 0 comment('用户等级id') INT(11)"` + InviteTotal int `json:"invite_total" xorm:"not null default 0 comment('直推邀请总人数') INT(11)"` + State int `json:"state" xorm:"not null default 1 comment('1正常,2冻结') TINYINT(1)"` + LastLoginIp string `json:"last_login_ip" xorm:"not null default '' comment('最后登录IP') CHAR(50)"` + Sex int `json:"sex" xorm:"not null default 0 comment('性别(0:未知 1:男 2:女)') TINYINT(1)"` + ParentUid int64 `json:"parent_uid" xorm:"not null default 0 comment('父级id') BIGINT(20)"` + SystemInviteCode string `json:"system_invite_code" xorm:"not null default '' comment('系统邀请码') CHAR(50)"` + CustomInviteCode string `json:"custom_invite_code" xorm:"not null default '' comment('自定义邀请码') CHAR(50)"` + Memo string `json:"memo" xorm:"not null default '' comment('备注信息') VARCHAR(244)"` + CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + IsRealName int `json:"is_real_name" xorm:"not null default 0 comment('0.未知,1.未实名,2.已实名') TINYINT(1)"` + RegisterType int `json:"register_type" xorm:"not null comment('注册类型(0.未知, 1:免验证码手机号注册,2.微信授权)') TINYINT(3)"` } diff --git a/src/model/user_tag.go b/src/model/user_tag.go new file mode 100644 index 0000000..c656652 --- /dev/null +++ b/src/model/user_tag.go @@ -0,0 +1,14 @@ +package model + +import ( + "time" +) + +type UserTag struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + TagName string `json:"tag_name" xorm:"not null default '' comment('tag名') index VARCHAR(16)"` + Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(80)"` + IsPunish int `json:"is_punish" xorm:"not null default 0 comment('是否为处罚标签(0:否 1:是)') TINYINT(1)"` + CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` +} diff --git a/src/model/user_tag_records.go b/src/model/user_tag_records.go new file mode 100644 index 0000000..e7a5ef5 --- /dev/null +++ b/src/model/user_tag_records.go @@ -0,0 +1,14 @@ +package model + +import ( + "time" +) + +type UserTagRecords struct { + Id int `json:"id" xorm:"not null pk autoincr comment('主键') INT(11)"` + TagId int `json:"tag_id" xorm:"not null default 0 INT(11)"` + Uid int64 `json:"uid" xorm:"not null default 0 comment('关联UserID') BIGINT(20)"` + Memo string `json:"memo" xorm:"not null default '' comment('备注') CHAR(50)"` + CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` +}