公会名不重复校验
This commit is contained in:
parent
ed6dbbe7f8
commit
4f5e027f64
@ -13,7 +13,7 @@ import (
|
||||
|
||||
// 公会创建
|
||||
func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.SociatyCreateReq) (code pb.ErrorCode) {
|
||||
if len(req.Notice) > 150 || req.Name == ""{
|
||||
if len(req.Notice) > 150 || req.Name == "" {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
return
|
||||
@ -58,6 +58,16 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
|
||||
return
|
||||
}
|
||||
|
||||
// 验证公会名是否重复
|
||||
if ok, err := this.module.modelSociaty.isNameExist(req.Name); ok {
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
} else {
|
||||
code = pb.ErrorCode_SociatyNameExist
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//检查钻石
|
||||
ggd := this.module.modelSociaty.moduleSociaty.configure.GetGlobalConf()
|
||||
if ggd == nil {
|
||||
|
@ -32,7 +32,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
|
||||
sociatyTask := this.module.modelSociaty.getUserTaskList(uid, sociaty.Id)
|
||||
for _, v := range sociatyTask.TaskList {
|
||||
if v.TaskId == req.TaskId {
|
||||
if v.Status == 1 {
|
||||
if v.Status == 1 {//已领取
|
||||
code = pb.ErrorCode_SociatyRewardReceived
|
||||
return
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package sociaty
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
@ -15,6 +14,8 @@ import (
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
@ -70,6 +71,20 @@ func (this *ModelSociaty) create(sociaty *pb.DBSociaty) error {
|
||||
return this.AddList("", sociaty.Id, sociaty)
|
||||
}
|
||||
|
||||
// 公会名是否存在
|
||||
func (this *ModelSociaty) isNameExist(name string) (bool, error) {
|
||||
var sociaties []*pb.DBSociaty
|
||||
if err := this.GetList("", &sociaties); err != nil {
|
||||
return false, err
|
||||
}
|
||||
for _, s := range sociaties {
|
||||
if s.Name == name {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// 公会列表
|
||||
func (this *ModelSociaty) list(uid string, filter pb.SociatyListFilter) (list []*pb.DBSociaty) {
|
||||
user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(uid)
|
||||
@ -656,7 +671,7 @@ func (this *ModelSociaty) IsSign(uid string, sociaty *pb.DBSociaty) bool {
|
||||
// 获取玩家任务列表
|
||||
func (this *ModelSociaty) getUserTaskList(uid, sociatyId string) (sociatyTask *pb.DBSociatyTask) {
|
||||
sociatyTask = &pb.DBSociatyTask{}
|
||||
this.moduleSociaty.modelSociatyTask.GetListObj(sociatyId, uid, sociatyTask)
|
||||
this.GetListObj(sociatyId, uid, sociatyTask)
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user