Browse Source

取货点和社区添加验证重复

master
dimengzhe 2 years ago
parent
commit
f302bb372e
  1. 10
      mallplus-admin/src/main/java/com/zscat/mallplus/build/controller/BuildWuyeCompanyController.java
  2. 17
      mallplus-admin/src/main/java/com/zscat/mallplus/build/controller/BuildingCommunityController.java
  3. 4
      mallplus-admin/src/main/java/com/zscat/mallplus/build/service/IBuildWuyeCompanyService.java
  4. 4
      mallplus-admin/src/main/java/com/zscat/mallplus/build/service/IBuildingCommunityService.java
  5. 10
      mallplus-admin/src/main/java/com/zscat/mallplus/build/service/impl/BuildWuyeCompanyServiceImpl.java
  6. 19
      mallplus-admin/src/main/java/com/zscat/mallplus/build/service/impl/BuildingCommunityServiceImpl.java
  7. 4
      mallplus-mbg/src/main/java/com/zscat/mallplus/build/mapper/BuildWuyeCompanyMapper.java
  8. 4
      mallplus-mbg/src/main/java/com/zscat/mallplus/build/mapper/BuildingCommunityMapper.java
  9. 16
      mallplus-mbg/src/main/resources/mapper/build/BuildWuyeCompanyMapper.xml
  10. 8
      mallplus-mbg/src/main/resources/mapper/build/ComminutyMapper.xml

10
mallplus-admin/src/main/java/com/zscat/mallplus/build/controller/BuildWuyeCompanyController.java

@ -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();
}

17
mallplus-admin/src/main/java/com/zscat/mallplus/build/controller/BuildingCommunityController.java

@ -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();
}

4
mallplus-admin/src/main/java/com/zscat/mallplus/build/service/IBuildWuyeCompanyService.java

@ -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);
}

4
mallplus-admin/src/main/java/com/zscat/mallplus/build/service/IBuildingCommunityService.java

@ -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);
}

10
mallplus-admin/src/main/java/com/zscat/mallplus/build/service/impl/BuildWuyeCompanyServiceImpl.java

@ -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);
}
}

19
mallplus-admin/src/main/java/com/zscat/mallplus/build/service/impl/BuildingCommunityServiceImpl.java

@ -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);
}
}

4
mallplus-mbg/src/main/java/com/zscat/mallplus/build/mapper/BuildWuyeCompanyMapper.java

@ -2,6 +2,7 @@ package com.zscat.mallplus.build.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zscat.mallplus.build.entity.BuildWuyeCompany;
import org.apache.ibatis.annotations.Param;
/**
* <p>
@ -13,4 +14,7 @@ import com.zscat.mallplus.build.entity.BuildWuyeCompany;
*/
public interface BuildWuyeCompanyMapper extends BaseMapper<BuildWuyeCompany> {
int selectByName(String name);
int selectByNameAndId(@Param("name") String name, @Param("id") Long id);
}

4
mallplus-mbg/src/main/java/com/zscat/mallplus/build/mapper/BuildingCommunityMapper.java

@ -31,4 +31,8 @@ public interface BuildingCommunityMapper extends BaseMapper<BuildingCommunity> {
@Param("pageSize") Integer pageSize);
IPage<BuildingCommunity> pagerList(Page<BuildingCommunity> buildingCommunityPage, @Param(Constants.WRAPPER)QueryWrapper<BuildingCommunity> buildingCommunityQueryWrapper);
int selectByNameAndCompanyId(@Param("name") String name, @Param("companyId") Long companyId);
int selectByNameAndCompanyIdAndId(@Param("name") String name, @Param("companyId") Long companyId, @Param("id") Long id);
}

16
mallplus-mbg/src/main/resources/mapper/build/BuildWuyeCompanyMapper.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.zscat.mallplus.build.mapper.BuildWuyeCompanyMapper">
<select id="selectByName" resultType="int">
select count(*)
from build_wuye_company
where name = #{name}
</select>
<select id="selectByNameAndId" resultType="int">
select count(*)
from build_wuye_company
where name = #{name}
and id &lt;&gt; #{id}
</select>
</mapper>

8
mallplus-mbg/src/main/resources/mapper/build/ComminutyMapper.xml

@ -45,4 +45,12 @@
${ew.sqlSegment}
</where>
</select>
<select id="selectByNameAndCompanyId" resultType="int">
select count(*) from building_community where name = #{name} and company_id = #{companyId}
</select>
<select id="selectByNameAndCompanyIdAndId" resultType="int">
select count(*) from building_community where name = #{name} and company_id = #{companyId} and id &lt;&gt; #{id}
</select>
</mapper>

Loading…
Cancel
Save