소스 검색

update

master
shenjiachi 6 일 전
부모
커밋
5550bb806e
6개의 변경된 파일468개의 추가작업 그리고 8개의 파일을 삭제
  1. +3
    -6
      app/hdl/institutional_management/public_platoon/hdl_basic.go
  2. +266
    -0
      app/hdl/member_center/hdl_user_management.go
  3. +119
    -0
      app/md/institutional_management/member_center/md_user_management.go
  4. +10
    -0
      app/router/router.go
  5. +68
    -0
      app/svc/member_center/svc_user_management.go
  6. +2
    -2
      go.mod

+ 3
- 6
app/hdl/institutional_management/public_platoon/hdl_basic.go 파일 보기

@@ -103,17 +103,14 @@ func UpdatePublicPlatoonBasic(c *gin.Context) {
CreateAt: "",
UpdateAt: "",
}
forceColumns := []string{"is_open", "system_punish_replace", "is_self_active_get_team_revenue"}
forceColumns := []string{"is_open", "originator_uid", "system_punish_replace", "is_self_active_get_team_revenue", "several_times", "several_rows", "system_punish_replace_value"}

updateAffected, err := publicPlatoonBasicDb.PublicPlatoonBasicSettingUpdate(publicPlatoonBasic.Id, setting, forceColumns...)
_, err = publicPlatoonBasicDb.PublicPlatoonBasicSettingUpdate(publicPlatoonBasic.Id, setting, forceColumns...)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if updateAffected <= 0 {
e.OutErr(c, e.ERR_DB_ORM, "更新数据表失败")
return
}

e.OutSuc(c, "success", nil)
}



+ 266
- 0
app/hdl/member_center/hdl_user_management.go 파일 보기

@@ -0,0 +1,266 @@
package member_center

import (
"applet/app/db"
"applet/app/e"
md "applet/app/md/institutional_management/member_center"
svc "applet/app/svc/member_center"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"github.com/gin-gonic/gin"
)

// UserManagementGetUserList
// @Summary 制度中心-会员中心-用户信息管理(获取)
// @Tags 会员中心
// @Description 用户信息管理(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body md.UserManagementGetUserListReq true "分页信息必填"
// @Success 200 {object} md.UserManagementGetUserListResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/userManagement/getUserList [post]
func UserManagementGetUserList(c *gin.Context) {
var req *md.UserManagementGetUserListReq
if err := c.ShouldBindJSON(&req); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
return
}

levelDb := implement.NewUserLevelDb(db.Db)
levels, err1 := levelDb.UserLevelAllByAsc()
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
levelsList := make([]map[string]interface{}, 0)
levelsMap := make(map[int]string)
for _, level := range levels {
levelsList = append(levelsList, map[string]interface{}{
"id": level.Id,
"name": level.LevelName,
})
levelsMap[level.Id] = level.LevelName
}

tagDb := implement.NewUserTagDb(db.Db)
tags, err2 := tagDb.UserTagAllByAsc()
if err2 != nil {
e.OutErr(c, e.ERR_DB_ORM, err2.Error())
return
}
tagsList := make([]map[string]interface{}, 0)
tagsMap := make(map[int]string)
for _, tag := range tags {
tagsList = append(tagsList, map[string]interface{}{
"id": tag.Id,
"name": tag.TagName,
})
tagsMap[tag.Id] = tag.TagName
}

users, total, err3 := svc.UserManagementGetUsers(db.Db, req)
if err3 != nil {
e.OutErr(c, e.ERR_DB_ORM, err3.Error())
return
}

var levelCounts []md.LevelCount
err4 := db.Db.Table("user").Select("level, Count(*) AS count").GroupBy("level").Find(&levelCounts)
if err4 != nil {
e.OutErr(c, e.ERR_DB_ORM, err4.Error())
return
}

