diff --git a/erp_web/pages/materials/materialcategory.html b/erp_web/pages/materials/materialcategory.html index 67c30147..d319fa09 100644 --- a/erp_web/pages/materials/materialcategory.html +++ b/erp_web/pages/materials/materialcategory.html @@ -195,11 +195,11 @@ ids: ids }), success: function (res) { - if(res && res.code === 200) { - $('#tt').tree('reload'); - } else { - $.messager.alert('删除提示', '删除商品类别信息失败,请稍后再试!', 'error'); + if(res.code!=200){ + $.messager.alert('提示', res.msg, 'error'); + return; } + $('#tt').tree('reload'); }, //此处添加错误处理 error: function () { diff --git a/sql/jsh_erp.sql b/sql/jsh_erp.sql index 6df2ee94..6211d3ca 100644 --- a/sql/jsh_erp.sql +++ b/sql/jsh_erp.sql @@ -1223,6 +1223,7 @@ ALTER TABLE jsh_materialcategory DROP FOREIGN KEY FK3EE7F725237A77D8; -- ---------------------------- -- 修改根目录父节点id为-1 +-- 设置根目录编号为1 -- ---------------------------- update jsh_materialcategory set ParentId='-1' where id='1'; @@ -1467,3 +1468,7 @@ DROP FUNCTION _buildOrgAndOrgUserRel; alter table jsh_user change Status Status tinyint(4) DEFAULT '0' COMMENT '状态,0:正常,1:删除,2封禁'; update jsh_user set status='0' where status is null; +-- ---------------------------- +-- 设置根目录编号为1 +-- ---------------------------- +update jsh_materialcategory set serial_no='1' where id='1'; diff --git a/src/main/java/com/jsh/erp/constants/ExceptionConstants.java b/src/main/java/com/jsh/erp/constants/ExceptionConstants.java index 4be7fd17..771a9e43 100644 --- a/src/main/java/com/jsh/erp/constants/ExceptionConstants.java +++ b/src/main/java/com/jsh/erp/constants/ExceptionConstants.java @@ -61,6 +61,12 @@ public class ExceptionConstants { //商品类别编号已存在 public static final int MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE = 7500003; public static final String MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG = "商品类别编号已存在"; + //根目录不支持修改 + public static final int MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_CODE = 7500004; + public static final String MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_MSG = "根目录不支持修改"; + //根目录不支持删除 + public static final int MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_CODE = 7500005; + public static final String MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_MSG = "根目录不支持删除"; /** * 商品信息 diff --git a/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java b/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java index 694cc20e..8dc3854b 100644 --- a/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java +++ b/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java @@ -138,20 +138,50 @@ public class MaterialCategoryService { } @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int batchDeleteMaterialCategoryByIds(String ids) throws Exception { + //更新时间 Date updateDate =new Date(); //更新人 User userInfo=userService.getCurrentUser(); Long updater=userInfo==null?null:userInfo.getId(); - StringBuffer sb=new StringBuffer(); String strArray[]=ids.split(","); if(strArray.length<1){ return 0; } + /** + * create by: qiankunpingtai + * create time: 2019/3/13 14:49 + * description: + * 添加一个限制,根目录不允许删除 + */ + String rootIdStr=BusinessConstants.MATERIAL_CATEGORY_ROOT_ID.toString(); + for(String s:strArray){ + if(rootIdStr.equals(s)){ + logger.error("异常码[{}],异常提示[{}],参数,id:[{}]", + ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_CODE, + ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_MSG,s); + throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_CODE, + ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_MSG); + } + } return materialCategoryMapperEx.batchDeleteMaterialCategoryByIds(updateDate,updater,strArray); } @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int editMaterialCategory(MaterialCategory mc) { + /** + * create by: qiankunpingtai + * create time: 2019/3/13 14:49 + * description: + * 添加一个限制根目录不允许修改 + */ + if(BusinessConstants.MATERIAL_CATEGORY_ROOT_ID.equals(mc.getId())){ + logger.error("异常码[{}],异常提示[{}],参数,id:[{}]", + ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_CODE, + ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_MSG,mc.getId()); + throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_CODE, + ExceptionConstants.MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_MSG); + + } //检查商品类型编号是否已存在 checkMaterialCategorySerialNo(mc); //更新时间 @@ -187,11 +217,15 @@ public class MaterialCategoryService { throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE, ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG); } - if(mc.getId()!=mList.get(0).getId()){ + /** + * 包装类型用equals来比较 + * */ + if(mc.getId().equals(mList.get(0).getId())){ //修改时,相同编号,id不同 throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE, ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG); } } + }