Browse Source

git fix

master
dengbiao 6 days ago
parent
commit
bbf44c7edf
10 changed files with 120 additions and 19 deletions
  1. +2
    -1
      src/dao/user_dao.go
  2. +4
    -1
      src/dao/user_level_dao.go
  3. +6
    -2
      src/dao/user_relate_dao.go
  4. +8
    -2
      src/dao/user_tag_dao.go
  5. +7
    -3
      src/dao/user_tag_records_dao.go
  6. +3
    -3
      src/implement/user_implement.go
  7. +26
    -1
      src/implement/user_level_implement.go
  8. +17
    -1
      src/implement/user_relate_implement.go
  9. +35
    -1
      src/implement/user_tag_implement.go
  10. +12
    -4
      src/implement/user_tag_records_implement.go

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

@@ -2,12 +2,13 @@ package dao

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)
UserFindByInviteCodes(codes ...string) (*[]model.User, error)
UserFindByCustomInviteCodes(codes ...string) (*[]model.User, error)


+ 4
- 1
src/dao/user_level_dao.go View File

@@ -1,4 +1,4 @@
package dao
package dao

import "code.fnuoos.com/EggPlanet/egg_models.git/src/model"

@@ -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)
}

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

@@ -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 {
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)
}

+ 8
- 2
src/dao/user_tag_dao.go View File

@@ -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 {
//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)
}

+ 7
- 3
src/dao/user_tag_records_dao.go View File

@@ -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 {
//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

@@ -60,15 +60,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


+ 26
- 1
src/implement/user_level_implement.go View File

@@ -1,4 +1,4 @@
package implement
package implement

import (
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
@@ -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
}

+ 17
- 1
src/implement/user_relate_implement.go View File

@@ -1,4 +1,4 @@
package implement
package implement

import (
"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
}

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
}

+ 35
- 1
src/implement/user_tag_implement.go View File

@@ -1,9 +1,10 @@
package implement
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"
"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{})
}
}

+ 12
- 4
src/implement/user_tag_records_implement.go View File

@@ -1,4 +1,4 @@
package implement
package implement

import (
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
@@ -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