大家好!我是职场程序猿,感谢您阅读本文,欢迎一键三连哦。
当前专栏:Java毕业设计
房地产销售管理系统是针对传统房地产企业管理模式与业务手段中逐渐表现出的效率低下、信息滞后、规范与执行力差等特点,利用先进的IT信息技术,结合房地产企业自身管理思想和模式,参考一系列大型房地产企业管理经验。系统采用B/S架构,基于Java进行搭建,帮助房地产企业保持稳定、健康的可持续性发展的信息化管理软件。
用户通过系统提供的注册、登陆功能,实现使用其它核心功能的目的。应用逻辑为用户点击进入系统,选择登陆类型是学生、老师或者管理员,管理员使用默认Admin账户而无需注册。![![在这里插入图片描述](https://img-blog.csdnimg.cn/da234c91205b4a3f878a190a89b4d3fb.png)
管理员可以通过该功能编辑系统公告,例如发布活动信息、新的房源信息等;用户可以通过该功能进行浏览,从而使双方可以最便捷的交换重要信息。具体实现效果如下图所示:
管理员或销售人员可以通过文字、图片等方式发布、编辑房产信息,用户可以搜索、浏览在售的房屋信息并进行评论,通过线上方式减少信息差。房屋信息分为在售房屋信息和已售房屋信息,便于用户进行对比,也便于管理人员对房屋售卖情况进行分类管理。
系统管理员拥有系统的最高权限,主要用于系统维护、管理,通过admin账户进行登陆。登陆后,系统在页面上有系统后台入口,进入后可以跳转至后台管理页面。
1.概述 6
1.1课题背景及研究意义 6
1.2国内外研究现状 7
1.3 论文结构 9
2.需求分析 10
3.项目技术简介 11
3.1 Java编程语言 11
3.2 B/S架构 12
3.3 Mysql数据库 15
3.4 JSP 16
4.系统设计实现 19
4.1 设计原则 19
4.2 开发工具及环境 19
4.2.1IntelliJ IDEA安装 20
4.2.2配置JAVA运行环境 25
4.3 主要功能模块功能设计 29
4.4数据库设计 30
4.5系统实现及实现效果 31
4.5.1注册登陆功能 31
4.5.2公告信息功能 32
4.5.3房屋信息展示 33
4.5.4购买合同信息 33
4.5.5系统管理员功能 34
5.软件测试 35
5.1 基本概念 35
5.2 软件测试的基本方法 36
5.3软件测试的原则 36
5.4测试用例 37
5.5测试结果 39
6.总结与展望 39
6.1 研究总结 39
6.2 展望 39
参考文献 41
致 谢 42
package com.example.controller;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.example.common.Result;
import com.example.common.ResultCode;
import com.example.entity.Account;
import com.example.entity.AuthorityInfo;
import com.example.exception.CustomException;
import com.example.entity.AdminInfo;
import com.example.entity.UserInfo;
import com.example.service.AdminInfoService;
import com.example.service.UserInfoService;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import cn.hutool.json.JSONUtil;
import java.util.*;
import java.util.stream.Collectors;
@RestController
public class AccountController {
@Value("${authority.info}")
private String authorityStr;
@Resource
private AdminInfoService adminInfoService;
@Resource
private UserInfoService userInfoService;
@PostMapping("/login")
public Result<Account> login(@RequestBody Account account, HttpServletRequest request) {
if (StrUtil.isBlank(account.getName()) || StrUtil.isBlank(account.getPassword()) || account.getLevel() == null) {
throw new CustomException(ResultCode.PARAM_LOST_ERROR);
}
Integer level = account.getLevel();
Account login = new Account();
if (1 == level) {
login = adminInfoService.login(account.getName(), account.getPassword());
}
if (2 == level) {
login = userInfoService.login(account.getName(), account.getPassword());
}
request.getSession().setAttribute("user", login);
return Result.success(login);
}
@PostMapping("/register")
public Result<Account> register(@RequestBody Account account) {
Integer level = account.getLevel();
Account login = new Account();
if (1 == level) {
AdminInfo info = new AdminInfo();
BeanUtils.copyProperties(account, info);
login = adminInfoService.add(info);
}
if (2 == level) {
UserInfo info = new UserInfo();
BeanUtils.copyProperties(account, info);
login = userInfoService.add(info);
}
return Result.success(login);
}
@GetMapping("/logout")
public Result logout(HttpServletRequest request) {
request.getSession().setAttribute("user", null);
return Result.success();
}
@GetMapping("/auth")
public Result getAuth(HttpServletRequest request) {
Object user = request.getSession().getAttribute("user");
if(user == null) {
return Result.error("401", "未登录");
}
return Result.success(user);
}
@GetMapping("/getAccountInfo")
public Result<Object> getAccountInfo(HttpServletRequest request) {
Account account = (Account) request.getSession().getAttribute("user");
if (account == null) {
return Result.success(new Object());
}
Integer level = account.getLevel();
if (1 == level) {
return Result.success(adminInfoService.findById(account.getId()));
}
if (2 == level) {
return Result.success(userInfoService.findById(account.getId()));
}
return Result.success(new Object());
}
@GetMapping("/getSession")
public Result<Map<String, String>> getSession(HttpServletRequest request) {
Account account = (Account) request.getSession().getAttribute("user");
if (account == null) {
return Result.success(new HashMap<>(1));
}
Map<String, String> map = new HashMap<>(1);
map.put("username", account.getName());
return Result.success(map);
}
@GetMapping("/getAuthority")
public Result<List<AuthorityInfo>> getAuthorityInfo() {
List<AuthorityInfo> authorityInfoList = JSONUtil.toList(JSONUtil.parseArray(authorityStr), AuthorityInfo.class);
return Result.success(authorityInfoList);
}
/**
* 获取当前用户所能看到的模块信息
* @param request
* @return
*/
@GetMapping("/authority")
public Result<List<Integer>> getAuthorityInfo(HttpServletRequest request) {
Account user = (Account) request.getSession().getAttribute("user");
if (user == null) {
return Result.success(new ArrayList<>());
}
JSONArray objects = JSONUtil.parseArray(authorityStr);
for (Object object : objects) {
JSONObject jsonObject = (JSONObject) object;
if (user.getLevel().equals(jsonObject.getInt("level"))) {
JSONArray array = JSONUtil.parseArray(jsonObject.getStr("models"));
List<Integer> modelIdList = array.stream().map((o -> {
JSONObject obj = (JSONObject) o;
return obj.getInt("modelId");
})).collect(Collectors.toList());
return Result.success(modelIdList);
}
}
return Result.success(new ArrayList<>());
}
@GetMapping("/permission/{modelId}")
public Result<List<Integer>> getPermission(@PathVariable Integer modelId, HttpServletRequest request) {
List<AuthorityInfo> authorityInfoList = JSONUtil.toList(JSONUtil.parseArray(authorityStr), AuthorityInfo.class);
Account user = (Account) request.getSession().getAttribute("user");
if (user == null) {
return Result.success(new ArrayList<>());
}
Optional<AuthorityInfo> optional = authorityInfoList.stream().filter(x -> x.getLevel().equals(user.getLevel())).findFirst();
if (optional.isPresent()) {
Optional<AuthorityInfo.Model> firstOption = optional.get().getModels().stream().filter(x -> x.getModelId().equals(modelId)).findFirst();
if (firstOption.isPresent()) {
List<Integer> info = firstOption.get().getOperation();
return Result.success(info);
}
}
return Result.success(new ArrayList<>());
}
@PutMapping("/updatePassword")
public Result updatePassword(@RequestBody Account info, HttpServletRequest request) {
Account account = (Account) request.getSession().getAttribute("user");
if (account == null) {
return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
}
String oldPassword = SecureUtil.md5(info.getPassword());
if (!oldPassword.equals(account.getPassword())) {
return Result.error(ResultCode.PARAM_PASSWORD_ERROR.code, ResultCode.PARAM_PASSWORD_ERROR.msg);
}
info.setPassword(SecureUtil.md5(info.getNewPassword()));
Integer level = account.getLevel();
if (1 == level) {
AdminInfo adminInfo = new AdminInfo();
BeanUtils.copyProperties(info, adminInfo);
adminInfoService.update(adminInfo);
}
if (2 == level) {
UserInfo userInfo = new UserInfo();
BeanUtils.copyProperties(info, userInfo);
userInfoService.update(userInfo);
}
info.setLevel(level);
info.setName(account.getName());
// 清空session,让用户重新登录
request.getSession().setAttribute("user", null);
return Result.success();
}
@PostMapping("/resetPassword")
public Result resetPassword(@RequestBody Account account) {
Integer level = account.getLevel();
if (1 == level) {
AdminInfo info = adminInfoService.findByUserName(account.getName());
if (info == null) {
return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
}
info.setPassword(SecureUtil.md5("123456"));
adminInfoService.update(info);
}
if (2 == level) {
UserInfo info = userInfoService.findByUserName(account.getName());
if (info == null) {
return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
}
info.setPassword(SecureUtil.md5("123456"));
userInfoService.update(info);
}
return Result.success();
}
}
package com.example.controller;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.example.common.Result;
import com.example.entity.Account;
import com.example.service.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
@RestController
public class MenuController {
@Resource
private AdminInfoService adminInfoService;
@Resource
private XiaoquInfoService xiaoquInfoService;
@Resource
private ZhangmuInfoService zhangmuInfoService;
@Resource
private UserInfoService userInfoService;
@Resource
private AdvertiserInfoService advertiserInfoService;
@GetMapping(value = "/getMenu", produces="application/json;charset=UTF-8")
public String getMenu(HttpServletRequest request) {
Account account = (Account) request.getSession().getAttribute("user");
Integer level;
if (account == null) {
level = 1;
} else {
level = account.getLevel();
}
JSONObject obj = new JSONObject();
obj.putOpt("code", 0);
obj.putOpt("msg", "");
JSONArray dataArray = new JSONArray();
dataArray.add(getJsonObject("/", "系统首页", "layui-icon-home", "/"));
JSONObject tableObj = new JSONObject();
tableObj.putOpt("title", "信息管理");
tableObj.putOpt("icon", "layui-icon-table");
if (1 == level) {
JSONArray array = new JSONArray();
array.add(getJsonObject("adminInfo", "管理员信息", "layui-icon-table", "adminInfo"));
array.add(getJsonObject("xiaoquInfo", "小区信息", "layui-icon-table", "xiaoquInfo"));
array.add(getJsonObject("zaishouInfo", "在售房屋信息", "layui-icon-table", "zaishouInfo"));
array.add(getJsonObject("yishouInfo", "已售房屋信息", "layui-icon-table", "yishouInfo"));
array.add(getJsonObject("zhangmuInfo", "已售账目信息", "layui-icon-table", "zhangmuInfo"));
array.add(getJsonObject("hetongInfo", "购买合同信息", "layui-icon-table", "hetongInfo"));
array.add(getJsonObject("userInfo", "用户信息", "layui-icon-table", "userInfo"));
array.add(getJsonObject("advertiserInfo", "公告信息", "layui-icon-table", "advertiserInfo"));
array.add(getJsonObject("accountAdminInfo", "个人信息", "layui-icon-user", "accountAdminInfo"));
tableObj.putOpt("list", array);
}
if (2 == level) {
JSONArray array = new JSONArray();
array.add(getJsonObject("xiaoquInfo", "小区信息", "layui-icon-table", "xiaoquInfo"));
array.add(getJsonObject("zaishouInfo", "在售房屋信息", "layui-icon-table", "zaishouInfo"));
array.add(getJsonObject("yishouInfo", "已售房屋信息", "layui-icon-table", "yishouInfo"));
array.add(getJsonObject("zhangmuInfo", "已售账目信息", "layui-icon-table", "zhangmuInfo"));
array.add(getJsonObject("hetongInfo", "购买合同信息", "layui-icon-table", "hetongInfo"));
array.add(getJsonObject("advertiserInfo", "公告信息", "layui-icon-table", "advertiserInfo"));
array.add(getJsonObject("accountUserInfo", "个人信息", "layui-icon-user", "accountUserInfo"));
tableObj.putOpt("list", array);
}
dataArray.add(tableObj);
dataArray.add(getJsonObject("zaishouInfoComment", "在售房屋评论", "layui-icon-group", "zaishouInfoComment"));
dataArray.add(getJsonObject("yishouInfoComment", "已售房屋评论", "layui-icon-group", "yishouInfoComment"));
dataArray.add(getJsonObject("hetongInfoComment", "购买合同评论", "layui-icon-group", "hetongInfoComment"));
dataArray.add(getJsonObject("updatePassword", "修改密码", "layui-icon-password", "updatePassword"));
dataArray.add(getJsonObject("login", "退出登录", "layui-icon-logout", "login"));
obj.putOpt("data", dataArray);
return obj.toString();
}
private JSONObject getJsonObject(String name, String title, String icon, String jump) {
JSONObject object = new JSONObject();
object.putOpt("name", name);
object.putOpt("title", title);
object.putOpt("icon", icon);
object.putOpt("jump", jump);
return object;
}
@GetMapping(value = "/getTotal", produces="application/json;charset=UTF-8")
public Result<Map<String, Integer>> getTotle() {
Map<String, Integer> resultMap = new HashMap<>();
resultMap.put("adminInfo", adminInfoService.findAll().size());
resultMap.put("xiaoquInfo", xiaoquInfoService.findAll().size());
resultMap.put("zhangmuInfo", zhangmuInfoService.findAll().size());
resultMap.put("userInfo", userInfoService.findAll().size());
resultMap.put("advertiserInfo", advertiserInfoService.findAll().size());
return Result.success(resultMap);
}
}