时间:2023-08-16 16:36:01 | 来源:网站运营
时间:2023-08-16 16:36:01 来源:网站运营
基于Web的机票管理系统设计与实现(附源码下载地址):@文章目录名称 | 解释 |
---|---|
flyTicket-parent | 父工程,用于管理子项目(如:maven依赖版本) |
flyTicket-dao | 子项目,用于存放所有对数据库的操作文件 |
flyTicket-pojo | 子项目,用于存放所有Java实体类文件 |
flyTicket-manage-web | 子项目,用于存放后台系统页面文件、controller文件 |
flyTicket-manage-service | 子项目,用于后台系统业务逻辑实现 |
flyTicket-portal-web | 子项目,用于存放前台系统页面文件、controller文件 |
flyTicket-portal-service | 子项目,用于前台系统业务逻辑实现 |
@RequestMapping("addFlight") public Result addFlight(@RequestBody Flight flight ) { //设置日期格式 SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); // new Date()为获取当前系统时间 flight.setFlightId("F"+df.format(new Date())); try { flightManageService.addFlight(flight); return new Result(true,"添加成功"); } catch (Exception e) { e.printStackTrace(); return new Result(false,"添加失败"); }}
public PageResult search(int pageNum, int pageSize, String searchEntity) { PageHelper.startPage(pageNum,pageSize); List<Flight> flightsList=flightManageMapper.select(searchEntity); Page<Flight> page=(Page<Flight>) flightsList; return new PageResult(page.getTotal(), page.getResult()); }
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" ><mapper namespace="com.cafuc.mapper.IOrderManageMapper"> <delete id="delete" parameterType="String"> delete from `order` where order_id in <foreach collection="selectIds" item="ids" open="(" close=")" separator=","> #{ids} </foreach> </delete></mapper>
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" ><mapper namespace="com.cafuc.mapper.IUserManageMapper"> <select id="select" resultType="com.cafuc.pojo.User"> select DISTINCT * from `user` as u where u.user_name like concat('%',#{searchEntity},'%') </select></mapper>
package com.cafuc.controller;import javax.annotation.Resource;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;import com.cafuc.pojo.PageResult;import com.cafuc.pojo.Result;import com.cafuc.service.IDiscussManageService;import com.cafuc.service.IOrderManageService;@RestController@RequestMapping("discussManage")public class DiscussManageController { @Resource private IDiscussManageService discussManageService; @RequestMapping("search") public PageResult search(int pageNum ,int pageSize,String searchEntity){ System.out.println(pageNum+" "+pageSize+" "+searchEntity); PageResult pageResult=discussManageService.search(pageNum, pageSize, searchEntity); return pageResult; } @RequestMapping("deleteBySelectIds") public Result deleteBySelectIds(String []selectIds) { try { discussManageService.deleteBySelectIds(selectIds); return new Result(true,"删除成功"); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return new Result(false,"删除失败"); } }}
@RequestMapping("addContent") public void addContent(@RequestParam("file") MultipartFile file,HttpServletRequest request,HttpServletResponse response) throws IOException { String describe=""; String url=""; String picture=""; if(request.getParameter("describe")!=null) { describe=request.getParameter("describe"); } if(request.getParameter("url")!=null) { url=request.getParameter("url"); } // 判断文件是否为空,空则返回失败页面 if (!file.isEmpty()) { try { // 获取文件存储路径(绝对路径) String path = request.getServletContext().getRealPath("/WEB-INF/file"); // 获取原文件名 String fileName = file.getOriginalFilename(); // 创建文件实例 File filePath = new File(path, fileName); // 如果文件目录不存在,创建目录 if (!filePath.getParentFile().exists()) { filePath.getParentFile().mkdirs(); System.out.println("创建目录" + filePath); } picture=filePath+""; // 写入文件 file.transferTo(filePath); Content content=new Content(); //设置日期格式 SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); // new Date()为获取当前系统时间 content.setContentId("C"+df.format(new Date())); content.setDescribe(describe); content.setPicture(picture); content.setUrl(url); contentManageServiceImpl.addContent(content); response.sendRedirect(request.getContextPath()+"/admin/list_content.html"); } catch (Exception e) { e.printStackTrace(); response.sendRedirect(request.getContextPath()+"/admin/add_content.html"); } } else { response.sendRedirect(request.getContextPath()+"/admin/add_content.html"); } }
//初始化$scope.adminEntity={};$scope.init=function () { console.log($.cookie('key')); adminManageService.init($.cookie('key')).success(function (res) { console.log(res) $scope.adminEntity=res; });}
@RequestMapping("editAdmin") public Result editAdmin(@RequestBody AdminUser adminUser){ try { adminManageServiceImpl.editAdmin(adminUser); redisTemplate.boundValueOps(adminUser.getUser()).set(adminUser); return new Result(true, "修改成功"); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return new Result(false, "修改失败"); } }
app.controller('portalLoginManageController',function($scope,$controller,portalLoginManageService){ $controller('baseController',{$scope:$scope}); //初始化 $scope.userEntity={userName:null,userPwd:null}; $scope.login=function(){ if($scope.userEntity.userName==null || $scope.userEntity.userName.trim()==""){ alert("用户名为空"); } else{ if($scope.userEntity.userPwd==null || $scope.userEntity.userPwd.trim()==""){ alert("密码为空"); } else{ portalLoginManageService.login($scope.userEntity).success(function(res){ if(res.result==false){ alert(res.message) } else{ window.location.href="index.html#?key="+$scope.userEntity.userName; } }); } }; }});
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" ><mapper namespace="com.cafuc.mapper.IPortalManageMapper"> <select id="select" resultType="com.cafuc.pojo.Flight"> select * from flight as f <where> <if test="flightStartTime1 !=null and flightStartTime1 !=''"> and f.flight_start_time like concat('%',#{flightStartTime1},'%') </if> <if test="flightStartPlace !=null and flightStartPlace !=''"> and f.flight_start_place like concat('%',#{flightStartPlace},'%') </if> <if test="flightEndPlace !=null and flightEndPlace !=''"> and f.flight_end_place like concat('%',#{flightEndPlace},'%') </if> </where> </select></mapper>
//保留n位小数 $scope.weishu=function(price,n){ return new Number(price).toFixed(n); } //下拉详情 $scope.lists=function(flightNumber){ //收缩状态 if($("#F_"+flightNumber).is(":visible")){ $scope.reloadList(); } $("#F_"+flightNumber).animate({ height:'toggle' }); } //判断最低价 $scope.minPrice=function(flightHighPrice,flightMiddlePrice,flightBasePrice){ return (flightHighPrice<=flightMiddlePrice?flightHighPrice:flightMiddlePrice)<=flightBasePrice?(flightHighPrice<=flightMiddlePrice?flightHighPrice:flightMiddlePrice):flightBasePrice } //判断是否有票 $scope.isKickets=function(kicketsNumber,flightNumber,temp){ /*console.log(flightNumber)*/ if(kicketsNumber>0){ $("#"+temp+"_"+flightNumber).css({ color:"green" }); return "有票"; } else{ $("#"+temp+"_"+flightNumber).css({ color:"red" }); return "无票"; } }
package com.cafuc.controller;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.List;import javax.annotation.Resource;import org.apache.commons.collections.FastArrayList;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.data.redis.core.RedisTemplate;import org.springframework.web.bind.annotation.RequestBody;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;import com.cafuc.pojo.Discuss;import com.cafuc.pojo.Flight;import com.cafuc.pojo.PageResult;import com.cafuc.pojo.Result;import com.cafuc.service.IDiscussManageService;import com.cafuc.service.IPortalManageService;@RestController@RequestMapping("discussManage")public class DiscussManageController { @Resource private IDiscussManageService discussManageService; @RequestMapping("addDiscuss") public Result addDiscuss(@RequestBody Discuss discuss){ try { System.out.println(discuss); discussManageService.addDiscuss(discuss); return new Result(true, "评论成功"); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return new Result(false, "评论失败"); } } @RequestMapping("init") public List<Discuss> init(){ return discussManageService.init(); }}
@RequestMapping("/ack") public void ack(Order order,HttpServletRequest request,HttpServletResponse response) throws IOException { try { if(order.getOrderDate() ==null) { order.setOrderDate(new Date()); } HttpSession httpSession=request.getSession(); httpSession.setAttribute("order", order); System.out.println(request.getSession().getAttribute("order")); response.sendRedirect(request.getContextPath()+"/pay/index.jsp"); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } }
//沙箱APPIDpublic static final String app_id = "**这里需要自己申请**";//沙箱私钥public static final String merchant_private_key = "**这里需要自己申请**";//支付宝公钥public static final String alipay_public_key = "**这里需要自己申请**";//沙箱网关地址public static final String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";//服务器异步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问public static String notify_url = "http://localhost:8081/flyTicket-portal-web/pay/notify_url.jsp";//页面跳转同步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问public static String return_url = "http://localhost:8081/flyTicket-portal-web/orderManage/complete";
完成以上配置后就可以实现订单支付功能了。点击确认付款后跳转到如下图所示界面。//支付完成后@RequestMapping("complete")public void complete(HttpServletRequest request,HttpServletResponse response) throws IOException { System.out.println(request.getSession().getAttribute("order")); Order order=(Order)request.getSession().getAttribute("order"); try { //将数据插入到订单表中 orderManageService.insertOrder(order); //更改库存 Flight flight=orderManageService.findOneByFlightNumber(order.getFlightNumber()); if(order.getGrade().equals("f")) { flight.setFlightHighNumber(flight.getFlightHighNumber()-1); } else if(order.getGrade().equals("b")) { flight.setFlightMiddleNumber(flight.getFlightMiddleNumber()-1); } else { flight.setFlightBaseNumber(flight.getFlightBaseNumber()-1); } orderManageService.updatesNum(flight); } catch (Exception e) { e.printStackTrace(); } response.sendRedirect(request.getContextPath()+"/default/index.html"); }
关键词:实现,地址,设计,系统,管理