门店名称重复验证

This commit is contained in:
19173159168
2025-09-02 23:48:54 +08:00
parent e42b95e556
commit 084d1c145b
5 changed files with 24 additions and 1 deletions

View File

@ -119,6 +119,10 @@ public class CompanyStoreController extends BaseController
{ {
return error("新增失败,门店编号'" + companyStore.getStoreNumber() + "'已存在"); return error("新增失败,门店编号'" + companyStore.getStoreNumber() + "'已存在");
} }
if (CompanyStore.NOT_UNIQUE.equals(companyStoreService.checkStoreNameUnique(companyStore)))
{
return error("新增失败,门店名称'" + companyStore.getName() + "'已存在");
}
companyStore.setCreateBy(getLoginName()); companyStore.setCreateBy(getLoginName());
int flag = companyStoreService.insertCompanyStore(companyStore); int flag = companyStoreService.insertCompanyStore(companyStore);
if(flag > 0){ if(flag > 0){
@ -158,6 +162,10 @@ public class CompanyStoreController extends BaseController
{ {
return error("修改失败,门店编号'" + companyStore.getStoreNumber() + "'已存在"); return error("修改失败,门店编号'" + companyStore.getStoreNumber() + "'已存在");
} }
if (CompanyStore.NOT_UNIQUE.equals(companyStoreService.checkStoreNameUnique(companyStore)))
{
return error("修改失败,门店名称'" + companyStore.getName() + "'已存在");
}
companyStore.setUpdateBy(getLoginName()); companyStore.setUpdateBy(getLoginName());
int flag = companyStoreService.updateCompanyStore(companyStore); int flag = companyStoreService.updateCompanyStore(companyStore);
if(flag > 0){ if(flag > 0){

View File

@ -26,6 +26,7 @@ public interface CompanyStoreMapper
* @return 门店信息 * @return 门店信息
*/ */
public CompanyStore checkStoreNoUnique(String storeNo); public CompanyStore checkStoreNoUnique(String storeNo);
public CompanyStore checkStoreNameUnique(String name);
/** /**
* 查询门店列表 * 查询门店列表

View File

@ -34,6 +34,7 @@ public interface ICompanyStoreService
*/ */
public String checkStoreNoUnique(CompanyStore companyStore); public String checkStoreNoUnique(CompanyStore companyStore);
public String checkStoreNameUnique(CompanyStore companyStore);
/** /**
* 新增门店 * 新增门店
* *

View File

@ -73,7 +73,16 @@ public class CompanyStoreServiceImpl implements ICompanyStoreService
} }
return CompanyStore.UNIQUE; return CompanyStore.UNIQUE;
} }
@Override
public String checkStoreNameUnique(CompanyStore companyStore) {
Long storeId = StringUtils.isNull(companyStore.getId()) ? -1L : companyStore.getId();
CompanyStore info = companyStoreMapper.checkStoreNameUnique(companyStore.getName());
if (StringUtils.isNotNull(info) && info.getId().longValue() != storeId.longValue())
{
return CompanyStore.NOT_UNIQUE;
}
return CompanyStore.UNIQUE;
}
/** /**
* 新增门店 * 新增门店
* *

View File

@ -124,6 +124,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectCompanyStoreVo"/> <include refid="selectCompanyStoreVo"/>
where store_number = #{storeNumber} and del_flag = '0' limit 1 where store_number = #{storeNumber} and del_flag = '0' limit 1
</select> </select>
<select id="checkStoreNameUnique" parameterType="String" resultMap="CompanyStoreResult">
<include refid="selectCompanyStoreVo"/>
where name = #{name} and del_flag = '0' limit 1
</select>
<insert id="insertCompanyStore" parameterType="CompanyStore" useGeneratedKeys="true" keyProperty="id"> <insert id="insertCompanyStore" parameterType="CompanyStore" useGeneratedKeys="true" keyProperty="id">
insert into zc_company_store insert into zc_company_store