添加商品类型和机构选择父级的时候只能从父级或者旁级选择的控制
This commit is contained in:
@@ -83,7 +83,14 @@ public class BusinessConstants {
|
||||
/**
|
||||
* 商品类别根目录id
|
||||
* */
|
||||
public static final Long MATERIAL_CATEGORY_ROOT_ID = 1L;
|
||||
/**
|
||||
* create by: qiankunpingtai
|
||||
* create time: 2019/3/14 11:41
|
||||
* description:
|
||||
* 为了使用户可以自己建初始目录,设定根目录的父级目录id为-1
|
||||
*
|
||||
*/
|
||||
public static final Long MATERIAL_CATEGORY_ROOT_PARENT_ID = -1L;
|
||||
/**
|
||||
* 商品类别状态
|
||||
* 0系统默认,1启用,2删除
|
||||
@@ -101,10 +108,10 @@ public class BusinessConstants {
|
||||
public static final String ORGANIZATION_STCD_BUSINESS_TERMINATED = "4";
|
||||
public static final String ORGANIZATION_STCD_REMOVED = "5";
|
||||
/**
|
||||
* 根机构编号
|
||||
* 根机构编号默认为-1
|
||||
* 根机构父级编号
|
||||
* 根机父级构编号默认为-1
|
||||
* */
|
||||
public static final String ORGANIZATION_ROOT_NO = "-1";
|
||||
public static final String ORGANIZATION_ROOT_PARENT_NO = "-1";
|
||||
/**
|
||||
* 新增用户默认密码
|
||||
* */
|
||||
|
||||
@@ -92,9 +92,9 @@ public class MaterialCategoryController {
|
||||
* @return com.alibaba.fastjson.JSONArray
|
||||
*/
|
||||
@RequestMapping(value = "/getMaterialCategoryTree")
|
||||
public JSONArray getMaterialCategoryTree() throws Exception{
|
||||
public JSONArray getMaterialCategoryTree(@RequestParam("id") Long id) throws Exception{
|
||||
JSONArray arr=new JSONArray();
|
||||
List<TreeNode> materialCategoryTree = materialCategoryService.getMaterialCategoryTree();
|
||||
List<TreeNode> materialCategoryTree = materialCategoryService.getMaterialCategoryTree(id);
|
||||
if(materialCategoryTree!=null&&materialCategoryTree.size()>0){
|
||||
for(TreeNode node:materialCategoryTree){
|
||||
String str=JSON.toJSONString(node);
|
||||
|
||||
@@ -95,9 +95,9 @@ public class OrganizationController {
|
||||
* @return com.alibaba.fastjson.JSONArray
|
||||
*/
|
||||
@RequestMapping(value = "/getOrganizationTree")
|
||||
public JSONArray getOrganizationTree() throws Exception{
|
||||
public JSONArray getOrganizationTree(@RequestParam("id") Long id) throws Exception{
|
||||
JSONArray arr=new JSONArray();
|
||||
List<TreeNode> organizationTree= organizationService.getOrganizationTree();
|
||||
List<TreeNode> organizationTree= organizationService.getOrganizationTree(id);
|
||||
if(organizationTree!=null&&organizationTree.size()>0){
|
||||
for(TreeNode node:organizationTree){
|
||||
String str=JSON.toJSONString(node);
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Description
|
||||
@@ -24,8 +25,8 @@ public interface MaterialCategoryMapperEx {
|
||||
@Param("name") String name,
|
||||
@Param("parentId") Integer parentId);
|
||||
|
||||
List<TreeNode> getNodeTree();
|
||||
List<TreeNode> getNextNodeTree(@Param("id") Long id);
|
||||
List<TreeNode> getNodeTree(@Param("currentId")Long currentId);
|
||||
List<TreeNode> getNextNodeTree(Map<String, Object> parameterMap);
|
||||
|
||||
int addMaterialCategory(MaterialCategory mc);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Description
|
||||
@@ -17,8 +18,8 @@ import java.util.List;
|
||||
public interface OrganizationMapperEx {
|
||||
|
||||
|
||||
List<TreeNode> getNodeTree();
|
||||
List<TreeNode> getNextNodeTree(@Param("id") Long id);
|
||||
List<TreeNode> getNodeTree(@Param("currentId")Long currentId);
|
||||
List<TreeNode> getNextNodeTree(Map<String, Object> parameterMap);
|
||||
|
||||
int addOrganization(Organization org);
|
||||
|
||||
|
||||
@@ -100,8 +100,8 @@ public class MaterialCategoryService {
|
||||
* @Param:
|
||||
* @return java.util.List<com.jsh.erp.datasource.vo.TreeNode>
|
||||
*/
|
||||
public List<TreeNode> getMaterialCategoryTree() throws Exception{
|
||||
return materialCategoryMapperEx.getNodeTree();
|
||||
public List<TreeNode> getMaterialCategoryTree(Long id) throws Exception{
|
||||
return materialCategoryMapperEx.getNodeTree(id);
|
||||
}
|
||||
/**
|
||||
* create by: cjl
|
||||
@@ -117,8 +117,8 @@ public class MaterialCategoryService {
|
||||
return 0;
|
||||
}
|
||||
if(mc.getParentid()==null){
|
||||
//没有给定父级目录的id,默认设置父级目录为根目录
|
||||
mc.setParentid(BusinessConstants.MATERIAL_CATEGORY_ROOT_ID);
|
||||
//没有给定父级目录的id,默认设置父级目录为根目录的父目录
|
||||
mc.setParentid(BusinessConstants.MATERIAL_CATEGORY_ROOT_PARENT_ID);
|
||||
}
|
||||
//检查商品类型编号是否已存在
|
||||
checkMaterialCategorySerialNo(mc);
|
||||
@@ -148,40 +148,16 @@ public class MaterialCategoryService {
|
||||
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);
|
||||
|
||||
if(mc.getParentid()==null){
|
||||
//没有给定父级目录的id,默认设置父级目录为根目录的父目录
|
||||
mc.setParentid(BusinessConstants.MATERIAL_CATEGORY_ROOT_PARENT_ID);
|
||||
}
|
||||
|
||||
//检查商品类型编号是否已存在
|
||||
checkMaterialCategorySerialNo(mc);
|
||||
//更新时间
|
||||
|
||||
@@ -82,7 +82,7 @@ public class OrganizationService {
|
||||
* 未指定父级机构的时候默认为根机构
|
||||
* */
|
||||
if(StringUtil.isEmpty(org.getOrgParentNo())){
|
||||
org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_NO);
|
||||
org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_PARENT_NO);
|
||||
}
|
||||
return organizationMapperEx.addOrganization(org);
|
||||
}
|
||||
@@ -103,13 +103,13 @@ public class OrganizationService {
|
||||
* 未指定父级机构的时候默认为根机构
|
||||
* */
|
||||
if(StringUtil.isEmpty(org.getOrgParentNo())){
|
||||
org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_NO);
|
||||
org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_PARENT_NO);
|
||||
}
|
||||
return organizationMapperEx.editOrganization(org);
|
||||
}
|
||||
|
||||
public List<TreeNode> getOrganizationTree()throws Exception {
|
||||
return organizationMapperEx.getNodeTree();
|
||||
public List<TreeNode> getOrganizationTree(Long id)throws Exception {
|
||||
return organizationMapperEx.getNodeTree(id);
|
||||
}
|
||||
|
||||
public List<Organization> findById(Long id) throws Exception{
|
||||
|
||||
Reference in New Issue
Block a user