package controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import pojo.House;
import pojo.Manager;
import pojo.Renter;
import service.ManagerService;
@Controller
@Transactional
public class ManagerController {
@Autowired
ManagerService managerService;
@GetMapping("/index")
public String managerAction() {
return "index";
}
@GetMapping("/showAddHousePage")
public String showAddHousePage() {
return "addHouse";
}
@GetMapping("loginvalid")
public void loginvalid(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException{
request.getSession().removeAttribute("user");
response.sendRedirect("index");
}
@PostMapping("/login")
public ModelAndView loginManager(String managerName, String managerPassword, HttpSession session) {
ModelAndView mav = new ModelAndView();
Manager mgr = null;
mgr = managerService.loginManager(managerName, managerPassword);
if (mgr != null) {
session.setAttribute("mgr", mgr);
mav.setViewName("manage");
} else {
mav.addObject("error", "该账户不存在或登录密码出错,请更改用户");
mav.setViewName("index");
}
return mav;
}
@PostMapping("/register")
public ModelAndView registerManager(Manager manager) {
ModelAndView mav = new ModelAndView();
int result = managerService.registerManager(manager);
if (result > 0) {
mav.setViewName("index");
} else {
mav.setViewName("index");
}
return mav;
}
@GetMapping("/getAllHouse")
public ModelAndView getAllHouse(String renter, String rentStartTime) {
ModelAndView mav = new ModelAndView();
int pageNum = 1;
int totalHouse = managerService.countHouses(renter, rentStartTime);
int size = 4;
int totalpage = 0;
if (totalHouse < size) {
totalpage = 1;
} else if (totalHouse % size == 0) {
totalpage = totalHouse / size;
} else {
totalpage = (totalHouse / size) + 1;
}
int start = (pageNum - 1) * size;
List<House> houseList = managerService.paging(start, size, renter, rentStartTime);
mav.addObject("renter", renter);
mav.addObject("rentStartTime", rentStartTime);
mav.addObject("pageNum", pageNum);
mav.addObject("totalpage", totalpage);
mav.addObject("houseList", houseList);
mav.setViewName("showAllHouse");
return mav;
}
@GetMapping("/preOrnext")
public ModelAndView preOrnext(int pageNum, int totalPage, String renter, String rentStartTime) {
ModelAndView mav = new ModelAndView();
int size = 4;
int start = (pageNum - 1) * size;
List<House> houseList = managerService.paging(start, size, renter, rentStartTime);
mav.addObject("pageNum", pageNum);
mav.addObject("totalpage", totalPage);
mav.addObject("houseList", houseList);
mav.addObject("renter", renter);
mav.addObject("rentStartTime", rentStartTime);
mav.setViewName("showAllHouse");
return mav;
}
@GetMapping("/checkHouseInfo")
public ModelAndView checkHouseInfo(String name) {
ModelAndView mav = new ModelAndView();
House house = managerService.findHouses(name);
mav.addObject("house", house);
mav.setViewName("details");
return mav;
}
@GetMapping("/addRenterPage")
public String addRenterPage() {
return "addRenter";
}
@PostMapping("/changeHouseInfo")
public ModelAndView changHouseInfo(HttpServletRequest request, @RequestParam("id") int id,
@RequestParam("name") String name, @RequestParam("price") String price,
@RequestParam("address") String address, @RequestParam("huxing") String huxing,
@RequestParam("area") String area, @RequestParam("floor") String floor,
@RequestParam("chaoxiang") String chaoxiang, @RequestParam("subway") String subway,
@RequestParam("descoration") String descoration, @RequestParam("renter") String renter,
@RequestParam("rentStartTime") String rentStartTime, @RequestParam("rentEndTime") String rentEndTime,
@RequestParam("image") String photoName) throws IllegalStateException, IOException {
ModelAndView mav = new ModelAndView();
House house = new House();
String imgName = "";
if (request instanceof MultipartHttpServletRequest) {
MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartHttpServletRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entry : fileMap.entrySet()) {
// 对文件进处理
String path = "D:\\Program Files\\myeclipse-2017\\Workspaces\\house_rent Maven Webapp\\src\\main\\webapp\\imgs\\";
imgName = entry.getValue().getOriginalFilename();
if (imgName.equals("") || imgName == null) {
imgName = photoName;
} else {
String t_path = request.getSession().getServletContext().getRealPath("imgs/");
File t_file = new File(t_path + imgName);
File old_t_file = new File(t_path + photoName);
old_t_file.delete();
if (!t_file.getParentFile().exists()) {
t_file.getParentFile().mkdirs();
}
if (!t_file.exists()) {
t_file.createNewFile();
}
File oldFile = new File(path + photoName);
oldFile.delete();
File tempFile = new File(path + imgName);
if (!tempFile.getParentFile().exists()) {
tempFile.getParentFile().mkdirs();
}
if (!tempFile.exists()) {
tempFile.createNewFile();
}
byte[] imageByte = entry.getValue().getBytes();
FileOutputStream is = new FileOutputStream(tempFile);
DataOutputStream dis = new DataOutputStream(is);
dis.write(imageByte);
dis.close();
is.close();
entry.getValue().transferTo(t_file);
}
}
}
if (renter != "" && renter != null) {
house.setRenter(null);
house.setRentStartTime(null);
house.setRentEndTime(null);
managerService.updateHouseIdByrenterName(renter, id);
}
house = new House(id, name, price, address, huxing, area, floor, chaoxiang, descoration, subway, renter,
rentStartTime, rentEndTime, imgName);
int result = managerService.updateHouseInfo(house);
mav.setViewName("manage");
return mav;
}
@PostMapping("/insertHouseInfo")
public ModelAndView insertHouseInfo(HttpServletRequest request, @RequestParam("name") String name,
@RequestParam("price") String price, @RequestParam("address") String address,
@RequestParam("huxing") String huxing, @RequestParam("area") String area,
@RequestParam("floor") String floor, @RequestParam("chaoxiang") String chaoxiang,
@RequestParam("subway") String subway, @RequestParam("descoration") String descoration)
throws IllegalStateException, IOException {
ModelAndView mav = new ModelAndView();
House house = new House();
String imgName = "";
if (request instanceof MultipartHttpServletRequest) {
MultipartHttpServletReq
没有合适的资源?快使用搜索试试~ 我知道了~
毕设项目:基于SSM架构实现的房屋租赁管理系统.zip
共106个文件
jar:16个
jpg:15个
xml:13个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 81 浏览量
2023-10-20
18:06:29
上传
评论 1
收藏 19.67MB ZIP 举报
温馨提示
毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统 毕设项目:基于SSM架构实现的房屋租赁管理系统
资源推荐
资源详情
资源评论
收起资源包目录
毕设项目:基于SSM架构实现的房屋租赁管理系统.zip (106个子文件)
House.class 4KB
ManagerServiceImpl.class 2KB
Manager.class 2KB
Renter.class 2KB
ManagerController.class 790B
ManagerDao.class 606B
ManagerService.class 523B
.classpath 2KB
org.eclipse.wst.common.component 845B
org.eclipse.wst.jsdt.ui.superType.container 49B
link.css 3KB
sah.css 1KB
details.css 913B
manage.css 836B
addHouse.css 446B
showAllRenter.css 50B
.gitignore 25B
.gitignore 11B
mybatis-3.4.5.jar 1.55MB
spring-web-5.0.2.RELEASE.jar 1.18MB
spring-core-5.0.2.RELEASE.jar 1.16MB
spring-context-5.0.2.RELEASE.jar 1.03MB
mysql-connector-java-5.1.38.jar 961KB
spring-webmvc-5.0.2.RELEASE.jar 764KB
spring-beans-5.0.2.RELEASE.jar 640KB
spring-jdbc-4.3.14.RELEASE.jar 418KB
jstl-1.2.jar 405KB
spring-aop-5.0.2.RELEASE.jar 352KB
spring-expression-5.0.2.RELEASE.jar 257KB
spring-tx-5.0.2.RELEASE.jar 243KB
commons-dbcp-1.4.jar 157KB
commons-pool-1.5.4.jar 94KB
mybatis-spring-1.3.1.jar 52KB
spring-jcl-5.0.2.RELEASE.jar 15KB
ManagerController.java 12KB
House.java 5KB
ManagerServiceImpl.java 3KB
ManagerDao.java 2KB
Renter.java 1KB
Manager.java 1KB
ManagerService.java 1KB
f1.jpg 1.44MB
bg3.jpg 174KB
h1.jpg 169KB
d1.jpg 166KB
e1.jpg 162KB
c1.jpg 158KB
b4.jpg 150KB
g1.jpg 147KB
i1.jpg 138KB
b1.jpg 136KB
a4.jpg 118KB
a3.jpg 108KB
b2.jpg 80KB
login.jpg 46KB
2.jpg 0B
jquery-3.2.1.min.js 85KB
manage.js 1KB
index.js 1KB
paging.js 848B
showAllRenter.js 604B
updateRenter.js 371B
addRenter.js 141B
.jsdtscope 626B
details.jsp 3KB
index.jsp 2KB
showAllHouse.jsp 2KB
showAllRenter.jsp 2KB
updateRenter.jsp 1KB
addHouse.jsp 1KB
addRenter.jsp 1KB
manage.jsp 1KB
register.jsp 523B
login.jsp 440B
index.jsp 52B
inputFiles.lst 736B
createdFiles.lst 176B
inputFiles.lst 0B
MANIFEST.MF 99B
.myumldata 64B
org.eclipse.wst.jsdt.ui.superType.name 6B
com.genuitec.eclipse.j2eedt.ui.prefs 1007B
org.eclipse.jdt.core.prefs 422B
org.eclipse.m2e.core.prefs 86B
com.genuitec.eclipse.modernweb.common.core.prefs 60B
org.eclipse.core.resources.prefs 55B
org.eclipse.wst.validation.prefs 48B
.project 1KB
pom.properties 253B
pom.properties 120B
database.property 171B
database.property 137B
house_rent.war 8.25MB
ManagerDao.xml 6KB
pom.xml 3KB
pom.xml 3KB
ManagerDao.xml 3KB
applicationContext.xml 2KB
applicationContext.xml 2KB
housemanager-servlet.xml 2KB
共 106 条
- 1
- 2
资源评论
辣椒种子
- 粉丝: 4139
- 资源: 5745
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功