背景適合人群: 應(yīng)屆生 推薦:可直接做為畢業(yè)設(shè)計項目,開發(fā)架構(gòu)簡單,按照統(tǒng)一" />

国产成人精品无码青草_亚洲国产美女精品久久久久∴_欧美人与鲁交大毛片免费_国产果冻豆传媒麻婆精东

15158846557 在線咨詢 在線咨詢
15158846557 在線咨詢
所在位置: 首頁 > 營銷資訊 > 網(wǎng)站運營 > 【項目分享~寫給應(yīng)屆生的一篇文章】基于Web電影院購票系統(tǒng) ~~ 選座模塊

【項目分享~寫給應(yīng)屆生的一篇文章】基于Web電影院購票系統(tǒng) ~~ 選座模塊

時間:2023-06-08 23:06:02 | 來源:網(wǎng)站運營

時間:2023-06-08 23:06:02 來源:網(wǎng)站運營

【項目分享~寫給應(yīng)屆生的一篇文章】基于Web電影院購票系統(tǒng) ~~ 選座模塊:【項目分享~寫給應(yīng)屆生的一篇文章】基于Web電影院購票系統(tǒng) ~~ 選座模塊

背景

適合人群: 應(yīng)屆生 推薦:可直接做為畢業(yè)設(shè)計項目,開發(fā)架構(gòu)簡單,按照統(tǒng)一的規(guī)范開發(fā),容易上少 原因:這個項目涉及到SSM三大框架,對于剛剛?cè)腴TJavaWeb的同學(xué)缺少太多必備的知識,導(dǎo)致學(xué)習(xí)這個項目事倍功半。如果你已經(jīng)是有一兩年工作經(jīng)驗開發(fā)者,這個項目對你的level太低了,也不推薦哦

每年都會指導(dǎo)一些應(yīng)屆生答辯計算機畢業(yè)設(shè)計,

針對以往應(yīng)屆生常問的一些問題如何去設(shè)計一個電影院購票選座的模塊

以“基于Web電影院購票系統(tǒng)”“基于Web電影院購票系統(tǒng)”這篇文章為例,今天給大家講講這個:選座模塊是如何實現(xiàn)的




小總結(jié)

你還在為大學(xué)最后的畢業(yè)設(shè)計而苦惱嗎? 你還在面對畢業(yè)設(shè)計而無從下手嗎? 你還在實習(xí),但苦于沒有時間做畢業(yè)設(shè)計嗎?

適合應(yīng)屆生當(dāng)做項目經(jīng)驗、或者畢設(shè)作品 小作者的隨手之作,實現(xiàn)難度不難

~~ 這個項目,你值得擁有

項目演示視頻分享

鏈接:https://pan.baidu.com/s/1gbC3i-FBp6-JfGRzmsfZgQ

提取碼:9lkr

想要源碼的可以私聊我,

亦或是加我qq:924155240 可指導(dǎo)畢設(shè),穩(wěn)過

項目截圖







電影院購票模塊的設(shè)計

最簡單的二維數(shù)組來存儲座位信息

1 2 3 4 56 7 8 9 10分別對應(yīng)坐標(biāo): [0][0] [0][1] [0][2] [0][3] [0][4] [1][0] [1][1] [1][2] [1][3] [1][4]

基于以上的設(shè)計,定出表結(jié)構(gòu)信息

CREATE TABLE `selected_seat` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '選座主鍵', `my_x` int(11) DEFAULT NULL COMMENT '一維度數(shù)組', `my_y` int(11) DEFAULT NULL COMMENT '二位度數(shù)組', `is_select` varchar(256) DEFAULT NULL COMMENT '是否選中', `u_id` int(11) DEFAULT NULL COMMENT '用戶編號', `u_name` varchar(256) DEFAULT NULL COMMENT '用戶信息', `s_id` int(11) DEFAULT NULL COMMENT '電影次的主鍵', PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1114 DEFAULT CHARSET=utf8;

添加電影播映的時候,根據(jù)放映廳的X與Y的值,生成選座信息

