对根目录添加限制,不允许修改和删除
This commit is contained in:
@@ -195,11 +195,11 @@
|
|||||||
ids: ids
|
ids: ids
|
||||||
}),
|
}),
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
if(res && res.code === 200) {
|
if(res.code!=200){
|
||||||
$('#tt').tree('reload');
|
$.messager.alert('提示', res.msg, 'error');
|
||||||
} else {
|
return;
|
||||||
$.messager.alert('删除提示', '删除商品类别信息失败,请稍后再试!', 'error');
|
|
||||||
}
|
}
|
||||||
|
$('#tt').tree('reload');
|
||||||
},
|
},
|
||||||
//此处添加错误处理
|
//此处添加错误处理
|
||||||
error: function () {
|
error: function () {
|
||||||
|
|||||||
@@ -1223,6 +1223,7 @@ ALTER TABLE jsh_materialcategory DROP FOREIGN KEY FK3EE7F725237A77D8;
|
|||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- 修改根目录父节点id为-1
|
-- 修改根目录父节点id为-1
|
||||||
|
-- 设置根目录编号为1
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
update jsh_materialcategory set ParentId='-1' where id='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封禁';
|
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;
|
update jsh_user set status='0' where status is null;
|
||||||
|
-- ----------------------------
|
||||||
|
-- 设置根目录编号为1
|
||||||
|
-- ----------------------------
|
||||||
|
update jsh_materialcategory set serial_no='1' where id='1';
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ public class ExceptionConstants {
|
|||||||
//商品类别编号已存在
|
//商品类别编号已存在
|
||||||
public static final int MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE = 7500003;
|
public static final int MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE = 7500003;
|
||||||
public static final String MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG = "商品类别编号已存在";
|
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 = "根目录不支持删除";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品信息
|
* 商品信息
|
||||||
|
|||||||
@@ -138,20 +138,50 @@ public class MaterialCategoryService {
|
|||||||
}
|
}
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int batchDeleteMaterialCategoryByIds(String ids) throws Exception {
|
public int batchDeleteMaterialCategoryByIds(String ids) throws Exception {
|
||||||
|
|
||||||
//更新时间
|
//更新时间
|
||||||
Date updateDate =new Date();
|
Date updateDate =new Date();
|
||||||
//更新人
|
//更新人
|
||||||
User userInfo=userService.getCurrentUser();
|
User userInfo=userService.getCurrentUser();
|
||||||
Long updater=userInfo==null?null:userInfo.getId();
|
Long updater=userInfo==null?null:userInfo.getId();
|
||||||
StringBuffer sb=new StringBuffer();
|
|
||||||
String strArray[]=ids.split(",");
|
String strArray[]=ids.split(",");
|
||||||
if(strArray.length<1){
|
if(strArray.length<1){
|
||||||
return 0;
|
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);
|
return materialCategoryMapperEx.batchDeleteMaterialCategoryByIds(updateDate,updater,strArray);
|
||||||
}
|
}
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int editMaterialCategory(MaterialCategory mc) {
|
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);
|
checkMaterialCategorySerialNo(mc);
|
||||||
//更新时间
|
//更新时间
|
||||||
@@ -187,11 +217,15 @@ public class MaterialCategoryService {
|
|||||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE,
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE,
|
||||||
ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG);
|
ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG);
|
||||||
}
|
}
|
||||||
if(mc.getId()!=mList.get(0).getId()){
|
/**
|
||||||
|
* 包装类型用equals来比较
|
||||||
|
* */
|
||||||
|
if(mc.getId().equals(mList.get(0).getId())){
|
||||||
//修改时,相同编号,id不同
|
//修改时,相同编号,id不同
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE,
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE,
|
||||||
ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG);
|
ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user