完善收支项目接口的重复提示
This commit is contained in:
@@ -146,6 +146,9 @@ public class ExceptionConstants {
|
|||||||
//修改收支项目信息失败
|
//修改收支项目信息失败
|
||||||
public static final int IN_OUT_ITEM_EDIT_FAILED_CODE = 3500002;
|
public static final int IN_OUT_ITEM_EDIT_FAILED_CODE = 3500002;
|
||||||
public static final String IN_OUT_ITEM_EDIT_FAILED_MSG = "修改收支项目信息失败";
|
public static final String IN_OUT_ITEM_EDIT_FAILED_MSG = "修改收支项目信息失败";
|
||||||
|
//该收支项目的名称已经存在
|
||||||
|
public static final int IN_OUT_ITEM_NAME_EXIST_FAILED_CODE = 3500003;
|
||||||
|
public static final String IN_OUT_ITEM_NAME_EXIST_FAILED_MSG = "该收支项目的名称已经存在,请修改!";
|
||||||
/**
|
/**
|
||||||
* 多单位信息
|
* 多单位信息
|
||||||
* type = 40
|
* type = 40
|
||||||
|
|||||||
@@ -94,8 +94,9 @@ public class InOutItemController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/checkIsNameExist")
|
@GetMapping(value = "/checkIsNameExist")
|
||||||
@ApiOperation(value = "检查名称是否存在")
|
@ApiOperation(value = "检查名称是否存在-后续废弃")
|
||||||
public String checkIsNameExist(@RequestParam Long id, @RequestParam(value ="name", required = false) String name,
|
public String checkIsNameExist(@RequestParam Long id,
|
||||||
|
@RequestParam(value ="name", required = false) String name,
|
||||||
HttpServletRequest request)throws Exception {
|
HttpServletRequest request)throws Exception {
|
||||||
Map<String, Object> objectMap = new HashMap<>();
|
Map<String, Object> objectMap = new HashMap<>();
|
||||||
int exist = inOutItemService.checkIsNameExist(id, name);
|
int exist = inOutItemService.checkIsNameExist(id, name);
|
||||||
|
|||||||
@@ -92,6 +92,12 @@ public class InOutItemService {
|
|||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int insertInOutItem(JSONObject obj, HttpServletRequest request)throws Exception {
|
public int insertInOutItem(JSONObject obj, HttpServletRequest request)throws Exception {
|
||||||
InOutItem inOutItem = JSONObject.parseObject(obj.toJSONString(), InOutItem.class);
|
InOutItem inOutItem = JSONObject.parseObject(obj.toJSONString(), InOutItem.class);
|
||||||
|
int exist = checkIsNameAndTypeExist(inOutItem.getId(), inOutItem.getName(), inOutItem.getType());
|
||||||
|
if(exist>0) {
|
||||||
|
//存在
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.IN_OUT_ITEM_NAME_EXIST_FAILED_CODE,
|
||||||
|
ExceptionConstants.IN_OUT_ITEM_NAME_EXIST_FAILED_MSG);
|
||||||
|
}
|
||||||
int result=0;
|
int result=0;
|
||||||
try{
|
try{
|
||||||
inOutItem.setEnabled(true);
|
inOutItem.setEnabled(true);
|
||||||
@@ -107,6 +113,12 @@ public class InOutItemService {
|
|||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int updateInOutItem(JSONObject obj, HttpServletRequest request)throws Exception {
|
public int updateInOutItem(JSONObject obj, HttpServletRequest request)throws Exception {
|
||||||
InOutItem inOutItem = JSONObject.parseObject(obj.toJSONString(), InOutItem.class);
|
InOutItem inOutItem = JSONObject.parseObject(obj.toJSONString(), InOutItem.class);
|
||||||
|
int exist = checkIsNameAndTypeExist(inOutItem.getId(), inOutItem.getName(), inOutItem.getType());
|
||||||
|
if(exist>0) {
|
||||||
|
//存在
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.IN_OUT_ITEM_NAME_EXIST_FAILED_CODE,
|
||||||
|
ExceptionConstants.IN_OUT_ITEM_NAME_EXIST_FAILED_MSG);
|
||||||
|
}
|
||||||
int result=0;
|
int result=0;
|
||||||
try{
|
try{
|
||||||
result=inOutItemMapper.updateByPrimaryKeySelective(inOutItem);
|
result=inOutItemMapper.updateByPrimaryKeySelective(inOutItem);
|
||||||
@@ -163,6 +175,20 @@ public class InOutItemService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int checkIsNameAndTypeExist(Long id, String name, String type)throws Exception {
|
||||||
|
id = id==null?0L:id;
|
||||||
|
InOutItemExample example = new InOutItemExample();
|
||||||
|
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andTypeEqualTo(type).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
|
List<InOutItem> list = null;
|
||||||
|
try{
|
||||||
|
list=inOutItemMapper.selectByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
JshException.readFail(logger, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list==null?0:list.size();
|
||||||
|
}
|
||||||
|
|
||||||
public int checkIsNameExist(Long id, String name)throws Exception {
|
public int checkIsNameExist(Long id, String name)throws Exception {
|
||||||
InOutItemExample example = new InOutItemExample();
|
InOutItemExample example = new InOutItemExample();
|
||||||
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
|
|||||||
Reference in New Issue
Block a user