@Override public boolean add(MovieSchedule movieSchedule) { Integer vId = movieSchedule.getvId(); VideoHall videoHall = videoHallMapper.selectByPrimaryKey(vId); Integer cId = videoHall.getcId(); Integer mId = movieSchedule.getmId(); CheckUtil.notNull(movieSchedule,"電影放映安排為空"); CheckUtil.notNull(cId,"電影院ID為空"); CheckUtil.notNull(vId,"電影院放映廳ID為空"); CheckUtil.notNull(mId,"電影ID為空"); CheckUtil.notNull(movieSchedule.getHallStatrTime(),"電影放映安排開始時間為空"); CheckUtil.notNull(movieSchedule.getHallEndTime(),"電影放映安排結(jié)束時間為空"); CheckUtil.notNull(movieSchedule.getSellMoney(),"影片售價為空"); // 判斷電影放映安排名稱是否存在 MovieScheduleExample movieScheduleExample = new MovieScheduleExample(); MovieScheduleExample.Criteria criteria = movieScheduleExample.createCriteria(); criteria.andCIdEqualTo(cId); criteria.andVIdEqualTo(vId); criteria.andHallStatrTimeLessThanOrEqualTo(movieSchedule.getHallStatrTime()); criteria.andHallEndTimeGreaterThanOrEqualTo(movieSchedule.getHallStatrTime()); List<MovieSchedule> lists = movieScheduleMapper.selectByExample(movieScheduleExample); if(CollectionUtils.isNotEmpty(lists)){ throw new CheckException(ResultBean.CHECK_FAIL, "該時間段已經(jīng)有電影正在播放,不能安排在改時間段,請檢查!"); } MovieScheduleExample movieScheduleExample2 = new MovieScheduleExample(); MovieScheduleExample.Criteria criteria2 = movieScheduleExample2.createCriteria(); criteria2.andCIdEqualTo(cId); criteria2.andVIdEqualTo(vId); criteria2.andHallStatrTimeLessThanOrEqualTo(movieSchedule.getHallEndTime()); criteria2.andHallEndTimeGreaterThanOrEqualTo(movieSchedule.getHallEndTime()); List<MovieSchedule> lists2 = movieScheduleMapper.selectByExample(movieScheduleExample2); if(CollectionUtils.isNotEmpty(lists2)){ throw new CheckException(ResultBean.CHECK_FAIL, "該時間段已經(jīng)有電影正在播放,不能安排在改時間段,請檢查!"); } // 補充其他信息 Cinema cinema = cinemaMapper.selectByPrimaryKey(cId); movieSchedule.setUpdateTime(new Date()); movieSchedule.setCreateTime(new Date()); movieSchedule.setcId(cinema.getCinemaId()); movieSchedule.setcNo(cinema.getCinemaNo()); movieSchedule.setcName(cinema.getCinemaName()); movieSchedule.setcAddress(cinema.getAddress()); movieSchedule.setvName(videoHall.getScreensName()); movieSchedule.setvNo(videoHall.getScreensNo()); movieSchedule.setvType(videoHall.getType()); Movie movie = movieMapper.selectByPrimaryKey(mId); movieSchedule.setmName(movie.getMovieName()); movieSchedule.setmEnglishName(movie.getMovieEnglishName()); movieSchedule.setMinuteLength(movie.getMinuteLength()); movieSchedule.setRemainingSeatNumber(videoHall.getSeatNumber() * videoHall.getRowNumber()); movieSchedule.setStandy2(movie.getMovieFile()); int i = movieScheduleMapper.insert(movieSchedule); // 生成座位信息 selectedSeatService.add(videoHall.getSeatNumber(), videoHall.getRowNumber(), movieSchedule.getId()); return this.returnBoolean(i); }具體生成座位信息

@Override public boolean add(Integer myX, Integer myY, Integer sId) { CheckUtil.notNull(myX,"座位數(shù)不能為空"); CheckUtil.notNull(myY,"排數(shù)為空"); CheckUtil.notNull(sId,"放映安排為空"); for(int i = 0; i < myX; i++){ for(int j = 0; j < myY; j++){ SelectedSeat selectedSeat = new SelectedSeat(); selectedSeat.setMyX(i); selectedSeat.setMyY(j); selectedSeat.setsId(sId); selectedSeat.setIsSelect("否"); selectedSeatMapper.insert(selectedSeat); } } SelectedSeatExample selectedSeatExample = new SelectedSeatExample(); SelectedSeatExample.Criteria criteria = selectedSeatExample.createCriteria(); criteria.andSIdEqualTo(sId); List<SelectedSeat> selectedSeats = selectedSeatMapper.selectByExample(selectedSeatExample); if(CollectionUtils.isNotEmpty(selectedSeats)){ return myX * myY == selectedSeats.size(); } return false; }

座位渲染前端

/** * 初始化日期選擇 * */ var price; function initDate() { var queryArgs = $tool.getQueryParam();//獲取查詢參數(shù) var id = queryArgs['id']; var req = { id:id }; $("#id").val(id); $api.GetSeatMessageVo(req,function (res) { var data = res.data; console.log(data) console.log("-----------------"); var seatArray = data.seatArray; var hadSelectedSeats = data.hadSelectedSeats; $("#mName").html(data.mName); $("#startTime").html(data.startTime); var $cart = $('#selected-seats'), //座位區(qū) $counter = $('#counter'), //票數(shù) $total = $('#total'); //總計金額 price = data.price; var sc = $('#seat-map').seatCharts({ map: seatArray, naming : { top : false, getLabel : function (character, row, column) { return column; } }, legend : { //定義圖例 node : $('#legend'), items : [ [ 'a', 'available', '可選座' ], [ 'a', 'unavailable', '已售出'] ] }, click: function () { //點擊事件 if (this.status() == 'available') { //可選座 $('<li>'+(this.settings.row+1)+'排'+this.settings.label+'</li>') .attr('id', 'cart-item-'+this.settings.id) .data('seatId', this.settings.id) .appendTo($cart); $counter.text(sc.find('selected').length+1); $total.text(recalculateTotal(sc)+price); return 'selected'; } else if (this.status() == 'selected') { //已選中 //更新數(shù)量 $counter.text(sc.find('selected').length-1); //更新總計 $total.text(recalculateTotal(sc)-price); //刪除已預(yù)訂座位 $('#cart-item-'+this.settings.id).remove(); //可選座 return 'available'; } else if (this.status() == 'unavailable') { //已售出 return 'unavailable'; } else { return this.style(); } } }); //已售出的座位 //sc.get(['1_2', '4_4','4_5','6_6','6_7','8_5','8_6','8_7','8_8', '10_1', '10_2']).status('unavailable'); sc.get(hadSelectedSeats).status('unavailable'); }); }

渲染座位信息

也就是把已經(jīng)出售的組裝成1_2的格式,前端就能渲染出來

@Override public SeatMessageVo toGetSeatMessage(Integer id) { SeatMessageVo seatMessageVo = new SeatMessageVo(); CheckUtil.notNull(id,"電影放映安排ID為空"); // 獲取到廳信息 MovieSchedule movieSchedule = movieScheduleMapper.selectByPrimaryKey(id); VideoHall videoHall = videoHallMapper.selectByPrimaryKey(movieSchedule.getvId()); // 獲取X軸 int myX = videoHall.getSeatNumber(); int myY = videoHall.getRowNumber(); String[] seatArray = new String[myY]; for(int i = 0; i < myY; i++){ StringBuffer sb = new StringBuffer(); for(int j = 0; j < myX; j++){ sb.append("a"); } seatArray[i] = sb.toString(); } // 獲取當(dāng)前已經(jīng)選中的座位 SelectedSeatExample selectedSeatExample = new SelectedSeatExample(); SelectedSeatExample.Criteria criteria = selectedSeatExample.createCriteria(); criteria.andSIdEqualTo(id); criteria.andIsSelectEqualTo("是"); List<SelectedSeat> selectedSeats = selectedSeatMapper.selectByExample(selectedSeatExample); List<String> hadSelectedSeatsList = new ArrayList<>(); if(CollectionUtils.isNotEmpty(selectedSeats)){ for(SelectedSeat selectedSeat : selectedSeats){ hadSelectedSeatsList.add((selectedSeat.getMyY() + 1) + "_" + (selectedSeat.getMyX() + 1)); } } // 從redis獲取座位信息 Set<String> keys = redisTemplate.keys("seat_" + id + "_" + "*"); for(String key : keys){ String data = redisTemplate.opsForValue().get(key); hadSelectedSeatsList.add(data); } String[] strArray = new String[hadSelectedSeatsList.size()]; hadSelectedSeatsList.toArray(strArray); seatMessageVo.setHadSelectedSeats(strArray); seatMessageVo.setSeatArray(seatArray); seatMessageVo.setStartTime(movieSchedule.getHallStatrTime()); seatMessageVo.setmName(movieSchedule.getmName()); seatMessageVo.setPrice(movieSchedule.getSellMoney()); return seatMessageVo; }

使用redis緩存有效時間

package com.gameloft9.demo.controllers.business;import com.gameloft9.demo.dataaccess.model.business.MovieOrder;import com.gameloft9.demo.dataaccess.model.business.MovieSchedule;import com.gameloft9.demo.dataaccess.model.business.SelectedSeat;import com.gameloft9.demo.mgrframework.annotation.BizOperLog;import com.gameloft9.demo.mgrframework.beans.constant.OperType;import com.gameloft9.demo.mgrframework.beans.response.IResult;import com.gameloft9.demo.mgrframework.beans.response.PageResultBean;import com.gameloft9.demo.mgrframework.beans.response.ResultBean;import com.gameloft9.demo.mgrframework.utils.CheckUtil;import com.gameloft9.demo.service.api.business.MovieOrderService;import com.github.pagehelper.PageInfo;import lombok.extern.slf4j.Slf4j;import org.apache.commons.lang3.StringUtils;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.data.redis.core.RedisTemplate;import org.springframework.stereotype.Controller;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 javax.validation.Valid;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Collection;import java.util.Date;import java.util.List;import java.util.concurrent.TimeUnit;/** * create by IntelliJ IDEA * * @author : xiaozheng * DATE: 2019/9/22 0022 * TIME: 下午 12:49 * Description: */@Slf4j@Controller@RequestMapping("/movieOrder")public class MovieOrderController extends BaseController{ @Autowired MovieOrderService movieOrderService; private static final String pd = "yy-MM-dd HH:mm:ss"; private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pd); @Autowired private RedisTemplate<String, String> redisTemplate; @RequestMapping(value = "/test") @ResponseBody public IResult test(){ for(int i = 0; i < 8; i++){ MovieOrder movieOrder = new MovieOrder(); movieOrder.setNumber(2); movieOrder.setSeatMessage("4排1座,4排2做"); movieOrder.setsId(26); movieOrder.setuId(1); movieOrderService.add(movieOrder); } return new ResultBean<Boolean>(true); } /** * 獲取所有影片訂單列表 ~ 分頁 * @param page 頁序 * @param limit 分頁大小 * */ @RequestMapping(value = "/getPageForAdmin") @ResponseBody public IResult getPage(String page, String limit, String orderNo, String uName, String uPhone, String cName, String cNo, String cAddress, String mName, String mEnglishName, String startTime, String endTime, String vType, String vName, String code, String status) throws Exception{ Date hallStartTime = null; Date hallEndTime = null; if(StringUtils.isNotEmpty(startTime)){ hallStartTime = simpleDateFormat.parse(startTime); } if(StringUtils.isNotEmpty(endTime)){ hallEndTime = simpleDateFormat.parse(endTime); } //返回json至前端的均返回ResultBean或者PageResultBean PageInfo pageInfo = movieOrderService.getPage(page, limit, orderNo, uName, uPhone, cName, cNo, cAddress, mName, mEnglishName, hallStartTime, hallEndTime, vType, vName, code, status); List<MovieOrder> pageInfoList = pageInfo.getList(); List<MovieOrder> movieOrders = new ArrayList<>(); for (MovieOrder movieOrder : pageInfoList){ String images = movieOrder.getmFile(); String a = "<img class=/"layui-upload-img/" src=/""+images+"/" style=/"width:50px; height:50px;/">"; movieOrder.setmFile(a); movieOrders.add(movieOrder); } Integer total = new Long(pageInfo.getTotal()).intValue(); return new PageResultBean<Collection<MovieOrder>>(movieOrders, total); } /** * 獲取所有影片訂單列表 ~ 分頁 * @param page 頁序 * @param limit 分頁大小 * */ @RequestMapping(value = "/getPageForUser") @ResponseBody public IResult getPageForUser(String page, String limit, String orderNo, String cName, String cAddress, String mName, String mEnglishName, String startTime, String endTime, String code, String status) throws Exception{ Date hallStartTime = null; Date hallEndTime = null; if(StringUtils.isNotEmpty(startTime)){ hallStartTime = simpleDateFormat.parse(startTime); } if(StringUtils.isNotEmpty(endTime)){ hallEndTime = simpleDateFormat.parse(endTime); } //返回json至前端的均返回ResultBean或者PageResultBean PageInfo pageInfo = movieOrderService.getPageForUser(page, limit, orderNo, cName, cAddress, mName, mEnglishName , hallStartTime, hallEndTime, code, status); List<MovieOrder> pageInfoList = pageInfo.getList(); List<MovieOrder> movieOrders = new ArrayList<>(); for (MovieOrder movieOrder : pageInfoList){ String images = movieOrder.getmFile(); String a = "<img class=/"layui-upload-img/" src=/""+images+"/" style=/"width:50px; height:50px;/">"; movieOrder.setmFile(a); movieOrders.add(movieOrder); } Integer total = new Long(pageInfo.getTotal()).intValue(); return new PageResultBean<Collection<MovieOrder>>(movieOrders, total); } /** * 添加影片訂單 * */ /*@RequestMapping(value = "/add") @ResponseBody @BizOperLog(operType = OperType.ADD,memo = "添加影片訂單") public IResult add(@RequestBody MovieOrder movieOrder){ //返回json至前端的均返回ResultBean或者PageResultBean return new ResultBean<Boolean>(movieOrderService.add(movieOrder)); }*/ @RequestMapping(value = "/add") @ResponseBody @BizOperLog(operType = OperType.ADD,memo = "添加影片訂單") public IResult add(Integer number, String seatMessage, Integer sId) throws Exception{ seatMessage = new String(seatMessage.getBytes("iso8859-1"), "utf-8"); // 判斷是否過期 String[] sArr = seatMessage.split(" "); int i = 0; boolean aggress = true; for(String s : sArr){ int myX = Integer.parseInt(s.split("排")[1].split("座")[0]); int myY = Integer.parseInt(s.split("排")[0]); String key = redisKeyForUser(sId, myX, myY); String s1 = redisTemplate.opsForValue().get(key); if(StringUtils.isEmpty(s1)){ aggress = false; } } if(aggress){ MovieOrder movieOrder = new MovieOrder(); movieOrder.setsId(sId); movieOrder.setSeatMessage(seatMessage); movieOrder.setNumber(number); //返回json至前端的均返回ResultBean或者PageResultBean return new ResultBean<Boolean>(movieOrderService.add(movieOrder)); }else { // 刪除緩存 for(String s : sArr){ int myX = Integer.parseInt(s.split("排")[1].split("座")[0]); int myY = Integer.parseInt(s.split("排")[0]); redisTemplate.delete(redisKey(sId, myX, myY)); redisTemplate.delete(redisKeyForUser(sId, myX, myY)); } CheckUtil.notNull(null, "訂單超時,無法支付請重新選擇!"); return new ResultBean<Boolean>(false); } } @RequestMapping(value = "/suoJia") @ResponseBody @BizOperLog(operType = OperType.ADD,memo = "添加影片訂單") public IResult suoJia(Integer number, String seatMessage, Integer sId) throws Exception{ seatMessage = new String(seatMessage.getBytes("iso8859-1"), "utf-8"); CheckUtil.notNull(sId, "電影播放安排sId為空"); CheckUtil.notNull(seatMessage, "座位信息為空"); String[] sArr = seatMessage.split(" "); int i = 0; // 鎖價之前先判斷是否存在 for(String s : sArr){ int myX = Integer.parseInt(s.split("排")[1].split("座")[0]); int myY = Integer.parseInt(s.split("排")[0]); String s1 = redisTemplate.opsForValue().get(redisKey(sId, myX, myY)); if(StringUtils.isNotEmpty(s1)){ CheckUtil.notNull(null, "非常抱歉該訂單已經(jīng)被其他客戶鎖住了,請重新選擇!"); } } for(String s : sArr){ int myX = Integer.parseInt(s.split("排")[1].split("座")[0]); int myY = Integer.parseInt(s.split("排")[0]); String redisDate = myY + "_" + myX; redisTemplate.opsForValue().set(redisKey(sId, myX, myY), redisDate, 60, TimeUnit.SECONDS); redisTemplate.opsForValue().set(redisKeyForUser(sId, myX, myY), redisDate, 60, TimeUnit.SECONDS); } //返回json至前端的均返回ResultBean或者PageResultBean return new ResultBean<Boolean>(true); } @RequestMapping(value = "/cancelOrder") @ResponseBody @BizOperLog(operType = OperType.ADD,memo = "刪除影片訂單") public IResult cancelOrder(Integer number, String seatMessage, Integer sId) throws Exception{ seatMessage = new String(seatMessage.getBytes("iso8859-1"), "utf-8"); CheckUtil.notNull(sId, "電影播放安排sId為空"); CheckUtil.notNull(seatMessage, "座位信息為空"); String[] sArr = seatMessage.split(" "); int i = 0; for(String s : sArr){ int myX = Integer.parseInt(s.split("排")[1].split("座")[0]); int myY = Integer.parseInt(s.split("排")[0]); redisTemplate.delete(redisKey(sId, myX, myY)); redisTemplate.delete(redisKeyForUser(sId, myX, myY)); } //返回json至前端的均返回ResultBean或者PageResultBean return new ResultBean<Boolean>(true); } private String redisKey(Integer sId, int myX, int myY){ return "seat_" + sId + "_" + myX + "_" + myY; } private String redisKeyForUser(Integer sId, int myX, int myY){ return getUserId() + "_seat_" + sId + "_" + myX + "_" + myY; } /** * 刪除影院 * */ @RequestMapping(value = "/delete") @ResponseBody @BizOperLog(operType = OperType.DELETE,memo = "刪除影片訂單") public IResult delete(Integer id){ //返回json至前端的均返回ResultBean或者PageResultBean return new ResultBean<Boolean>(movieOrderService.deleteById(id)); } @ResponseBody @RequestMapping("/getById") public IResult getById(Integer id) { return new ResultBean<MovieOrder>(movieOrderService.getById(id)); } /** * 更新學(xué)院 * */ @RequestMapping(value = "/update") @ResponseBody @BizOperLog(operType = OperType.UPDATE,memo = "更新影院") public IResult update(@RequestBody @Valid MovieOrder movieOrder){ //傳遞了數(shù)組,前臺放在payload里面了,后臺通過@RequestBody獲取 //返回json至前端的均返回ResultBean或者PageResultBean if("退票完成".equals(movieOrder.getStatus())){ return new ResultBean<Boolean>(movieOrderService.toRemitAmount(movieOrder)); }else{ return new ResultBean<Boolean>(movieOrderService.updateById(movieOrder)); } } /** * 更新學(xué)院 * */ @RequestMapping(value = "/remitOperator") @ResponseBody @BizOperLog(operType = OperType.UPDATE,memo = "退款操作") public IResult remitOperator(@RequestBody @Valid MovieOrder movieOrder){ //傳遞了數(shù)組,前臺放在payload里面了,后臺通過@RequestBody獲取 //返回json至前端的均返回ResultBean或者PageResultBean return new ResultBean<Boolean>(movieOrderService.remitAmount(movieOrder)); }}

代碼All

dao層

package com.gameloft9.demo.dataaccess.dao.business;import com.gameloft9.demo.dataaccess.model.business.SelectedSeat;import com.gameloft9.demo.dataaccess.model.business.SelectedSeatExample;import java.util.List;import org.apache.ibatis.annotations.Param;public interface SelectedSeatMapper { int countByExample(SelectedSeatExample example); int deleteByExample(SelectedSeatExample example); int deleteByPrimaryKey(Integer id); int insert(SelectedSeat record); int insertSelective(SelectedSeat record); List<SelectedSeat> selectByExample(SelectedSeatExample example); SelectedSeat selectByPrimaryKey(Integer id); int updateByExampleSelective(@Param("record") SelectedSeat record, @Param("example") SelectedSeatExample example); int updateByExample(@Param("record") SelectedSeat record, @Param("example") SelectedSeatExample example); int updateByPrimaryKeySelective(SelectedSeat record); int updateByPrimaryKey(SelectedSeat record); int deleteBySid(Integer sId);}<?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.gameloft9.demo.dataaccess.dao.business.SelectedSeatMapper" > <resultMap id="BaseResultMap" type="com.gameloft9.demo.dataaccess.model.business.SelectedSeat" > <id column="id" property="id" jdbcType="INTEGER" /> <result column="my_x" property="myX" jdbcType="INTEGER" /> <result column="my_y" property="myY" jdbcType="INTEGER" /> <result column="is_select" property="isSelect" jdbcType="VARCHAR" /> <result column="u_id" property="uId" jdbcType="INTEGER" /> <result column="u_name" property="uName" jdbcType="VARCHAR" /> <result column="s_id" property="sId" jdbcType="INTEGER" /> </resultMap> <sql id="Example_Where_Clause" > <where > <foreach collection="oredCriteria" item="criteria" separator="or" > <if test="criteria.valid" > <trim prefix="(" suffix=")" prefixOverrides="and" > <foreach collection="criteria.criteria" item="criterion" > <choose > <when test="criterion.noValue" > and ${criterion.condition} </when> <when test="criterion.singleValue" > and ${criterion.condition} #{criterion.value} </when> <when test="criterion.betweenValue" > and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} </when> <when test="criterion.listValue" > and ${criterion.condition} <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," > #{listItem} </foreach> </when> </choose> </foreach> </trim> </if> </foreach> </where> </sql> <sql id="Update_By_Example_Where_Clause" > <where > <foreach collection="example.oredCriteria" item="criteria" separator="or" > <if test="criteria.valid" > <trim prefix="(" suffix=")" prefixOverrides="and" > <foreach collection="criteria.criteria" item="criterion" > <choose > <when test="criterion.noValue" > and ${criterion.condition} </when> <when test="criterion.singleValue" > and ${criterion.condition} #{criterion.value} </when> <when test="criterion.betweenValue" > and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} </when> <when test="criterion.listValue" > and ${criterion.condition} <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," > #{listItem} </foreach> </when> </choose> </foreach> </trim> </if> </foreach> </where> </sql> <sql id="Base_Column_List" > id, my_x, my_y, is_select, u_id, u_name, s_id </sql> <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.gameloft9.demo.dataaccess.model.business.SelectedSeatExample" > select <if test="distinct" > distinct </if> <include refid="Base_Column_List" /> from selected_seat <if test="_parameter != null" > <include refid="Example_Where_Clause" /> </if> <if test="orderByClause != null" > order by ${orderByClause} </if> </select> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > select <include refid="Base_Column_List" /> from selected_seat where id = #{id,jdbcType=INTEGER} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > delete from selected_seat where id = #{id,jdbcType=INTEGER} </delete> <delete id="deleteByExample" parameterType="com.gameloft9.demo.dataaccess.model.business.SelectedSeatExample" > delete from selected_seat <if test="_parameter != null" > <include refid="Example_Where_Clause" /> </if> </delete> <insert id="insert" parameterType="com.gameloft9.demo.dataaccess.model.business.SelectedSeat" > insert into selected_seat (id, my_x, my_y, is_select, u_id, u_name, s_id) values (#{id,jdbcType=INTEGER}, #{myX,jdbcType=INTEGER}, #{myY,jdbcType=INTEGER}, #{isSelect,jdbcType=VARCHAR}, #{uId,jdbcType=INTEGER}, #{uName,jdbcType=VARCHAR}, #{sId,jdbcType=INTEGER}) </insert> <insert id="insertSelective" parameterType="com.gameloft9.demo.dataaccess.model.business.SelectedSeat" > insert into selected_seat <trim prefix="(" suffix=")" suffixOverrides="," > <if test="id != null" > id, </if> <if test="myX != null" > my_x, </if> <if test="myY != null" > my_y, </if> <if test="isSelect != null" > is_select, </if> <if test="uId != null" > u_id, </if> <if test="uName != null" > u_name, </if> <if test="sId != null" > s_id, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides="," > <if test="id != null" > #{id,jdbcType=INTEGER}, </if> <if test="myX != null" > #{myX,jdbcType=INTEGER}, </if> <if test="myY != null" > #{myY,jdbcType=INTEGER}, </if> <if test="isSelect != null" > #{isSelect,jdbcType=VARCHAR}, </if> <if test="uId != null" > #{uId,jdbcType=INTEGER}, </if> <if test="uName != null" > #{uName,jdbcType=VARCHAR}, </if> <if test="sId != null" > #{sId,jdbcType=INTEGER}, </if> </trim> </insert> <select id="countByExample" parameterType="com.gameloft9.demo.dataaccess.model.business.SelectedSeatExample" resultType="java.lang.Integer" > select count(*) from selected_seat <if test="_parameter != null" > <include refid="Example_Where_Clause" /> </if> </select> <update id="updateByExampleSelective" parameterType="map" > update selected_seat <set > <if test="record.id != null" > id = #{record.id,jdbcType=INTEGER}, </if> <if test="record.myX != null" > my_x = #{record.myX,jdbcType=INTEGER}, </if> <if test="record.myY != null" > my_y = #{record.myY,jdbcType=INTEGER}, </if> <if test="record.isSelect != null" > is_select = #{record.isSelect,jdbcType=VARCHAR}, </if> <if test="record.uId != null" > u_id = #{record.uId,jdbcType=INTEGER}, </if> <if test="record.uName != null" > u_name = #{record.uName,jdbcType=VARCHAR}, </if> <if test="record.sId != null" > s_id = #{record.sId,jdbcType=INTEGER}, </if> </set> <if test="_parameter != null" > <include refid="Update_By_Example_Where_Clause" /> </if> </update> <update id="updateByExample" parameterType="map" > update selected_seat set id = #{record.id,jdbcType=INTEGER}, my_x = #{record.myX,jdbcType=INTEGER}, my_y = #{record.myY,jdbcType=INTEGER}, is_select = #{record.isSelect,jdbcType=VARCHAR}, u_id = #{record.uId,jdbcType=INTEGER}, u_name = #{record.uName,jdbcType=VARCHAR}, s_id = #{record.sId,jdbcType=INTEGER} <if test="_parameter != null" > <include refid="Update_By_Example_Where_Clause" /> </if> </update> <update id="updateByPrimaryKeySelective" parameterType="com.gameloft9.demo.dataaccess.model.business.SelectedSeat" > update selected_seat <set > <if test="myX != null" > my_x = #{myX,jdbcType=INTEGER}, </if> <if test="myY != null" > my_y = #{myY,jdbcType=INTEGER}, </if> <if test="isSelect != null" > is_select = #{isSelect,jdbcType=VARCHAR}, </if> <if test="uId != null" > u_id = #{uId,jdbcType=INTEGER}, </if> <if test="uName != null" > u_name = #{uName,jdbcType=VARCHAR}, </if> <if test="sId != null" > s_id = #{sId,jdbcType=INTEGER}, </if> </set> where id = #{id,jdbcType=INTEGER} </update> <update id="updateByPrimaryKey" parameterType="com.gameloft9.demo.dataaccess.model.business.SelectedSeat" > update selected_seat set my_x = #{myX,jdbcType=INTEGER}, my_y = #{myY,jdbcType=INTEGER}, is_select = #{isSelect,jdbcType=VARCHAR}, u_id = #{uId,jdbcType=INTEGER}, u_name = #{uName,jdbcType=VARCHAR}, s_id = #{sId,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER} </update> <!--以下是我自己開發(fā)的代碼--> <delete id="deleteBySid" parameterType="java.lang.Integer"> delete from selected_seat where s_id = #{sId,jdbcType=INTEGER} </delete></mapper>Service 層

package com.gameloft9.demo.service.api.business;import com.gameloft9.demo.dataaccess.model.business.VideoHall;import com.github.pagehelper.PageInfo;import java.util.*;/** * create by IntelliJ IDEA * * @author : xiaozheng * DATE: 2019/9/22 0022 * TIME: 下午 12:38 * Description: */public interface SelectedSeatService { /** * 生成座位信息 * @param * @return */ boolean add(Integer myX, Integer myY, Integer sId); /** * 根據(jù)主鍵刪除電影院廳信息 * @param sId * @return */ boolean deleteBySId(Integer sId); /** * 根據(jù)主鍵更新電影院廳信息 * @param seatMessage * @param sId * @return */ boolean updateByMyXAndMyYAndSid(String seatMessage, Integer sId, String isSelected);}package com.gameloft9.demo.service.impl.business;import com.gameloft9.demo.dataaccess.dao.business.SelectedSeatMapper;import com.gameloft9.demo.dataaccess.model.business.SelectedSeat;import com.gameloft9.demo.dataaccess.model.business.SelectedSeatExample;import com.gameloft9.demo.mgrframework.utils.CheckUtil;import com.gameloft9.demo.service.api.business.SelectedSeatService;import lombok.extern.slf4j.Slf4j;import org.apache.commons.collections.CollectionUtils;import org.apache.ibatis.annotations.Select;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import java.util.List;import java.util.Map;/** * create by IntelliJ IDEA * * @author : xiaozheng * DATE: 2019/9/22 0022 * TIME: 下午 12:43 * Description: */@Slf4j@Servicepublic class SelectedSeatServiceImpl implements SelectedSeatService { @Autowired private SelectedSeatMapper selectedSeatMapper; @Override public boolean add(Integer myX, Integer myY, Integer sId) { CheckUtil.notNull(myX,"座位數(shù)不能為空"); CheckUtil.notNull(myY,"排數(shù)為空"); CheckUtil.notNull(sId,"放映安排為空"); for(int i = 0; i < myX; i++){ for(int j = 0; j < myY; j++){ SelectedSeat selectedSeat = new SelectedSeat(); selectedSeat.setMyX(i); selectedSeat.setMyY(j); selectedSeat.setsId(sId); selectedSeat.setIsSelect("否"); selectedSeatMapper.insert(selectedSeat); } } SelectedSeatExample selectedSeatExample = new SelectedSeatExample(); SelectedSeatExample.Criteria criteria = selectedSeatExample.createCriteria(); criteria.andSIdEqualTo(sId); List<SelectedSeat> selectedSeats = selectedSeatMapper.selectByExample(selectedSeatExample); if(CollectionUtils.isNotEmpty(selectedSeats)){ return myX * myY == selectedSeats.size(); } return false; } @Override public boolean deleteBySId(Integer sId) { CheckUtil.notNull(sId, "刪除電影播放安排ID為空"); int i = selectedSeatMapper.deleteBySid(sId); return this.returnBoolean(i); } @Override public boolean updateByMyXAndMyYAndSid(String seatMessage, Integer sId, String isSelected) { CheckUtil.notNull(sId, "電影播放安排sId為空"); CheckUtil.notNull(sId, "座位信息為空"); String[] sArr = seatMessage.split(" "); int i = 0; for(String s : sArr){ int myX = Integer.parseInt(s.split("排")[1].split("座")[0]); int myY = Integer.parseInt(s.split("排")[0]); SelectedSeat oldSelectedSeat = this.getByMyXAndMyYAndSid(myX - 1, myY - 1, sId); oldSelectedSeat.setIsSelect(isSelected); i = selectedSeatMapper.updateByPrimaryKey(oldSelectedSeat); } return this.returnBoolean(i); } private SelectedSeat getByMyXAndMyYAndSid(Integer myX, Integer myY, Integer sId){ SelectedSeatExample selectedSeatExample = new SelectedSeatExample(); SelectedSeatExample.Criteria criteria = selectedSeatExample.createCriteria(); criteria.andMyXEqualTo(myX); criteria.andMyYEqualTo(myY); criteria.andSIdEqualTo(sId); return selectedSeatMapper.selectByExample(selectedSeatExample).get(0); } private boolean returnBoolean(int i ){ if( i > 0) { return true; }else{ return false; } } public static void main(String[] args) { String s = "3排6座"; int myX = Integer.parseInt(s.substring(2,3)); int myY = Integer.parseInt(s.substring(0,1)); System.out.println(myX); System.out.println(myY); }}

小總結(jié)

知道的越多,不知道的越多,希望對你有幫助!

想 要 源 碼 , 想 要 指 導(dǎo) 畢 業(yè) 設(shè) 計 ,



關(guān)鍵詞:電影院,系統(tǒng),文章,項目,應(yīng)屆

74
73
25
news

版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。

為了最佳展示效果,本站不支持IE9及以下版本的瀏覽器,建議您使用谷歌Chrome瀏覽器。 點擊下載Chrome瀏覽器
關(guān)閉