org.jeecg.modules.system.entity.SysDepart Java Examples

The following examples show how to use org.jeecg.modules.system.entity.SysDepart. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SysDepartServiceImpl.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * saveDepartData 对应 add 保存用户在页面添加的新的部门对象数据
 */
@Override
@Transactional
public void saveDepartData(SysDepart sysDepart, String username) {
	if (sysDepart != null && username != null) {
		if (sysDepart.getParentId() == null) {
			sysDepart.setParentId("");
		}
		String s = UUID.randomUUID().toString().replace("-", "");
		sysDepart.setId(s);
		// 先判断该对象有无父级ID,有则意味着不是最高级,否则意味着是最高级
		// 获取父级ID
		String parentId = sysDepart.getParentId();
		String[] codeArray = generateOrgCode(parentId);
		sysDepart.setOrgCode(codeArray[0]);
		String orgType = codeArray[1];
		sysDepart.setOrgType(String.valueOf(orgType));
		sysDepart.setCreateTime(new Date());
		sysDepart.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
		this.save(sysDepart);
	}

}
 
Example #2
Source File: SysDepartServiceImpl.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 根据用户所负责部门ids获取父级部门编码
 * @param departIds
 * @return
 */
private String[] getMyDeptParentOrgCode(String departIds){
	//根据部门id查询所负责部门
	LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
	query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
	query.in(SysDepart::getId, Arrays.asList(departIds.split(",")));
	query.orderByAsc(SysDepart::getOrgCode);
	List<SysDepart> list = this.list(query);
	//查找根部门
	if(list == null || list.size()==0){
		return null;
	}
	String orgCode = this.getMyDeptParentNode(list);
	String[] codeArr = orgCode.split(",");
	return codeArr;
}
 
Example #3
Source File: SysDepartServiceImpl.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 获取负责部门父节点
 * @param list
 * @return
 */
private String getMyDeptParentNode(List<SysDepart> list){
	Map<String,String> map = new HashMap<>();
	//1.先将同一公司归类
	for(SysDepart dept : list){
		String code = dept.getOrgCode().substring(0,3);
		if(map.containsKey(code)){
			String mapCode = map.get(code)+","+dept.getOrgCode();
			map.put(code,mapCode);
		}else{
			map.put(code,dept.getOrgCode());
		}
	}
	StringBuffer parentOrgCode = new StringBuffer();
	//2.获取同一公司的根节点
	for(String str : map.values()){
		String[] arrStr = str.split(",");
		parentOrgCode.append(",").append(this.getMinLengthNode(arrStr));
	}
	return parentOrgCode.substring(1);
}
 
Example #4
Source File: SysDepartController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
    *   通过id删除
   * @param id
   * @return
   */
//@RequiresRoles({"admin"})
   @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
  public Result<SysDepart> delete(@RequestParam(name="id",required=true) String id) {

      Result<SysDepart> result = new Result<SysDepart>();
      SysDepart sysDepart = sysDepartService.getById(id);
      if(sysDepart==null) {
          result.error500("未找到对应实体");
      }else {
          boolean ok = sysDepartService.delete(id);
          if(ok) {
            //清除部门树内存
   		   //FindsDepartsChildrenUtil.clearSysDepartTreeList();
   		   // FindsDepartsChildrenUtil.clearDepartIdModel();
              result.success("删除成功!");
          }
      }
      return result;
  }
 
Example #5
Source File: SysDepartController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 编辑数据 编辑部门的部分数据,并保存到数据库
 * 
 * @param sysDepart
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
public Result<SysDepart> edit(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
	String username = JwtUtil.getUserNameByToken(request);
	sysDepart.setUpdateBy(username);
	Result<SysDepart> result = new Result<SysDepart>();
	SysDepart sysDepartEntity = sysDepartService.getById(sysDepart.getId());
	if (sysDepartEntity == null) {
		result.error500("未找到对应实体");
	} else {
		boolean ok = sysDepartService.updateDepartDataById(sysDepart, username);
		// TODO 返回false说明什么?
		if (ok) {
			//清除部门树内存
			//FindsDepartsChildrenUtil.clearSysDepartTreeList();
			//FindsDepartsChildrenUtil.clearDepartIdModel();
			result.success("修改成功!");
		}
	}
	return result;
}
 
