公会重名校验
This commit is contained in:
@@ -41,6 +41,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.accompany.common.status.BusiStatus.GUILD_APPLY_GUILD_NAME_CHECK;
|
||||
|
||||
@Service
|
||||
public class FamilyManageAdminService {
|
||||
|
||||
@@ -157,6 +159,11 @@ public class FamilyManageAdminService {
|
||||
throw new AdminServiceException(BusiStatus.FAMILY_NOT_EXIST);
|
||||
}
|
||||
|
||||
boolean equalsName = familyService.checkFamilyEqualsName(name, id);
|
||||
if (equalsName) {
|
||||
throw new AdminServiceException(GUILD_APPLY_GUILD_NAME_CHECK);
|
||||
}
|
||||
|
||||
Long inviteUid = bdBound(family, inviteErbanNo);
|
||||
|
||||
familyService.lambdaUpdate().eq(Family::getId, id)
|
||||
|
@@ -14,10 +14,7 @@ import com.accompany.business.model.guild.GuildApply;
|
||||
import com.accompany.business.model.guild.GuildMember;
|
||||
import com.accompany.business.model.guild.GuildOperateRecord;
|
||||
import com.accompany.business.service.UploadAvatarService;
|
||||
import com.accompany.business.service.guild.GuildMemberService;
|
||||
import com.accompany.business.service.guild.GuildMessageService;
|
||||
import com.accompany.business.service.guild.GuildOperateRecordService;
|
||||
import com.accompany.business.service.guild.GuildService;
|
||||
import com.accompany.business.service.guild.*;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.business.vo.guild.GuildOperateRecordAdminVo;
|
||||
import com.accompany.common.constant.Constant;
|
||||
@@ -47,6 +44,8 @@ import org.springframework.util.CollectionUtils;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.accompany.common.status.BusiStatus.GUILD_APPLY_GUILD_NAME_CHECK;
|
||||
|
||||
@Service
|
||||
public class GuildManageAdminService {
|
||||
|
||||
@@ -76,6 +75,8 @@ public class GuildManageAdminService {
|
||||
private RechargeUserService rechargeUserService;
|
||||
@Autowired
|
||||
private BdInfoAdminService bdInfoAdminService;
|
||||
@Autowired
|
||||
private GuildApplyService guildApplyService;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createGuild(Long erbanNo, Integer adminId, String guildContactType, String guildContact, Long inviteErbanNo) {
|
||||
@@ -182,6 +183,16 @@ public class GuildManageAdminService {
|
||||
if (null == guild || !Boolean.TRUE.equals(guild.getEnable())){
|
||||
throw new AdminServiceException(BusiStatus.FAMILY_NOT_EXIST);
|
||||
}
|
||||
|
||||
GuildApply existNotAuditByGuildName = guildApplyService.getExistNotAuditByGuildName(name);
|
||||
if (existNotAuditByGuildName != null) {
|
||||
throw new AdminServiceException(GUILD_APPLY_GUILD_NAME_CHECK);
|
||||
}
|
||||
boolean equalsName = guildService.checkGuildEqualsName(name, id);
|
||||
if (equalsName) {
|
||||
throw new AdminServiceException(GUILD_APPLY_GUILD_NAME_CHECK);
|
||||
}
|
||||
|
||||
//后天添加了公会超管,绑定之后不允许更改邀请人
|
||||
this.guildSuperAdminCheck(guild, inviteErbanNo);
|
||||
|
||||
|
@@ -914,6 +914,7 @@ public enum BusiStatus {
|
||||
GUILD_APPLY_PARAM_CHECK(20503, "请填入准确信息。"),
|
||||
GUILD_APPLY_RECHARGE_CHECK(20503, "充值代理用户不能申请成为公会会长。"),
|
||||
GUILD_APPLY_EXIST_CHECK(20503, "Under review。"),
|
||||
GUILD_APPLY_GUILD_NAME_CHECK(20503, "你的公会名称已重复,请更换一个"),
|
||||
GUILD_APPLY_CHECK_IN(20503, "该用户无法加入公会。"),
|
||||
INVITE_NOT_REWARD(20504, "暂无可领取奖励。"),
|
||||
|
||||
|
@@ -38,6 +38,13 @@ public class FamilyService extends ServiceImpl<FamilyMapper, Family> {
|
||||
.list();
|
||||
}
|
||||
|
||||
public boolean checkFamilyEqualsName(String guildName, Integer notEqualFamilyId) {
|
||||
return this.lambdaQuery()
|
||||
.eq(Family::getName, guildName)
|
||||
.ne(notEqualFamilyId != null, Family::getId, notEqualFamilyId)
|
||||
.count() > 0;
|
||||
}
|
||||
|
||||
public Map<Integer, Family> mapFamilyByIds(List<Integer> familyIdList) {
|
||||
return this.lambdaQuery()
|
||||
.in(Family::getId, familyIdList)
|
||||
|
@@ -19,4 +19,7 @@ public interface GuildApplyService extends IService<GuildApply> {
|
||||
GuildApply getExistNotAuditByApplyUid(Long applyUid);
|
||||
|
||||
GuildApplyParamOption getParamOptions();
|
||||
|
||||
GuildApply getExistNotAuditByGuildName(String guildName);
|
||||
|
||||
}
|
||||
|
@@ -32,12 +32,10 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.accompany.common.status.BusiStatus.GUILD_APPLY_EXIST_CHECK;
|
||||
import static com.accompany.common.status.BusiStatus.GUILD_APPLY_RECHARGE_CHECK;
|
||||
import static com.accompany.common.status.BusiStatus.*;
|
||||
|
||||
/**
|
||||
* 公会申请审核表 服务实现类
|
||||
@@ -61,6 +59,8 @@ public class GuildApplyServiceImpl extends ServiceImpl<GuildApplyMapper, GuildAp
|
||||
private GiveUserService giveUserService;
|
||||
@Autowired
|
||||
private AreaInfoService areaInfoService;
|
||||
@Autowired
|
||||
private GuildService guildService;
|
||||
|
||||
@Override
|
||||
public BusiResult<Void> apply(GuildApplyParam guildApplyParam) {
|
||||
@@ -88,6 +88,14 @@ public class GuildApplyServiceImpl extends ServiceImpl<GuildApplyMapper, GuildAp
|
||||
if (existNotAuditByApplyUid != null) {
|
||||
throw new ServiceException(GUILD_APPLY_EXIST_CHECK);
|
||||
}
|
||||
GuildApply existNotAuditByGuildName = getExistNotAuditByGuildName(guildApplyParam.getGuildName());
|
||||
if (existNotAuditByGuildName != null) {
|
||||
throw new ServiceException(GUILD_APPLY_GUILD_NAME_CHECK);
|
||||
}
|
||||
boolean equalsName = guildService.checkGuildEqualsName(guildApplyParam.getGuildName(), null);
|
||||
if (equalsName) {
|
||||
throw new ServiceException(GUILD_APPLY_GUILD_NAME_CHECK);
|
||||
}
|
||||
GuildApply guildApply = new GuildApply();
|
||||
if (guildApplyParam.getInviteErbanNo() != null && guildApplyParam.getInviteErbanNo() != 0) {
|
||||
Users inviteUser = usersService.getUserByErbanNo(guildApplyParam.getInviteErbanNo());
|
||||
@@ -121,6 +129,13 @@ public class GuildApplyServiceImpl extends ServiceImpl<GuildApplyMapper, GuildAp
|
||||
return baseMapper.selectOne(queryWrapper, false);
|
||||
}
|
||||
|
||||
public GuildApply getExistNotAuditByGuildName(String guildName) {
|
||||
LambdaQueryWrapper<GuildApply> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.eq(GuildApply::getGuildName, guildName);
|
||||
queryWrapper.eq(GuildApply::getAuditStatus, Constant.CommonAuditStatus.wait);
|
||||
return baseMapper.selectOne(queryWrapper, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuildApplyParamOption getParamOptions() {
|
||||
List<String> areaCodeOption = areaInfoService.list(Wrappers.<AreaInfo>lambdaQuery().select(AreaInfo::getPhoneAreaCode))
|
||||
|
@@ -39,6 +39,13 @@ public class GuildService extends ServiceImpl<GuildMapper, Guild> {
|
||||
.list();
|
||||
}
|
||||
|
||||
public boolean checkGuildEqualsName(String guildName, Integer notEqualGuildId) {
|
||||
return this.lambdaQuery()
|
||||
.eq(Guild::getName, guildName)
|
||||
.ne(notEqualGuildId != null, Guild::getId, notEqualGuildId)
|
||||
.count() > 0;
|
||||
}
|
||||
|
||||
public Map<Integer, Guild> mapGuildByIds(List<Integer> familyIdList) {
|
||||
return this.lambdaQuery()
|
||||
.in(Guild::getId, familyIdList)
|
||||
|
Reference in New Issue
Block a user