|  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Set; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; | 
|---|
|  |  |  | import com.github.xiaoymin.knife4j.annotations.ApiSort; | 
|---|
|  |  |  | import com.ruoyi.common.annotation.Anonymous; | 
|---|
|  |  |  | import com.ruoyi.common.utils.PageUtils; | 
|---|
|  |  |  | import com.ruoyi.framework.web.service.SysPasswordService; | 
|---|
|  |  |  | import com.ruoyi.system.service.ISysConfigService; | 
|---|
|  |  |  | import com.ruoyi.system.service.ISysUserService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @Api(tags = "登录验证接口") | 
|---|
|  |  |  | @ApiSort(1) | 
|---|
|  |  |  | @Anonymous | 
|---|
|  |  |  | public class SysLoginController { | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SysPermissionService permissionService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ISysUserService userService; | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 登录方法 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/login") | 
|---|
|  |  |  | @ApiOperation(value = "登录") | 
|---|
|  |  |  | @ApiOperationSupport(order = 1) | 
|---|
|  |  |  | public AjaxResult login(@RequestBody LoginBody loginBody) { | 
|---|
|  |  |  | AjaxResult ajax = AjaxResult.success(); | 
|---|
|  |  |  | // 生成令牌 | 
|---|
|  |  |  | 
|---|
|  |  |  | ajax.put(Constants.TOKEN, token); | 
|---|
|  |  |  | return ajax; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/validate") | 
|---|
|  |  |  | @ApiOperation(value = "验证密码") | 
|---|
|  |  |  | @ApiOperationSupport(order = 1) | 
|---|
|  |  |  | public AjaxResult validate(@RequestBody SysUser sysUser) { | 
|---|
|  |  |  | SysUser user = userService.selectUserByUserName(sysUser.getUserName()); | 
|---|
|  |  |  | boolean b = SecurityUtils.matchesPassword(sysUser.getPassword(),user.getPassword()); | 
|---|
|  |  |  | if(b) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return AjaxResult.success("原密码正确"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return AjaxResult.error("原密码错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取用户信息 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("getInfo") | 
|---|
|  |  |  | @ApiOperation(value = "获取用户信息") | 
|---|
|  |  |  | @ApiOperationSupport(order = 2) | 
|---|
|  |  |  | public AjaxResult getInfo() { | 
|---|
|  |  |  | SysUser user = SecurityUtils.getLoginUser().getUser(); | 
|---|
|  |  |  | // 赋值融云token到用户信息 | 
|---|
|  |  |  | 
|---|
|  |  |  | @GetMapping("getRouters") | 
|---|
|  |  |  | public AjaxResult getRouters() { | 
|---|
|  |  |  | String userId = SecurityUtils.getUserId(); | 
|---|
|  |  |  | PageUtils.clearPage();//修复分页缓存获取不到二级菜单的问题 | 
|---|
|  |  |  | List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId); | 
|---|
|  |  |  | return AjaxResult.success(menuService.buildMenus(menus)); | 
|---|
|  |  |  | } | 
|---|