项目介绍
园区招商管理系统。共分为三种角色,超级管理员、企业人员、高级用户。
超级管理员角色具有功能:
系统设置-用户管理、页面管理、角色管理;
招商管理-招商列表;
公司管理-公司列表、我的申请;
投诉管理-投诉列表、我的投诉;
合同管理-合同列表;
项目管理-项目列表、我的项目;
新闻管理-新闻列表;
环境需要
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.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 8.0版本;
技术栈
1. 后端:SpringBoot;
2. 前端:html+thymeleaf;
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 将项目中application.properties配置文件中的数据库配置改为自己的配置
3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
4. 运行项目,输入localhost:8081 登录
5. 管理员账户:admin 密码:123456
6. 企业人员和高级用户菜单可通过管理员进行分配;
用户管理控制层:
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@Autowired
private CarService carservice;
@Autowired
private RoomService roomservice;
@RequestMapping("/welcome")
public String welcome(HttpServletRequest request,ModelMap model){
return "login";
}
/**
* 用户登录
* @param request
* @return
*/
@RequestMapping("/login")
public String login(HttpServletRequest request,ModelMap model){
String username = request.getParameter("username");
String password = request.getParameter("password");
if(StringUtils.isEmpty(username)||StringUtils.isEmpty(password)){
return "login";
}
User user = userService.getUserByUsername(username);
HttpSession session = request.getSession();
session.setAttribute("user", user);
if(user.getPassword().equals(password)){
if(user.getRole().equals(0)){
return "adminindex";
}else {
return "userindex";
}
}else{
model.put("msg", "用户名或者密码错误!");
return "login";
}
}
/**
* 跳转用户注册页面
*/
@RequestMapping(value="/getregister")
public String getRegister(){
return "register";
}
/**
* 用户注册
* @param user
* @param modelMap
* @return
*/
@RequestMapping("/register")
public String register(ModelMap modelMap,HttpServletRequest request){
try{
String username = request.getParameter("username");
String password = request.getParameter("password");
String realname = request.getParameter("realname");
String idCardNum = request.getParameter("idCardNum");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
String settleTime = request.getParameter("settleTime");
Date date = sdf.parse(settleTime);
String sex = request.getParameter("sex");
String address = request.getParameter("address");
User user = new User();
user.setUserName(username);
user.setPassword(password);
user.setRealName(realname);
user.setIdCardNum(idCardNum);
user.setSettleTime(date);
user.setSex(sex);
user.setAddress(address);
userService.addUser(user);
modelMap.put("msg", "注册成功,请登录!");
return "login";
}catch(Exception e){
modelMap.put("msg", "注册失败!");
e.printStackTrace();
return "register";
}
}
/**
* 跳转更新用户页面
*/
@RequestMapping(value="/getupdateUser")
public String getupdateUser(HttpServletRequest request,User user,ModelMap model){
HttpSession session = request.getSession();
user = (User) session.getAttribute("user");
int id = user.getId();
user = userService.getUserById(id);
model.put("user", user);
return "updateUser";
}
/**
* 更新用户
* @param user
* @return
* @throws ParseException
*/
@RequestMapping("/updateUser")
public String updateUser(HttpServletRequest request,User user,ModelMap model,
HttpSession session) throws ParseException{
user = (User) session.getAttribute("user");
int id = user.getId();
String userName = request.getParameter("username");
String companyName = request.getParameter("companyname");
String phone = request.getParameter("phone");
String email = request.getParameter("email");
/*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss E");
String outmigrationTime = request.getParameter("outmigrationTime");
Date date = sdf.parse(outmigrationTime);*/
String relationship = request.getParameter("relationship");
user.setId(id);
user.setUserName(userName);
user.setCompanyName(companyName);
user.setPhone(phone);
user.setEmail(email);
/*user.setOutmigrationTime(date);*/
user.setRelationship(relationship);
userService.updateUser(user);
//人
user = userService.getUserByUsername(userName);
model.put("user", user);
//车
Car car = carservice.getCarById(id);
model.put("car", car);
//房
Room room = roomservice.getRoomByUserId(id);
model.put("room", room);
return "userinfo";
}
/**
* 跳转修改密码页面
*/
@RequestMapping(value="/getupdatePassword")
public String getUpdatePassword(HttpServletRequest request,User user,
ModelMap model){
HttpSession session = request.getSession();
user = (User) session.getAttribute("user");
String username = user.getUserName();
model.put("username", username);
return "pass";
}
/**
* 更新密码
* @param user
* @return
*/
@RequestMapping("/updatePassword")
public String updatePassword(HttpServletRequest request,ModelMap modelMap){
HttpSession session = request.getSession();
User user1=(User) session.getAttribute("user");
String username = user1.getUserName();
String mpass = request.getParameter("mpass");
String newpass = request.getParameter("newpass");
User user2 = userService.getUserByUsername(username);
if (user2.getPassword().equals(mpass)) {
User user3 = new User();
user3.setUserName(username);
user3.setPassword(newpass);
userService.updatePassword(user3);
modelMap.put("msg", "更新成功!");
//人
User user = userService.getUserByUsername(username);
modelMap.put("user", user);
//车
Car car = carservice.getCarById(user2.getId());
modelMap.put("car", car);
//房
Room room = roomservice.getRoomByUserId(user2.getId());
modelMap.put("room", room);
return "user";
}else{
modelMap.put("msg", "原密码输入错误!");
return "pass";
}
}
/**
* 分页查询用户列表(未做)
* @param page
* @return
*/
@RequestMapping("/getAllUserByPage")
public String getAllUserByPage(HttpServletRequest request,ModelMap model){
List<User> userList = userService.getAllUsers();
model.put("userList", userList);
for (User user : userList) {
Room room = roomservice.getRoomByUserId(user.getId());
if(room==null) {
continue;
}
user.setRelationship(room.getBuildingNum()+"号楼"+room.getUnitNum()+"单元"+room.getRoomNum());
}
return "adminUserAll";
}
/**
* 获取单个用户信息
* @param request
* @return
*/
@RequestMapping("/getUserById")
public String getUserById(HttpServletRequest request,ModelMap model,HttpSession session){
User user1 = (User) session.getAttribute("user");
int id = user1.getId();
User user = userService.getUserById(id);
model.addAttribute("user", user);
return "user";
}
/**
* 首页
* @param request
* @return
*/
@RequestMapping(value="/getWelcome")
public String Welcome(HttpServletRequest request){
return "user";
}
}
设备信息管理控制层:
@Controller
@RequestMapping("/equipment")
public class EquipmentController {
@Autowired
private EquipmentService equipmentService;
/**
* 查询所有设备信息
* @param request
* @param model
* @return
*/
@RequestMapping(value="/allequipment")
public String getAllEquipment(HttpServletRequest request,ModelMap model){
List<Equipment> equipments = equipmentService.getAllEquipmentByPage(0,10);
model.put("equipments", equipments);
return "adminEquipment";
}
/**
* 跳转--添加/修改
* @param request
* @return
*/
@RequestMapping(value="/getaddEquipment")
public String getAddEquipment(HttpServletRequest request){
return "adminEquipment";
}
/**
* 添加设备信息
* @param request
* @param model
* @param equipment
* @return
* @throws ParseException
*/
@RequestMapping(value="/addEquipment")
public String getAddEquipment(HttpServletRequest request,ModelMap model) throws ParseException{
String equipmentName = request.getParameter("equipmentName");
String location = request.getParameter("location");
String serialNumber = request.getParameter("serialNumber");
String type = request.getParameter("type");
String brand = request.getParameter("brand");
String status = request.getParameter("status");
String condition = request.getParameter("condition");
//价格
BigDecimal price = new BigDecimal(request.getParameter("price"));
BigDecimal bigDecimal = price.setScale(2, BigDecimal.ROUND_DOWN);
//时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
String boughtDate = request.getParameter("boughtDate");
Date date = sdf.parse(boughtDate);
Date date2 = new Date(System.currentTimeMillis());
Equipment equipment = new Equipment();
equipment.setEquipmentName(equipmentName);
equipment.setLocation(location);
equipment.setSerialNumber(serialNumber);
equipment.setBoughtDate(date);
equipment.setType(type);
equipment.setBrand(brand);
equipment.setStatus(status);
equipment.setConditiona(condition);
equipment.setPrice(bigDecimal);
equipment.setCreateTime(date2);
equipmentService.addEquipment(equipment);
System.out.println(equipment.toString());
List<Equipment> equipments = equipmentService.getAllEquipmentByPage(0,10);
model.put("equipments", equipments);
return "adminEquipment";
}
/**
* 跳转--修改
* @param request
* @return
*/
@RequestMapping(value="/getupdateEquipment")
public String getUpEquipment(HttpServletRequest request){
return "adminEquipmentUpdate";
}
/**
* 修改设备信息
* @param request
* @param model
* @return
*/
@RequestMapping(value="/updateEquipment")
public String getupdateEquipment(HttpServletRequest request,ModelMap model){
int id = Integer.parseInt(request.getParameter("id"));
String location = request.getParameter("location");
String status = request.getParameter("status");
String conditiona = request.getParameter("conditiona");
Equipment equipment = new Equipment();
equipment.setId(id);
equipment.setLocation(location);
equipment.setStatus(status);
equipment.setConditiona(conditiona);
equipmentService.updateEquipment(equipment);
List<Equipment> equipmentlist = equipmentService.getAllEquipmentByPage(0,10);
model.put("equipmentlist", equipmentlist);
return "adminEquipment";
}
}
投诉建议控制层:
@Controller
@RequestMapping("/complain")
public class ComplainController {
@Autowired
private ComplainService complainService;
/**
* 查询所有投诉--admin
* @param model
* @return
*/
@RequestMapping(value="/allComplain")
public String getAllCompalinByPage(ModelMap model){
List<Complain> complains = complainService.getComplainByStatus("等待处理");
if(complains != null && complains.size()>0){
model.put("complains", complains);
return "adminComplain";
}else{
String msg = "无投诉内容!";
model.put("msg", msg);
return "adminComplain";
}
}
/**
* 根据id查询--user
* @return
*/
@RequestMapping(value="/complainById")
public String getComplainById(HttpServletRequest request,HttpSession session,
ModelMap model){
User user = (User) session.getAttribute("user");
Map<String, Object> map = new HashMap<>();
map.put("userId", user.getId());
map.put("status", "等待处理");
List<Complain> complainslist1 = complainService.getComplainByUser(map);
if(complainslist1 != null && complainslist1.size()>0){
model.put("complainslist1", complainslist1);
}else{
String msg = "暂无投诉内容!";
model.put("msg", msg);
}
return "userComplain";
}
/**
* 跳转--添加/修改
* @return
*/
@RequestMapping(value="/getaddComplain")
public String getaddComplain(HttpServletRequest request,HttpSession session,ModelMap model){
User user = (User) session.getAttribute("user");
if(user.getRole().equals(0)){
return "adminComplain";
}else{
return "userComplain";
}
}
/**
* 添加投诉--user
* @param request
* @param model
* @return
*/
@RequestMapping(value="/addComplain")
public String addComplain(HttpServletRequest request,ModelMap model,
HttpSession session,Complain complain){
Date createTime = new Date(System.currentTimeMillis());
int userId = Integer.parseInt(request.getParameter("userId"));
String realName = request.getParameter("realName");
String phone = request.getParameter("phone");
String content= request.getParameter("content");
complain.setCreateTime(createTime);
complain.setUserId(userId);
complain.setRealName(realName);
complain.setPhone(phone);
complain.setContent(content);
complain.setStatus("等待处理");
complain.setAgreement(0);
complainService.addComplain(complain);
User user = (User) session.getAttribute("user");
Map<String, Object> map0 = new HashMap<>();
map0.put("userId", user.getId());
map0.put("status", "已处理");
List<Complain> complainslist0 = complainService.getComplainByUser(map0);
if(complainslist0 != null && complainslist0.size()>0){
model.put("complainslist0", complainslist0);
}
Map<String, Object> map1 = new HashMap<>();
map1.put("userId", user.getId());
map1.put("status", "等待处理");
List<Complain> complainslist1 = complainService.getComplainByUser(map1);
if(complainslist1 != null && complainslist1.size()>0){
model.put("complainslist1", complainslist1);
}
return "userComplain";
}
/**
* 更新投诉--admin
* @param request
* @param complain
* @return
*/
@RequestMapping(value="/updateComplain")
public String updateComplain(HttpServletRequest request,
Complain complain,ModelMap model){
Date date = new Date(System.currentTimeMillis());
int id = Integer.parseInt(request.getParameter("id"));
String operaterName = request.getParameter("operaterName");
int operaterUserId = Integer.parseInt(request.getParameter("operaterUserId"));
//是否接受 0--不接受 1--接受
String comments = request.getParameter("comments");
complain.setId(id);
complain.setDealTime(date);
complain.setOperaterName(operaterName);
complain.setOperaterUserId(operaterUserId);
complain.setAgreement(1);
complain.setComments(comments);
complain.setStatus("已处理");
complainService.updateComplain(complain);
// List<Complain> complains = complainService.getAllCompalinByPage(0, 10);
List<Complain> complainlist = complainService.getComplainByStatus("已处理");
model.put("complainlist", complainlist);
return "adminComplain";
}
}