提交修改
This commit is contained in:
parent
2c17a09954
commit
929753989b
@ -144,6 +144,19 @@ public class StringUtil extends StringUtils {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static List<Long> splitToLongList(String source, String sep) {
|
||||||
|
List<Long> result = new ArrayList<Long>();
|
||||||
|
if (isBlank(source)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
String[] tempResult = source.split(sep);
|
||||||
|
for (String item : tempResult) {
|
||||||
|
result.add(NumberUtil.objToLongDefault(item,0));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param source 待处理字符串
|
* @param source 待处理字符串
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
@ -267,6 +267,13 @@ public class TestController {
|
|||||||
R r = resultRecordService.initFlowRecord(resultRecordId);
|
R r = resultRecordService.initFlowRecord(resultRecordId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// http://localhost:8080/lz_management/test/getAuth?userId=314
|
||||||
|
@RequestMapping("/test/getAuth")
|
||||||
|
public R getAuth(Long userId) throws Exception{
|
||||||
|
Map<String,Integer> map = staffRoleService.getRoleByUserId(userId);
|
||||||
|
return R.ok().put("data",map);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String a = "{\"313\":[17,20,13]}";
|
String a = "{\"313\":[17,20,13]}";
|
||||||
|
|||||||
@ -40,4 +40,6 @@ public interface RecordAuthMapper extends BaseMapper<RecordAuth> {
|
|||||||
List<RecordAuth> selectAll();
|
List<RecordAuth> selectAll();
|
||||||
|
|
||||||
List<AuthDto> selectAuthByRoleIds(@Param("roleIds") List<Long> roleIds);
|
List<AuthDto> selectAuthByRoleIds(@Param("roleIds") List<Long> roleIds);
|
||||||
|
|
||||||
|
List<AuthDto> selectAuthByIds(@Param("authIds") List<Long> authIds);
|
||||||
}
|
}
|
||||||
@ -9,6 +9,8 @@ package com.lz.modules.flow.dao;
|
|||||||
*/
|
*/
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.lz.modules.flow.entity.AuthDto;
|
||||||
|
import com.lz.modules.flow.entity.StaffMenu;
|
||||||
import com.lz.modules.flow.entity.StaffRole;
|
import com.lz.modules.flow.entity.StaffRole;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
@ -52,4 +54,8 @@ public interface StaffRoleMapper extends BaseMapper<StaffRole> {
|
|||||||
List<StaffRole> selectPageByRoleLevel(@Param("page") IPage page, @Param("name") String name);
|
List<StaffRole> selectPageByRoleLevel(@Param("page") IPage page, @Param("name") String name);
|
||||||
|
|
||||||
StaffRole selectStaffRolesByStaffIdDepartmentLevel(@Param("staffId") Long staffId, @Param("departmentLevel") String departmentLevel);
|
StaffRole selectStaffRolesByStaffIdDepartmentLevel(@Param("staffId") Long staffId, @Param("departmentLevel") String departmentLevel);
|
||||||
|
|
||||||
|
List<StaffRole> selectAllByStaffId(@Param("staffId") Long staffId);
|
||||||
|
|
||||||
|
List<StaffMenu> selectAllMenus(@Param("userId") Long userId);
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ public class StaffMenu implements java.io.Serializable {
|
|||||||
private Long parentId;
|
private Long parentId;
|
||||||
//授权 id
|
//授权 id
|
||||||
@ApiModelProperty(value = "授权 id", name = "authIds")
|
@ApiModelProperty(value = "授权 id", name = "authIds")
|
||||||
private Long authIds;
|
private String authIds;
|
||||||
@TableField(exist=false)
|
@TableField(exist=false)
|
||||||
private List<StaffMenu> childs;
|
private List<StaffMenu> childs;
|
||||||
/**
|
/**
|
||||||
@ -139,14 +139,14 @@ public class StaffMenu implements java.io.Serializable {
|
|||||||
* 授权 id
|
* 授权 id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Long getAuthIds() {
|
public String getAuthIds() {
|
||||||
return authIds;
|
return authIds;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 授权 id
|
* 授权 id
|
||||||
* @param authIds
|
* @param authIds
|
||||||
*/
|
*/
|
||||||
public void setAuthIds(Long authIds) {
|
public void setAuthIds(String authIds) {
|
||||||
this.authIds = authIds;
|
this.authIds = authIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -47,4 +47,6 @@ public interface RecordAuthService extends IService<RecordAuth> {
|
|||||||
Long getRoleIdByStaffRoleInfo(String flowStaffIdRole,Long approvalStaffId);
|
Long getRoleIdByStaffRoleInfo(String flowStaffIdRole,Long approvalStaffId);
|
||||||
|
|
||||||
Map<String, Integer> selectAuthByRoleIds(List<Long> roleIds);
|
Map<String, Integer> selectAuthByRoleIds(List<Long> roleIds);
|
||||||
|
|
||||||
|
Map<String, Integer> selectAuthByIds(List<Long> authIds);
|
||||||
}
|
}
|
||||||
@ -61,4 +61,8 @@ public interface StaffRoleService extends IService<StaffRole> {
|
|||||||
R roleAddOrUpdate(RoleModel roleModel);
|
R roleAddOrUpdate(RoleModel roleModel);
|
||||||
|
|
||||||
R delete(RoleModel roleModel);
|
R delete(RoleModel roleModel);
|
||||||
|
|
||||||
|
List<StaffRole> selectAllByStaffId(Long userId);
|
||||||
|
|
||||||
|
Map<String, Integer> getRoleByUserId(Long userId);
|
||||||
}
|
}
|
||||||
@ -129,8 +129,20 @@ public class RecordAuthServiceImpl extends ServiceImpl<RecordAuthMapper, RecordA
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Integer> selectAuthByIds(List<Long> authIds) {
|
||||||
|
Map<String,Integer> map = new HashMap<>();
|
||||||
|
List<AuthDto> list = recordAuthMapper.selectAuthByIds(authIds);
|
||||||
|
if(CollectionUtils.isNotEmpty(list)){
|
||||||
|
for(AuthDto authDto:list){
|
||||||
|
map.put(authDto.getIdentity(),authDto.getStatus());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
public Auth getAuth(List<RecordAuth> auths) {
|
|
||||||
|
public Auth getAuth(List<RecordAuth> auths) {
|
||||||
Map<String, Integer> map = new HashMap<>();
|
Map<String, Integer> map = new HashMap<>();
|
||||||
if (CollectionUtils.isNotEmpty(auths)) {
|
if (CollectionUtils.isNotEmpty(auths)) {
|
||||||
for(RecordAuth recordAuth : auths){
|
for(RecordAuth recordAuth : auths){
|
||||||
|
|||||||
@ -32,6 +32,7 @@ import com.lz.modules.sys.entity.SysMenuEntity;
|
|||||||
import com.lz.modules.sys.entity.SysRoleEntity;
|
import com.lz.modules.sys.entity.SysRoleEntity;
|
||||||
import com.lz.modules.sys.service.app.ResultRecordService;
|
import com.lz.modules.sys.service.app.ResultRecordService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -90,13 +91,16 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
|
|||||||
private StaffRoleEvaluationGroupService staffRoleEvaluationGroupService;
|
private StaffRoleEvaluationGroupService staffRoleEvaluationGroupService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private StaffMenuService staffMenuService;
|
private StaffMenuService staffMenuService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private StaffRoleDepartmentService staffRoleDepartmentService;
|
private StaffRoleDepartmentService staffRoleDepartmentService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RecordAuthService recordAuthService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StaffRole selectStaffRoleById(Long id) {
|
public StaffRole selectStaffRoleById(Long id) {
|
||||||
return staffRoleMapper.selectStaffRoleById(id);
|
return staffRoleMapper.selectStaffRoleById(id);
|
||||||
@ -328,7 +332,7 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
|
|||||||
List<String> deparmentNames = new ArrayList<>();
|
List<String> deparmentNames = new ArrayList<>();
|
||||||
if (staffRole.getDepartmentId().equals(new Long(2))) {
|
if (staffRole.getDepartmentId().equals(new Long(2))) {
|
||||||
List<StaffRoleDepartment> staffRoleDepartments = staffRoleDepartmentService.selectStaffRoleDepartmentByStaffRoleId(staffRole.getId());
|
List<StaffRoleDepartment> staffRoleDepartments = staffRoleDepartmentService.selectStaffRoleDepartmentByStaffRoleId(staffRole.getId());
|
||||||
for(StaffRoleDepartment staffRoleDepartment:staffRoleDepartments){
|
for (StaffRoleDepartment staffRoleDepartment : staffRoleDepartments) {
|
||||||
DepartmentsEntity departmentsEntity = departmentsDao.selectByDepartmentId(staffRoleDepartment.getDepartmentId());
|
DepartmentsEntity departmentsEntity = departmentsDao.selectByDepartmentId(staffRoleDepartment.getDepartmentId());
|
||||||
deparmentNames.add(departmentsEntity.getDepartmentName());
|
deparmentNames.add(departmentsEntity.getDepartmentName());
|
||||||
}
|
}
|
||||||
@ -360,8 +364,8 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R selectRoleDetail(RoleModel roleModel) {
|
public R selectRoleDetail(RoleModel roleModel) {
|
||||||
StaffRole staffRole= staffRoleMapper.selectById(roleModel.getId());
|
StaffRole staffRole = staffRoleMapper.selectById(roleModel.getId());
|
||||||
if(staffRole == null ){
|
if (staffRole == null) {
|
||||||
staffRole = new StaffRole();
|
staffRole = new StaffRole();
|
||||||
}
|
}
|
||||||
StaffRoleDetailInfo info = new StaffRoleDetailInfo();
|
StaffRoleDetailInfo info = new StaffRoleDetailInfo();
|
||||||
@ -407,8 +411,8 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
|
|||||||
return R.ok("更新成功");
|
return R.ok("更新成功");
|
||||||
}
|
}
|
||||||
} else if (roleModel.getStaffId() != null) { // 员工不为空
|
} else if (roleModel.getStaffId() != null) { // 员工不为空
|
||||||
StaffRole data = staffRoleMapper.selectStaffRolesByStaffIdDepartmentLevel(roleModel.getStaffId(),roleModel.getDepartmentLevel());
|
StaffRole data = staffRoleMapper.selectStaffRolesByStaffIdDepartmentLevel(roleModel.getStaffId(), roleModel.getDepartmentLevel());
|
||||||
if(data !=null ){
|
if (data != null) {
|
||||||
return R.error("该管理员己经存在");
|
return R.error("该管理员己经存在");
|
||||||
}
|
}
|
||||||
staffRole = new StaffRole();
|
staffRole = new StaffRole();
|
||||||
@ -458,6 +462,43 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
|
|||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<StaffRole> selectAllByStaffId(Long staffId) {
|
||||||
|
|
||||||
|
return staffRoleMapper.selectAllByStaffId(staffId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Integer> getRoleByUserId(Long userId) {
|
||||||
|
Map<String ,Integer> map = new HashMap<>();
|
||||||
|
List<StaffRole> staffRoleList = staffRoleMapper.selectAllByStaffId(userId);
|
||||||
|
List<StaffMenu> staffMenus = new ArrayList<>();
|
||||||
|
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectLastDepartmentByStaffId(userId);
|
||||||
|
if(new Integer(1).equals(departmentsStaffRelateEntity.getIsLeader())){
|
||||||
|
List<StaffMenu> staffMenuDepartmentList= staffMenuService.selectByParentId( RoleMenuEnums.DEPARTMENT_PM.getType());
|
||||||
|
if(CollectionUtils.isNotEmpty(staffMenuDepartmentList)){
|
||||||
|
staffMenus.addAll(staffMenuDepartmentList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(CollectionUtils.isNotEmpty(staffRoleList)){
|
||||||
|
List<StaffMenu> staffMenuList = staffRoleMapper.selectAllMenus(userId);
|
||||||
|
if(CollectionUtils.isNotEmpty(staffMenuList)){
|
||||||
|
staffMenus.addAll(staffMenuList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(CollectionUtils.isNotEmpty(staffMenus) && staffMenus.size() > 0 ){
|
||||||
|
List<Long> authIds = new ArrayList<>();
|
||||||
|
for(StaffMenu staffMenu:staffMenus){
|
||||||
|
List<Long> ids = StringUtil.splitToLongList(staffMenu.getAuthIds(),",");
|
||||||
|
authIds.addAll(ids);
|
||||||
|
}
|
||||||
|
if(authIds.size() > 0){
|
||||||
|
map = recordAuthService.selectAuthByIds(authIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
public void insertPM(StaffRole staffRole, Long parentId, StaffEntity staffEntity) {
|
public void insertPM(StaffRole staffRole, Long parentId, StaffEntity staffEntity) {
|
||||||
staffRole.setEvaluationGroupId(EvaluationGroupEnums.ALL.getType());//全部考评组
|
staffRole.setEvaluationGroupId(EvaluationGroupEnums.ALL.getType());//全部考评组
|
||||||
staffRole.setDepartmentId(DepartmentPMEnums.ALL.getType());//所有部门
|
staffRole.setDepartmentId(DepartmentPMEnums.ALL.getType());//所有部门
|
||||||
|
|||||||
@ -18,6 +18,8 @@ import com.lz.modules.app.enums.SmsTypeEnum;
|
|||||||
import com.lz.modules.app.service.CodeRecordService;
|
import com.lz.modules.app.service.CodeRecordService;
|
||||||
import com.lz.modules.app.service.SmsTemplateService;
|
import com.lz.modules.app.service.SmsTemplateService;
|
||||||
import com.lz.modules.app.service.StaffService;
|
import com.lz.modules.app.service.StaffService;
|
||||||
|
import com.lz.modules.flow.entity.StaffRole;
|
||||||
|
import com.lz.modules.flow.service.StaffRoleService;
|
||||||
import com.lz.modules.sys.entity.SysConfigEntity;
|
import com.lz.modules.sys.entity.SysConfigEntity;
|
||||||
import com.lz.modules.sys.entity.SysUserEntity;
|
import com.lz.modules.sys.entity.SysUserEntity;
|
||||||
import com.lz.modules.sys.form.SysLoginForm;
|
import com.lz.modules.sys.form.SysLoginForm;
|
||||||
@ -41,9 +43,7 @@ import javax.servlet.ServletOutputStream;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录相关
|
* 登录相关
|
||||||
@ -64,6 +64,9 @@ public class SysLoginController extends AbstractController {
|
|||||||
private CodeRecordService codeRecordService;
|
private CodeRecordService codeRecordService;
|
||||||
@Resource
|
@Resource
|
||||||
private SysConfigService sysConfigService;
|
private SysConfigService sysConfigService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StaffRoleService staffRoleService;
|
||||||
@Resource
|
@Resource
|
||||||
private DhgjSmsUtil dhgjSmsUtil;
|
private DhgjSmsUtil dhgjSmsUtil;
|
||||||
|
|
||||||
@ -71,7 +74,7 @@ public class SysLoginController extends AbstractController {
|
|||||||
private String environment;
|
private String environment;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private StaffService staffService ;
|
private StaffService staffService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码
|
* 验证码
|
||||||
@ -181,7 +184,7 @@ public class SysLoginController extends AbstractController {
|
|||||||
SysUserEntity user = sysUserService.queryByUserName(form.getUserName());
|
SysUserEntity user = sysUserService.queryByUserName(form.getUserName());
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
StaffEntity staffEntity = staffService.selectByPhone(form.getUserName());
|
StaffEntity staffEntity = staffService.selectByPhone(form.getUserName());
|
||||||
if(staffEntity != null){
|
if (staffEntity != null) {
|
||||||
user = new SysUserEntity();
|
user = new SysUserEntity();
|
||||||
user.setPassword(staffEntity.getPassword());
|
user.setPassword(staffEntity.getPassword());
|
||||||
user.setMobile(staffEntity.getMobile());
|
user.setMobile(staffEntity.getMobile());
|
||||||
@ -193,7 +196,7 @@ public class SysLoginController extends AbstractController {
|
|||||||
user.setUsername(staffEntity.getMobile());
|
user.setUsername(staffEntity.getMobile());
|
||||||
user.setRealName(staffEntity.getName());
|
user.setRealName(staffEntity.getName());
|
||||||
user.setUserNo(staffEntity.getMobile());
|
user.setUserNo(staffEntity.getMobile());
|
||||||
}else{
|
} else {
|
||||||
return R.error("账号不存在!");
|
return R.error("账号不存在!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,11 +221,15 @@ public class SysLoginController extends AbstractController {
|
|||||||
}
|
}
|
||||||
//生成token,并保存到数据库
|
//生成token,并保存到数据库
|
||||||
R r = sysUserTokenService.createToken(user);
|
R r = sysUserTokenService.createToken(user);
|
||||||
return r;
|
Map<String,Integer> map = staffRoleService.getRoleByUserId(user.getUserId());
|
||||||
|
return r.put("data",map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退出
|
* 退出
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -108,5 +108,14 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectAuthByIds" resultType="com.lz.modules.flow.entity.AuthDto">
|
||||||
|
select * from (select identity ,status from lz_record_auth where id in
|
||||||
|
<foreach item="item" collection="authIds" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
order by status desc)a group by identity
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|||||||
@ -159,6 +159,17 @@
|
|||||||
select * from lz_staff_role where is_delete = 0 and department_level = #{departmentLevel} and staff_id =#{staffId}
|
select * from lz_staff_role where is_delete = 0 and department_level = #{departmentLevel} and staff_id =#{staffId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAllByStaffId" resultType="com.lz.modules.flow.entity.StaffRole">
|
||||||
|
select * from lz_staff_role where is_delete = 0 and staff_id =#{staffId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectAllMenus" resultType="com.lz.modules.flow.entity.StaffMenu">
|
||||||
|
select * from lz_staff_menu where id in (
|
||||||
|
select menu_id from lz_staff_role_menu where role_id in (
|
||||||
|
select id from lz_staff_role where staff_id = #{userId}))
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user