list := make([]md.UserManagementGetUserListNode, len(*users))
for i, user := range *users {
list[i] = md.UserManagementGetUserListNode{
ID: user.Id,
Tag: tagsMap[user.TagID],
Avatar: user.Avatar,
Nickname: user.Nickname,
Phone: user.Phone,
IsRealName: user.IsRealName,
Level: levelsMap[user.Level],
InviteCode: user.SystemInviteCode,
ParentID: user.ParentUid,
ParentInviteCode: user.ParentSystemInviteCode,
ParentPhone: user.Phone,
RegisterTime: user.CreateAt,
Memo: user.Memo,
}
}

resp := md.UserManagementGetUserListResp{
LevelsList: levelsList,
TagsList: tagsList,
List: list,
Paginate: md.Paginate{
Limit: req.Limit,
Page: req.Page,
Total: total,
},
}
e.OutSuc(c, resp, nil)
}

// UserManagementUpdateUserInfo
// @Summary 制度中心-会员中心-用户信息管理(更新)
// @Tags 会员中心
// @Description 用户信息管理(更新)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body md.UserManagementUpdateUserInfoReq true "用户ID 必传"
// @Success 200 {int} "修改数据行数"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/userManagement/updateUserInfo [post]
func UserManagementUpdateUserInfo(c *gin.Context) {
var req *md.UserManagementUpdateUserInfoReq
if err := c.ShouldBindJSON(&req); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
return
}

userDb := implement.NewUserDb(db.Db)

var affected int64
var err1 error
forceColumns := make([]string, 0)
user := model.User{
Id: req.UID,
}
if req.Memo != "" {
user.Memo = req.Memo
forceColumns = append(forceColumns, "memo")
}
if req.Disable != false {
user.State = 2
forceColumns = append(forceColumns, "state")
}
if req.LastLoginIp != "" {
user.LastLoginIp = req.LastLoginIp
forceColumns = append(forceColumns, "last_login_ip")
}
if req.Avatar != "" {
user.Avatar = req.Avatar
forceColumns = append(forceColumns, "avatar")
}
if len(forceColumns) > 0 {
affected, err1 = userDb.UserUpdate(req.UID, &user)
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
}

var err2 error
if req.Tag != 0 {
record := model.UserTagRecords{
TagId: req.Tag,
}
recordsDb := implement.NewUserTagRecordsDb(db.Db)
affected, err2 = recordsDb.UserTagRecordsUpdate(req.UID, &record, "tag_id")
if err2 != nil {
e.OutErr(c, e.ERR_DB_ORM, err2.Error())
return
}

}

e.OutSuc(c, affected, nil)
}

