提交修改
This commit is contained in:
parent
804747f3e3
commit
3184452779
@ -58,60 +58,13 @@ public class RecordRoleController {
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Long id) {
|
||||
RecordRole lzRecordRole = lzRecordRoleService.selectRecordRoleById(id);
|
||||
SysRoleEntity role = new SysRoleEntity();
|
||||
role.setRoleId(lzRecordRole.getId());
|
||||
role.setRoleName(lzRecordRole.getName());
|
||||
//查询角色对应的菜单
|
||||
List<Long> menuIdList = recordRoleAuthService.queryMenuIdList(id);
|
||||
role.setMenuIdList(menuIdList);
|
||||
SysRoleEntity role = lzRecordRoleService.getRole(id);
|
||||
return R.ok().put("role", role);
|
||||
}
|
||||
|
||||
@RequestMapping("/menu/list")
|
||||
public List<SysMenuEntity> menuList() {
|
||||
List<SysMenuEntity> list = new ArrayList<>();
|
||||
List<RecordAuth> recordAuths = recordAuthService.selectAll();
|
||||
for (int i = 0; i < recordAuths.size(); i++) {
|
||||
RecordAuth recordAuth = recordAuths.get(i);
|
||||
Long parentId = recordAuth.getId();
|
||||
if (i + 1 < recordAuths.size()) {
|
||||
RecordAuth child = recordAuths.get(i + 1);
|
||||
if (child.getIdentity().equals(recordAuth.getIdentity())) {
|
||||
parentId = NumberUtil.objToLong(recordAuth.getId() + "000000");
|
||||
}
|
||||
}
|
||||
SysMenuEntity sysMenuEntity = buildMenuEntity(parentId, recordAuth.getName(), 0l, "");
|
||||
list.add(sysMenuEntity);
|
||||
if (i + 1 < recordAuths.size()) {
|
||||
RecordAuth child = recordAuths.get(i + 1);
|
||||
if (!child.getIdentity().equals(recordAuth.getIdentity())) {
|
||||
continue;
|
||||
}
|
||||
for (int j = i; j < recordAuths.size(); j++) {
|
||||
child = recordAuths.get(j);
|
||||
if (!child.getIdentity().equals(recordAuth.getIdentity())) {
|
||||
if (j == recordAuths.size() - 1) {
|
||||
i = j;
|
||||
} else {
|
||||
i = j - 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
String name = "不可见";
|
||||
if (child.getStatus().equals(1)) {
|
||||
name = "可见";
|
||||
} else if (child.getStatus().equals(2)) {
|
||||
name = "可编辑";
|
||||
}
|
||||
SysMenuEntity childMenuEntity = buildMenuEntity(child.getId(), name, parentId, recordAuth.getName());
|
||||
list.add(childMenuEntity);
|
||||
if (j == recordAuths.size() - 1) {
|
||||
i = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SysMenuEntity> list = lzRecordRoleService.selectMenuList();
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -155,14 +108,6 @@ public class RecordRoleController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
public SysMenuEntity buildMenuEntity(Long id, String name, Long parentId, String parentName) {
|
||||
SysMenuEntity sysMenuEntity = new SysMenuEntity();
|
||||
sysMenuEntity.setMenuId(id);
|
||||
sysMenuEntity.setName(name);
|
||||
sysMenuEntity.setParentId(parentId);
|
||||
sysMenuEntity.setParentName(parentName);
|
||||
return sysMenuEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
|
||||
@ -1,21 +1,27 @@
|
||||
package com.lz.modules.app.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.lz.common.utils.PageUtils;
|
||||
import com.lz.common.utils.R;
|
||||
import com.lz.modules.app.entity.DepartmentsEntity;
|
||||
import com.lz.modules.app.entity.StaffEntity;
|
||||
import com.lz.modules.app.service.DepartmentsService;
|
||||
import com.lz.modules.app.service.StaffService;
|
||||
import com.lz.modules.flow.entity.RecordRole;
|
||||
import com.lz.modules.flow.entity.StaffRole;
|
||||
import com.lz.modules.flow.entity.StaffRoleDepartment;
|
||||
import com.lz.modules.flow.req.StaffRoleRequest;
|
||||
import com.lz.modules.flow.service.RecordRoleService;
|
||||
import com.lz.modules.flow.service.StaffRoleDepartmentService;
|
||||
import com.lz.modules.flow.service.StaffRoleService;
|
||||
import com.lz.modules.sys.entity.SysMenuEntity;
|
||||
import com.lz.modules.sys.entity.SysRoleEntity;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@ -31,12 +37,26 @@ public class StaffRoleController {
|
||||
@Autowired
|
||||
private StaffRoleService staffRoleService;
|
||||
|
||||
@Autowired
|
||||
private StaffService staffService;
|
||||
|
||||
@Autowired
|
||||
private RecordRoleService recordRoleService;
|
||||
|
||||
@Autowired
|
||||
private StaffRoleDepartmentService staffRoleDepartmentService;
|
||||
|
||||
@Autowired
|
||||
private DepartmentsService departmentsService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@RequiresPermissions("user:lzstaffrole:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = staffRoleService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
@ -46,32 +66,97 @@ public class StaffRoleController {
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
@RequiresPermissions("user:lzstaffrole:info")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
StaffRole lzStaffRole = staffRoleService.selectByStaffId(id);
|
||||
|
||||
return R.ok().put("lzStaffRole", lzStaffRole);
|
||||
public R info(@PathVariable("id") Long id) {
|
||||
StaffRole lzStaffRole = staffRoleService.selectStaffRoleById(id);
|
||||
List<StaffEntity> staffEntityList = staffService.selectAll();
|
||||
List<StaffEntity> newList = new ArrayList<>();
|
||||
staffEntityList.forEach(p -> {
|
||||
StaffEntity staffEntity = new StaffEntity();
|
||||
staffEntity.setId(p.getId());
|
||||
staffEntity.setName(p.getName());
|
||||
newList.add(staffEntity);
|
||||
});
|
||||
List<RecordRole> roles = recordRoleService.selectAll();
|
||||
return R.ok().put("lzStaffRole", lzStaffRole)
|
||||
.put("staffs", newList)
|
||||
.put("targetRoles", roles)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("user:lzstaffrole:save")
|
||||
public R save(@RequestBody StaffRole lzStaffRole){
|
||||
staffRoleService.insertStaffRole(lzStaffRole);
|
||||
|
||||
return R.ok();
|
||||
@RequestMapping("/role/list/{id}")
|
||||
public R roleList(@PathVariable("id") Long id) {
|
||||
SysRoleEntity role = staffRoleService.getRole(id);
|
||||
return R.ok().put("role", role);
|
||||
}
|
||||
|
||||
@RequestMapping("/menu/list")
|
||||
public List<SysMenuEntity> menuList() {
|
||||
List<SysMenuEntity> list = staffRoleService.selectMenuList();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequestMapping("/updateOrAdd")
|
||||
@RequiresPermissions("user:lzstaffrole:update")
|
||||
public R update(@RequestBody StaffRole lzStaffRole){
|
||||
staffRoleService.updateById(lzStaffRole);
|
||||
public R update(@RequestBody StaffRoleRequest req) {
|
||||
StaffRole staffRole = null;
|
||||
List<StaffRole> staffRoles = staffRoleService.selectByRole(req.getDepartmentLevel());
|
||||
List<Long> ids = staffRoles.stream().map(StaffRole::getId).collect(Collectors.toList());
|
||||
if (req.getId() == null || req.getId() <= 0) {
|
||||
staffRole = new StaffRole();
|
||||
} else {
|
||||
staffRole = staffRoleService.selectStaffRoleById(req.getId());
|
||||
}
|
||||
|
||||
staffRole.setStaffId(req.getStaffId());
|
||||
staffRole.setDepartmentLevel(req.getDepartmentLevel());
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
map.put("type1", req.getTargetRole());
|
||||
map.put("type2", req.getResultRole());
|
||||
staffRole.setTypeRoleIds(JSON.toJSONString(map));
|
||||
List<Long> menuIdList = req.getMenuIdList();
|
||||
for(Long menuId : menuIdList) {
|
||||
if (menuId <= 0) {
|
||||
continue;
|
||||
}
|
||||
StaffRoleDepartment staffRoleDepartment = staffRoleDepartmentService.selectStaffRoleDepartmentByDepartmentIdRoleIds(menuId, ids);
|
||||
if (staffRoleDepartment != null) {
|
||||
StaffRole staffRoleOld = staffRoleService.selectStaffRoleById(staffRoleDepartment.getStaffRoleId());
|
||||
if (staffRoleOld.getStaffId().equals(req.getStaffId()) && req.getId() != null && req.getId() > 0) {
|
||||
// 如果是编辑的时候,排除自己
|
||||
continue;
|
||||
}
|
||||
StaffEntity staffEntity = staffService.getById(staffRoleOld.getStaffId());
|
||||
DepartmentsEntity departmentsEntity = departmentsService.selectByDepartmentId(staffRoleDepartment.getDepartmentId());
|
||||
return R.error(departmentsEntity.getDepartmentName() + " 己经分给了 " + staffEntity.getName() + " 审批,如需要更换,请去掉" + staffEntity.getName() + " 权限 ");
|
||||
}
|
||||
staffRoleDepartment = new StaffRoleDepartment();
|
||||
staffRoleDepartment.setDepartmentId(menuId + "");
|
||||
staffRoleDepartment.setStaffRoleId(staffRole.getId());
|
||||
staffRoleDepartmentService.insertStaffRoleDepartment(staffRoleDepartment);
|
||||
}
|
||||
if (req.getId() != null && req.getId() > 0) {
|
||||
List<StaffRoleDepartment> staffRoleDepartments = staffRoleDepartmentService.selectStaffRoleDepartmentByStaffRoleId(staffRole.getId());
|
||||
for(StaffRoleDepartment staffRoleDepartment : staffRoleDepartments){
|
||||
if(!menuIdList.contains(staffRoleDepartment.getDepartmentId())){
|
||||
// 删除没有选的部门
|
||||
staffRoleDepartmentService.deleteStaffRoleDepartment(staffRoleDepartment.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (req.getId() == null) {
|
||||
staffRoleService.insertStaffRole(staffRole);
|
||||
} else {
|
||||
staffRoleService.updateStaffRoleById(staffRole);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ -80,8 +165,8 @@ public class StaffRoleController {
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("user:lzstaffrole:delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
staffRoleService.deleteBatchIds(Arrays.asList(ids));
|
||||
public R delete(@RequestBody Long[] ids) {
|
||||
staffRoleService.deleteBatchIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ -78,4 +78,6 @@ public interface StaffDao extends BaseMapper<StaffEntity> {
|
||||
StaffEntity selectStaffByEmployeeId(@Param("employeeId") String employeeId);
|
||||
|
||||
List<StaffEntity> selectBySearchName(@Param("page") IPage page, @Param("model") FindByNameModel nameModel);
|
||||
|
||||
List<StaffEntity> selectAll();
|
||||
}
|
||||
|
||||
@ -80,5 +80,7 @@ public interface StaffService extends IService<StaffEntity> {
|
||||
|
||||
//查询部门下的所有人员 包括子部门下人员
|
||||
List<Long> selectAllStaffByDepartmentId(String departmentId);
|
||||
|
||||
List<StaffEntity> selectAll();
|
||||
}
|
||||
|
||||
|
||||
@ -390,6 +390,11 @@ public class StaffServiceImpl extends ServiceImpl<StaffDao, StaffEntity> impleme
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StaffEntity> selectAll() {
|
||||
return staffDao.selectAll();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param departmentsList 最终的存储集合
|
||||
|
||||
@ -34,4 +34,10 @@ public interface StaffRoleDepartmentMapper extends BaseMapper<StaffRoleDepartmen
|
||||
|
||||
|
||||
List<StaffRoleDepartment> selectStaffRoleDepartmentByStaffRoleId(@Param("staffRoleId") Long staffRoleId);
|
||||
|
||||
StaffRoleDepartment selectStaffRoleDepartmentByDepartmentId(@Param("departmentId") Long departmentId);
|
||||
|
||||
StaffRoleDepartment selectStaffRoleDepartmentByDepartmentIdRoleIds(@Param("departmentId") Long departmentId, @Param("ids") List<Long> ids);
|
||||
|
||||
void deleteStaffRoleDepartment(@Param("id") Long id);
|
||||
}
|
||||
14
src/main/java/com/lz/modules/flow/req/StaffRoleRequest.java
Normal file
14
src/main/java/com/lz/modules/flow/req/StaffRoleRequest.java
Normal file
@ -0,0 +1,14 @@
|
||||
package com.lz.modules.flow.req;
|
||||
|
||||
import com.lz.modules.flow.entity.StaffRole;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class StaffRoleRequest extends StaffRole {
|
||||
private List<Long> menuIdList;
|
||||
private Integer targetRole;
|
||||
private Integer resultRole;
|
||||
|
||||
}
|
||||
@ -3,6 +3,8 @@ package com.lz.modules.flow.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.lz.common.utils.PageUtils;
|
||||
import com.lz.modules.flow.entity.RecordRole;
|
||||
import com.lz.modules.sys.entity.SysMenuEntity;
|
||||
import com.lz.modules.sys.entity.SysRoleEntity;
|
||||
import com.lz.modules.sys.entity.app.ResultRecord;
|
||||
|
||||
import java.util.List;
|
||||
@ -40,4 +42,10 @@ public interface RecordRoleService extends IService<RecordRole> {
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
List<RecordRole> selectAll();
|
||||
|
||||
SysRoleEntity getRole(Long id);
|
||||
|
||||
List<SysMenuEntity> selectMenuList();
|
||||
|
||||
SysMenuEntity buildMenuEntity(Long id, String name, Long parentId, String parentName);
|
||||
}
|
||||
@ -33,4 +33,10 @@ public interface StaffRoleDepartmentService extends IService<StaffRoleDepartment
|
||||
|
||||
|
||||
List<StaffRoleDepartment> selectStaffRoleDepartmentByStaffRoleId(Long staffRoleId);
|
||||
|
||||
StaffRoleDepartment selectStaffRoleDepartmentByDepartmentId(Long departmentId);
|
||||
|
||||
StaffRoleDepartment selectStaffRoleDepartmentByDepartmentIdRoleIds(Long menuId, List<Long> ids);
|
||||
|
||||
void deleteStaffRoleDepartment(Long id);
|
||||
}
|
||||
@ -3,6 +3,8 @@ package com.lz.modules.flow.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.lz.common.utils.PageUtils;
|
||||
import com.lz.modules.flow.entity.StaffRole;
|
||||
import com.lz.modules.sys.entity.SysMenuEntity;
|
||||
import com.lz.modules.sys.entity.SysRoleEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -41,4 +43,8 @@ public interface StaffRoleService extends IService<StaffRole> {
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
void deleteBatchIds(List<Long> asList);
|
||||
|
||||
SysRoleEntity getRole(Long id);
|
||||
|
||||
List<SysMenuEntity> selectMenuList();
|
||||
}
|
||||
@ -4,12 +4,17 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.lz.common.utils.NumberUtil;
|
||||
import com.lz.common.utils.PageUtils;
|
||||
import com.lz.modules.flow.dao.RecordRoleMapper;
|
||||
import com.lz.modules.flow.entity.RecordAuth;
|
||||
import com.lz.modules.flow.entity.RecordRole;
|
||||
import com.lz.modules.flow.service.RecordAuthService;
|
||||
import com.lz.modules.flow.service.RecordRoleAuthService;
|
||||
import com.lz.modules.flow.service.RecordRoleService;
|
||||
import com.lz.modules.sys.entity.app.ResultRecord;
|
||||
import com.lz.modules.sys.entity.SysMenuEntity;
|
||||
import com.lz.modules.sys.entity.SysRoleEntity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -29,6 +34,13 @@ public class RecordRoleServiceImpl extends ServiceImpl<RecordRoleMapper, RecordR
|
||||
@Autowired
|
||||
private RecordRoleMapper recordRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private RecordRoleAuthService recordRoleAuthService;
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private RecordAuthService recordAuthService;
|
||||
|
||||
|
||||
@Override
|
||||
@ -86,5 +98,77 @@ public class RecordRoleServiceImpl extends ServiceImpl<RecordRoleMapper, RecordR
|
||||
return recordRoleMapper.selectAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysRoleEntity getRole(Long id) {
|
||||
RecordRole lzRecordRole = selectRecordRoleById(id);
|
||||
SysRoleEntity role = new SysRoleEntity();
|
||||
role.setRoleId(lzRecordRole.getId());
|
||||
role.setRoleName(lzRecordRole.getName());
|
||||
//查询角色对应的菜单
|
||||
List<Long> menuIdList = recordRoleAuthService.queryMenuIdList(id);
|
||||
|
||||
role.setMenuIdList(menuIdList);
|
||||
return role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenuEntity> selectMenuList() {
|
||||
List<SysMenuEntity> list = new ArrayList<>();
|
||||
List<RecordAuth> recordAuths = recordAuthService.selectAll();
|
||||
for (int i = 0; i < recordAuths.size(); i++) {
|
||||
RecordAuth recordAuth = recordAuths.get(i);
|
||||
Long parentId = recordAuth.getId();
|
||||
if (i + 1 < recordAuths.size()) {
|
||||
RecordAuth child = recordAuths.get(i + 1);
|
||||
if (child.getIdentity().equals(recordAuth.getIdentity())) {
|
||||
parentId = NumberUtil.objToLong(recordAuth.getId() + "000000");
|
||||
}
|
||||
}
|
||||
SysMenuEntity sysMenuEntity = buildMenuEntity(parentId, recordAuth.getName(), 0l, "");
|
||||
list.add(sysMenuEntity);
|
||||
if (i + 1 < recordAuths.size()) {
|
||||
RecordAuth child = recordAuths.get(i + 1);
|
||||
if (!child.getIdentity().equals(recordAuth.getIdentity())) {
|
||||
continue;
|
||||
}
|
||||
for (int j = i; j < recordAuths.size(); j++) {
|
||||
child = recordAuths.get(j);
|
||||
if (!child.getIdentity().equals(recordAuth.getIdentity())) {
|
||||
if (j == recordAuths.size() - 1) {
|
||||
i = j;
|
||||
} else {
|
||||
i = j - 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
String name = "不可见";
|
||||
if (child.getStatus().equals(1)) {
|
||||
name = "可见";
|
||||
} else if (child.getStatus().equals(2)) {
|
||||
name = "可编辑";
|
||||
}
|
||||
SysMenuEntity childMenuEntity = buildMenuEntity(child.getId(), name, parentId, recordAuth.getName());
|
||||
list.add(childMenuEntity);
|
||||
if (j == recordAuths.size() - 1) {
|
||||
i = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public SysMenuEntity buildMenuEntity(Long id, String name, Long parentId, String parentName) {
|
||||
SysMenuEntity sysMenuEntity = new SysMenuEntity();
|
||||
sysMenuEntity.setMenuId(id);
|
||||
sysMenuEntity.setName(name);
|
||||
sysMenuEntity.setParentId(parentId);
|
||||
sysMenuEntity.setParentName(parentName);
|
||||
return sysMenuEntity;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -65,5 +65,20 @@ public class StaffRoleDepartmentServiceImpl extends ServiceImpl<StaffRoleDepartm
|
||||
return staffRoleDepartmentMapper.selectStaffRoleDepartmentByStaffRoleId(staffRoleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StaffRoleDepartment selectStaffRoleDepartmentByDepartmentId(Long departmentId) {
|
||||
return staffRoleDepartmentMapper.selectStaffRoleDepartmentByDepartmentId(departmentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StaffRoleDepartment selectStaffRoleDepartmentByDepartmentIdRoleIds(Long departmentId, List<Long> ids) {
|
||||
return staffRoleDepartmentMapper.selectStaffRoleDepartmentByDepartmentIdRoleIds(departmentId,ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteStaffRoleDepartment(Long id) {
|
||||
staffRoleDepartmentMapper.deleteStaffRoleDepartment(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -5,21 +5,33 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.lz.common.utils.NumberUtil;
|
||||
import com.lz.common.utils.PageUtils;
|
||||
import com.lz.modules.app.dao.DepartmentsDao;
|
||||
import com.lz.modules.app.dao.StaffDao;
|
||||
import com.lz.modules.app.dto.StaffRoleResp;
|
||||
import com.lz.modules.app.entity.DepartmentsEntity;
|
||||
import com.lz.modules.app.entity.StaffEntity;
|
||||
import com.lz.modules.flow.dao.RecordRoleMapper;
|
||||
import com.lz.modules.flow.dao.StaffRoleDepartmentMapper;
|
||||
import com.lz.modules.flow.dao.StaffRoleMapper;
|
||||
import com.lz.modules.flow.entity.RecordRole;
|
||||
import com.lz.modules.flow.entity.StaffRole;
|
||||
import com.lz.modules.flow.entity.StaffRoleDepartment;
|
||||
import com.lz.modules.flow.service.RecordRoleService;
|
||||
import com.lz.modules.flow.service.StaffRoleDepartmentService;
|
||||
import com.lz.modules.flow.service.StaffRoleService;
|
||||
import com.lz.modules.sys.entity.SysMenuEntity;
|
||||
import com.lz.modules.sys.entity.SysRoleEntity;
|
||||
import com.lz.modules.sys.service.app.ResultRecordService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -31,6 +43,7 @@ import java.util.Map;
|
||||
*/
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole> implements StaffRoleService {
|
||||
|
||||
|
||||
@ -44,6 +57,16 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
|
||||
@Autowired
|
||||
private RecordRoleMapper recordRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private StaffRoleDepartmentMapper staffRoleDepartmentMapper;
|
||||
@Autowired
|
||||
private DepartmentsDao departmentsDao;
|
||||
|
||||
@Autowired
|
||||
private ResultRecordService resultRecordService;
|
||||
|
||||
@Autowired
|
||||
private RecordRoleService recordRoleService;
|
||||
|
||||
@Override
|
||||
public StaffRole selectStaffRoleById(Long id) {
|
||||
@ -133,4 +156,49 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysRoleEntity getRole(Long id) {
|
||||
StaffRole staffRole = staffRoleMapper.selectStaffRoleById(id);
|
||||
SysRoleEntity role = new SysRoleEntity();
|
||||
List<Long> menuIdList= new ArrayList<>();
|
||||
if(staffRole!=null){
|
||||
List<StaffRoleDepartment> staffRoleDepartments = staffRoleDepartmentMapper.selectStaffRoleDepartmentByStaffRoleId(staffRole.getId());
|
||||
role.setRoleId(staffRole.getId());
|
||||
role.setRoleName(staffRole.getDepartmentLevel());
|
||||
for(StaffRoleDepartment staffRoleDepartment: staffRoleDepartments){
|
||||
menuIdList.add(NumberUtil.objToLongDefault(staffRoleDepartment.getDepartmentId(),0l));
|
||||
}
|
||||
}
|
||||
role.setMenuIdList(menuIdList);
|
||||
return role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenuEntity> selectMenuList() {
|
||||
List<DepartmentsEntity> tDepartments = departmentsDao.selectAll();
|
||||
List<DepartmentsEntity> parentDepartments = tDepartments.stream()
|
||||
//根据两个属性进行过滤
|
||||
.filter(s -> s.getDepartmentParentId().equals("1"))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<SysMenuEntity> list = new ArrayList<>();
|
||||
for(DepartmentsEntity d:parentDepartments){
|
||||
SysMenuEntity entity = recordRoleService.buildMenuEntity(NumberUtil.objToLongDefault(d.getDepartmentId(),0l),d.getDepartmentName(),0l,"");
|
||||
getMenuList(tDepartments,entity,list);
|
||||
list.add(entity);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void getMenuList(List<DepartmentsEntity> tDepartments,SysMenuEntity sysMenuEntity,List<SysMenuEntity> list) {
|
||||
for(DepartmentsEntity child : tDepartments) {
|
||||
if(NumberUtil.objToLongDefault(child.getDepartmentParentId(),0l).equals(sysMenuEntity.getMenuId())){
|
||||
SysMenuEntity entity = recordRoleService.buildMenuEntity(NumberUtil.objToLongDefault(child.getDepartmentId(),0l),
|
||||
child.getDepartmentName(),sysMenuEntity.getMenuId(),sysMenuEntity.getName());
|
||||
getMenuList(tDepartments,entity,list);
|
||||
list.add(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.lz.common.utils.PageUtils;
|
||||
import com.lz.common.utils.R;
|
||||
import com.lz.modules.app.dto.ChartDto;
|
||||
import com.lz.modules.app.dto.GraphicsStatisticalDto;
|
||||
import com.lz.modules.app.entity.DepartmentsEntity;
|
||||
import com.lz.modules.app.entity.StaffEntity;
|
||||
import com.lz.modules.app.req.ResultRecordReq;
|
||||
import com.lz.modules.app.resp.OwnResultResp;
|
||||
@ -15,6 +16,7 @@ import com.lz.modules.sys.entity.SysUserEntity;
|
||||
import com.lz.modules.sys.entity.app.ResultRecord;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -86,4 +88,6 @@ public interface ResultRecordService extends IService<ResultRecord> {
|
||||
*/
|
||||
List<ChartDto> departmentDistribution(String monthTime);
|
||||
|
||||
Map<String, List<DepartmentsEntity>> getStringListMap(List<DepartmentsEntity> tDepartments);
|
||||
|
||||
}
|
||||
@ -225,7 +225,8 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
|
||||
return pageUtils;
|
||||
}
|
||||
|
||||
private Map<String, List<DepartmentsEntity>> getStringListMap(List<DepartmentsEntity> tDepartments) {
|
||||
@Override
|
||||
public Map<String, List<DepartmentsEntity>> getStringListMap(List<DepartmentsEntity> tDepartments) {
|
||||
Map<String, List<DepartmentsEntity>> departmentMap = new HashMap<>();
|
||||
for(DepartmentsEntity department : tDepartments) {
|
||||
List<DepartmentsEntity> list = new ArrayList<>();
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<select id="selectStaffRoleDepartmentById" resultType="StaffRoleDepartment" >
|
||||
select * from lz_staff_role_department where id=#{id} and is_delete = 0 limit 1
|
||||
</select>
|
||||
@ -80,7 +79,23 @@
|
||||
<select id="selectStaffRoleDepartmentByStaffRoleId" resultType="com.lz.modules.flow.entity.StaffRoleDepartment">
|
||||
select * from lz_staff_role_department where staff_role_id=#{staffRoleId} and is_delete = 0
|
||||
</select>
|
||||
<select id="selectStaffRoleDepartmentByDepartmentId"
|
||||
resultType="com.lz.modules.flow.entity.StaffRoleDepartment">
|
||||
select * from lz_staff_role_department where department_id=#{departmentId} and is_delete = 0
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectStaffRoleDepartmentByDepartmentIdRoleIds" resultType="com.lz.modules.flow.entity.StaffRoleDepartment">
|
||||
select * from lz_staff_role_department where department_id=#{departmentId} and is_delete = 0
|
||||
and staff_role_id in
|
||||
<foreach collection="ids" item="item" index="index" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<delete id="deleteStaffRoleDepartment">
|
||||
delete from lz_staff_role_department where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
@ -75,6 +75,7 @@
|
||||
<select id="selectAll" resultType="com.lz.modules.app.entity.DepartmentsEntity">
|
||||
select * from lz_departments where is_delete=0
|
||||
</select>
|
||||
|
||||
<select id="selectEntityByParentDepartmentId" resultType="com.lz.modules.app.entity.DepartmentsEntity">
|
||||
select * from lz_departments where is_delete=0 and department_parent_id = #{parentId}
|
||||
</select>
|
||||
|
||||
@ -443,4 +443,8 @@
|
||||
AND staf.name LIKE CONCAT('%',#{model.name},'%')
|
||||
</select>
|
||||
|
||||
<select id="selectAll" resultType="com.lz.modules.app.entity.StaffEntity">
|
||||
select * from lz_staff where is_delete = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user