添加目录的完成

main
@t2652009480 2 years ago
parent ab89deb409
commit 0c5de007b7

@ -4,6 +4,7 @@ import com.zhiyun.zhiyun03.user.entity.User;
import com.zhiyun.zhiyun03.user.service.UserService;
import com.zhiyun.zhiyun03.user.vo.UserVo;
import com.zhiyun.zhiyun03.utils.common.JsonResult;
import com.zhiyun.zhiyun03.utils.common.ResultCode;
import com.zhiyun.zhiyun03.utils.exception.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -23,61 +24,22 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
@Controller
@RestController
@RequestMapping("/user")
public class UserController {
@Autowired
UserService userService;
@RequestMapping(path = "/login")
public String login(HttpServletRequest request, HttpServletResponse response, @RequestParam(name = "username") String username, @RequestParam(name = "password") String password, Model model) {
// //1、讲页面提交的密码进行md5加密
// password = DigestUtils.md5DigestAsHex(password.getBytes());
//2、根据用户名查数据库
User login = userService.login(username,password);
String url="";
//3、判断是否查询到
if (login != null){
//(2)成功 1.把数据保存到session中 2.跳转页面到index.html
request.getSession().setAttribute("USER",login);
url="layui-v2.6.8/index";
// try {
// response.sendRedirect("/static/layui-v2.6.8/index.html");
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
}else{
//(3)失败 1.把异常信息保存到model中 2.跳转到login.html
model.addAttribute("msg","登录名或者密码错误");
url = "layui-v2.6.8/login";
public JsonResult<User> login(HttpServletRequest request, @RequestParam(name = "userCode") String username, @RequestParam(name = "password") String password) {
if (username.isEmpty() || password.isEmpty()) {
return JsonResult.error(ResultCode.NO_NULL_ERROR, "账号或密码不能为空");
}
//经过视图解析器,最终路径解析为 前缀(/templates/)+url+后缀(.html)
return url;
User login = userService.login(username, password);
if (login != null) {
request.getSession().setAttribute("USER", login);
return JsonResult.success(ResultCode.SUCCESS);
}
return JsonResult.error(ResultCode.USER_ACCOUNT_ERROR, "账号或密码错误");
}
// @RequestMapping("/login1")
// public JsonResult login1(HttpRequest request,HttpServletResponse response, @RequestBody UserVo userVo){
// if (userVo.getUsername().isEmpty()&userVo.getPassword().isEmpty())
// {
// throw new ServiceException("300","账号密码不为空");
// }
//
// User user =userService.login(userVo.getUsername(), userVo.getPassword());
// if (user!=null)
// {
// try {
//
//
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return JsonResult.success();
// }
}

@ -9,7 +9,7 @@ public enum ResultCode {
USER_EXIST_ERROR("2001", "用户已存在"),
USER_ACCOUNT_ERROR("2002", "账号或密码错误"),
USER_NOT_EXIST_ERROR("2003", "未找到用户"),
NO_NULL_ERROR("3001", "账号或密码错误"),
NO_NULL_ERROR("3001", "账号或密码不能为空"),
PARAM_LOST_ERROR("2004", "参数缺失"),
PARAM_PASSWORD_ERROR("2005", "原密码输入错误"),
;

Loading…
Cancel
Save