laozt 1 year ago
commit d9d41aec2e

@ -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")){ } else {
ajax.put("status",1); ajax.put("pstatus", 0);
}else{
ajax.put("status",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));

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

@ -1,15 +1,15 @@
package com.ruoyi.system.service; package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import java.util.List;
/** /**
* *
* *
* @author ruoyi * @author ruoyi
*/ */
public interface ISysUserService public interface ISysUserService {
{
/** /**
* *
* *
@ -131,7 +131,7 @@ public interface ISysUserService
/** /**
* *
* *
* @param userId ID * @param userId ID
* @param roleIds * @param roleIds
*/ */
public void insertUserAuth(Long userId, Long[] roleIds); public void insertUserAuth(Long userId, Long[] roleIds);
@ -156,7 +156,7 @@ public interface ISysUserService
* *
* *
* @param userName * @param userName
* @param avatar * @param avatar
* @return * @return
*/ */
public boolean updateUserAvatar(String userName, String avatar); public boolean updateUserAvatar(String userName, String avatar);
@ -197,10 +197,18 @@ public interface ISysUserService
/** /**
* *
* *
* @param userList * @param userList
* @param isUpdateSupport * @param isUpdateSupport
* @param operName * @param operName
* @return * @return
*/ */
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName); 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(); return successMsg.toString();
} }
@Override
public SysUser findByPwd(String name) {
return userMapper.findByPwd(name);
}
} }

@ -202,6 +202,10 @@
where email = #{email} where email = #{email}
and del_flag = '0' limit 1 and del_flag = '0' limit 1
</select> </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 id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user( insert into sys_user(

Loading…
Cancel
Save