// UserManagementGetOneBasic
// @Summary 制度中心-会员中心-会员明细概况(获取)
// @Tags 会员中心
// @Description 会员明细概况(更新)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param uid query int true "用户 ID"
// @Success 200 {object} md.UserManagementGetOneBasicResp "会员明细概况具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/userManagement/getOneBasicInfo [get]
//func UserManagementGetOneBasic(c *gin.Context) {
// uid := c.Query("uid")
// userDb := implement.NewUserDb(db.Db)
// user, err := userDb.UserGetOneByParams(map[string]interface{}{
// "key": "id",
// "value": uid,
// })
// if err != nil {
// e.OutErr(c, e.ERR_DB_ORM, err.Error())
// return
// }
//
// levelDb := implement.NewUserLevelDb(db.Db)
// levels, err1 := levelDb.UserLevelAllByAsc()
// if err1 != nil {
// e.OutErr(c, e.ERR_DB_ORM, err1.Error())
// return
// }
// levelsList := make([]map[string]interface{}, 0)
// levelsMap := make(map[int]string)
// for _, level := range levels {
// levelsList = append(levelsList, map[string]interface{}{
// "id": level.Id,
// "name": level.LevelName,
// })
// levelsMap[level.Id] = level.LevelName
// }
//
// tagDb := implement.NewUserTagDb(db.Db)
// tags, err2 := tagDb.UserTagAllByAsc()
// if err2 != nil {
// e.OutErr(c, e.ERR_DB_ORM, err2.Error())
// return
// }
// tagsList := make([]map[string]interface{}, 0)
// tagsMap := make(map[int]string)
// for _, tag := range tags {
// tagsList = append(tagsList, map[string]interface{}{
// "id": tag.Id,
// "name": tag.TagName,
// })
// tagsMap[tag.Id] = tag.TagName
// }
//
// coinDb := implement.NewVirtualCoinDb(db.Db)
// coins, err3 := coinDb.VirtualCoinFindAll()
// if err3 != nil {
// e.OutErr(c, e.ERR_DB_ORM, err3.Error())
// return
// }
// coinsList := make([]map[string]interface{}, 0)
// coinsMap := make(map[int]string)
// for _, coin := range coins {
// coinsList = append(coinsList, map[string]interface{}{
// "id": coin.Id,
// "name": coin.Name,
// })
// coinsMap[coin.Id] = coin.Name
// }
//
// parent, err := userDb.UserGetOneByParams(map[string]interface{}{
// "key": "id",
// "value": user.ParentUid,
// })
// if err != nil {
// e.OutErr(c, e.ERR_DB_ORM, err.Error())
// return
// }
//
// recordsDb := implement.NewUserTagRecordsDb(db.Db)
// userTagRecord, err := recordsDb.UserTagRecordsGetOneByParams(map[string]interface{}{
// "key": "uid",
// "value": uid,
// })
// if err != nil {
// return
// }
//
// amountDb := implement.NewUserVirtualAmountDb(db.Db)
// amountDb.GetUserVirtualWalletBySession()
//}

+ 119
- 0
app/md/institutional_management/member_center/md_user_management.go 파일 보기

@@ -0,0 +1,119 @@
package md

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

type UserManagementGetUserListReq struct {
ID int64 `json:"id"` // 会员 ID
Nickname string `json:"nickname" example:"会员昵称"`
RecommendID int64 `json:"recommend_id"` // 推荐人 ID
Tag int `json:"tag"` // 标签 id
Phone string `json:"phone" example:"会员手机号"`
InviteCode string `json:"invite_code" example:"会员邀请码"`
ParentInviteCode string `json:"parent_invite_code" example:"上级邀请码"`
ParentPhone string `json:"parent_phone" example:"上级手机号"`
Sex int `json:"sex"` // 性别
UnionId string `json:"union_id" example:"微信号"`
Level int `json:"level"` // 会员等级
RegisterType int `json:"register_type"` // 注册类型(0.未知, 1.免验证码手机号注册,2.微信授权)
State int `json:"state"` // 状态
Effective int `json:"effective"` // 有效会员
IsRealName int `json:"is_real_name"` // 是否实名 0.未实名,1.已实名
Memo string `json:"memo"` // 备注
RegisterBefore string `json:"register_before"` // 注册时间起点
RegisterAfter string `json:"register_after"` // 注册时间终点
LoginBefore string `json:"login_before"` // 最近登录开始时间
LoginAfter string `json:"login_after"` // 最近登录结束时间
Page int `json:"page"`
Limit int `json:"limit"`
}

type Paginate struct {
Limit int `json:"limit"` // 每页大小
Page int `json:"page"` // 页数
Total int64 `json:"total"` // 总数据量
}

type UserManagementGetUserListNode struct {
ID int64 `json:"id"` // 会员 ID
Tag string `json:"tag_name"` // 会员标签
Avatar string `json:"avatar"` // 头像
Nickname string `json:"nickname"` // 昵称
Phone string `json:"phone"` // 手机号
IsRealName int `json:"is_real_name"` // 是否实名 0.未实名,1.已实名
Level string `json:"level_name"` // 会员等级
InviteCode string `json:"invite_code" example:"会员邀请码"`
ParentID int64 `json:"parent_id"` // 推荐人 ID
ParentInviteCode string `json:"parent_invite_code" example:"推荐人邀请码"`
ParentPhone string `json:"parent_phone" example:"推荐人手机号"`
RegisterTime time.Time `json:"register_time"` // 注册时间
Memo string `json:"memo"` // 备注
model.User
}

type UserManagementGetUserListResp struct {
LevelsList []map[string]interface{} `json:"levels_list"` // 等级列表
TagsList []map[string]interface{} `json:"tags_list"` // 标签列表
List []UserManagementGetUserListNode `json:"list"`
Paginate Paginate `json:"paginate"` // 分页信息
}

type UserInfo struct {
model.User `xorm:"extends"`
TagID int `xorm:"tag_id"`
ParentPhone string `xorm:"parent_phone"`
ParentSystemInviteCode string `xorm:"parent_system_invite_code"`
ParentCustomInviteCode string `xorm:"parent_custom_invite_code"`
}

type LevelCount struct {
Level int `xorm:"level"`
Count int `xorm:"count"`
}

type UserManagementUpdateUserInfoReq struct {
UID int64 `json:"uid,required"`
Memo string `json:"memo" example:"备注"`
Disable bool `json:"disable"` // 是否禁用用户
Tag int `json:"tag"` // 用户标签 ID
LastLoginIp string `json:"last_login_ip"` // 用户最后登录 IP
Avatar string `json:"avatar"` // 头像
}

type UserManagementGetOneBasicNode struct {
Avatar string `json:"avatar"` // 头像
Sex int `json:"sex"` // 性别
Nickname string `json:"nickname"` // 会员名称
TagID int `json:"tag_id"` // 标签 ID
Phone string `json:"phone"` // 手机号
UnionId string `json:"union_id"` // 微信号
Password string `json:"password"` // 登录密码
Passcode string `json:"passcode"` // 支付密码
State int `json:"state"` // 账号状态 1正常,2冻结
Memo string `json:"memo"` // 备注
ParentUid int64 `json:"parent_uid"` // 推荐人
ParentName string `json:"parent_name"` // 推荐人名称
ParentPhone string `json:"parent_phone"` // 推荐人手机号
SystemInviteCode string `json:"system_invite_code"` // 系统邀请码
CustomInviteCode string `json:"custom_invite_code"` // 自定义邀请码
Level int `json:"level"` // 等级 ID
}

type OtherNode struct {
LastLoginIp string `json:"last_login_ip" ` // 最后登录 IP
LastLoginAt string `json:"last_login_at" ` // 最近登录时间
CreateAt string `json:"create_at" ` // 注册时间
RegisterType int `json:"register_at" ` // 注册类型(0.未知, 1.免验证码手机号注册,2.微信授权)
}

type WalletNode struct {
Amount string `json:"amount"` // 用户余额
}

type UserManagementGetOneBasicResp struct {
TagsList []map[string]interface{} `json:"tags_list"` // 标签列表
LevelsList []map[string]interface{} `json:"levels_list"` // 等级列表
CoinsList []map[string]interface{} `json:"coins_list"` // 货币列表
}

+ 10
- 0
app/router/router.go 파일 보기

@@ -7,6 +7,7 @@ import (
"applet/app/hdl/institutional_management/egg_energy"
"applet/app/hdl/institutional_management/public_platoon"
"applet/app/hdl/marketing_applications/new_user_red_package"
"applet/app/hdl/member_center"
"applet/app/hdl/setCenter/oss/aliyun"
"applet/app/mw"
_ "applet/docs"
@@ -58,6 +59,7 @@ func route(r *gin.RouterGroup) {
r.Use(mw.CheckPermission) // 检测权限
rInstitutionalManagement(r.Group("/institutionalManagement"))
rMarketingApplications(r.Group("/marketingApplications"))
rMemberCenter(r.Group("/memberCenter"))
rSettCenter(r.Group("/settCenter"))
}

@@ -141,6 +143,14 @@ func rMarketingApplications(r *gin.RouterGroup) { //营销应用
rNewUserRedPackage.POST("/recordFlowList", new_user_red_package.NewUserRedPackageRecordFlowList)
}
}
func rMemberCenter(r *gin.RouterGroup) { // 会员中心
rUserManagement := r.Group("/userManagement")
{
rUserManagement.POST("/getUserList", member_center.UserManagementGetUserList)
//rUserManagement.GET("/userData", member_center.UserManagementGetOneBasic)
rUserManagement.POST("/updateUserInfo", member_center.UserManagementUpdateUserInfo)
}
}

