Commit a318b203 authored by chenweijian's avatar chenweijian

家族

parent 37768a2f
......@@ -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 {
......
......@@ -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
......
......@@ -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
}
......
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