门店名称重复验证
This commit is contained in:
@ -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){
|
||||||
|
|||||||
@ -26,6 +26,7 @@ public interface CompanyStoreMapper
|
|||||||
* @return 门店信息
|
* @return 门店信息
|
||||||
*/
|
*/
|
||||||
public CompanyStore checkStoreNoUnique(String storeNo);
|
public CompanyStore checkStoreNoUnique(String storeNo);
|
||||||
|
public CompanyStore checkStoreNameUnique(String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询门店列表
|
* 查询门店列表
|
||||||
|
|||||||
@ -34,6 +34,7 @@ public interface ICompanyStoreService
|
|||||||
*/
|
*/
|
||||||
public String checkStoreNoUnique(CompanyStore companyStore);
|
public String checkStoreNoUnique(CompanyStore companyStore);
|
||||||
|
|
||||||
|
public String checkStoreNameUnique(CompanyStore companyStore);
|
||||||
/**
|
/**
|
||||||
* 新增门店
|
* 新增门店
|
||||||
*
|
*
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 新增门店
|
* 新增门店
|
||||||
*
|
*
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user