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,19 +9,31 @@ 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;
/** /**
* *
* *
* @author ruoyi * @author ruoyi
*/ */
@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;
@ -41,13 +42,12 @@ public class SysLoginController
/** /**
* *
* *
* @param loginBody * @param loginBody
* @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(),
@ -76,7 +75,7 @@ public class SysLoginController
/** /**
* *
* *
* @return * @return
*/ */
@GetMapping("getInfo") @GetMapping("getInfo")
@ -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);
@ -106,12 +102,11 @@ 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,18 +1,18 @@
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 {
{
/** /**
* *
* *
* @param user * @param user
* @return * @return
*/ */
@ -20,7 +20,7 @@ public interface ISysUserService
/** /**
* *
* *
* @param user * @param user
* @return * @return
*/ */
@ -28,7 +28,7 @@ public interface ISysUserService
/** /**
* *
* *
* @param user * @param user
* @return * @return
*/ */
@ -36,7 +36,7 @@ public interface ISysUserService
/** /**
* *
* *
* @param userName * @param userName
* @return * @return
*/ */
@ -44,7 +44,7 @@ public interface ISysUserService
/** /**
* ID * ID
* *
* @param userId ID * @param userId ID
* @return * @return
*/ */
@ -52,7 +52,7 @@ public interface ISysUserService
/** /**
* ID * ID
* *
* @param userName * @param userName
* @return * @return
*/ */
@ -60,7 +60,7 @@ public interface ISysUserService
/** /**
* ID * ID
* *
* @param userName * @param userName
* @return * @return
*/ */
@ -68,7 +68,7 @@ public interface ISysUserService
/** /**
* *
* *
* @param user * @param user
* @return * @return
*/ */
@ -92,21 +92,21 @@ public interface ISysUserService
/** /**
* *
* *
* @param user * @param user
*/ */
public void checkUserAllowed(SysUser user); public void checkUserAllowed(SysUser user);
/** /**
* *
* *
* @param userId id * @param userId id
*/ */
public void checkUserDataScope(Long userId); public void checkUserDataScope(Long userId);
/** /**
* *
* *
* @param user * @param user
* @return * @return
*/ */
@ -114,7 +114,7 @@ public interface ISysUserService
/** /**
* *
* *
* @param user * @param user
* @return * @return
*/ */
@ -122,7 +122,7 @@ public interface ISysUserService
/** /**
* *
* *
* @param user * @param user
* @return * @return
*/ */
@ -130,15 +130,15 @@ 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);
/** /**
* *
* *
* @param user * @param user
* @return * @return
*/ */
@ -146,7 +146,7 @@ public interface ISysUserService
/** /**
* *
* *
* @param user * @param user
* @return * @return
*/ */
@ -154,16 +154,16 @@ 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);
/** /**
* *
* *
* @param user * @param user
* @return * @return
*/ */
@ -171,7 +171,7 @@ public interface ISysUserService
/** /**
* *
* *
* @param userName * @param userName
* @param password * @param password
* @return * @return
@ -180,7 +180,7 @@ public interface ISysUserService
/** /**
* ID * ID
* *
* @param userId ID * @param userId ID
* @return * @return
*/ */
@ -188,7 +188,7 @@ public interface ISysUserService
/** /**
* *
* *
* @param userIds ID * @param userIds ID
* @return * @return
*/ */
@ -196,11 +196,19 @@ 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