Commit f22773d5 authored by hujiebin's avatar hujiebin

Feature/family up

parent 05a557cb
package groupPower_e package groupPower_e
import "git.hilo.cn/hilo-common/resource/mysql"
//国家势力状态 //国家势力状态
type GroupPowerStatus = mysql.Type type GroupPowerStatus = uint8
const ( const (
//上架 //上架
...@@ -15,7 +13,7 @@ const ( ...@@ -15,7 +13,7 @@ const (
) )
//国家势力用户角色 //国家势力用户角色
type GroupPowerUserRole = mysql.Type type GroupPowerUserRole = uint8
const ( const (
//普通用户 //普通用户
...@@ -27,7 +25,7 @@ const ( ...@@ -27,7 +25,7 @@ const (
) )
//国家势力排行榜类型 //国家势力排行榜类型
type GroupPowerRankType = mysql.Type type GroupPowerRankType = uint8
const ( const (
GroupPowerRankTypeFamous GroupPowerRankType = 1 GroupPowerRankTypeFamous GroupPowerRankType = 1
...@@ -36,7 +34,7 @@ const ( ...@@ -36,7 +34,7 @@ const (
) )
//国家势力日志操作类型 //国家势力日志操作类型
type GroupPowerUserLogType = mysql.Type type GroupPowerUserLogType = uint8
const ( const (
//加入 //加入
...@@ -51,7 +49,7 @@ const ( ...@@ -51,7 +49,7 @@ const (
GroupPowerUserLogDissolve GroupPowerUserLogType = 5 GroupPowerUserLogDissolve GroupPowerUserLogType = 5
) )
type GroupPowerDiamondLogType = mysql.Type type GroupPowerDiamondLogType = uint8
const ( const (
//群组原因加入 //群组原因加入
...@@ -67,3 +65,7 @@ const ( ...@@ -67,3 +65,7 @@ const (
PowerSuppportAwarded PowerSupportAwardState = 1 // 已经领取 PowerSuppportAwarded PowerSupportAwardState = 1 // 已经领取
PowerSuppportWaiting PowerSupportAwardState = 2 // 待领取 PowerSuppportWaiting PowerSupportAwardState = 2 // 待领取
) )
const (
LongestNameplate = 15
)
...@@ -140,8 +140,8 @@ func UpdateFamily(model *domain.Model, familyId uint64, name, nameplate, declara ...@@ -140,8 +140,8 @@ func UpdateFamily(model *domain.Model, familyId uint64, name, nameplate, declara
if groupPower.ModifyNameplate != mysql.YES { if groupPower.ModifyNameplate != mysql.YES {
// 同步修改铭牌 // 同步修改铭牌
n := len([]rune(name)) n := len([]rune(name))
if n > 6 { if n > groupPower_e.LongestNameplate {
n = 6 n = groupPower_e.LongestNameplate
} }
updateMap["nameplate"] = string([]rune(name[0:n])) updateMap["nameplate"] = string([]rune(name[0:n]))
} }
......
...@@ -2,6 +2,7 @@ package groupPower_m ...@@ -2,6 +2,7 @@ package groupPower_m
import ( import (
"git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm" "gorm.io/gorm"
"hilo-group/common" "hilo-group/common"
"hilo-group/myerr" "hilo-group/myerr"
...@@ -88,3 +89,16 @@ func DelGroupPowerApplyJoinNoDeal(model *domain.Model, userId uint64) error { ...@@ -88,3 +89,16 @@ func DelGroupPowerApplyJoinNoDeal(model *domain.Model, userId uint64) error {
} }
return nil return nil
} }
// 获取家族申请人数
// param: isAccept 0:未审核 1:通过 2:拒绝
func CountGroupPowerApply(model *domain.Model, groupPowerId mysql.ID, isAccept int) (int64, error) {
var cnt int64
if err := model.DB().Model(GroupPowerApplyJoin{}).
Where("group_power_id = ?", groupPowerId).
Where("is_accept = ?", isAccept).Count(&cnt).Error; err != nil {
model.Log.Errorf("CountGroupPowerApply fail:%v", err)
return cnt, err
}
return cnt, nil
}
...@@ -1223,6 +1223,41 @@ func GroupPowerApplyList(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -1223,6 +1223,41 @@ func GroupPowerApplyList(c *gin.Context) (*mycontext.MyContext, error) {
return myContext, nil return myContext, nil
} }
// @Tags 家族
// @Summary 申请人数
// @Success 200 {object} int
// @Router /v1/groupPower/apply/count [get]
func GroupPowerApplyCount(c *gin.Context) (*mycontext.MyContext, error) {
myContext := mycontext.CreateMyContext(c.Keys)
userId, err := req.GetUserId(c)
if err != nil {
return myContext, err
}
model := domain.CreateModelContext(myContext)
// 判断是否加入了家族
gpU := groupPower_m.GroupPowerUser{UserId: userId}
myGroupPUser, err := gpU.GetGroupPowerUser(model)
if err != nil {
return myContext, err
}
// 操作者是否加入了家族,是否有操作权限
if myGroupPUser == nil || myGroupPUser.ID == 0 {
return myContext, bizerr.GroupPowerHaveNoJoin
}
if myGroupPUser.Role == 0 || myGroupPUser.Role == groupPower_e.GroupPowerUserRoleUser {
return myContext, bizerr.GroupPowerHaveNoPower
}
// 申请人数
cnt, err := groupPower_m.CountGroupPowerApply(model, myGroupPUser.GroupPowerId, 0)
if err != nil {
return myContext, err
}
resp.ResponseOk(c, cnt)
return myContext, nil
}
// @Tags 家族 // @Tags 家族
// @Summary 退出/踢出家族 // @Summary 退出/踢出家族
// @Param type formData int true "1.自己退出,2.踢人" // @Param type formData int true "1.自己退出,2.踢人"
...@@ -1510,7 +1545,7 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -1510,7 +1545,7 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) {
return myContext, res_m.GetErrByLanguage(model.Db, common.MSG_ID_SET_FAMILY_NAMEPL, lang, bizerr.GroupPowerChangeNameplate) return myContext, res_m.GetErrByLanguage(model.Db, common.MSG_ID_SET_FAMILY_NAMEPL, lang, bizerr.GroupPowerChangeNameplate)
} }
// 检查铭牌长度和唯一性 // 检查铭牌长度和唯一性
if len(para.Nameplate) > 6 { if len(para.Nameplate) > groupPower_e.LongestNameplate {
return myContext, bizerr.GroupPowerHaveTooLong return myContext, bizerr.GroupPowerHaveTooLong
} }
if groupPower_m.IsExistsNameplate(model, para.Nameplate) { if groupPower_m.IsExistsNameplate(model, para.Nameplate) {
......
...@@ -133,6 +133,7 @@ func InitRouter() *gin.Engine { ...@@ -133,6 +133,7 @@ func InitRouter() *gin.Engine {
groupPower.POST("/apply", wrapper(group_power_r.GroupPowerApplyJoin)) groupPower.POST("/apply", wrapper(group_power_r.GroupPowerApplyJoin))
groupPower.POST("/apply/pass", wrapper(group_power_r.GroupPowerApplyPass)) groupPower.POST("/apply/pass", wrapper(group_power_r.GroupPowerApplyPass))
groupPower.GET("/apply/list", wrapper(group_power_r.GroupPowerApplyList)) groupPower.GET("/apply/list", wrapper(group_power_r.GroupPowerApplyList))
groupPower.GET("/apply/count", wrapper(group_power_r.GroupPowerApplyCount))
groupPower.POST("/quit", wrapper(group_power_r.GroupPowerQuit)) groupPower.POST("/quit", wrapper(group_power_r.GroupPowerQuit))
groupPower.GET("/quit/list", wrapper(group_power_r.GroupPowerQuitList)) groupPower.GET("/quit/list", wrapper(group_power_r.GroupPowerQuitList))
groupPower.POST("/admin", wrapper(group_power_r.GroupPowerSetAdmin)) groupPower.POST("/admin", wrapper(group_power_r.GroupPowerSetAdmin))
......
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