md
This commit is contained in:
parent
bb31ab810c
commit
093f80bc79
@ -16,6 +16,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.xdadan.erp.common.annotation.filter.jackson.JacksonFilter;
|
||||
import com.xdadan.erp.emis.domain.EmisSite;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -104,7 +105,13 @@ public class EmisCountryController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody EmisCountry emisCountry)
|
||||
{
|
||||
return toAjax(emisCountryService.insertEmisCountry(emisCountry));
|
||||
// 判断国家是否有重复
|
||||
try {
|
||||
return toAjax(emisCountryService.insertEmisCountry(emisCountry));
|
||||
} catch (EmisBizError emisBizError) {
|
||||
emisBizError.printStackTrace();
|
||||
return AjaxResult.error(emisBizError.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -13,6 +13,9 @@ package com.xdadan.erp.emis.mapper;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xdadan.erp.emis.domain.EmisCountry;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* @ClassName EmisCountryMapper
|
||||
* @Description <p> 国家 Mapper 接口 </p>
|
||||
@ -21,6 +24,16 @@ import com.xdadan.erp.emis.domain.EmisCountry;
|
||||
*/
|
||||
public interface EmisCountryMapper extends BaseMapper<EmisCountry>
|
||||
{
|
||||
|
||||
@Select("select count(1) from emis_country where name=${name} or name_en=${nameEn} or code ")
|
||||
public int checkCountryIsExists(@Param("name") String name,
|
||||
@Param("nameEn") String nameEn,
|
||||
@Param("code") String code,
|
||||
@Param("two_code") String twoCode,
|
||||
@Param("three_code") String threeCode
|
||||
|
||||
);
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
* @param id
|
||||
|
||||
@ -11,8 +11,9 @@ package com.xdadan.erp.emis.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.xdadan.erp.emis.domain.EmisCountry;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @ClassName EmisCountryService
|
||||
* @Description 国家
|
||||
* @author linfso
|
||||
@ -41,7 +42,7 @@ public interface IEmisCountryService
|
||||
* @param emisCountry 国家
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmisCountry(EmisCountry emisCountry);
|
||||
public int insertEmisCountry(EmisCountry emisCountry) throws EmisBizError;
|
||||
|
||||
/**
|
||||
* 修改国家
|
||||
|
||||
@ -11,6 +11,10 @@
|
||||
package com.xdadan.erp.emis.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.xdadan.erp.emis.domain.EmisCountry;
|
||||
@ -60,8 +64,11 @@ public class EmisCountryServiceImpl implements IEmisCountryService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertEmisCountry(EmisCountry emisCountry)
|
||||
{
|
||||
public int insertEmisCountry(EmisCountry emisCountry) throws EmisBizError {
|
||||
int cnt=emisCountryMapper.checkCountryIsExists(emisCountry.getName(),emisCountry.getNameEn(),emisCountry.getCode(),emisCountry.getTwoCode(),emisCountry.getThreeCode());
|
||||
if(cnt>0){
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,"国家信息不能重复,请检查!");
|
||||
}
|
||||
return emisCountryMapper.insertEmisCountry(emisCountry);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user