| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package com.goldenwater.web.controller.system;
- import java.util.Map;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import com.goldenwater.common.config.RuoYiConfig;
- import com.goldenwater.common.core.domain.AjaxResult;
- import com.goldenwater.common.core.domain.entity.SysUser;
- import com.goldenwater.common.utils.SecurityUtils;
- import com.goldenwater.common.utils.StringUtils;
- import com.goldenwater.system.service.ISysUserService;
- /**
- * 首页
- *
- * @author goldenwater
- */
- @RestController
- public class SysIndexController
- {
- /** 系统基础配置 */
- @Autowired
- private RuoYiConfig goldenwaterConfig;
- @Autowired
- private ISysUserService userService;
- /**
- * 访问首页,提示语
- */
- @RequestMapping("/")
- public String index()
- {
- return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", goldenwaterConfig.getName(), goldenwaterConfig.getVersion());
- }
- /**
- * 解锁屏幕
- */
- @PostMapping("/unlockscreen")
- public AjaxResult unlockScreen(@RequestBody Map<String, String> body)
- {
- String password = body.get("password");
- if (StringUtils.isEmpty(password))
- {
- return AjaxResult.error("密码不能为空");
- }
- String username = SecurityUtils.getUsername();
- SysUser user = userService.selectUserByUserName(username);
- if (user == null)
- {
- return AjaxResult.error("服务器超时,请重新登录");
- }
- if (!SecurityUtils.matchesPassword(password, user.getPassword()))
- {
- return AjaxResult.error("密码错误,请重新输入");
- }
- return AjaxResult.success("解锁成功");
- }
- }
|