From fc918ff41c10a52dd1b3ed5f411529c1f919935c Mon Sep 17 00:00:00 2001 From: Vinjor Date: Wed, 16 Oct 2024 18:35:34 +0800 Subject: [PATCH] =?UTF-8?q?app=E5=9B=9E=E6=98=BE=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/CompanyStaffController.java | 27 ++++++++++++++++++- .../service/impl/ApiAppLoginServiceImpl.java | 14 ++++++++++ .../admin/RepairWorkerController.java | 18 ++++++++++--- .../base/service/RepairWorkerService.java | 8 ++++++ .../service/impl/RepairWorkerServiceImpl.java | 16 +++++++++++ .../dal/dataobject/user/AdminUserDO.java | 11 ++++++++ 6 files changed, 89 insertions(+), 5 deletions(-) diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java index 3a169f47..a0360000 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java @@ -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 getCompanyStaffById(@RequestParam("id") String id) { return success(staffService.getOne(new LambdaQueryWrapper().eq(CompanyStaff::getUserId, id))); } @@ -270,4 +278,21 @@ public class CompanyStaffController { public CommonResult> getStaffListByCorpId(String id){ return success(staffService.list(new LambdaQueryWrapper().eq(CompanyStaff::getCorpId, id))); } + + /** + * 退出登录状态 + * @author vinjor-M + * @date 17:55 2024/10/16 + * @return cn.iocoder.yudao.framework.common.pojo.CommonResult + **/ + @PostMapping("/logout") + @Operation(summary = "登出系统") + public CommonResult logout(HttpServletRequest request) { + String token = SecurityFrameworkUtils.obtainAuthorization(request, + securityProperties.getTokenHeader(), securityProperties.getTokenParameter()); + if (StrUtil.isNotBlank(token)) { + loginService.logout(token,1); + } + return success(true); + } } diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/ApiAppLoginServiceImpl.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/ApiAppLoginServiceImpl.java index 4427e9c8..fa419ba2 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/ApiAppLoginServiceImpl.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/ApiAppLoginServiceImpl.java @@ -145,22 +145,36 @@ public class ApiAppLoginServiceImpl implements ApiAppLoginService { **/ private boolean checkRepairCanLogin(AdminUserDO user,List roleCodeList){ boolean flag = false; + List thisRoleCodeList = new ArrayList<>(); + List 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; } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/controller/admin/RepairWorkerController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/controller/admin/RepairWorkerController.java index bb20e700..d4dfc183 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/controller/admin/RepairWorkerController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/controller/admin/RepairWorkerController.java @@ -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()); + } + + } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java index a14c8721..730e7e3d 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java @@ -76,4 +76,12 @@ public interface RepairWorkerService extends IService { * @date 16:55 2024/10/14 **/ List listByLeads(); + + /** + * 查当前登录用户是否维修班组长 + * @author vinjor-M + * @date 18:17 2024/10/16 + * @return boolean + **/ + boolean getIfLeader(); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java index e2117ec2..c06edd16 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java @@ -137,4 +137,20 @@ public class RepairWorkerServiceImpl extends ServiceImpl !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 queryWrapper = new LambdaQueryWrapper() + .eq(RepairWorker::getUserId,userId); + List list = this.list(queryWrapper); + return !list.isEmpty() && "1".equals(list.get(0).getIsLeads()); + } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java index 30453969..154c7763 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java @@ -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; + }