解决商品类别修改的时候无法去掉父级目录的bug
This commit is contained in:
@@ -93,10 +93,7 @@ public class MaterialCategoryController {
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 获取商品类别树数据
|
||||
* create time: 2019/2/19 11:49
|
||||
* @Param:
|
||||
* @return com.alibaba.fastjson.JSONArray
|
||||
*/
|
||||
@@ -114,44 +111,4 @@ public class MaterialCategoryController {
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 新增商品类别数据
|
||||
* create time: 2019/2/19 17:17
|
||||
* @Param: beanJson
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@RequestMapping(value = "/addMaterialCategory")
|
||||
@ApiOperation(value = "新增商品类别数据")
|
||||
public Object addMaterialCategory(@RequestParam("info") String beanJson) throws Exception {
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
MaterialCategory mc= JSON.parseObject(beanJson, MaterialCategory.class);
|
||||
int i= materialCategoryService.addMaterialCategory(mc);
|
||||
if(i<1){
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_ADD_FAILED_CODE,
|
||||
ExceptionConstants.MATERIAL_CATEGORY_ADD_FAILED_MSG);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 修改商品类别数据
|
||||
* create time: 2019/2/20 9:30
|
||||
* @Param: beanJson
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@RequestMapping(value = "/editMaterialCategory")
|
||||
@ApiOperation(value = "修改商品类别数据")
|
||||
public Object editMaterialCategory(@RequestParam("info") String beanJson) throws Exception {
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
MaterialCategory mc= JSON.parseObject(beanJson, MaterialCategory.class);
|
||||
int i= materialCategoryService.editMaterialCategory(mc);
|
||||
if(i<1){
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_EDIT_FAILED_CODE,
|
||||
ExceptionConstants.MATERIAL_CATEGORY_EDIT_FAILED_MSG);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public class MaterialCategoryService {
|
||||
materialCategory.setUpdateTime(new Date());
|
||||
int result=0;
|
||||
try{
|
||||
result=materialCategoryMapper.updateByPrimaryKeySelective(materialCategory);
|
||||
result=materialCategoryMapperEx.editMaterialCategory(materialCategory);
|
||||
logService.insertLog("商品类型",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialCategory.getName()).toString(), request);
|
||||
}catch(Exception e){
|
||||
@@ -238,12 +238,8 @@ public class MaterialCategoryService {
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
*获取商品类别树数据
|
||||
* create time: 2019/2/19 14:30
|
||||
* @Param:
|
||||
* @return java.util.List<com.jsh.erp.datasource.vo.TreeNode>
|
||||
* 获取商品类别树数据
|
||||
*/
|
||||
public List<TreeNode> getMaterialCategoryTree(Long id) throws Exception{
|
||||
List<TreeNode> list=null;
|
||||
@@ -254,67 +250,6 @@ public class MaterialCategoryService {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 新增商品类别信息
|
||||
* create time: 2019/2/19 16:30
|
||||
* @Param: mc
|
||||
* @return void
|
||||
*/
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int addMaterialCategory(MaterialCategory mc) throws Exception {
|
||||
logService.insertLog("商品类型",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(mc.getName()).toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
if(mc==null){
|
||||
return 0;
|
||||
}
|
||||
if(mc.getParentId()==null){
|
||||
//没有给定父级目录的id,默认设置父级目录为根目录的父目录
|
||||
mc.setParentId(BusinessConstants.MATERIAL_CATEGORY_ROOT_PARENT_ID);
|
||||
}
|
||||
//检查商品类型编号是否已存在
|
||||
checkMaterialCategorySerialNo(mc);
|
||||
//数据状态新增时默认设置为启用
|
||||
Date date=new Date();
|
||||
User userInfo=userService.getCurrentUser();
|
||||
//创建时间
|
||||
mc.setCreateTime(date);
|
||||
//更新时间
|
||||
mc.setUpdateTime(date);
|
||||
int result=0;
|
||||
try{
|
||||
result=materialCategoryMapperEx.addMaterialCategory(mc);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int editMaterialCategory(MaterialCategory mc) throws Exception{
|
||||
logService.insertLog("商品类型",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(mc.getName()).toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
if(mc.getParentId()==null){
|
||||
//没有给定父级目录的id,默认设置父级目录为根目录的父目录
|
||||
mc.setParentId(BusinessConstants.MATERIAL_CATEGORY_ROOT_PARENT_ID);
|
||||
}
|
||||
//检查商品类型编号是否已存在
|
||||
checkMaterialCategorySerialNo(mc);
|
||||
//更新时间
|
||||
mc.setUpdateTime(new Date());
|
||||
//更新人
|
||||
User userInfo=userService.getCurrentUser();
|
||||
int result=0;
|
||||
try{
|
||||
result= materialCategoryMapperEx.editMaterialCategory(mc);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 根据商品类别编号判断商品类别是否已存在
|
||||
* */
|
||||
|
||||
Reference in New Issue
Block a user