diff --git a/cv/group_power_cv/groupPower.go b/cv/group_power_cv/groupPower.go index 4c9522dbc56a4a366fd7ca1a499db259a42f69ee..ff988dbd01f9ae0c2b67d78bf752bf780cf2a107 100644 --- a/cv/group_power_cv/groupPower.go +++ b/cv/group_power_cv/groupPower.go @@ -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 { diff --git a/domain/model/groupPower_m/family.go b/domain/model/groupPower_m/family.go index a2a079105dd3c151bf609b83cb24b101dac60a18..4a07f1bbb9bb743ea0e33caf2362bc590ade31ea 100644 --- a/domain/model/groupPower_m/family.go +++ b/domain/model/groupPower_m/family.go @@ -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 } diff --git a/domain/model/groupPower_m/groupPower.go b/domain/model/groupPower_m/groupPower.go index 19a4cd7ad0c00a5dd56ba084376d0cf0ccbc7476..12c7f1ade6a7071268bd0e43167c0a0f07eedff9 100644 --- a/domain/model/groupPower_m/groupPower.go +++ b/domain/model/groupPower_m/groupPower.go @@ -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 // 等级勋章图片 } diff --git a/route/group_power_r/group_power.go b/route/group_power_r/group_power.go index 1d11c61cb696e22793db0e48334a435758617ddc..84ee767f4fad0c63f9d61e174ad0fa555a0bd09b 100644 --- a/route/group_power_r/group_power.go +++ b/route/group_power_r/group_power.go @@ -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 != "" {