Commit ffb7acdc authored by hujiebin's avatar hujiebin

feat:补上等级

parent ef0d3aed
......@@ -657,21 +657,21 @@ type GroupPowerInfo struct {
}
type GroupPower struct {
Id uint64 `json:"id"`
Name string `json:"name"`
Nameplate string `json:"nameplate"` // 铭牌
Declaration string `json:"declaration"` // 宣言
Icon string `json:"icon"` // 头像
Grade mysql.Num `json:"grade" gorm:"-"` // 等级
Exp mysql.Num `json:"exp" gorm:"-"` // 当前经验值
NextExp mysql.Num `json:"nextExp" gorm:"-"` // 升到下一级需要的经验值
GradeName mysql.Str `json:"gradeName"` // 等级称号
GradeMedal mysql.Str `json:"gradeMedal"` // 等级勋章图片
MemberNum mysql.Num `json:"memberNum" gorm:"-"` // 当前人数
MemberMax mysql.Num `json:"memberMax" gorm:"-"` // 最大人数
Role int `json:"role" gorm:"-"` // 我在此家族中的角色 0.路人 1.成员 2.家族长 3.管理员
IsApply bool `json:"isApply" gorm:"-"` // 最大人数
MonthRank int `json:"monthRank" gorm:"-"` // 家族月排名
Id uint64 `json:"id"`
Name string `json:"name"`
Nameplate string `json:"nameplate"` // 铭牌
Declaration string `json:"declaration"` // 宣言
Icon string `json:"icon"` // 头像
Grade groupPower_e.GroupPowerGrade `json:"grade" gorm:"-"` // 等级
Exp mysql.Num `json:"exp" gorm:"-"` // 当前经验值
NextExp mysql.Num `json:"nextExp" gorm:"-"` // 升到下一级需要的经验值
GradeName mysql.Str `json:"gradeName"` // 等级称号
GradeMedal mysql.Str `json:"gradeMedal"` // 等级勋章图片
MemberNum mysql.Num `json:"memberNum" gorm:"-"` // 当前人数
MemberMax mysql.Num `json:"memberMax" gorm:"-"` // 最大人数
Role int `json:"role" gorm:"-"` // 我在此家族中的角色 0.路人 1.成员 2.家族长 3.管理员
IsApply bool `json:"isApply" gorm:"-"` // 最大人数
MonthRank int `json:"monthRank" gorm:"-"` // 家族月排名
}
type GroupPowerUser struct {
......
......@@ -2,7 +2,6 @@ package groupPower_m
import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"hilo-group/_const/enum/groupPower_e"
"hilo-group/common"
......@@ -41,11 +40,6 @@ func (this *GroupPower) Get(model *domain.Model) (*GroupPower, error) {
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
}
if grade.GroupPowerId > 0 {
group.Grade = mysql.Num(grade.Grade)
group.Exp = mysql.Num(grade.Exp)
group.NextExp = mysql.Num(grade.Exp)
}
return group, nil
}
......
......@@ -29,9 +29,6 @@ type GroupPower struct {
Nameplate mysql.Str // 铭牌
Declaration mysql.Str // 宣言
Icon mysql.Str // 头像
Grade mysql.Num `gorm:"-"` // 等级
Exp mysql.Num `gorm:"-"` // 当前经验值
NextExp mysql.Num `gorm:"-"` // 升到下一级需要的经验值
GradeName mysql.Str // 等级称号
GradeMedal mysql.Str // 等级勋章图片
}
......
......@@ -744,9 +744,18 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) {
resMembers = append(resMembers, &group_power_cv.GroupPowerUser{User: userMap[v.UserId], Role: v.Role})
}
groupPowerGrade, err := groupPower_m.MGetGroupPowerGrade(model, []mysql.ID{gp.ID})
gradeM, err := groupPower_m.MGetGroupPowerGrade(model, []mysql.ID{gp.ID})
if err != nil {
return myContext, err
}
grade := gradeM[gp.ID]
nextExp := mysql.Num(0)
if grade.Grade != groupPower_e.GroupPowerGradeMax {
nextExp = groupPower_e.GroupPowerGradeExp[grade.Grade+1]
}
info := &group_power_cv.GroupPower{
Id: gpInfo.ID, Name: gpInfo.Name, Nameplate: gpInfo.Nameplate, Declaration: gpInfo.Declaration, Icon: gpInfo.Icon,
Grade: gpInfo.Grade, Exp: gpInfo.Exp, NextExp: gpInfo.NextExp, GradeName: gpInfo.GradeName, GradeMedal: gpInfo.GradeMedal,
Grade: grade.Grade, Exp: grade.Exp, NextExp: nextExp, GradeName: gpInfo.GradeName, GradeMedal: gpInfo.GradeMedal,
MemberNum: mysql.Num(total), MemberMax: mysql.Num(group_power_cv.GroupPowerGradePrivilegeNum[groupPowerGrade[gp.ID].Grade][0].Num),
}
if info.Icon != "" {
......@@ -1399,12 +1408,12 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) {
// 检查铭牌是否能够修改
if para.Nameplate != "" {
// 等级检查
gp := &groupPower_m.GroupPower{Entity: mysql.Entity{ID: myGroupPUser.GroupPowerId}}
groupPInfo, err := gp.Get(model)
gradeM, err := groupPower_m.MGetGroupPowerGrade(model, []mysql.ID{myGroupPUser.GroupPowerId})
if err != nil {
return myContext, err
}
if groupPInfo.Grade < 1 {
grade := gradeM[myGroupPUser.GroupPowerId]
if grade.Grade < 1 {
return myContext, bizerr.GroupPowerChangeNameplate
}
// 检查铭牌长度和唯一性
......@@ -1433,9 +1442,18 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) {
return myContext, myerr.WrapErr(err)
}
groupPowerGrade, err := groupPower_m.MGetGroupPowerGrade(model, []mysql.ID{gp.ID})
gradeM, err := groupPower_m.MGetGroupPowerGrade(model, []mysql.ID{gp.ID})
if err != nil {
return myContext, err
}
grade := gradeM[gp.ID]
nextExp := mysql.Num(0)
if grade.Grade != groupPower_e.GroupPowerGradeMax {
nextExp = groupPower_e.GroupPowerGradeExp[grade.Grade+1]
}
info := &group_power_cv.GroupPower{
Id: gpInfo.ID, Name: gpInfo.Name, Nameplate: gpInfo.Nameplate, Declaration: gpInfo.Declaration, Icon: gpInfo.Icon,
Grade: gpInfo.Grade, Exp: gpInfo.Exp, NextExp: gpInfo.NextExp, GradeName: gpInfo.GradeName, GradeMedal: gpInfo.GradeMedal,
Grade: grade.Grade, Exp: grade.Exp, NextExp: nextExp, GradeName: gpInfo.GradeName, GradeMedal: gpInfo.GradeMedal,
MemberNum: mysql.Num(total), MemberMax: mysql.Num(group_power_cv.GroupPowerGradePrivilegeNum[groupPowerGrade[gp.ID].Grade][0].Num),
}
if info.Icon != "" {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment