saas建站工具,网站提供什么服务,太原网站建设方案服务,网站和自媒体都可以做末尾获取源码 开发语言#xff1a;Java Java开发工具#xff1a;JDK1.8 后端框架#xff1a;SSM 前端#xff1a;采用JSP技术开发 数据库#xff1a;MySQL5.7和Navicat管理工具结合 服务器#xff1a;Tomcat8.5 开发软件#xff1a;IDEA / Eclipse 是否Maven项目#x… 末尾获取源码 开发语言Java Java开发工具JDK1.8 后端框架SSM 前端采用JSP技术开发 数据库MySQL5.7和Navicat管理工具结合 服务器Tomcat8.5 开发软件IDEA / Eclipse 是否Maven项目是 目录
一、项目简介
二、数据库设计
数据库概念设计
数据库物理设计
房屋出租信息表
房东信息表
房屋类型信息表
房屋信息表
合同信息表
新闻资讯信息表
管理员信息表
用户信息表
三、系统项目截图
房东管理
用户管理
合同管理
房屋评论管理
房屋管理
房屋出租管理
房屋管理
合同管理
客栈信息
新闻资讯
房屋信息
租房信息
四、核心代码
4.1登录相关
4.2文件上传
4.3封装 一、项目简介
互联网发展至今无论是其理论还是技术都已经成熟而且它广泛参与在社会中的方方面面。它让信息都可以通过网络传播搭配信息管理工具可以很好地为人们提供服务。所以各行业尤其是规模较大的企业和学校等都开始借助互联网和软件工具管理信息传播信息共享信息等等以此可以增强自身实力提高在同行业当中的竞争能力并从各种激烈的竞争中获取发展的机会。针对房屋出租信息管理混乱出错率高信息安全性差劳动强度大费时费力等问题经过分析和考虑在目前的情况下可以引进一款共享客栈管理系统这样的现代化管理工具这个工具就是解决上述问题的最好的解决方案。它不仅可以实时完成信息处理还缩短房屋出租信息管理流程使其系统化和规范化。同时还可以减少工作量节约房屋出租信息管理需要的人力和资金。所以共享客栈管理系统是信息管理环节中不可缺少的工具它对管理者来说非常重要。 二、数据库设计
开发一个系统也需要提前设计数据库。这里的数据库是相关数据的集合存储在一起的这些数据也是按照一定的组织方式进行的。目前数据库能够服务于多种应用程序则是源于它存储方式最佳具备数据冗余率低的优势。虽然数据库为程序提供信息存储服务但它与程序之间也可以保持较高的独立性。总而言之数据库经历了很长一段时间的发展从最初的不为人知到现在的人尽皆知其相关技术也越发成熟同时也拥有着坚实的理论基础。
数据库概念设计
这部分内容需要借助数据库关系图来完成也需要使用专门绘制数据库关系图的工具比如Visio工具就可以设计E-R图数据库关系图。设计数据库也需要按照设计的流程进行首先还是要根据需求完成实体的确定分析实体具有的特征还有对实体间的关联关系进行确定。最后才是使用E-R模型的表示方法绘制本系统的E-R图。不管是使用亿图软件还是Visio工具对于E-R模型的表示符号都一样通常矩形代表实体实体间存在的关系用菱形符号表示实体的属性也就是实体的特征用符号椭圆表示。最后使用直线将矩形菱形和椭圆等符号连接起来。接下来就开始对本系统的E-R图进行绘制。
1下图是合同实体和其具备的属性。 2下图是房东实体和其具备的属性。 3下图是房屋实体和其具备的属性。 4下图是用户实体和其具备的属性。 5下图为上述各实体间相互之间的关系。 数据库物理设计
本数据库是关系型数据库因此对二维表的结构设计也比较关键。毕竟二维表格模型就是关系型数据库中的关系模型。而一些常用的关系模型中的概念也需要了解才可以对关系模型进行设计。下面就简单介绍关系元组属性域关键字等常用概念的含义。
关系关系就是数据库中的一张数据表每张数据表都有命名也就是每个关系也有名字那就是数据表名
元组元组就是数据表中的一行记录
属性属性就是数据表中的字段也就是数据表中的一列
域域就是对数据表中属性的取值进行限定
关键字关键字就是数据表中的主键
在了解了表结构设计的常用概念后接下来就需要使用前面绘制的E-R模型完成表结构的设计工作并在数据库中创建数据表并为各个数据表进行命名。以下就对设计的结果通过表格形式进行展示。
房屋出租信息表 字段 类型 空 默认 注释 id (主键) int(11) 否 主键 fw_types tinyint(255) 是 NULL 房屋名称 fd_types tinyint(255) 是 NULL 房东姓名 yh_types tinyint(255) 是 NULL 用户姓名 create_time timestamp 是 NULL 租房时间 finish_time timestamp 是 NULL 结束租房时间
房东信息表 字段 类型 空 默认 注释 id (主键) int(11) 否 id name varchar(255) 是 NULL 姓名 account varchar(255) 是 NULL 账号 password varchar(255) 是 NULL 密码 img_photo varchar(255) 是 NULL 头像 role varchar(255) 是 NULL 身份
房屋类型信息表 字段 类型 空 默认 注释 id (主键) int(11) 否 主键 fwname varchar(255) 是 NULL 房屋类型
房屋信息表 字段 类型 空 默认 注释 id (主键) int(11) 否 主键 fwname varchar(255) 是 NULL 房屋名称 fwlx_types tinyint(4) 是 NULL 房屋类型 money decimal(10,0) 是 NULL 一个月的价格 img_photo varchar(255) 是 NULL 房屋图片 address varchar(255) 是 NULL 地址 fwstate_types tinyint(255) 是 NULL 房屋状态 fd_types tinyint(255) 是 NULL 所属房东 phone varchar(255) 是 NULL 房东联系电话 notice_content varchar(255) 是 NULL 具体信息
合同信息表 字段 类型 空 默认 注释 id (主键) int(11) 否 主键 htname varchar(255) 是 NULL 合同名称 prove_file varchar(255) 是 NULL 附件信息 fd_types tinyint(255) 是 NULL 甲方名称 yh_types tinyint(255) 是 NULL 乙方名称 create_time datetime 是 NULL 签约时间
新闻资讯信息表 字段 类型 空 默认 注释 id (主键) bigint(20) 否 主键 addtime timestamp 否 CURRENT_TIMESTAMP 创建时间 title varchar(200) 否 标题 img_photo varchar(200) 否 图片 notice_content longtext 否 内容
管理员信息表 字段 类型 空 默认 注释 id (主键) int(20) 否 主键 username varchar(100) 否 用户名 password varchar(100) 否 密码 role varchar(100) 否 管理员 角色 addtime timestamp 否 CURRENT_TIMESTAMP 新增时间
用户信息表 字段 类型 空 默认 注释 id (主键) int(11) 否 id name varchar(255) 是 NULL 姓名 account varchar(255) 是 NULL 账号 password varchar(255) 是 NULL 密码 img_photo varchar(255) 是 NULL 头像 role varchar(255) 是 NULL 身份 三、系统项目截图
房东管理
管理员进入指定功能操作区之后可以管理房东。其页面见下图。管理员可以增删改查房东资料。 用户管理
管理员进入指定功能操作区之后可以管理用户。其页面见下图。管理员增删改查用户资料。 合同管理
管理员进入指定功能操作区之后可以管理合同。其页面见下图。管理员在本页面可以增删改查合同信息可以实现合同文件下载功能。 房屋评论管理
管理员进入指定功能操作区之后可以管理房屋评论信息。其页面见下图。房屋评论信息是用户发布的信息管理员查看评论内容可以回复用户评论。 房屋管理
管理员进入指定功能操作区之后可以管理房屋信息。其页面见下图。管理员增删改查房屋信息查看房屋状态房屋所属房东以及房东的联系电话。 房屋出租管理
房东进入指定功能操作区之后可以管理房屋出租信息。其页面见下图。房东对已经出租的房屋进行租房取消或者续租操作。 房屋管理
房东进入指定功能操作区之后可以管理房屋。其页面见下图。房东管理房屋信息包括房屋信息登记修改查询等操作。 合同管理
房东进入指定功能操作区之后可以管理合同。其页面见下图。房东登记合同信息时需要上传合同文件房东在本页面内对已有的合同信息进行维护。 客栈信息
用户进入指定功能操作区之后可以查看客栈信息。其页面见下图。用户查看房屋介绍可以选择立即租房也能评价本页面显示的房屋。 新闻资讯
用户进入指定功能操作区之后可以查看新闻资讯。其页面见下图。用户查看各种新闻的标题以及详细内容。 房屋信息
用户进入个人后台在房屋信息页面也能进行租房。其页面见下图。用户点击租房按钮设置租房日期即可成功租房。 租房信息
用户进入个人后台在租房信息页面可以取消租房。其页面见下图。用户查询租房信息可以取消租房。 四、核心代码
4.1登录相关 package com.controller;import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;/*** 登录相关*/
RequestMapping(users)
RestController
public class UserController{Autowiredprivate UserService userService;Autowiredprivate TokenService tokenService;/*** 登录*/IgnoreAuthPostMapping(value /login)public R login(String username, String password, String captcha, HttpServletRequest request) {UserEntity user userService.selectOne(new EntityWrapperUserEntity().eq(username, username));if(usernull || !user.getPassword().equals(password)) {return R.error(账号或密码不正确);}String token tokenService.generateToken(user.getId(),username, users, user.getRole());return R.ok().put(token, token);}/*** 注册*/IgnoreAuthPostMapping(value /register)public R register(RequestBody UserEntity user){
// ValidatorUtils.validateEntity(user);if(userService.selectOne(new EntityWrapperUserEntity().eq(username, user.getUsername())) !null) {return R.error(用户已存在);}userService.insert(user);return R.ok();}/*** 退出*/GetMapping(value logout)public R logout(HttpServletRequest request) {request.getSession().invalidate();return R.ok(退出成功);}/*** 密码重置*/IgnoreAuthRequestMapping(value /resetPass)public R resetPass(String username, HttpServletRequest request){UserEntity user userService.selectOne(new EntityWrapperUserEntity().eq(username, username));if(usernull) {return R.error(账号不存在);}user.setPassword(123456);userService.update(user,null);return R.ok(密码已重置为123456);}/*** 列表*/RequestMapping(/page)public R page(RequestParam MapString, Object params,UserEntity user){EntityWrapperUserEntity ew new EntityWrapperUserEntity();PageUtils page userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));return R.ok().put(data, page);}/*** 列表*/RequestMapping(/list)public R list( UserEntity user){EntityWrapperUserEntity ew new EntityWrapperUserEntity();ew.allEq(MPUtil.allEQMapPre( user, user)); return R.ok().put(data, userService.selectListView(ew));}/*** 信息*/RequestMapping(/info/{id})public R info(PathVariable(id) String id){UserEntity user userService.selectById(id);return R.ok().put(data, user);}/*** 获取用户的session用户信息*/RequestMapping(/session)public R getCurrUser(HttpServletRequest request){Long id (Long)request.getSession().getAttribute(userId);UserEntity user userService.selectById(id);return R.ok().put(data, user);}/*** 保存*/PostMapping(/save)public R save(RequestBody UserEntity user){
// ValidatorUtils.validateEntity(user);if(userService.selectOne(new EntityWrapperUserEntity().eq(username, user.getUsername())) !null) {return R.error(用户已存在);}userService.insert(user);return R.ok();}/*** 修改*/RequestMapping(/update)public R update(RequestBody UserEntity user){
// ValidatorUtils.validateEntity(user);userService.updateById(user);//全部更新return R.ok();}/*** 删除*/RequestMapping(/delete)public R delete(RequestBody Long[] ids){userService.deleteBatchIds(Arrays.asList(ids));return R.ok();}
}4.2文件上传
package com.controller;import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;/*** 上传文件映射表*/
RestController
RequestMapping(file)
SuppressWarnings({unchecked,rawtypes})
public class FileController{Autowiredprivate ConfigService configService;/*** 上传文件*/RequestMapping(/upload)public R upload(RequestParam(file) MultipartFile file,String type) throws Exception {if (file.isEmpty()) {throw new EIException(上传文件不能为空);}String fileExt file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(.)1);File path new File(ResourceUtils.getURL(classpath:static).getPath());if(!path.exists()) {path new File();}File upload new File(path.getAbsolutePath(),/upload/);if(!upload.exists()) {upload.mkdirs();}String fileName new Date().getTime().fileExt;File dest new File(upload.getAbsolutePath()/fileName);file.transferTo(dest);FileUtils.copyFile(dest, new File(C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload/fileName));if(StringUtils.isNotBlank(type) type.equals(1)) {ConfigEntity configEntity configService.selectOne(new EntityWrapperConfigEntity().eq(name, faceFile));if(configEntitynull) {configEntity new ConfigEntity();configEntity.setName(faceFile);configEntity.setValue(fileName);} else {configEntity.setValue(fileName);}configService.insertOrUpdate(configEntity);}return R.ok().put(file, fileName);}/*** 下载文件*/IgnoreAuthRequestMapping(/download)public ResponseEntitybyte[] download(RequestParam String fileName) {try {File path new File(ResourceUtils.getURL(classpath:static).getPath());if(!path.exists()) {path new File();}File upload new File(path.getAbsolutePath(),/upload/);if(!upload.exists()) {upload.mkdirs();}File file new File(upload.getAbsolutePath()/fileName);if(file.exists()){/*if(!fileService.canRead(file, SessionManager.getSessionUser())){getResponse().sendError(403);}*/HttpHeaders headers new HttpHeaders();headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); headers.setContentDispositionFormData(attachment, fileName); return new ResponseEntitybyte[](FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);}} catch (IOException e) {e.printStackTrace();}return new ResponseEntitybyte[](HttpStatus.INTERNAL_SERVER_ERROR);}}4.3封装
package com.utils;import java.util.HashMap;
import java.util.Map;/*** 返回数据*/
public class R extends HashMapString, Object {private static final long serialVersionUID 1L;public R() {put(code, 0);}public static R error() {return error(500, 未知异常请联系管理员);}public static R error(String msg) {return error(500, msg);}public static R error(int code, String msg) {R r new R();r.put(code, code);r.put(msg, msg);return r;}public static R ok(String msg) {R r new R();r.put(msg, msg);return r;}public static R ok(MapString, Object map) {R r new R();r.putAll(map);return r;}public static R ok() {return new R();}public R put(String key, Object value) {super.put(key, value);return this;}
}