@@ -2,12 +2,13 @@ package dao | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | ||||
"xorm.io/xorm" | |||||
) | ) | ||||
type UserDao interface { | type UserDao interface { | ||||
UserGetOneByParams(params map[string]interface{}) (*model.User, error) | UserGetOneByParams(params map[string]interface{}) (*model.User, error) | ||||
UserFindByParams(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) | |||||
UserUpdateBySession(session *xorm.Session, id interface{}, user *model.User, forceColumns ...string) (int64, error) | |||||
UserFindAndCount(uid int64, phone string, nickname string, level int, page, limit int) (*[]model.User, int64, error) | UserFindAndCount(uid int64, phone string, nickname string, level int, page, limit int) (*[]model.User, int64, error) | ||||
UserFindByInviteCodes(codes ...string) (*[]model.User, error) | UserFindByInviteCodes(codes ...string) (*[]model.User, error) | ||||
UserFindByCustomInviteCodes(codes ...string) (*[]model.User, error) | UserFindByCustomInviteCodes(codes ...string) (*[]model.User, error) | ||||
@@ -1,4 +1,4 @@ | |||||
package dao | |||||
package dao | |||||
import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | ||||
@@ -9,4 +9,7 @@ type UserLevelDao interface { | |||||
UserLevelByID(id interface{}) (*model.UserLevel, error) | UserLevelByID(id interface{}) (*model.UserLevel, error) | ||||
//UserLevelAllByAsc 获取所有开启等级并且升序返回 | //UserLevelAllByAsc 获取所有开启等级并且升序返回 | ||||
UserLevelAllByAsc() ([]*model.UserLevel, error) | UserLevelAllByAsc() ([]*model.UserLevel, error) | ||||
// UserLevelAllByAscByPage 获取所有开启等级升序分页返回 | |||||
UserLevelAllByAscByPage(page, limit int) ([]*model.UserLevel, int64, error) | |||||
UserLevelUpdate(id interface{}, level *model.UserLevel, forceColumns ...string) (int64, error) | |||||
} | } |
@@ -1,6 +1,9 @@ | |||||
package dao | |||||
package dao | |||||
import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
import ( | |||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
"xorm.io/xorm" | |||||
) | |||||
type UserRelateDao interface { | type UserRelateDao interface { | ||||
FindUserRelate(uid int64, level int) (*[]model.UserRelate, error) | FindUserRelate(uid int64, level int) (*[]model.UserRelate, error) | ||||
@@ -9,4 +12,5 @@ type UserRelateDao interface { | |||||
SumUserRelateByParentUid(parentUid string) (total int64, userRelate []*model.UserRelate, err error) | SumUserRelateByParentUid(parentUid string) (total int64, userRelate []*model.UserRelate, err error) | ||||
PageFindUserRelateByParentUid(uid int64, page, pageSize int) (*[]model.UserRelate, int64, error) | PageFindUserRelateByParentUid(uid int64, page, pageSize int) (*[]model.UserRelate, int64, error) | ||||
PageFindUserRelateByParentUidAndLevel(uid int64, page, limit int, level int) (*[]model.UserRelate, int64, error) | PageFindUserRelateByParentUidAndLevel(uid int64, page, limit int, level int) (*[]model.UserRelate, int64, error) | ||||
UpdateUserRelateBySession(session *xorm.Session, uid int64, relate *model.UserRelate, forceColumns ...string) (int64, error) | |||||
} | } |
@@ -1,8 +1,14 @@ | |||||
package dao | |||||
package dao | |||||
import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
import ( | |||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
"xorm.io/xorm" | |||||
) | |||||
type UserTagDao interface { | type UserTagDao interface { | ||||
//TODO:: You can add specific method definitions here | //TODO:: You can add specific method definitions here | ||||
UserTagAllByAsc() ([]*model.UserTag, error) | UserTagAllByAsc() ([]*model.UserTag, error) | ||||
UserTagAllByAscByPage(page, limit int) (*[]model.UserTag, int64, error) | |||||
UserTagUpdate(id interface{}, userTag *model.UserTag, forceColumns ...string) (int64, error) | |||||
UserTagDeleteBySession(session *xorm.Session, tagID interface{}) (int64, error) | |||||
} | } |
@@ -1,9 +1,13 @@ | |||||
package dao | |||||
package dao | |||||
import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
import ( | |||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
"xorm.io/xorm" | |||||
) | |||||
type UserTagRecordsDao interface { | type UserTagRecordsDao interface { | ||||
//TODO:: You can add specific method definitions here | //TODO:: You can add specific method definitions here | ||||
UserTagRecordsGetOneByParams(params map[string]interface{}) (*model.UserTagRecords, error) | UserTagRecordsGetOneByParams(params map[string]interface{}) (*model.UserTagRecords, error) | ||||
UserTagRecordsUpdate(uid interface{}, user *model.UserTagRecords, forceColumns ...string) (int64, error) | |||||
UserTagRecordsUpdateBySession(session *xorm.Session, uid interface{}, user *model.UserTagRecords, forceColumns ...string) (int64, error) | |||||
UserTagRecordDeleteBySession(session *xorm.Session, tagID int64) (int64, error) | |||||
} | } |
@@ -60,15 +60,15 @@ func (u UserDb) UserFindByParams(params map[string]interface{}) ([]model.User, e | |||||
return m, nil | return m, nil | ||||
} | } | ||||
func (u UserDb) UserUpdate(id interface{}, user *model.User, forceColumns ...string) (int64, error) { | |||||
func (u UserDb) UserUpdateBySession(session *xorm.Session, id interface{}, user *model.User, forceColumns ...string) (int64, error) { | |||||
var ( | var ( | ||||
affected int64 | affected int64 | ||||
err error | err error | ||||
) | ) | ||||
if forceColumns != nil { | if forceColumns != nil { | ||||
affected, err = u.Db.Where("id=?", id).MustCols(forceColumns...).Update(user) | |||||
affected, err = session.Where("id=?", id).MustCols(forceColumns...).Update(user) | |||||
} else { | } else { | ||||
affected, err = u.Db.Where("id=?", id).Update(user) | |||||
affected, err = session.Where("id=?", id).Update(user) | |||||
} | } | ||||
if err != nil { | if err != nil { | ||||
return 0, err | return 0, err | ||||
@@ -1,4 +1,4 @@ | |||||
package implement | |||||
package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | ||||
@@ -49,3 +49,28 @@ func (u UserLevelDb) UserLevelAllByAsc() ([]*model.UserLevel, error) { | |||||
} | } | ||||
return m, nil | return m, nil | ||||
} | } | ||||
func (u UserLevelDb) UserLevelAllByAscByPage(page, limit int) ([]*model.UserLevel, int64, error) { | |||||
var m []*model.UserLevel | |||||
total, err := u.Db.Where("is_use = ?", 1).Asc("level_weight").FindAndCount(&m) | |||||
if err != nil { | |||||
return nil, 0, zhios_order_relate_logx.Warn(err) | |||||
} | |||||
return m, total, nil | |||||
} | |||||
func (u UserLevelDb) UserLevelUpdate(id interface{}, userLevel *model.UserLevel, forceColumns ...string) (int64, error) { | |||||
var ( | |||||
affected int64 | |||||
err error | |||||
) | |||||
if forceColumns != nil { | |||||
affected, err = u.Db.Where("id=?", id).MustCols(forceColumns...).Update(userLevel) | |||||
} else { | |||||
affected, err = u.Db.Where("id=?", id).Update(userLevel) | |||||
} | |||||
if err != nil { | |||||
return 0, zhios_order_relate_logx.Error(err.Error()) | |||||
} | |||||
return affected, nil | |||||
} |
@@ -1,4 +1,4 @@ | |||||
package implement | |||||
package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | ||||
@@ -85,3 +85,19 @@ func (u UserRelateDb) PageFindUserRelateByParentUidAndLevel(uid int64, page, lim | |||||
} | } | ||||
return &userRelate, total, nil | return &userRelate, total, nil | ||||
} | } | ||||
func (u UserRelateDb) UpdateUserRelateBySession(session *xorm.Session, uid int64, relate *model.UserRelate, forceColumns ...string) (int64, error) { | |||||
var ( | |||||
affected int64 | |||||
err error | |||||
) | |||||
if forceColumns != nil { | |||||
affected, err = session.Where("uid=?", uid).MustCols(forceColumns...).Update(relate) | |||||
} else { | |||||
affected, err = session.Where("uid=?", uid).Update(relate) | |||||
} | |||||
if err != nil { | |||||
return 0, zhios_order_relate_logx.Error(err.Error()) | |||||
} | |||||
return affected, nil | |||||
} |
@@ -1,9 +1,10 @@ | |||||
package implement | |||||
package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | ||||
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" | zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" | ||||
"reflect" | |||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
) | ) | ||||
@@ -23,3 +24,36 @@ func (u UserTagDb) UserTagAllByAsc() ([]*model.UserTag, error) { | |||||
} | } | ||||
return m, nil | return m, nil | ||||
} | } | ||||
func (u UserTagDb) UserTagAllByAscByPage(page, limit int) (*[]model.UserTag, int64, error) { | |||||
var m []model.UserTag | |||||
total, err := u.Db.Asc("id").Limit(limit, (page-1)*limit).FindAndCount(&m) | |||||
if err != nil { | |||||
return nil, 0, zhios_order_relate_logx.Error(err) | |||||
} | |||||
return &m, total, nil | |||||
} | |||||
func (u UserTagDb) UserTagUpdate(id interface{}, userTag *model.UserTag, forceColumns ...string) (int64, error) { | |||||
var ( | |||||
affected int64 | |||||
err error | |||||
) | |||||
if forceColumns != nil { | |||||
affected, err = u.Db.Where("id=?", id).MustCols(forceColumns...).Update(userTag) | |||||
} else { | |||||
affected, err = u.Db.Where("id=?", id).Update(userTag) | |||||
} | |||||
if err != nil { | |||||
return 0, zhios_order_relate_logx.Error(err.Error()) | |||||
} | |||||
return affected, nil | |||||
} | |||||
func (u UserTagDb) UserTagDeleteBySession(session *xorm.Session, tagID interface{}) (int64, error) { | |||||
if reflect.TypeOf(tagID).Kind() == reflect.Slice { | |||||
return session.In("id", tagID).Delete(model.UserTag{}) | |||||
} else { | |||||
return session.Where("id = ?", tagID).Delete(model.UserTag{}) | |||||
} | |||||
} |
@@ -1,4 +1,4 @@ | |||||
package implement | |||||
package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | ||||
@@ -25,18 +25,26 @@ func (u UserTagRecordsDb) UserTagRecordsGetOneByParams(params map[string]interfa | |||||
return &m, nil | return &m, nil | ||||
} | } | ||||
func (u UserTagRecordsDb) UserTagRecordsUpdate(uid interface{}, user *model.UserTagRecords, forceColumns ...string) (int64, error) { | |||||
func (u UserTagRecordsDb) UserTagRecordsUpdateBySession(session *xorm.Session, uid interface{}, user *model.UserTagRecords, forceColumns ...string) (int64, error) { | |||||
var ( | var ( | ||||
affected int64 | affected int64 | ||||
err error | err error | ||||
) | ) | ||||
if forceColumns != nil { | if forceColumns != nil { | ||||
affected, err = u.Db.Where("uid=?", uid).Cols(forceColumns...).Update(user) | |||||
affected, err = session.Where("uid=?", uid).Cols(forceColumns...).Update(user) | |||||
} else { | } else { | ||||
affected, err = u.Db.Where("uid=?", uid).Update(user) | |||||
affected, err = session.Where("uid=?", uid).Update(user) | |||||
} | } | ||||
if err != nil { | if err != nil { | ||||
return 0, err | return 0, err | ||||
} | } | ||||
return affected, nil | return affected, nil | ||||
} | } | ||||
func (u UserTagRecordsDb) UserTagRecordDeleteBySession(session *xorm.Session, tagID int64) (int64, error) { | |||||
affected, err := session.Where("tag_id = ?", tagID).Delete(model.UserTagRecords{}) | |||||
if err != nil { | |||||
return 0, zhios_order_relate_logx.Error(err.Error()) | |||||
} | |||||
return affected, nil | |||||
} |