diff --git a/dl-module-jx/src/main/java/cn/iocoder/yudao/module/jx/controller/api/JxAuthController.java b/dl-module-jx/src/main/java/cn/iocoder/yudao/module/jx/controller/api/JxAuthController.java new file mode 100644 index 00000000..702f930e --- /dev/null +++ b/dl-module-jx/src/main/java/cn/iocoder/yudao/module/jx/controller/api/JxAuthController.java @@ -0,0 +1,86 @@ +package cn.iocoder.yudao.module.jx.controller.api; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.security.config.SecurityProperties; +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.module.jx.domain.DriveSchoolCoach; +import cn.iocoder.yudao.module.jx.domain.DriveSchoolInfo; +import cn.iocoder.yudao.module.jx.mapper.DriveSchoolCoachMapper; +import cn.iocoder.yudao.module.jx.service.IDriveSchoolInfoService; +import cn.iocoder.yudao.module.system.api.permission.PermissionApi; +import cn.iocoder.yudao.module.system.api.permission.RoleApi; +import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import cn.iocoder.yudao.module.system.service.auth.AdminAuthService; +import cn.iocoder.yudao.module.system.service.permission.MenuService; +import cn.iocoder.yudao.module.system.service.permission.PermissionService; +import cn.iocoder.yudao.module.system.service.permission.RoleService; +import cn.iocoder.yudao.module.system.service.social.SocialClientService; +import cn.iocoder.yudao.module.system.service.user.AdminUserService; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 认证") +@RestController +@RequestMapping("/jx/auth") +@Validated +@Slf4j +public class JxAuthController { + + + @Resource + private AdminUserService userService; + @Resource + private PermissionService permissionService; + @Resource + private DriveSchoolCoachMapper driveSchoolCoachMapper; + @Resource + private IDriveSchoolInfoService driveSchoolInfoService; + + + + + /** + * 获取 + * + * @return 用户信息 + */ + @GetMapping("/getJxInfo") + public CommonResult getJxInfo() + { + LoginUser user = SecurityFrameworkUtils.getLoginUser(); + // 获取当前登录用户code + Set roles = permissionService.getRolePermission(user.getId()); + //获取驾校的 + Long userId = user.getId(); + + AdminUserDO sysUser = userService.getUser(userId); + String phonenumber = sysUser.getMobile(); + DriveSchoolCoach driveSchoolCoach = driveSchoolCoachMapper.selectByPhonenumber(phonenumber); + + if (ObjectUtils.isNotEmpty(driveSchoolCoach)){ + sysUser.setAvatar(driveSchoolCoach.getImage()); + } + DriveSchoolInfo driveSchoolInfo = driveSchoolInfoService.getSchoolInfoByDeptId(); + + Map result = new HashMap<>(); + result.put("user", sysUser); + result.put("roles", roles); + result.put("schoolInfo", driveSchoolInfo); + + return CommonResult.success(result); + } + +} diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java index feb4ebb7..99a0c39e 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java @@ -26,9 +26,11 @@ import cn.iocoder.yudao.module.system.service.auth.AdminAuthService; import cn.iocoder.yudao.module.system.service.permission.MenuService; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.thoughtworks.xstream.core.SecurityUtils; import io.swagger.v3.oas.annotations.Operation; import lombok.extern.slf4j.Slf4j; import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.client.RestTemplate; @@ -38,10 +40,7 @@ import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import java.security.spec.AlgorithmParameterSpec; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; @@ -63,9 +62,7 @@ public class SysLoginController { @Resource private MenuService menuService; - // -// @Autowired -// private SysPermissionService permissionService; + @Resource private AdminUserApi userService; @@ -268,12 +265,12 @@ public class SysLoginController { // @GetMapping("getJxInfo") // public CommonResult getJxInfo() // { -// AdminUserRespDTO user = SecurityFrameworkUtils.getLoginUser() +// LoginUser user = SecurityFrameworkUtils.getLoginUser(); // // 角色集合 // Set roles = permissionService.getRolePermission(user); // //获取驾校的 -// -// Long userId = SecurityUtils.getUserId(); +// LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); +// Long userId = loginUser.getId(); // SysUser sysUser = sysUserMapper.selectUserById(userId); // String phonenumber = sysUser.getPhonenumber(); // DriveSchoolCoach driveSchoolCoach = driveSchoolCoachMapper.selectByPhonenumber(phonenumber); diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java index ead7aa2d..570896d4 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java @@ -129,7 +129,8 @@ public class YudaoWebSecurityConfigurerAdapter { .authorizeRequests() // 1.1 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll() - .antMatchers(HttpMethod.POST, "/admin-api/rescue/login", "/admin-api/rescue/loginApp","/admin-api/system/auth/loginApp", "/admin-api/rescue/driverLogin").anonymous() + + .antMatchers(HttpMethod.POST, "/admin-api/rescue/login","/admin-api/jx/auth/getJxInfo", "/admin-api/rescue/loginApp","/admin-api/system/auth/loginApp", "/admin-api/rescue/driverLogin").anonymous() // 1.2 设置 @PermitAll 无需认证 .antMatchers(HttpMethod.GET, permitAllUrls.get(HttpMethod.GET).toArray(new String[0])).permitAll() .antMatchers(HttpMethod.POST, permitAllUrls.get(HttpMethod.POST).toArray(new String[0])).permitAll() diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java index 86b99438..93c1c49c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java @@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.exception.ErrorCode; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.security.config.SecurityProperties; +import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.system.api.permission.PermissionApi; import cn.iocoder.yudao.module.system.api.permission.RoleApi; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionService.java index f0d6dfa6..07dda53f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionService.java @@ -143,6 +143,8 @@ public interface PermissionService { */ Set getUserRoleIdListByUserIdFromCache(Long userId); + Set getRolePermission(Long userId); + // ========== 用户-部门的相关方法 ========== /** diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java index 2dd0e6e0..51e1c8dd 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java @@ -267,6 +267,11 @@ public class PermissionServiceImpl implements PermissionService { return getUserRoleIdListByUserId(userId); } + @Override + public Set getRolePermission(Long userId) { + return null; + } + @Override public Set getUserRoleIdListByRoleId(Collection roleIds) { return convertSet(userRoleMapper.selectListByRoleIds(roleIds), UserRoleDO::getUserId);