Example #6
Source File: SysDepartController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 添加新数据 添加用户新建的部门对象数据,并保存到数据库
 * 
 * @param sysDepart
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/add", method = RequestMethod.POST)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
public Result<SysDepart> add(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
	Result<SysDepart> result = new Result<SysDepart>();
	String username = JwtUtil.getUserNameByToken(request);
	try {
		sysDepart.setCreateBy(username);
		sysDepartService.saveDepartData(sysDepart, username);
		//清除部门树内存
		// FindsDepartsChildrenUtil.clearSysDepartTreeList();
		// FindsDepartsChildrenUtil.clearDepartIdModel();
		result.success("添加成功!");
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		result.error500("操作失败");
	}
	return result;
}
 
Example #7
Source File: SysDepartTreeModel.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
    * 将SysDepart对象转换成SysDepartTreeModel对象
    * @param sysDepart
    */
public SysDepartTreeModel(SysDepart sysDepart) {
	this.key = sysDepart.getId();
       this.value = sysDepart.getId();
       this.title = sysDepart.getDepartName();
       this.id = sysDepart.getId();
       this.parentId = sysDepart.getParentId();
       this.departName = sysDepart.getDepartName();
       this.departNameEn = sysDepart.getDepartNameEn();
       this.departNameAbbr = sysDepart.getDepartNameAbbr();
       this.departOrder = sysDepart.getDepartOrder();
       this.description = sysDepart.getDescription();
       this.orgCategory = sysDepart.getOrgCategory();
       this.orgType = sysDepart.getOrgType();
       this.orgCode = sysDepart.getOrgCode();
       this.mobile = sysDepart.getMobile();
       this.fax = sysDepart.getFax();
       this.address = sysDepart.getAddress();
       this.memo = sysDepart.getMemo();
       this.status = sysDepart.getStatus();
       this.delFlag = sysDepart.getDelFlag();
       this.createBy = sysDepart.getCreateBy();
       this.createTime = sysDepart.getCreateTime();
       this.updateBy = sysDepart.getUpdateBy();
       this.updateTime = sysDepart.getUpdateTime();
   }
 
Example #8
Source File: SysDepartController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
  * 导出excel
  *
  * @param request
  */
 @RequestMapping(value = "/exportXls")
 public ModelAndView exportXls(SysDepart sysDepart,HttpServletRequest request) {
     // Step.1 组装查询条件
     QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(sysDepart, request.getParameterMap());
     //Step.2 AutoPoi 导出Excel
     ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
     List<SysDepart> pageList = sysDepartService.list(queryWrapper);
     //按字典排序
     Collections.sort(pageList, new Comparator<SysDepart>() {
         @Override
public int compare(SysDepart arg0, SysDepart arg1) {
         	return arg0.getOrgCode().compareTo(arg1.getOrgCode());
         }
     });
     //导出文件名称
     mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表");
     mv.addObject(NormalExcelConstants.CLASS, SysDepart.class);
     LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
     mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:"+user.getRealname(), "导出信息"));
     mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
     return mv;
 }
 
Example #9
Source File: SysDepartController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
  * 导出excel
  *
  * @param request
  */
 @RequestMapping(value = "/exportXls")
 public ModelAndView exportXls(SysDepart sysDepart,HttpServletRequest request) {
     // Step.1 组装查询条件
     QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(sysDepart, request.getParameterMap());
     //Step.2 AutoPoi 导出Excel
     ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
     List<SysDepart> pageList = sysDepartService.list(queryWrapper);
     //按字典排序
     Collections.sort(pageList, new Comparator<SysDepart>() {
         @Override
public int compare(SysDepart arg0, SysDepart arg1) {
         	return arg0.getOrgCode().compareTo(arg1.getOrgCode());
         }
     });
     //导出文件名称
     mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表");
     mv.addObject(NormalExcelConstants.CLASS, SysDepart.class);
     LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
     mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:"+user.getRealname(), "导出信息"));
     mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
     return mv;
 }
 
Example #10
Source File: SysDepartTreeModel.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
    * 将SysDepart对象转换成SysDepartTreeModel对象
    * @param sysDepart
    */
