Search in sources :

Example 16 with SysDept

use of com.ruoyi.common.core.domain.entity.SysDept in project hocassian-media-matrix by hokaso.

the class SysDeptServiceImpl method updateDept.

/**
 * 修改保存部门信息
 *
 * @param dept 部门信息
 * @return 结果
 */
@Override
public int updateDept(SysDept dept) {
    SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
    SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
    if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
        String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
        String oldAncestors = oldDept.getAncestors();
        dept.setAncestors(newAncestors);
        updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
    }
    int result = deptMapper.updateDept(dept);
    if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) {
        // 如果该部门是启用状态,则启用该部门的所有上级部门
        updateParentDeptStatus(dept);
    }
    return result;
}
Also used : SysDept(com.ruoyi.common.core.domain.entity.SysDept)

Example 17 with SysDept

use of com.ruoyi.common.core.domain.entity.SysDept in project RuoYi-Vue-Plus by JavaLionLi.

the class SysUserController method export.

@ApiOperation("导出用户列表")
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@SaCheckPermission("system:user:export")
@PostMapping("/export")
public void export(SysUser user, HttpServletResponse response) {
    List<SysUser> list = userService.selectUserList(user);
    List<SysUserExportVo> listVo = BeanUtil.copyToList(list, SysUserExportVo.class);
    for (int i = 0; i < list.size(); i++) {
        SysDept dept = list.get(i).getDept();
        SysUserExportVo vo = listVo.get(i);
        if (ObjectUtil.isNotEmpty(dept)) {
            vo.setDeptName(dept.getDeptName());
            vo.setLeader(dept.getLeader());
        }
    }
    ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response);
}
Also used : SysUser(com.ruoyi.common.core.domain.entity.SysUser) SysDept(com.ruoyi.common.core.domain.entity.SysDept) SysUserExportVo(com.ruoyi.system.domain.vo.SysUserExportVo) Log(com.ruoyi.common.annotation.Log) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Example 18 with SysDept

use of com.ruoyi.common.core.domain.entity.SysDept in project RuoYi-Vue-Plus by JavaLionLi.

the class SysDeptController method roleDeptTreeselect.

/**
 * 加载对应角色部门列表树
 */
@ApiOperation("加载对应角色部门列表树")
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
public R<Map<String, Object>> roleDeptTreeselect(@ApiParam("角色ID") @PathVariable("roleId") Long roleId) {
    List<SysDept> depts = deptService.selectDeptList(new SysDept());
    Map<String, Object> ajax = new HashMap<>();
    ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
    ajax.put("depts", deptService.buildDeptTreeSelect(depts));
    return R.ok(ajax);
}
Also used : HashMap(java.util.HashMap) SysDept(com.ruoyi.common.core.domain.entity.SysDept) ApiOperation(io.swagger.annotations.ApiOperation)

Example 19 with SysDept

use of com.ruoyi.common.core.domain.entity.SysDept in project RuoYi-Vue-Plus by JavaLionLi.

the class SysDeptServiceImpl method updateDept.

/**
 * 修改保存部门信息
 *
 * @param dept 部门信息
 * @return 结果
 */
@Override
public int updateDept(SysDept dept) {
    SysDept newParentDept = baseMapper.selectById(dept.getParentId());
    SysDept oldDept = baseMapper.selectById(dept.getDeptId());
    if (ObjectUtil.isNotNull(newParentDept) && ObjectUtil.isNotNull(oldDept)) {
        String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
        String oldAncestors = oldDept.getAncestors();
        dept.setAncestors(newAncestors);
        updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
    }
    int result = baseMapper.updateById(dept);
    if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) && !StringUtils.equals(UserConstants.DEPT_NORMAL, dept.getAncestors())) {
        // 如果该部门是启用状态,则启用该部门的所有上级部门
        updateParentDeptStatusNormal(dept);
    }
    return result;
}
Also used : SysDept(com.ruoyi.common.core.domain.entity.SysDept)

Example 20 with SysDept

use of com.ruoyi.common.core.domain.entity.SysDept in project RuoYi-Flowable-Plus by KonBAI-Q.

the class SysUserController method export.

@ApiOperation("导出用户列表")
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@SaCheckPermission("system:user:export")
@PostMapping("/export")
public void export(SysUser user, HttpServletResponse response) {
    List<SysUser> list = userService.selectUserList(user);
    List<SysUserExportVo> listVo = BeanUtil.copyToList(list, SysUserExportVo.class);
    for (int i = 0; i < list.size(); i++) {
        SysDept dept = list.get(i).getDept();
        SysUserExportVo vo = listVo.get(i);
        if (ObjectUtil.isNotEmpty(dept)) {
            vo.setDeptName(dept.getDeptName());
            vo.setLeader(dept.getLeader());
        }
    }
    ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response);
}
Also used : SysUser(com.ruoyi.common.core.domain.entity.SysUser) SysDept(com.ruoyi.common.core.domain.entity.SysDept) SysUserExportVo(com.ruoyi.system.domain.vo.SysUserExportVo) Log(com.ruoyi.common.annotation.Log) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Aggregations

SysDept (com.ruoyi.common.core.domain.entity.SysDept)39 ServiceException (com.ruoyi.common.exception.ServiceException)8 ArrayList (java.util.ArrayList)7 GetMapping (org.springframework.web.bind.annotation.GetMapping)6 SaCheckPermission (cn.dev33.satoken.annotation.SaCheckPermission)4 ApiOperation (io.swagger.annotations.ApiOperation)4 AjaxResult (com.ruoyi.common.core.domain.AjaxResult)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)3 Log (com.ruoyi.common.annotation.Log)2 SysUser (com.ruoyi.common.core.domain.entity.SysUser)2 SysUserExportVo (com.ruoyi.system.domain.vo.SysUserExportVo)2 HashMap (java.util.HashMap)2 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 CustomException (com.ruoyi.common.exception.CustomException)1