提交修改

This commit is contained in:
quyixiao 2020-11-09 16:41:55 +08:00
parent 2c17a09954
commit 929753989b
12 changed files with 131 additions and 17 deletions

View File

@ -144,6 +144,19 @@ public class StringUtil extends StringUtils {
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 待处理字符串
* @return

View File

@ -267,6 +267,13 @@ public class TestController {
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) {
String a = "{\"313\":[17,20,13]}";

View File

@ -40,4 +40,6 @@ public interface RecordAuthMapper extends BaseMapper<RecordAuth> {
List<RecordAuth> selectAll();
List<AuthDto> selectAuthByRoleIds(@Param("roleIds") List<Long> roleIds);
List<AuthDto> selectAuthByIds(@Param("authIds") List<Long> authIds);
}

View File

@ -9,6 +9,8 @@ package com.lz.modules.flow.dao;
*/
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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 org.apache.ibatis.annotations.Mapper;
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);
StaffRole selectStaffRolesByStaffIdDepartmentLevel(@Param("staffId") Long staffId, @Param("departmentLevel") String departmentLevel);
List<StaffRole> selectAllByStaffId(@Param("staffId") Long staffId);
List<StaffMenu> selectAllMenus(@Param("userId") Long userId);
}

View File

@ -42,7 +42,7 @@ public class StaffMenu implements java.io.Serializable {
private Long parentId;
//授权 id
@ApiModelProperty(value = "授权 id", name = "authIds")
private Long authIds;
private String authIds;
@TableField(exist=false)
private List<StaffMenu> childs;
/**
@ -139,14 +139,14 @@ public class StaffMenu implements java.io.Serializable {
* 授权 id
* @return
*/
public Long getAuthIds() {
public String getAuthIds() {
return authIds;
}
/**
* 授权 id
* @param authIds
*/
public void setAuthIds(Long authIds) {
public void setAuthIds(String authIds) {
this.authIds = authIds;
}

View File

@ -47,4 +47,6 @@ public interface RecordAuthService extends IService<RecordAuth> {
Long getRoleIdByStaffRoleInfo(String flowStaffIdRole,Long approvalStaffId);
Map<String, Integer> selectAuthByRoleIds(List<Long> roleIds);
Map<String, Integer> selectAuthByIds(List<Long> authIds);
}

View File

@ -61,4 +61,8 @@ public interface StaffRoleService extends IService<StaffRole> {
R roleAddOrUpdate(RoleModel roleModel);
R delete(RoleModel roleModel);
List<StaffRole> selectAllByStaffId(Long userId);
Map<String, Integer> getRoleByUserId(Long userId);
}

View File

@ -129,8 +129,20 @@ public class RecordAuthServiceImpl extends ServiceImpl<RecordAuthMapper, RecordA
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<>();
if (CollectionUtils.isNotEmpty(auths)) {
for(RecordAuth recordAuth : auths){

View File

@ -32,6 +32,7 @@ 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.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -90,13 +91,16 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
private StaffRoleEvaluationGroupService staffRoleEvaluationGroupService;
@Autowired
private StaffMenuService staffMenuService;
@Autowired
private StaffRoleDepartmentService staffRoleDepartmentService;
@Autowired
private RecordAuthService recordAuthService;
@Override
public StaffRole selectStaffRoleById(Long id) {
return staffRoleMapper.selectStaffRoleById(id);
@ -328,7 +332,7 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
List<String> deparmentNames = new ArrayList<>();
if (staffRole.getDepartmentId().equals(new Long(2))) {
List<StaffRoleDepartment> staffRoleDepartments = staffRoleDepartmentService.selectStaffRoleDepartmentByStaffRoleId(staffRole.getId());
for(StaffRoleDepartment staffRoleDepartment:staffRoleDepartments){
for (StaffRoleDepartment staffRoleDepartment : staffRoleDepartments) {
DepartmentsEntity departmentsEntity = departmentsDao.selectByDepartmentId(staffRoleDepartment.getDepartmentId());
deparmentNames.add(departmentsEntity.getDepartmentName());
}
@ -360,8 +364,8 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
@Override
public R selectRoleDetail(RoleModel roleModel) {
StaffRole staffRole= staffRoleMapper.selectById(roleModel.getId());
if(staffRole == null ){
StaffRole staffRole = staffRoleMapper.selectById(roleModel.getId());
if (staffRole == null) {
staffRole = new StaffRole();
}
StaffRoleDetailInfo info = new StaffRoleDetailInfo();
@ -407,8 +411,8 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
return R.ok("更新成功");
}
} else if (roleModel.getStaffId() != null) { // 员工不为空
StaffRole data = staffRoleMapper.selectStaffRolesByStaffIdDepartmentLevel(roleModel.getStaffId(),roleModel.getDepartmentLevel());
if(data !=null ){
StaffRole data = staffRoleMapper.selectStaffRolesByStaffIdDepartmentLevel(roleModel.getStaffId(), roleModel.getDepartmentLevel());
if (data != null) {
return R.error("该管理员己经存在");
}
staffRole = new StaffRole();
@ -458,6 +462,43 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
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) {
staffRole.setEvaluationGroupId(EvaluationGroupEnums.ALL.getType());//全部考评组
staffRole.setDepartmentId(DepartmentPMEnums.ALL.getType());//所有部门

View File

@ -18,6 +18,8 @@ import com.lz.modules.app.enums.SmsTypeEnum;
import com.lz.modules.app.service.CodeRecordService;
import com.lz.modules.app.service.SmsTemplateService;
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.SysUserEntity;
import com.lz.modules.sys.form.SysLoginForm;
@ -41,9 +43,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.*;
/**
* 登录相关
@ -64,6 +64,9 @@ public class SysLoginController extends AbstractController {
private CodeRecordService codeRecordService;
@Resource
private SysConfigService sysConfigService;
@Autowired
private StaffRoleService staffRoleService;
@Resource
private DhgjSmsUtil dhgjSmsUtil;
@ -71,7 +74,7 @@ public class SysLoginController extends AbstractController {
private String environment;
@Autowired
private StaffService staffService ;
private StaffService staffService;
/**
* 验证码
@ -181,7 +184,7 @@ public class SysLoginController extends AbstractController {
SysUserEntity user = sysUserService.queryByUserName(form.getUserName());
if (user == null) {
StaffEntity staffEntity = staffService.selectByPhone(form.getUserName());
if(staffEntity != null){
if (staffEntity != null) {
user = new SysUserEntity();
user.setPassword(staffEntity.getPassword());
user.setMobile(staffEntity.getMobile());
@ -193,7 +196,7 @@ public class SysLoginController extends AbstractController {
user.setUsername(staffEntity.getMobile());
user.setRealName(staffEntity.getName());
user.setUserNo(staffEntity.getMobile());
}else{
} else {
return R.error("账号不存在!");
}
}
@ -218,11 +221,15 @@ public class SysLoginController extends AbstractController {
}
//生成token并保存到数据库
R r = sysUserTokenService.createToken(user);
return r;
Map<String,Integer> map = staffRoleService.getRoleByUserId(user.getUserId());
return r.put("data",map);
}
/**
* 退出
*/

View File

@ -108,5 +108,14 @@
</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>

View File

@ -159,6 +159,17 @@
select * from lz_staff_role where is_delete = 0 and department_level = #{departmentLevel} and staff_id =#{staffId}
</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>