public SysDepartTreeModel(SysDepart sysDepart) {
	this.key = sysDepart.getId();
       this.value = sysDepart.getId();
       this.title = sysDepart.getDepartName();
       this.id = sysDepart.getId();
       this.parentId = sysDepart.getParentId();
       this.departName = sysDepart.getDepartName();
       this.departNameEn = sysDepart.getDepartNameEn();
       this.departNameAbbr = sysDepart.getDepartNameAbbr();
       this.departOrder = sysDepart.getDepartOrder();
       this.description = sysDepart.getDescription();
       this.orgCategory = sysDepart.getOrgCategory();
       this.orgType = sysDepart.getOrgType();
       this.orgCode = sysDepart.getOrgCode();
       this.mobile = sysDepart.getMobile();
       this.fax = sysDepart.getFax();
       this.address = sysDepart.getAddress();
       this.memo = sysDepart.getMemo();
       this.status = sysDepart.getStatus();
       this.delFlag = sysDepart.getDelFlag();
       this.createBy = sysDepart.getCreateBy();
       this.createTime = sysDepart.getCreateTime();
       this.updateBy = sysDepart.getUpdateBy();
       this.updateTime = sysDepart.getUpdateTime();
   }
 
Example #11
Source File: SysDepartController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * 编辑数据 编辑部门的部分数据,并保存到数据库
 * 
 * @param sysDepart
 * @return
 */
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
public Result<SysDepart> edit(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
	String username = JwtUtil.getUserNameByToken(request);
	sysDepart.setUpdateBy(username);
	Result<SysDepart> result = new Result<SysDepart>();
	SysDepart sysDepartEntity = sysDepartService.getById(sysDepart.getId());
	if (sysDepartEntity == null) {
		result.error500("未找到对应实体");
	} else {
		boolean ok = sysDepartService.updateDepartDataById(sysDepart, username);
		// TODO 返回false说明什么?
		if (ok) {
			//清除部门树内存
			//FindsDepartsChildrenUtil.clearSysDepartTreeList();
			//FindsDepartsChildrenUtil.clearDepartIdModel();
			result.success("修改成功!");
		}
	}
	return result;
}
 
Example #12
Source File: SysDepartController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
    *   通过id删除
   * @param id
   * @return
   */
   @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
  public Result<SysDepart> delete(@RequestParam(name="id",required=true) String id) {

      Result<SysDepart> result = new Result<SysDepart>();
      SysDepart sysDepart = sysDepartService.getById(id);
      if(sysDepart==null) {
          result.error500("未找到对应实体");
      }else {
          boolean ok = sysDepartService.delete(id);
          if(ok) {
            //清除部门树内存
   		   //FindsDepartsChildrenUtil.clearSysDepartTreeList();
   		   // FindsDepartsChildrenUtil.clearDepartIdModel();
              result.success("删除成功!");
          }
      }
      return result;
  }
 
Example #13
Source File: SysDepartController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
  * 导出excel
  *
  * @param request
  */
 @RequestMapping(value = "/exportXls")
 public ModelAndView exportXls(SysDepart sysDepart,HttpServletRequest request) {
     // Step.1 组装查询条件
     QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(sysDepart, request.getParameterMap());
     //Step.2 AutoPoi 导出Excel
     ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
     List<SysDepart> pageList = sysDepartService.list(queryWrapper);
     //按字典排序
     Collections.sort(pageList, new Comparator<SysDepart>() {
         @Override
public int compare(SysDepart arg0, SysDepart arg1) {
         	return arg0.getOrgCode().compareTo(arg1.getOrgCode());
         }
     });
     //导出文件名称
     mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表");
     mv.addObject(NormalExcelConstants.CLASS, SysDepart.class);
     LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
     mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:"+user.getRealname(), "导出信息"));
     mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
     return mv;
 }
 
Example #14
Source File: SysDepartController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
  * 导出excel
  *
  * @param request
  * @param response
  */
 @RequestMapping(value = "/exportXls")
 public ModelAndView exportXls(SysDepart sysDepart,HttpServletRequest request) {
     // Step.1 组装查询条件
     QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(sysDepart, request.getParameterMap());
     //Step.2 AutoPoi 导出Excel
     ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
     List<SysDepart> pageList = sysDepartService.list(queryWrapper);
     //按字典排序
     Collections.sort(pageList, new Comparator<SysDepart>() {
         @Override
public int compare(SysDepart arg0, SysDepart arg1) {
         	return arg0.getOrgCode().compareTo(arg1.getOrgCode());
         }
     });
     //导出文件名称
     mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表");
     mv.addObject(NormalExcelConstants.CLASS, SysDepart.class);
     LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
     mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:"+user.getRealname(), "导出信息"));
     mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
     return mv;
 }
 
