Browse Source

add membe_center

master
shenjiachi 1 month ago
parent
commit
d30667f88d
10 changed files with 115 additions and 12 deletions
  1. +5
    -2
      src/dao/user_dao.go
  2. +3
    -0
      src/dao/user_level_dao.go
  3. +5
    -1
      src/dao/user_relate_dao.go
  4. +7
    -1
      src/dao/user_tag_dao.go
  5. +6
    -2
      src/dao/user_tag_records_dao.go
  6. +3
    -3
      src/implement/user_implement.go
  7. +25
    -0
      src/implement/user_level_implement.go
  8. +16
    -0
      src/implement/user_relate_implement.go
  9. +34
    -0
      src/implement/user_tag_implement.go
  10. +11
    -3
      src/implement/user_tag_records_implement.go

+ 5
- 2
src/dao/user_dao.go View File

@@ -1,10 +1,13 @@
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 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)
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)
}

+ 3
- 0
src/dao/user_level_dao.go View File

@@ -9,4 +9,7 @@ type UserLevelDao interface {
UserLevelByID(id interface{}) (*model.UserLevel, error)
//UserLevelAllByAsc 获取所有开启等级并且升序返回
UserLevelAllByAsc() ([]*model.UserLevel, error)
// UserLevelAllByAscByPage 获取所有开启等级升序分页返回
UserLevelAllByAscByPage(page, limit int) ([]*model.UserLevel, int64, error)
UserLevelUpdate(id interface{}, level *model.UserLevel, forceColumns ...string) (int64, error)
}

+ 5
- 1
src/dao/user_relate_dao.go View File

@@ -1,6 +1,9 @@
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 {
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)
PageFindUserRelateByParentUid(uid int64, page, pageSize 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)
}

+ 7
- 1
src/dao/user_tag_dao.go View File

@@ -1,8 +1,14 @@
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 {
//TODO:: You can add specific method definitions here
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)
}

+ 6
- 2
src/dao/user_tag_records_dao.go View File

@@ -1,9 +1,13 @@
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 {
//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)
UserTagRecordsUpdateBySession(session *xorm.Session, uid interface{}, user *model.UserTagRecords, forceColumns ...string) (int64, error)
UserTagRecordDeleteBySession(session *xorm.Session, tagID int64) (int64, error)
}

+ 3
- 3
src/implement/user_implement.go View File

@@ -44,15 +44,15 @@ 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) {
func (u UserDb) UserUpdateBySession(session *xorm.Session, id interface{}, user *model.User, forceColumns ...string) (int64, error) {
var (
affected int64
err error
)
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 {
affected, err = u.Db.Where("id=?", id).Update(user)
affected, err = session.Where("id=?", id).Update(user)
}
if err != nil {
return 0, err


+ 25
- 0
src/implement/user_level_implement.go View File

@@ -49,3 +49,28 @@ func (u UserLevelDb) UserLevelAllByAsc() ([]*model.UserLevel, error) {
}
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
}

+ 16
- 0
src/implement/user_relate_implement.go View File

@@ -85,3 +85,19 @@ func (u UserRelateDb) PageFindUserRelateByParentUidAndLevel(uid int64, page, lim
}
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
}

+ 34
- 0
src/implement/user_tag_implement.go View File

@@ -4,6 +4,7 @@ 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"
"reflect"
"xorm.io/xorm"
)

@@ -23,3 +24,36 @@ func (u UserTagDb) UserTagAllByAsc() ([]*model.UserTag, error) {
}
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{})
}
}

+ 11
- 3
src/implement/user_tag_records_implement.go View File

@@ -25,18 +25,26 @@ func (u UserTagRecordsDb) UserTagRecordsGetOneByParams(params map[string]interfa
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 (
affected int64
err error
)
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 {
affected, err = u.Db.Where("uid=?", uid).Update(user)
affected, err = session.Where("uid=?", uid).Update(user)
}
if err != nil {
return 0, err
}
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
}

Loading…
Cancel
Save