func rComm(r *gin.RouterGroup) {
r.POST("/getMenuList", comm.MenuList) // 获取菜单栏列表


+ 68
- 0
app/svc/member_center/svc_user_management.go 파일 보기

@@ -0,0 +1,68 @@
package svc

import (
md "applet/app/md/institutional_management/member_center"
"xorm.io/xorm"
)

func UserManagementGetUsers(engine *xorm.Engine, req *md.UserManagementGetUserListReq) (*[]md.UserInfo, int64, error) {
var users []md.UserInfo
session := engine.SQL("SELECT a.*, user_tag_records.tag_id AS tag_id, b.phone AS parent_phone, b.system_invite_code AS parent_system_invite_code, b.custom_invite_code AS parent_custom_invite_code FROM `user` AS a, `user` AS b, `user_tag_records`" +
"WHERE a.parent_uid = b.id AND user_tag_records.uid = a.id")
if req.ID != 0 {
session = session.Where("a.id = ?", req.ID)
}
if req.Nickname != "" {
session = session.Where("a.nickname = ?", req.Nickname)
}
if req.RecommendID != 0 {
session = session.Where("a.parent_uid = ?", req.RecommendID)
}
if req.Tag != 0 {
session = session.Where("a.tag_id = ?", req.Tag)
}
if req.Phone != "" {
session = session.Where("a.phone = ?", req.Phone)
}
if req.InviteCode != "" {
session = session.Where("a.system_invite_code = ? or a.custom_invite_code = ?", req.InviteCode, req.InviteCode)
}
if req.ParentPhone != "" {
session = session.Where("b.phone= ?", req.ParentPhone)
}
if req.ParentInviteCode != "" {
session = session.Where("b.system_invite_code = ? or b.custom_invite_code = ?", req.ParentInviteCode, req.ParentInviteCode)
}
if req.Sex != 0 {
session = session.Where("a.sex = ?")
}
if req.UnionId != "" {
session = session.Where("a.union_id = ?", req.UnionId)
}
if req.Level != 0 {
session = session.Where("a.level = ?", req.Level)
}
if req.RegisterType != 0 {
session = session.Where("a.register_type = ?", req.RegisterType)
}
if req.State != 0 {
session = session.Where("a.state = ?", req.State)
}
if req.IsRealName != 0 {
session = session.Where("a.is_real_name = ?", req.IsRealName)
}
if req.Memo != "" {
session = session.Where("a.memo = ?", req.Memo)
}
if req.RegisterBefore != "" && req.RegisterAfter != "" {
session = session.Where("a.create_at > ? and a.create_at < ?", req.RegisterBefore, req.RegisterAfter)
}
if req.LoginBefore != "" && req.LoginAfter != "" {
session = session.Where("a.update_at > ? and a.update_at < ?", req.LoginBefore, req.LoginAfter)
}
total, err := session.Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&users)
if err != nil {
return nil, 0, err
}
return &users, total, nil
}

+ 2
- 2
go.mod 파일 보기

@@ -2,9 +2,9 @@ module applet

go 1.19

//replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models
replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models

//replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules
replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules

require (
github.com/boombuler/barcode v1.0.1


불러오는 중...
취소
저장