Example #15
Source File: SysDepartController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
    *   通过id删除
   * @param id
   * @return
   */
   @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
  public Result<SysDepart> delete(@RequestParam(name="id",required=true) String id) {

      Result<SysDepart> result = new Result<SysDepart>();
      SysDepart sysDepart = sysDepartService.getById(id);
      if(sysDepart==null) {
          result.error500("未找到对应实体");
      }else {
          boolean ok = sysDepartService.delete(id);
          if(ok) {
            //清除部门树内存
   		   //FindsDepartsChildrenUtil.clearSysDepartTreeList();
   		   // FindsDepartsChildrenUtil.clearDepartIdModel();
              result.success("删除成功!");
          }
      }
      return result;
  }
 
Example #16
Source File: SysDepartTreeModel.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
    * 将SysDepart对象转换成SysDepartTreeModel对象
    * @param sysDepart
    */
public SysDepartTreeModel(SysDepart sysDepart) {
	this.key = sysDepart.getId();
       this.value = sysDepart.getId();
       this.title = sysDepart.getDepartName();
       this.id = sysDepart.getId();
       this.parentId = sysDepart.getParentId();
       this.departName = sysDepart.getDepartName();
       this.departNameEn = sysDepart.getDepartNameEn();
       this.departNameAbbr = sysDepart.getDepartNameAbbr();
       this.departOrder = sysDepart.getDepartOrder();
       this.description = sysDepart.getDescription();
       this.orgCategory = sysDepart.getOrgCategory();
       this.orgType = sysDepart.getOrgType();
       this.orgCode = sysDepart.getOrgCode();
       this.mobile = sysDepart.getMobile();
       this.fax = sysDepart.getFax();
       this.address = sysDepart.getAddress();
       this.memo = sysDepart.getMemo();
       this.status = sysDepart.getStatus();
       this.delFlag = sysDepart.getDelFlag();
       this.createBy = sysDepart.getCreateBy();
       this.createTime = sysDepart.getCreateTime();
       this.updateBy = sysDepart.getUpdateBy();
       this.updateTime = sysDepart.getUpdateTime();
   }
 
Example #17
Source File: SysDepartController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 编辑数据 编辑部门的部分数据,并保存到数据库
 * 
 * @param sysDepart
 * @return
 */
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
public Result<SysDepart> edit(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
	String username = JwtUtil.getUserNameByToken(request);
	sysDepart.setUpdateBy(username);
	Result<SysDepart> result = new Result<SysDepart>();
	SysDepart sysDepartEntity = sysDepartService.getById(sysDepart.getId());
	if (sysDepartEntity == null) {
		result.error500("未找到对应实体");
	} else {
		boolean ok = sysDepartService.updateDepartDataById(sysDepart, username);
		// TODO 返回false说明什么?
		if (ok) {
			//清除部门树内存
			//FindsDepartsChildrenUtil.clearSysDepartTreeList();
			//FindsDepartsChildrenUtil.clearDepartIdModel();
			result.success("修改成功!");
		}
	}
	return result;
}
 
Example #18
Source File: SysDepartController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * 添加新数据 添加用户新建的部门对象数据,并保存到数据库
 * 
 * @param sysDepart
 * @return
 */
@RequestMapping(value = "/add", method = RequestMethod.POST)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
public Result<SysDepart> add(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
	Result<SysDepart> result = new Result<SysDepart>();
	String username = JwtUtil.getUserNameByToken(request);
	try {
		sysDepart.setCreateBy(username);
		sysDepartService.saveDepartData(sysDepart, username);
		//清除部门树内存
		// FindsDepartsChildrenUtil.clearSysDepartTreeList();
		// FindsDepartsChildrenUtil.clearDepartIdModel();
		result.success("添加成功!");
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		result.error500("操作失败");
	}
	return result;
}
 
Example #19
Source File: SysDepartTreeModel.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
    * 将SysDepart对象转换成SysDepartTreeModel对象
    * @param sysDepart
    */
