前言介绍
旅游资源网站的主要使用者分为管理员和用户,实现功能包括管理员:首页、个人中心、用户管理、景点信息管理、购票信息管理、酒店信息管理、客房类型管理、客房信息管理、客房预订管理、交流论坛、系统管理,用户:首页、个人中心、购票信息管理、客房预订管理、我的收藏管理,前台首页;首页、景点信息、酒店信息、客房信息、交流论坛、红色文化、个人中心、后台管理、客服等功能。由于本网站的功能模块设计比较全面,所以使得整个旅游资源网站信息管理的过程得以实现。
本系统的使用可以实现旅游资源网站管理的信息化,可以方便管理员进行更加方便快捷的管理,可以提高管理人员的工作效率。
系统功能分析
本旅游资源网站主要包括二大功能模块,即用户功能模块和管理员功能模块。
(1)管理员模块:系统中的核心用户是管理员,管理员登录后,通过管理员功能来管理后台系统。主要功能有:首页、个人中心、用户管理、景点信息管理、购票信息管理、酒店信息管理、客房类型管理、客房信息管理、客房预订管理、交流论坛、系统管理等功能。管理员用例图如图
用户:首页、个人中心、购票信息管理、客房预订管理、我的收藏管理等功能,用户如图
本旅游资源网站结构图如图
系统详细设计
前台首页功能模块
旅游资源网站 ,在系统首页可以查看首页、景点信息、酒店信息、客房信息、交流论坛、红色文化、个人中心、后台管理、客服等内容,如图
用户登录、用户注册,在注册页面可以填写用户名、密码、姓名、手机、身份证等信息进行注册、登录,如图
用户登录
景点信息,在景点信息页面通过填写景点名称、景点图片、景点等级、景点地址、门票价格、开放时间、购票须知等信息进行购票,如图5-3所示。在酒店信息页面通过填写酒店名称、图片、星级、酒店类型、酒店地址、联系电话等信息进行点我收藏操作,如图
景点信息界面图
酒店信息界面图
客房信息
客房信息界面图
红色文化
管理员功能模块
管理员登录,通过填写用户名、密码、角色进行登录,如图
管理员登录进入旅游资源网站可以查看首页、个人中心、用户管理、景点信息管理、购票信息管理、酒店信息管理、客房类型管理、客房信息管理、客房预订管理、交流论坛、系统管理等信息。
用户管理,在用户管理页面中可以通过填写用户名、密码、姓名、性别、头像、手机、身份证等内容进行修改、删除,如图
还可以根据需要对景点信息管理进行详情,修改或删除等详细操作,如图
购票信息管理
酒店信息管理,在酒店信息管理页面中可以填写酒店名称、图片、星级、酒店类型、酒店地址、联系电话等信息,并可根据需要对已有酒店信息管理进行修改或删除等操作,如图
客房类型管理,在客房类型管理页面中可以填写客房类型等信息,并可根据需要对已有客房类型管理进行修改或删除等详细操作,如图
客房信息管理,在客房信息管理页面中可以查看客房名称、客房类型、客房图片、客房设施、客房价格、客房状态、酒店名称、酒店类型、酒店地址等内容,并且根据需要对已有客房信息管理进行详情,修改或删除等详细操作,如图
轮播图;该页面为轮播图管理界面。管理员可以在此页面进行首页轮播图的管理,通过新建操作可在轮播图中加入新的图片,还可以对以上传的图片进行修改操作,以及图片的删除操作,如图
客房预订管理,在客房预订管理页面中可以查看订单编号、客房名称、客房类型、客房状态、酒店名称、客房价格、预订天数、总价格、下单时间、入住时间、用户名、姓名、身份证、是否支付、审核回复、审核状态、审核等内容,并且根据需要对已有客房预订管理进行详情,修改或删除等详细操作,如图
用户功能模块
用户登录进入旅游资源网站可以查看首页、个人中心、购票信息管理、客房预订管理、我的收藏管理等内容
个人信息,在个人信息页面中通过填写用户名、密码、姓名、性别、头像、手机、身份证等信息,还可以根据需要对个人信息进行修改、删除如图
客房预订管理,在客房预订管理页面中可以查看订单编号、客房名称、客房类型、客房状态、酒店名称、客房价格、预订天数、总价格、下单时间、入住时间、用户名、姓名、身份证、是否支付、审核回复、审核状态、审核等信息内容,并且根据需要对已有客房预订管理进行修改或删除等其他详细操作,如图
部分核心代码:
controller层
/**
* 购票信息
* 后端接口
* @author
* @date 2021-03-03 13:33:00
*/
@RestController
@RequestMapping("/goupiaoxinxi")
public class GoupiaoxinxiController {
@Autowired
private GoupiaoxinxiService goupiaoxinxiService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Mapparams,GoupiaoxinxiEntity goupiaoxinxi, HttpServletRequest request){ ,>
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("yonghu")) {
goupiaoxinxi.setYonghuming((String)request.getSession().getAttribute("username"));
}
EntityWrapperew = new EntityWrapper ();
PageUtils page = goupiaoxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, goupiaoxinxi), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Mapparams,GoupiaoxinxiEntity goupiaoxinxi, HttpServletRequest request){ ,>
EntityWrapperew = new EntityWrapper ();
PageUtils page = goupiaoxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, goupiaoxinxi), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( GoupiaoxinxiEntity goupiaoxinxi){
EntityWrapperew = new EntityWrapper ();
ew.allEq(MPUtil.allEQMapPre( goupiaoxinxi, "goupiaoxinxi"));
return R.ok().put("data", goupiaoxinxiService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(GoupiaoxinxiEntity goupiaoxinxi){
EntityWrapper< GoupiaoxinxiEntity> ew = new EntityWrapper< GoupiaoxinxiEntity>();
ew.allEq(MPUtil.allEQMapPre( goupiaoxinxi, "goupiaoxinxi"));
GoupiaoxinxiView goupiaoxinxiView = goupiaoxinxiService.selectView(ew);
return R.ok("查询购票信息成功").put("data", goupiaoxinxiView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
GoupiaoxinxiEntity goupiaoxinxi = goupiaoxinxiService.selectById(id);
return R.ok().put("data", goupiaoxinxi);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
GoupiaoxinxiEntity goupiaoxinxi = goupiaoxinxiService.selectById(id);
return R.ok().put("data", goupiaoxinxi);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody GoupiaoxinxiEntity goupiaoxinxi, HttpServletRequest request){
goupiaoxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(goupiaoxinxi);
goupiaoxinxiService.insert(goupiaoxinxi);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody GoupiaoxinxiEntity goupiaoxinxi, HttpServletRequest request){
goupiaoxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(goupiaoxinxi);
goupiaoxinxiService.insert(goupiaoxinxi);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody GoupiaoxinxiEntity goupiaoxinxi, HttpServletRequest request){
//ValidatorUtils.validateEntity(goupiaoxinxi);
goupiaoxinxiService.updateById(goupiaoxinxi);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
goupiaoxinxiService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Mapmap) { ,>
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapperwrapper = new EntityWrapper ();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("yonghu")) {
wrapper.eq("yonghuming", (String)request.getSession().getAttribute("username"));
}
int count = goupiaoxinxiService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
登陆拦截功能实现
/** * 权限(Token)验证 */@Componentpublic class AuthorizationInterceptor implements HandlerInterceptor { public static final String LOGIN_TOKEN_KEY = "Token"; @Autowired private TokenService tokenService; @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { //支持跨域请求 response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Credentials", "true"); response.setHeader("Access-Control-Allow-Headers", "x-requested-with,request-source,Token, Origin,imgType, Content-Type, cache-control,postman-token,Cookie, Accept,authorization"); response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin")); IgnoreAuth annotation; if (handler instanceof HandlerMethod) { annotation = ((HandlerMethod) handler).getMethodAnnotation(IgnoreAuth.class); } else { return true; } //从header中获取token String token = request.getHeader(LOGIN_TOKEN_KEY); /** * 不需要验证权限的方法直接放过 */ if(annotation!=null) { return true; } TokenEntity tokenEntity = null; if(StringUtils.isNotBlank(token)) { tokenEntity = tokenService.getTokenEntity(token); } if(tokenEntity != null) { request.getSession().setAttribute("userId", tokenEntity.getUserid()); request.getSession().setAttribute("role", tokenEntity.getRole()); request.getSession().setAttribute("tableName", tokenEntity.getTablename()); request.getSession().setAttribute("username", tokenEntity.getUsername()); return true; } PrintWriter writer = null; response.setCharacterEncoding("UTF-8"); response.setContentType("application/json; charset=utf-8"); try { writer = response.getWriter(); writer.print(JSONObject.toJSONString(R.error(401, "请先登录"))); } finally { if(writer != null){ writer.close(); } }// throw new EIException("请先登录", 401); return false; }}
文件上传功能
/** * 上传文件映射表 */@RestController@RequestMapping("file")@SuppressWarnings({"unchecked","rawtypes"})public class FileController{ @Autowired private ConfigService configService; /** * 上传文件 */ @RequestMapping("/upload") public R upload(@RequestParam("file") MultipartFile file, String type,HttpServletRequest request) throws Exception { if (file.isEmpty()) { throw new EIException("上传文件不能为空"); } String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1); String fileName = new Date().getTime()+"."+fileExt; File dest = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+fileName); file.transferTo(dest); if(StringUtils.isNotBlank(type) && type.equals("1")) { ConfigEntity configEntity = configService.selectOne(new EntityWrapper().eq("name", "faceFile")); if(configEntity==null) { configEntity = new ConfigEntity(); configEntity.setName("faceFile"); configEntity.setValue(fileName); } else { configEntity.setValue(fileName); } configService.insertOrUpdate(configEntity); } return R.ok().put("file", fileName); } /** * 下载文件 */ @IgnoreAuth @RequestMapping("/download") public void download(@RequestParam String fileName, HttpServletRequest request, HttpServletResponse response) { try { File file = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+fileName); if (file.exists()) { response.reset(); response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName+"\""); response.setHeader("Cache-Control", "no-cache"); response.setHeader("Access-Control-Allow-Credentials", "true"); response.setContentType("application/octet-stream; charset=UTF-8"); IOUtils.write(FileUtils.readFileToByteArray(file), response.getOutputStream()); } } catch (IOException e) { e.printStackTrace(); } } }
entity层代码
/** * 自定义填充处理器 */public class MyMetaObjectHandler extends MetaObjectHandler { @Override public void insertFill(MetaObject metaObject) { this.setFieldValByName("ctime", new Date(), metaObject); } @Override public boolean openUpdateFill() { return false; } @Override public void updateFill(MetaObject metaObject) { // 关闭更新填充、这里不执行 }}
Original: https://blog.51cto.com/u_15644450/5359477
Author: wx62845597d9404
Title: SpringMVC+Vue项目旅游资源网站
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/517578/
转载文章受原作者版权保护。转载请注明原作者出处!