app回显个人信息

This commit is contained in:
Vinjor 2024-10-16 18:35:34 +08:00
parent fab9fd8e8f
commit fc918ff41c
6 changed files with 89 additions and 5 deletions

View File

@ -1,15 +1,19 @@
package cn.iocoder.yudao.module.staff.controller.admin;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.security.config.SecurityProperties;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.label.entity.Label;
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
import cn.iocoder.yudao.module.staff.service.CompanyStaffService;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffReqVO;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO;
import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO;
import cn.iocoder.yudao.module.system.service.auth.AdminAuthService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -22,6 +26,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
@ -46,6 +51,10 @@ public class CompanyStaffController {
@Resource
private CompanyStaffService staffService;
@Resource
private SecurityProperties securityProperties;
@Resource
private AdminAuthService loginService;
/**
* 分页查询
@ -151,7 +160,6 @@ public class CompanyStaffController {
@GetMapping("/getById")
@Operation(summary = "获得企业管理-员工信息表信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('company:staff:query')")
public CommonResult<CompanyStaff> getCompanyStaffById(@RequestParam("id") String id) {
return success(staffService.getOne(new LambdaQueryWrapper<CompanyStaff>().eq(CompanyStaff::getUserId, id)));
}
@ -270,4 +278,21 @@ public class CompanyStaffController {
public CommonResult<List<CompanyStaff>> getStaffListByCorpId(String id){
return success(staffService.list(new LambdaQueryWrapper<CompanyStaff>().eq(CompanyStaff::getCorpId, id)));
}
/**
* 退出登录状态
* @author vinjor-M
* @date 17:55 2024/10/16
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
**/
@PostMapping("/logout")
@Operation(summary = "登出系统")
public CommonResult<Boolean> logout(HttpServletRequest request) {
String token = SecurityFrameworkUtils.obtainAuthorization(request,
securityProperties.getTokenHeader(), securityProperties.getTokenParameter());
if (StrUtil.isNotBlank(token)) {
loginService.logout(token,1);
}
return success(true);
}
}

View File

@ -145,22 +145,36 @@ public class ApiAppLoginServiceImpl implements ApiAppLoginService {
**/
private boolean checkRepairCanLogin(AdminUserDO user,List<String> roleCodeList){
boolean flag = false;
List<String> thisRoleCodeList = new ArrayList<>();
List<String> thisRoleNameList = new ArrayList<>();
if(roleCodeList.contains(RepairRoleEnum.ADMIN.getCode())){
//维修业务管理员
flag = true;
thisRoleCodeList.add(RepairRoleEnum.ADMIN.getCode());
thisRoleNameList.add(RepairRoleEnum.ADMIN.getName());
}else if(roleCodeList.contains(RepairRoleEnum.INSPECTION.getCode())){
//总检
flag = true;
thisRoleCodeList.add(RepairRoleEnum.INSPECTION.getCode());
thisRoleNameList.add(RepairRoleEnum.INSPECTION.getName());
}else if(roleCodeList.contains(RepairRoleEnum.ADVISOR.getCode())){
//维修服务顾问
flag = true;
thisRoleCodeList.add(RepairRoleEnum.ADVISOR.getCode());
thisRoleNameList.add(RepairRoleEnum.ADVISOR.getName());
}else if(roleCodeList.contains(RepairRoleEnum.WAREHOUSE.getCode())){
//维修仓库管理员
flag = true;
thisRoleCodeList.add(RepairRoleEnum.WAREHOUSE.getCode());
thisRoleNameList.add(RepairRoleEnum.WAREHOUSE.getName());
}else if(roleCodeList.contains(RepairRoleEnum.REPAIR_STAFF.getCode())){
//维修工
flag = true;
thisRoleCodeList.add(RepairRoleEnum.REPAIR_STAFF.getCode());
thisRoleNameList.add(RepairRoleEnum.REPAIR_STAFF.getName());
}
user.setRoleCodes(String.join(",",thisRoleCodeList));
user.setRoleNames(String.join(",",thisRoleNameList));
return flag;
}
}

View File

@ -1,14 +1,12 @@
package cn.iocoder.yudao.module.base.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.base.entity.RepairWorker;
import cn.iocoder.yudao.module.base.service.RepairWorkerService;
import cn.iocoder.yudao.module.base.vo.RepairWorkerPageReqVO;
import cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO;
import cn.iocoder.yudao.module.base.vo.RepairWorkerSaveReqVO;
import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO;
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -19,8 +17,6 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -114,4 +110,18 @@ public class RepairWorkerController {
public CommonResult<?> listByLeads() {
return success(workerService.listByLeads());
}
/**
* 查当前登录用户是否维修班组长
* @author vinjor-M
* @date 18:08 2024/10/16
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
**/
@GetMapping("/getIfLeader")
@Operation(summary = "查当前登录用户是否维修班组长")
public CommonResult<?> getIfLeader() {
return success(workerService.getIfLeader());
}
}

View File

@ -76,4 +76,12 @@ public interface RepairWorkerService extends IService<RepairWorker> {
* @date 16:55 2024/10/14
**/
List<RepairWorker> listByLeads();
/**
* 查当前登录用户是否维修班组长
* @author vinjor-M
* @date 18:17 2024/10/16
* @return boolean
**/
boolean getIfLeader();
}

View File

@ -137,4 +137,20 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
// 去掉班组长自己
return workerList.stream().filter(item -> !Objects.equals(item.getUserId(), worker.getUserId())).collect(Collectors.toList());
}
/**
* 查当前登录用户是否维修班组长
*
* @return boolean
* @author vinjor-M
* @date 18:17 2024/10/16
**/
@Override
public boolean getIfLeader() {
Long userId = SecurityFrameworkUtils.getLoginUserId();
LambdaQueryWrapper<RepairWorker> queryWrapper = new LambdaQueryWrapper<RepairWorker>()
.eq(RepairWorker::getUserId,userId);
List<RepairWorker> list = this.list(queryWrapper);
return !list.isEmpty() && "1".equals(list.get(0).getIsLeads());
}
}

View File

@ -114,4 +114,15 @@ public class AdminUserDO extends TenantBaseDO {
private Long inviteId;
private String repairOpenId;
/**
* 当前用户的角色code多个以英文逗号隔开
*/
@TableField(exist = false)
private String roleCodes;
/**
* 当前用户的角色名称多个以英文逗号隔开
*/
@TableField(exist = false)
private String roleNames;
}