public SysDepartTreeModel(SysDepart sysDepart) {
	this.key = sysDepart.getId();
       this.value = sysDepart.getId();
       this.title = sysDepart.getDepartName();
       this.id = sysDepart.getId();
       this.parentId = sysDepart.getParentId();
       this.departName = sysDepart.getDepartName();
       this.departNameEn = sysDepart.getDepartNameEn();
       this.departNameAbbr = sysDepart.getDepartNameAbbr();
       this.departOrder = sysDepart.getDepartOrder();
       this.description = sysDepart.getDescription();
       this.orgCategory = sysDepart.getOrgCategory();
       this.orgType = sysDepart.getOrgType();
       this.orgCode = sysDepart.getOrgCode();
       this.mobile = sysDepart.getMobile();
       this.fax = sysDepart.getFax();
       this.address = sysDepart.getAddress();
       this.memo = sysDepart.getMemo();
       this.status = sysDepart.getStatus();
       this.delFlag = sysDepart.getDelFlag();
       this.createBy = sysDepart.getCreateBy();
       this.createTime = sysDepart.getCreateTime();
       this.updateBy = sysDepart.getUpdateBy();
       this.updateTime = sysDepart.getUpdateTime();
   }
 
Example #20
Source File: FindsDepartsChildrenUtil.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 获取 DepartIdModel
 * @param recordList
 * @return
 */
public static List<DepartIdModel> wrapTreeDataToDepartIdTreeList(List<SysDepart> recordList) {
    // 在该方法每请求一次,都要对全局list集合进行一次清理
    //idList.clear();
    List<DepartIdModel> idList = new ArrayList<DepartIdModel>();
    List<SysDepartTreeModel> records = new ArrayList<>();
    for (int i = 0; i < recordList.size(); i++) {
        SysDepart depart = recordList.get(i);
        records.add(new SysDepartTreeModel(depart));
    }
    findChildren(records, idList);
    return idList;
}
 
Example #21
Source File: SysDepartServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * updateDepartDataById 对应 edit 根据部门主键来更新对应的部门数据
 */
@Override
@Transactional
public Boolean updateDepartDataById(SysDepart sysDepart, String username) {
	if (sysDepart != null && username != null) {
		sysDepart.setUpdateTime(new Date());
		sysDepart.setUpdateBy(username);
		this.updateById(sysDepart);
		return true;
	} else {
		return false;
	}

}
 
Example #22
Source File: SysDepartServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * delete 方法调用
 * @param id
 * @param idList
 */
private void checkChildrenExists(String id, List<String> idList) {	
	LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
	query.eq(SysDepart::getParentId,id);
	List<SysDepart> departList = this.list(query);
	if(departList != null && departList.size() > 0) {
		for(SysDepart depart : departList) {
			idList.add(depart.getId());
			this.checkChildrenExists(depart.getId(), idList);
		}
	}
}
 
Example #23
Source File: FindsDepartsChildrenUtil.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 获取 DepartIdModel
 * @param recordList
 * @return
 */
public static List<DepartIdModel> wrapTreeDataToDepartIdTreeList(List<SysDepart> recordList) {
    // 在该方法每请求一次,都要对全局list集合进行一次清理
    //idList.clear();
    List<DepartIdModel> idList = new ArrayList<DepartIdModel>();
    List<SysDepartTreeModel> records = new ArrayList<>();
    for (int i = 0; i < recordList.size(); i++) {
        SysDepart depart = recordList.get(i);
        records.add(new SysDepartTreeModel(depart));
    }
    findChildren(records, idList);
    return idList;
}
 
Example #24
Source File: FindsDepartsChildrenUtil.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * queryTreeList的子方法 ====1=====
 * 该方法是s将SysDepart类型的list集合转换成SysDepartTreeModel类型的集合
 */
public static List<SysDepartTreeModel> wrapTreeDataToTreeList(List<SysDepart> recordList) {
    // 在该方法每请求一次,都要对全局list集合进行一次清理
    //idList.clear();
	List<DepartIdModel> idList = new ArrayList<DepartIdModel>();
    List<SysDepartTreeModel> records = new ArrayList<>();
    for (int i = 0; i < recordList.size(); i++) {
        SysDepart depart = recordList.get(i);
        records.add(new SysDepartTreeModel(depart));
    }
    List<SysDepartTreeModel> tree = findChildren(records, idList);
    setEmptyChildrenAsNull(tree);
    return tree;
}
 
