Commit 11aa56d4 authored by hujiebin's avatar hujiebin

Merge branch 'feature/family-up' into 'master'

Feature/family up

See merge request !13
parents 05a557cb f22773d5
package groupPower_e
import "git.hilo.cn/hilo-common/resource/mysql"
//国家势力状态
type GroupPowerStatus = mysql.Type
type GroupPowerStatus = uint8
const (
//上架
......@@ -15,7 +13,7 @@ const (
)
//国家势力用户角色
type GroupPowerUserRole = mysql.Type
type GroupPowerUserRole = uint8
const (
//普通用户
......@@ -27,7 +25,7 @@ const (
)
//国家势力排行榜类型
type GroupPowerRankType = mysql.Type
type GroupPowerRankType = uint8
const (
GroupPowerRankTypeFamous GroupPowerRankType = 1
......@@ -36,7 +34,7 @@ const (
)
//国家势力日志操作类型
type GroupPowerUserLogType = mysql.Type
type GroupPowerUserLogType = uint8
const (
//加入
......@@ -51,7 +49,7 @@ const (
GroupPowerUserLogDissolve GroupPowerUserLogType = 5
)
type GroupPowerDiamondLogType = mysql.Type
type GroupPowerDiamondLogType = uint8
const (
//群组原因加入
......@@ -67,3 +65,7 @@ const (
PowerSuppportAwarded PowerSupportAwardState = 1 // 已经领取
PowerSuppportWaiting PowerSupportAwardState = 2 // 待领取
)
const (
LongestNameplate = 15
)
......@@ -140,8 +140,8 @@ func UpdateFamily(model *domain.Model, familyId uint64, name, nameplate, declara
if groupPower.ModifyNameplate != mysql.YES {
// 同步修改铭牌
n := len([]rune(name))
if n > 6 {
n = 6
if n > groupPower_e.LongestNameplate {
n = groupPower_e.LongestNameplate
}
updateMap["nameplate"] = string([]rune(name[0:n]))
}
......
......@@ -2,6 +2,7 @@ package groupPower_m
import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"hilo-group/common"
"hilo-group/myerr"
......@@ -88,3 +89,16 @@ func DelGroupPowerApplyJoinNoDeal(model *domain.Model, userId uint64) error {
}
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) {
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 家族
// @Summary 退出/踢出家族
// @Param type formData int true "1.自己退出,2.踢人"
......@@ -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)
}
// 检查铭牌长度和唯一性
if len(para.Nameplate) > 6 {
if len(para.Nameplate) > groupPower_e.LongestNameplate {
return myContext, bizerr.GroupPowerHaveTooLong
}
if groupPower_m.IsExistsNameplate(model, para.Nameplate) {
......
......@@ -133,6 +133,7 @@ func InitRouter() *gin.Engine {
groupPower.POST("/apply", wrapper(group_power_r.GroupPowerApplyJoin))
groupPower.POST("/apply/pass", wrapper(group_power_r.GroupPowerApplyPass))
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.GET("/quit/list", wrapper(group_power_r.GroupPowerQuitList))
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