博主主页:Java旅途
简介:分享计算机知识、学习路线、系统源码及教程
文末获取源码
房屋租赁网站基于SpringBoot+Mybatis开发,系统分为管理员和普通用户两种角色。
管理员功能如下:
普通用户功能如下:
OrderController
package com.house.wym.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.house.wym.entity.*;
import com.house.wym.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class OrderController {
@Autowired
private IOrderService sevice;
@RequestMapping("/myorder")
public String toOrderPage() {
return "myorder";
}
@RequestMapping("/updatepwd")
public String toUpdatepwdPage() {
return "updatepwd";
}
@RequestMapping("/addOrder")
@ResponseBody
public String addOrder(String id,HttpServletRequest request) {
Users u = (Users) request.getSession().getAttribute("loginUser");
try {
Order order = new Order();
order.sethID(Integer.parseInt(id));
order.setOrderUser(u.getuNickName());
order.setuID(u.getuID());
int n = sevice.addOrder(order);
if(n>0) {
return "OK";
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
return "FAIL";
}
@RequestMapping("/myOrderInfo")
@ResponseBody
public UserOrderData findAllOrder(int page, int limit, HttpServletRequest request){
Page p = new Page();
p.setPage((page - 1) * limit);
p.setLimit(limit);
Users u = (Users) request.getSession().getAttribute("loginUser");
p.setuID(u.getuID());
UserOrderData uod = new UserOrderData();
List<UserOrder> order = sevice.findAllOrder(p);
uod.setCode(0);
uod.setCount(sevice.getOrderCount(u.getuID()));
uod.setData(order);
uod.setMsg("200");
return uod;
}
@RequestMapping("/deleteOrder")
@ResponseBody
public String deleteOrder(int oID) {
int n = sevice.deleteOrder(oID);
if(n>0)
return "OK";
return "FAIL";
}
}
LoginController
package com.house.wym.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.house.wym.config.MD5;
import com.house.wym.entity.Users;
import com.house.wym.service.IUserService;
import com.wf.captcha.utils.CaptchaUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class LoginController {
@Autowired
private IUserService mapper;
@RequestMapping("/captcha")
public void captcha(HttpServletRequest request, HttpServletResponse response) throws Exception {
CaptchaUtil.out(request, response);
}
@RequestMapping("/login")
@ResponseBody
public String toCustomerPage(String username,String password,String verCode,HttpServletRequest req ) {
if (!CaptchaUtil.ver(verCode, req)) {
CaptchaUtil.clear(req); // 清除session中的验证码
return "FAIL1";
}
Users user = new Users();
user.setuName(username);
user.setuPassword(MD5.getMD5ofStr(password));
Users loginUser = mapper.login(user);
if(loginUser!=null) {
req.getSession().setAttribute("loginUser", loginUser);
return "OK";
}
return "FAIL";
}
@RequestMapping("/signout")
public String signout(HttpSession session) {
session.invalidate();
return "redirect:toIndexPage";
}
@RequestMapping("/regist")
@ResponseBody
public String regist(Users user,String verCode,HttpServletRequest req) {
if (!CaptchaUtil.ver(verCode, req)) {
CaptchaUtil.clear(req); // 清除session中的验证码
return "FAIL1";
}
int regist;
try {
regist = mapper.regist(user);
if(regist>0) {
return "OK";
}
} catch (Exception e) {
e.printStackTrace();
}
return "FAIL";
}
}
大家点赞、收藏、关注、评论啦 、👇🏻点开下方卡片👇🏻关注后回复 101