SysIndexController.java 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package com.goldenwater.web.controller.system;
  2. import java.util.Map;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.web.bind.annotation.PostMapping;
  5. import org.springframework.web.bind.annotation.RequestBody;
  6. import org.springframework.web.bind.annotation.RequestMapping;
  7. import org.springframework.web.bind.annotation.RestController;
  8. import com.goldenwater.common.config.RuoYiConfig;
  9. import com.goldenwater.common.core.domain.AjaxResult;
  10. import com.goldenwater.common.core.domain.entity.SysUser;
  11. import com.goldenwater.common.utils.SecurityUtils;
  12. import com.goldenwater.common.utils.StringUtils;
  13. import com.goldenwater.system.service.ISysUserService;
  14. /**
  15. * 首页
  16. *
  17. * @author goldenwater
  18. */
  19. @RestController
  20. public class SysIndexController
  21. {
  22. /** 系统基础配置 */
  23. @Autowired
  24. private RuoYiConfig goldenwaterConfig;
  25. @Autowired
  26. private ISysUserService userService;
  27. /**
  28. * 访问首页,提示语
  29. */
  30. @RequestMapping("/")
  31. public String index()
  32. {
  33. return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", goldenwaterConfig.getName(), goldenwaterConfig.getVersion());
  34. }
  35. /**
  36. * 解锁屏幕
  37. */
  38. @PostMapping("/unlockscreen")
  39. public AjaxResult unlockScreen(@RequestBody Map<String, String> body)
  40. {
  41. String password = body.get("password");
  42. if (StringUtils.isEmpty(password))
  43. {
  44. return AjaxResult.error("密码不能为空");
  45. }
  46. String username = SecurityUtils.getUsername();
  47. SysUser user = userService.selectUserByUserName(username);
  48. if (user == null)
  49. {
  50. return AjaxResult.error("服务器超时,请重新登录");
  51. }
  52. if (!SecurityUtils.matchesPassword(password, user.getPassword()))
  53. {
  54. return AjaxResult.error("密码错误,请重新输入");
  55. }
  56. return AjaxResult.success("解锁成功");
  57. }
  58. }