diff --git a/cv/group_power_cv/groupPower.go b/cv/group_power_cv/groupPower.go index 79e3d590cf0cbf128cd7725a25e80c8f4da39fdc..022347afa835256a2a5f650873942fba72fa15d4 100644 --- a/cv/group_power_cv/groupPower.go +++ b/cv/group_power_cv/groupPower.go @@ -658,10 +658,10 @@ type GroupPowerInfo struct { type GroupPower struct { Id uint64 `json:"id"` - Name mysql.Str `json:"name"` - Nameplate mysql.Str `json:"nameplate"` // 铭牌 - Declaration mysql.Str `json:"declaration"` // 宣言 - Icon mysql.Str `json:"icon"` // 头像 + 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:"-"` // 升到下一级需要的经验值 @@ -669,6 +669,8 @@ type GroupPower struct { 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:"-"` // 最大人数 } type GroupPowerUser struct { diff --git a/domain/model/groupPower_m/group_power_apply.go b/domain/model/groupPower_m/group_power_apply.go index 18725fae13b44a1531590dc03d518aff5d492da2..c1f5480304f083789e12bb432743d12df168b953 100644 --- a/domain/model/groupPower_m/group_power_apply.go +++ b/domain/model/groupPower_m/group_power_apply.go @@ -32,9 +32,13 @@ func InsertGroupPowerApplyJoin(model *domain.Model, userId, familyId uint64) err return nil } -func GetGroupPowerApplyJoin(model *domain.Model, userId, familyId uint64) (*GroupPowerApplyJoin, error) { +func GetGroupPowerApplyJoin(model *domain.Model, userId, familyId uint64, isAccept int) (*GroupPowerApplyJoin, error) { res := new(GroupPowerApplyJoin) - err := model.Db.Where(GroupPowerApplyJoin{UserId: userId, GroupPowerId: familyId}).Where("is_accept=0").First(&res).Error + db := model.Db.Where(GroupPowerApplyJoin{UserId: userId, GroupPowerId: familyId}) + if isAccept != -1 { + db = db.Where("is_accept=?", isAccept) + } + err := db.First(&res).Error if err != nil { if err == gorm.ErrRecordNotFound { return nil, nil diff --git a/route/group_power_r/group_power.go b/route/group_power_r/group_power.go index ef678671e39425d8983b29d52d28f667407bb3a8..887acb0ae503325f15821919bc07ce1f3c8e28cc 100644 --- a/route/group_power_r/group_power.go +++ b/route/group_power_r/group_power.go @@ -709,10 +709,10 @@ func GroupPowerBillboardOwnerWeek(c *gin.Context) (*mycontext.MyContext, error) // @Router /v1/groupPower/info [get] func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) { myContext := mycontext.CreateMyContext(c.Keys) - //userId, err := req.GetUserId(c) - //if err != nil { - // return myContext, err - //} + myUserId, err := req.GetUserId(c) + if err != nil { + return myContext, err + } familyId, err := strconv.ParseUint(c.Query("id"), 10, 64) if err != nil { return myContext, err @@ -748,6 +748,24 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) { Grade: gpInfo.Grade, Exp: gpInfo.Exp, NextExp: gpInfo.NextExp, GradeName: gpInfo.GradeName, GradeMedal: gpInfo.GradeMedal, MemberNum: mysql.Num(total), MemberMax: mysql.Num(group_power_cv.GroupPowerGradePrivilegeNum[groupPowerGrade[gp.ID].Grade][0].Num), } + // 我在该家族中的角色 + myPU := groupPower_m.GroupPowerUser{UserId: myUserId} + myGroupPUser, err := myPU.GetGroupPowerUser(model) + if err != nil { + return myContext, err + } + if myGroupPUser != nil && myGroupPUser.GroupPowerId == info.Id { + info.Role = int(myGroupPUser.Role) + } else { + // 是否申请了加入 + apply, err := groupPower_m.GetGroupPowerApplyJoin(model, myUserId, info.Id, -1) + if err != nil { + return myContext, err + } + if apply != nil && apply.IsAccept == 0 { + info.IsApply = true + } + } // 补上家族之星三个榜一 stars, err := groupPower_m.GetGroupPowerMonthStartTop1(model, gp.ID) if err != nil { @@ -973,7 +991,7 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) { return myContext, bizerr.GroupPowerHaveNoPower } // 查找申请记录 - apply, err := groupPower_m.GetGroupPowerApplyJoin(model, optUser.ID, myGroupPUser.GroupPowerId) + apply, err := groupPower_m.GetGroupPowerApplyJoin(model, optUser.ID, myGroupPUser.GroupPowerId, 0) if err != nil { return myContext, err }