|
|
@ -1,16 +1,5 @@
|
|
|
|
package com.ruoyi.web.controller.system;
|
|
|
|
package com.ruoyi.web.controller.system;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.web.controller.common.RSAUtil;
|
|
|
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
|
|
@ -20,6 +9,17 @@ import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
import com.ruoyi.framework.web.service.SysLoginService;
|
|
|
|
import com.ruoyi.framework.web.service.SysLoginService;
|
|
|
|
import com.ruoyi.framework.web.service.SysPermissionService;
|
|
|
|
import com.ruoyi.framework.web.service.SysPermissionService;
|
|
|
|
import com.ruoyi.system.service.ISysMenuService;
|
|
|
|
import com.ruoyi.system.service.ISysMenuService;
|
|
|
|
|
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 登录验证
|
|
|
|
* 登录验证
|
|
|
@ -28,11 +28,12 @@ import com.ruoyi.system.service.ISysMenuService;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@Api("登录验证")
|
|
|
|
@Api("登录验证")
|
|
|
|
public class SysLoginController
|
|
|
|
public class SysLoginController {
|
|
|
|
{
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private SysLoginService loginService;
|
|
|
|
private SysLoginService loginService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ISysUserService userService;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ISysMenuService menuService;
|
|
|
|
private ISysMenuService menuService;
|
|
|
|
|
|
|
|
|
|
|
@ -46,8 +47,7 @@ public class SysLoginController
|
|
|
|
* @return 结果
|
|
|
|
* @return 结果
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PostMapping("/login")
|
|
|
|
@PostMapping("/login")
|
|
|
|
public AjaxResult login(@RequestBody LoginBody loginBody)
|
|
|
|
public AjaxResult login(@RequestBody LoginBody loginBody) {
|
|
|
|
{
|
|
|
|
|
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
|
// 生成令牌
|
|
|
|
// 生成令牌
|
|
|
|
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
|
|
|
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
|
|
@ -64,8 +64,7 @@ public class SysLoginController
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ApiOperation("不带校验码登录方法")
|
|
|
|
@ApiOperation("不带校验码登录方法")
|
|
|
|
@PostMapping("/loginNoCaptcha")
|
|
|
|
@PostMapping("/loginNoCaptcha")
|
|
|
|
public AjaxResult loginNoCaptcha(@RequestBody LoginBody loginBody)
|
|
|
|
public AjaxResult loginNoCaptcha(@RequestBody LoginBody loginBody) {
|
|
|
|
{
|
|
|
|
|
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
|
// 生成令牌
|
|
|
|
// 生成令牌
|
|
|
|
String token = loginService.loginNoCaptcha(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
|
|
|
String token = loginService.loginNoCaptcha(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
|
|
@ -88,16 +87,13 @@ public class SysLoginController
|
|
|
|
// 权限集合
|
|
|
|
// 权限集合
|
|
|
|
Set<String> permissions = permissionService.getMenuPermission(user);
|
|
|
|
Set<String> permissions = permissionService.getMenuPermission(user);
|
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
|
|
|
|
|
/** 先根据用户输入的用户名查询数据 */
|
|
|
|
String oldPassword = RSAUtil.decryptByPrivateKey(user.getPassword());
|
|
|
|
SysUser u = userService.findByPwd(user.getUserName());
|
|
|
|
|
|
|
|
if (user.getPassword() != null && SecurityUtils.matchesPassword(u.getPassword(), user.getPassword())) {
|
|
|
|
//判断密码是否为初始密码
|
|
|
|
ajax.put("pstatus", 1);
|
|
|
|
if (oldPassword.equals("Yingji@123")){
|
|
|
|
|
|
|
|
ajax.put("status",1);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ajax.put("status",0);
|
|
|
|
ajax.put("pstatus", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ajax.put("user", user);
|
|
|
|
ajax.put("user", user);
|
|
|
|
ajax.put("roles", roles);
|
|
|
|
ajax.put("roles", roles);
|
|
|
|
ajax.put("permissions", permissions);
|
|
|
|
ajax.put("permissions", permissions);
|
|
|
@ -110,8 +106,7 @@ public class SysLoginController
|
|
|
|
* @return 路由信息
|
|
|
|
* @return 路由信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@GetMapping("getRouters")
|
|
|
|
@GetMapping("getRouters")
|
|
|
|
public AjaxResult getRouters()
|
|
|
|
public AjaxResult getRouters() {
|
|
|
|
{
|
|
|
|
|
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
|
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
|
|
|
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
|
|
|
return AjaxResult.success(menuService.buildMenus(menus));
|
|
|
|
return AjaxResult.success(menuService.buildMenus(menus));
|
|
|
|