本文主要是介绍Java项目:SSM在线租房售房平台多城市版本,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
作者主页:源码空间站2022
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
本项目分为前后台,共有管理员与普通用户两种角色;
管理员角色包含以下功能:
管理员登录,修改基本信息,用户管理,租房管理,售房管理,举报用户管理,举报房源管理等功能。
用户角色包含以下功能:
用户角色,修改个人信息,发布租房信息,发布售房信息,查找房源,查看消息通知,查看被举报记录,租房管理,售房管理等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
6.是否Maven项目:是;
技术栈
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript+Bootstrap+jQuery
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中datasource.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,http://localhost:8080/
用户账号/密码:user/123456
管理员账号/密码:admin/admin
运行截图
用户角色
管理员角色
相关代码
房子控制器
package com.houserss.controller;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.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;import com.houserss.common.Const;
import com.houserss.common.Const.Role;
import com.houserss.common.ServerResponse;
import com.houserss.dao.HouseMapper;
import com.houserss.pojo.House;
import com.houserss.pojo.User;
import com.houserss.service.IHouseService;
import com.houserss.vo.HouseVo;
import com.houserss.vo.PageInfoVo;@Controller
@RequestMapping("/house/")
public class HouseController {@Autowiredprivate IHouseService iHouseService;@Autowiredprivate HouseMapper houseMapper;@RequestMapping(value="publish.do",method = RequestMethod.POST)@ResponseBodypublic ServerResponse<String> publish(House house, @RequestParam(value = "images", required = false)MultipartFile images[], String[] deletes, HttpSession session,HttpServletRequest request){User currentUser = (User)session.getAttribute(Const.CURRENT_USER);String path = request.getSession().getServletContext().getRealPath("upload");if(currentUser == null){return ServerResponse.createByErrorMessage("用户未登录,请登录后在编辑");}return iHouseService.publish(currentUser,house, images, deletes,path);}@RequestMapping(value="delete.do",method = RequestMethod.POST)@ResponseBodypublic ServerResponse<String> delete(int houseId, HttpSession session){User currentUser = (User)session.getAttribute(Const.CURRENT_USER);if(currentUser == null){return ServerResponse.createByErrorMessage("用户未登录,请登录后在删除");}return iHouseService.delete(currentUser,houseId);}@RequestMapping(value="houseList.do",method = RequestMethod.POST)@ResponseBodypublic ServerResponse<PageInfoVo<HouseVo>> houseList(@RequestParam(value = "pageNum",defaultValue = "1")int pageNum,@RequestParam(value = "pageSize",defaultValue = "10") int pageSize,@RequestParam(value = "sellType",required = false)String sellType,@RequestParam(value = "zone",required = false)String zone,@RequestParam(value = "houseType",required = false)String houseType,@RequestParam(value = "minPrice",required = false)String minPrice,@RequestParam(value = "maxPrice",required = false)String maxPrice,@RequestParam(value = "orientation",required = false)String orientation,@RequestParam(value = "decorateType",required = false)Integer decorateType,@RequestParam(value = "minArea",required = false)String minArea,@RequestParam(value = "maxArea",required = false)String maxArea,@RequestParam(value = "address",required = false)String address,@RequestParam(value = "isSelf",defaultValue = "false")boolean isSelf,@RequestParam(value = "orderType",defaultValue = "0")int orderType,@RequestParam(value = "status",required=false)Integer status,@RequestParam(value = "isHide",required=false)Integer isHide,HttpSession session){int userId = 0;User currentUser = (User)session.getAttribute(Const.CURRENT_USER);if(currentUser != null && currentUser.getRoleType() == Role.ROLE_ADMIN) {return iHouseService.houseList(pageNum,pageSize,sellType,zone,houseType,minPrice,maxPrice,orientation,minArea,maxArea,address,decorateType,userId,orderType,status,isHide);}if(currentUser != null && isSelf) {userId = currentUser.getId();}return iHouseService.houseList(pageNum,pageSize,sellType,zone,houseType,minPrice,maxPrice,orientation,minArea,maxArea,address,decorateType,userId,orderType,status,isHide);}@RequestMapping(value="detailHouse.do",method = RequestMethod.POST)@ResponseBodypublic ServerResponse<HouseVo> detailHouse(int houseId, HttpSession session){return iHouseService.detailHouse(houseId);}@RequestMapping(value="updateHouse.do",method = RequestMethod.POST)@ResponseBodypublic ServerResponse<String> updateHouse(House house,HttpSession session){User currentUser = (User)session.getAttribute(Const.CURRENT_USER);if(currentUser == null){return ServerResponse.createByErrorMessage("用户未登录");}House tempHouse = houseMapper.selectById(house.getId());if(tempHouse == null) {return ServerResponse.createByErrorMessage("未找到要修改房源信息");}return iHouseService.againPublishHouse(house);}@RequestMapping(value="setHideStatus.do",method = RequestMethod.POST)@ResponseBodypublic ServerResponse<String> setHideStatus(@RequestParam(required=true)int houseId,@RequestParam(required=true)int isHide,HttpSession session){User currentUser = (User)session.getAttribute(Const.CURRENT_USER);if(currentUser == null){return ServerResponse.createByErrorMessage("用户未登录");}House tempHouse = houseMapper.selectById(houseId);if(tempHouse == null) {return ServerResponse.createByErrorMessage("未找到要修改房源信息");}if(currentUser.getRoleType() == Role.ROLE_ADMIN){return iHouseService.setHideStatus(houseId,isHide);}else{if(tempHouse.getUserId() == currentUser.getId()){return iHouseService.setHideStatus(houseId,isHide);}}return ServerResponse.createByErrorMessage("设置房源状态异常");}// backend/*** 审核房源* @param session* @return*/@RequestMapping(value="verified.do",method = RequestMethod.POST)@ResponseBodypublic ServerResponse<String> verified(@RequestParam(required=true)int houseId,@RequestParam(required=true)int status,@RequestParam(defaultValue="",required=false)String reason,HttpSession session){User currentUser = (User)session.getAttribute(Const.CURRENT_USER);if(currentUser == null){return ServerResponse.createByErrorMessage("用户未登录");}if(currentUser.getRoleType() != Role.ROLE_ADMIN) {return ServerResponse.createByErrorMessage("该用户无权限访问");}return iHouseService.verified(houseId,status,reason);}}
如果也想学习本系统,下面领取。回复:195ssm
这篇关于Java项目:SSM在线租房售房平台多城市版本的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!