Example #25
Source File: FindsDepartsChildrenUtil.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 获取 DepartIdModel
 * @param recordList
 * @return
 */
public static List<DepartIdModel> wrapTreeDataToDepartIdTreeList(List<SysDepart> recordList) {
    // 在该方法每请求一次,都要对全局list集合进行一次清理
    //idList.clear();
    List<DepartIdModel> idList = new ArrayList<DepartIdModel>();
    List<SysDepartTreeModel> records = new ArrayList<>();
    for (int i = 0; i < recordList.size(); i++) {
        SysDepart depart = recordList.get(i);
        records.add(new SysDepartTreeModel(depart));
    }
    findChildren(records, idList);
    return idList;
}
 
Example #26
Source File: FindsDepartsChildrenUtil.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * queryTreeList的子方法 ====1=====
 * 该方法是s将SysDepart类型的list集合转换成SysDepartTreeModel类型的集合
 */
public static List<SysDepartTreeModel> wrapTreeDataToTreeList(List<SysDepart> recordList) {
    // 在该方法每请求一次,都要对全局list集合进行一次清理
    //idList.clear();
	List<DepartIdModel> idList = new ArrayList<DepartIdModel>();
    List<SysDepartTreeModel> records = new ArrayList<>();
    for (int i = 0; i < recordList.size(); i++) {
        SysDepart depart = recordList.get(i);
        records.add(new SysDepartTreeModel(depart));
    }
    List<SysDepartTreeModel> tree = findChildren(records, idList);
    setEmptyChildrenAsNull(tree);
    return tree;
}
 
Example #27
Source File: SysUserDepartServiceImpl.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 根据用户id查询部门信息
 */
@Override
public List<DepartIdModel> queryDepartIdsOfUser(String userId) {
	LambdaQueryWrapper<SysUserDepart> queryUDep = new LambdaQueryWrapper<SysUserDepart>();
	LambdaQueryWrapper<SysDepart> queryDep = new LambdaQueryWrapper<SysDepart>();
	try {
		queryUDep.eq(SysUserDepart::getUserId, userId);
		List<String> depIdList = new ArrayList<>();
		List<DepartIdModel> depIdModelList = new ArrayList<>();
		List<SysUserDepart> userDepList = this.list(queryUDep);
		if(userDepList != null && userDepList.size() > 0) {
		for(SysUserDepart userDepart : userDepList) {
				depIdList.add(userDepart.getDepId());
			}
		queryDep.in(SysDepart::getId, depIdList);
		List<SysDepart> depList = sysDepartService.list(queryDep);
		if(depList != null || depList.size() > 0) {
			for(SysDepart depart : depList) {
				depIdModelList.add(new DepartIdModel().convertByUserDepart(depart));
			}
		}
		return depIdModelList;
		}
	}catch(Exception e) {
		e.fillInStackTrace();
	}
	return null;
	
	
}
 
Example #28
Source File: SysDepartServiceImpl.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * delete 方法调用
 * @param id
 * @param idList
 */
private void checkChildrenExists(String id, List<String> idList) {	
	LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
	query.eq(SysDepart::getParentId,id);
	List<SysDepart> departList = this.list(query);
	if(departList != null && departList.size() > 0) {
		for(SysDepart depart : departList) {
			idList.add(depart.getId());
			this.checkChildrenExists(depart.getId(), idList);
		}
	}
}
 
Example #29
Source File: SysDepartServiceImpl.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * updateDepartDataById 对应 edit 根据部门主键来更新对应的部门数据
 */
@Override
@Transactional
public Boolean updateDepartDataById(SysDepart sysDepart, String username) {
	if (sysDepart != null && username != null) {
		sysDepart.setUpdateTime(new Date());
		sysDepart.setUpdateBy(username);
		this.updateById(sysDepart);
		return true;
	} else {
		return false;
	}

}
 
Example #30
Source File: SysDepartController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 批量删除 根据前端请求的多个ID,对数据库执行删除相关部门数据的操作
 * 
 * @param ids
 * @return
 */
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
public Result<SysDepart> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {

	Result<SysDepart> result = new Result<SysDepart>();
	if (ids == null || "".equals(ids.trim())) {
		result.error500("参数不识别!");
	} else {
		this.sysDepartService.deleteBatchWithChildren(Arrays.asList(ids.split(",")));
		result.success("删除成功!");
	}
	return result;
}