取货点和社区添加验证重复
This commit is contained in:
@@ -63,6 +63,11 @@ public class BuildWuyeCompanyController {
|
||||
@PreAuthorize("hasAuthority('build:wuyeCompany:create')")
|
||||
public Object saveBuildWuyeCompany(@RequestBody BuildWuyeCompany entity) {
|
||||
try {
|
||||
//查询是否存在该社区
|
||||
int count = IBuildWuyeCompanyService.selectByName(entity.getName());
|
||||
if(count>0){
|
||||
return new CommonResult().failed("该社区已存在");
|
||||
}
|
||||
entity.setStatus(StatusEnum.AuditType.SUCESS.code());
|
||||
if (IBuildWuyeCompanyService.saveCompany(entity)) {
|
||||
return new CommonResult().success();
|
||||
@@ -80,6 +85,11 @@ public class BuildWuyeCompanyController {
|
||||
@PreAuthorize("hasAuthority('build:wuyeCompany:update')")
|
||||
public Object updateBuildWuyeCompany(@RequestBody BuildWuyeCompany entity) {
|
||||
try {
|
||||
//查询是否存在该社区
|
||||
int count = IBuildWuyeCompanyService.selectByNameAndId(entity.getName(),entity.getId());
|
||||
if(count>0){
|
||||
return new CommonResult().failed("该社区已存在");
|
||||
}
|
||||
if (IBuildWuyeCompanyService.updateById(entity)) {
|
||||
return new CommonResult().success();
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ public class BuildingCommunityController {
|
||||
) {
|
||||
try {
|
||||
QueryWrapper<BuildingCommunity> qw = new QueryWrapper<>();
|
||||
if(StringUtils.isNotBlank(entity.getKeyword())){
|
||||
qw.like("bc.name",entity.getKeyword());
|
||||
if (StringUtils.isNotBlank(entity.getKeyword())) {
|
||||
qw.like("bc.name", entity.getKeyword());
|
||||
}
|
||||
IPage<BuildingCommunity> page = IBuildingCommunityService.pagerList(new Page<BuildingCommunity>(pageNum, pageSize), qw);
|
||||
return new CommonResult().success(page);
|
||||
@@ -70,10 +70,12 @@ public class BuildingCommunityController {
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setStatus(StatusEnum.AuditType.SUCESS.code());
|
||||
if (ValidatorUtils.empty(entity.getCompanyId())) {
|
||||
// entity.setCompanyId(UserUtils.getCurrentMember().getStoreId());
|
||||
return new CommonResult().failed("请选择物业啊");
|
||||
}
|
||||
if (ValidatorUtils.empty(entity.getCompanyId())) {
|
||||
return new CommonResult().failed("请选择物业攻啊");
|
||||
//判断该物业是否存在相同小区的名称
|
||||
int count = IBuildingCommunityService.selectByNameAndCompanyId(entity.getName(),entity.getCompanyId());
|
||||
if(count > 0){
|
||||
return new CommonResult().failed("该取货点已存在");
|
||||
}
|
||||
if (IBuildingCommunityService.saveCommunity(entity)) {
|
||||
return new CommonResult().success();
|
||||
@@ -91,6 +93,11 @@ public class BuildingCommunityController {
|
||||
|
||||
public Object updateBuildingCommunity(@RequestBody BuildingCommunity entity) {
|
||||
try {
|
||||
//判断该物业是否存在相同小区的名称
|
||||
int count = IBuildingCommunityService.selectByNameAndCompanyIdAndId(entity.getName(),entity.getCompanyId(),entity.getId());
|
||||
if(count > 0){
|
||||
return new CommonResult().failed("该取货点已存在");
|
||||
}
|
||||
if (IBuildingCommunityService.updateById(entity)) {
|
||||
return new CommonResult().success();
|
||||
}
|
||||
|
||||
@@ -14,4 +14,8 @@ import com.zscat.mallplus.build.entity.BuildWuyeCompany;
|
||||
public interface IBuildWuyeCompanyService extends IService<BuildWuyeCompany> {
|
||||
|
||||
boolean saveCompany(BuildWuyeCompany entity);
|
||||
|
||||
int selectByName(String name);
|
||||
|
||||
int selectByNameAndId(String name, Long id);
|
||||
}
|
||||
|
||||
@@ -19,4 +19,8 @@ public interface IBuildingCommunityService extends IService<BuildingCommunity> {
|
||||
boolean saveCommunity(BuildingCommunity entity);
|
||||
|
||||
IPage<BuildingCommunity> pagerList(Page<BuildingCommunity> buildingCommunityPage, QueryWrapper<BuildingCommunity> buildingCommunityQueryWrapper);
|
||||
|
||||
int selectByNameAndCompanyId(String name, Long companyId);
|
||||
|
||||
int selectByNameAndCompanyIdAndId(String name, Long companyId, Long id);
|
||||
}
|
||||
|
||||
@@ -67,4 +67,14 @@ public class BuildWuyeCompanyServiceImpl extends ServiceImpl<BuildWuyeCompanyMap
|
||||
// userRoleMapper.insert(userRole);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectByName(String name) {
|
||||
return baseMapper.selectByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectByNameAndId(String name, Long id) {
|
||||
return baseMapper.selectByNameAndId(name,id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,26 +44,25 @@ public class BuildingCommunityServiceImpl extends ServiceImpl<BuildingCommunityM
|
||||
entity.setCreateTime(new Date());
|
||||
communityMapper.insert(entity);
|
||||
// 2 创建物业公司账号
|
||||
SysUser user = new SysUser();
|
||||
/* SysUser user = new SysUser();
|
||||
user.setUsername(entity.getName());
|
||||
SysUser umsAdminList = userMapper.selectByUserName(entity.getName());
|
||||
if (umsAdminList != null) {
|
||||
throw new ApiMallPlusException("此小区已存在");
|
||||
}
|
||||
user.setStatus(1);
|
||||
// user.setStoreId(entity.getId());
|
||||
user.setPassword(passwordEncoder.encode("123456"));
|
||||
user.setCreateTime(new Date());
|
||||
user.setSupplyId(0L);
|
||||
user.setNote("小区账户:小区ID=" + entity.getName() + "," + entity.getId());
|
||||
user.setNickName(entity.getName());
|
||||
userMapper.insert(user);
|
||||
userMapper.insert(user);*/
|
||||
|
||||
// 3 分配物业公司角色
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
/* SysUserRole userRole = new SysUserRole();
|
||||
userRole.setAdminId(user.getId());
|
||||
userRole.setRoleId(5L);
|
||||
userRoleMapper.insert(userRole);
|
||||
userRoleMapper.insert(userRole);*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -72,4 +71,14 @@ public class BuildingCommunityServiceImpl extends ServiceImpl<BuildingCommunityM
|
||||
IPage<BuildingCommunity> page = baseMapper.pagerList(buildingCommunityPage,buildingCommunityQueryWrapper);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectByNameAndCompanyId(String name, Long companyId) {
|
||||
return baseMapper.selectByNameAndCompanyId(name,companyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectByNameAndCompanyIdAndId(String name, Long companyId, Long id) {
|
||||
return baseMapper.selectByNameAndCompanyIdAndId(name,companyId,id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user