zhangtao
dongdingding 1 year ago
parent 6cc775bf26
commit 7c47547fae

@ -1,16 +1,5 @@
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.core.domain.AjaxResult;
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.SysPermissionService;
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
@Api("登录验证")
public class SysLoginController
{
public class SysLoginController {
@Autowired
private SysLoginService loginService;
@Autowired
private ISysUserService userService;
@Autowired
private ISysMenuService menuService;
@ -46,8 +47,7 @@ public class SysLoginController
* @return
*/
@PostMapping("/login")
public AjaxResult login(@RequestBody LoginBody loginBody)
{
public AjaxResult login(@RequestBody LoginBody loginBody) {
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
@ -64,8 +64,7 @@ public class SysLoginController
*/
@ApiOperation("不带校验码登录方法")
@PostMapping("/loginNoCaptcha")
public AjaxResult loginNoCaptcha(@RequestBody LoginBody loginBody)
{
public AjaxResult loginNoCaptcha(@RequestBody LoginBody loginBody) {
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = loginService.loginNoCaptcha(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
@ -88,16 +87,13 @@ public class SysLoginController
// 权限集合
Set<String> permissions = permissionService.getMenuPermission(user);
AjaxResult ajax = AjaxResult.success();
String oldPassword = RSAUtil.decryptByPrivateKey(user.getPassword());
//判断密码是否为初始密码
if (oldPassword.equals("Yingji@123")){
ajax.put("status",1);
}else{
ajax.put("status",0);
/** 先根据用户输入的用户名查询数据 */
SysUser u = userService.findByPwd(user.getUserName());
if (user.getPassword() != null && SecurityUtils.matchesPassword(u.getPassword(), user.getPassword())) {
ajax.put("pstatus", 1);
} else {
ajax.put("pstatus", 0);
}
ajax.put("user", user);
ajax.put("roles", roles);
ajax.put("permissions", permissions);
@ -110,8 +106,7 @@ public class SysLoginController
* @return
*/
@GetMapping("getRouters")
public AjaxResult getRouters()
{
public AjaxResult getRouters() {
Long userId = SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
return AjaxResult.success(menuService.buildMenus(menus));

@ -124,4 +124,14 @@ public interface SysUserMapper
* @return
*/
public SysUser checkEmailUnique(String email);
/**
*
*
* @param name
* @return
*/
SysUser findByPwd(@Param("name") String name);
}

@ -1,15 +1,15 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.common.core.domain.entity.SysUser;
import java.util.List;
/**
*
*
* @author ruoyi
*/
public interface ISysUserService
{
public interface ISysUserService {
/**
*
*
@ -203,4 +203,12 @@ public interface ISysUserService
* @return
*/
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
/**
*
*
* @param name
* @return
*/
SysUser findByPwd(String name);
}

@ -541,4 +541,9 @@ public class SysUserServiceImpl implements ISysUserService
}
return successMsg.toString();
}
@Override
public SysUser findByPwd(String name) {
return userMapper.findByPwd(name);
}
}

@ -202,6 +202,10 @@
where email = #{email}
and del_flag = '0' limit 1
</select>
<select id="findByPwd" resultType="com.ruoyi.common.core.domain.entity.SysUser">
select password
from sys_user where user_name =#{name}
</select>
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user(

Loading…
Cancel
Save