基于javaweb+mysql的springboot电影购票管理系统(java+springboot+vue+maven+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot电影购票管理系统(java+springboot+vue+maven+mysql)
一、项目运行 环境配置:
Jdk1.8 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。
项目技术:
Spring + SpringBoot+ mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。
@PostMapping("")
@ApiOperation("新增电影场次")
public void save(@RequestBody Arrangement arrangement) {
arrangementService.save(arrangement);
}
@PutMapping("")
@ApiOperation("修改排片信息")
public Arrangement update(@RequestBody Arrangement arrangement) {
return arrangementService.Update(arrangement);
}
@DeleteMapping("")
@ApiOperation("根据id删除排片")
public void delete(@RequestParam String id) {
arrangementService.deleteById(id);
}
@GetMapping("")
@ApiOperation("列出电影排片")
public List<Arrangement> list() {
return arrangementService.findAll();
}
@GetMapping("/{id}")
@ApiOperation("查询拍片")
public Map<String, Object> findById(@PathVariable String id) {
HashMap<String, Object> map = new HashMap<>();
Arrangement arrangement = arrangementService.findById(id);
map.put("film", filmService.findById(arrangement.getFid()));
map.put("arrangement", arrangement);
return map;
}
@GetMapping("/getSeats")
@ApiOperation("获取座位情况")
public List<Integer> getSeats(String id) {
return arrangementService.getSeatsHaveSelected(id);
}
@GetMapping("/film/{fid}")
@ApiOperation("查询某个电影的所有拍片")
public ArrangementVO findByFilmId(@PathVariable String fid) {
return arrangementService.findByFilmId(fid);
}
}
@RestController
@Api(tags = "留言接口")
@RequestMapping("/api/lm")
public class LeavingMessageController {
@Resource
private LeavingMessageService leavingMessageService;
@PostMapping("")
@ApiOperation(value = "新增留言接口")
public void save(@RequestBody LeavingMessage leavingMessage) {
leavingMessageService.save(leavingMessage);
}
@PutMapping("")
@ApiOperation("回复留言")
public void reply(@RequestBody LeavingMessage leavingMessage) {
leavingMessageService.reply(leavingMessage);
}
@GetMapping("")
@ApiOperation("获取所有影院留言")
public List<LeavingMessageVO> list() {
return leavingMessageService.findAll();
}
@GetMapping("/active")
@ApiOperation("获取活跃留言的用户")
public List<ActiveUserVO> findActiveUsers() {
return leavingMessageService.findActiveUsers();
public void get(@RequestParam("id") String id, HttpServletResponse response) throws Exception {
if ("".equals(id)) {
return;
}
Upload upload = uploadMapper.selectById(id);
if (upload == null) {
throw new Exception("图片不存在");
}
byte[] data = upload.getBytes();
response.setContentType("image/jpeg");
response.setCharacterEncoding("UTF-8");
OutputStream outputStream = response.getOutputStream();
InputStream in = new ByteArrayInputStream(data);
int len;
byte[] buf = new byte[1024];
while ((len = in.read(buf, 0, 1024)) != -1) {
outputStream.write(buf, 0, len);
}
outputStream.close();
}
}
@RestController
@Api(tags = "员工接口")
@RequestMapping("/api/worker")
public class WorkerController {
@Resource
* 上传图片存放为二进制到mysql
*/
@RestController
@Api(tags = "上传接口")
@RequestMapping("/api/upload")
public class UploadController {
@Value("${server.port}")
private String serverPort;
@Resource
private UploadService uploadService;
@Resource
private UploadMapper uploadMapper;
@PostMapping("")
@ApiOperation(value = "上传图片")
@PreAuthorize("hasAnyRole('ROLE_ADMIN', 'ROLE_USER', 'ROLE_WORKER')")
@DisableBaseResponse
public String upload(MultipartFile file) throws Exception {
if (file == null) throw new Exception("请求参数缺失");
if (file.isEmpty()) {
throw new Exception("上传失败,请选择文件");
}
return "http://localhost:" + serverPort + "/api/upload?id=" + uploadService.checkAndSaveUpload(file);
}
@DeleteMapping("")
@ApiOperation(value = "删除图片")
public void delete(@RequestParam("id") String id) {
uploadService.deleteById(id);
}
@GetMapping("")
@ApiOperation(value = "获取图片")
@PermitAll
@DisableBaseResponse
public void get(@RequestParam("id") String id, HttpServletResponse response) throws Exception {
if ("".equals(id)) {
workerService.deleteById(id);
}
@PutMapping("")
@ApiOperation("更新员工信息")
public void update(@RequestBody Worker worker) throws Exception {
workerService.update(worker);
}
}
/**
* Authorization 授权 发放token
*/
public class AuthorizationFilter extends BasicAuthenticationFilter {
public AuthorizationFilter(AuthenticationManager authenticationManager) {
super(authenticationManager);
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws IOException, ServletException {
@RestController
@Api(tags = "客服评价接口")
@RequestMapping("/api/we")
public class WorkerEvaluateController {
@Resource
private WorkerEvaluateService workerEvaluateService;
@PostMapping("")
@ApiOperation(value = "保存客服评价")
public void save(@RequestBody WorkerEvaluate workerEvaluate) {
workerEvaluateService.save(workerEvaluate);
}
@GetMapping("")
@ApiOperation(value = "查看客服评价")
public List<WorkerEvaluate> save(String id) {
return workerEvaluateService.findByWorkerId(id);
}
@DeleteMapping("{id}")
@ApiOperation(value = "删除客服评价")
public void deleteById(@PathVariable String id) {
workerEvaluateService.deleteById(id);
}
}
@RestController
@Api(tags = "用户购物车接口")
@RestController
@Api(tags = "活动接口")
@RequestMapping("/api/activity")
public class ActivityController {
@Resource
private ActivityService activityService;
@PostMapping("")
@ApiOperation("新增活动")
public void create(@RequestBody Activity activity) {
activityService.create(activity);
}
@GetMapping("")
@ApiOperation("获取全部活动")
public List<Activity> findAll() {
return activityService.findAll();
}
@GetMapping("{id}")
@ApiOperation("根据id查找活动")
public Activity findById(@PathVariable String id) {
return activityService.findById(id);
}
@DeleteMapping("{id}")
@ApiOperation("删除活动")
public void delete(@PathVariable String id) {
activityService.deleteById(id);
}
}
private LeavingMessageService leavingMessageService;
@PostMapping("")
@ApiOperation(value = "新增留言接口")
public void save(@RequestBody LeavingMessage leavingMessage) {
leavingMessageService.save(leavingMessage);
}
@PutMapping("")
@ApiOperation("回复留言")
public void reply(@RequestBody LeavingMessage leavingMessage) {
leavingMessageService.reply(leavingMessage);
}
@GetMapping("")
@ApiOperation("获取所有影院留言")
public List<LeavingMessageVO> list() {
return leavingMessageService.findAll();
}
@GetMapping("/active")
@ApiOperation("获取活跃留言的用户")
public List<ActiveUserVO> findActiveUsers() {
return leavingMessageService.findActiveUsers();
}
}
@RestController
@Api(tags = "活动接口")
@RequestMapping("/api/activity")
public class ActivityController {
@RestController
@Api(tags = "用户接口")
@RequestMapping("/api/user")
public class UserController {
@Resource
private UserService userService;
@PostMapping("/login")
@ApiOperation("用户登录")
public Map<String, Object> login(@RequestBody LoginDto dto) throws Exception {
User user = userService.login(dto);
Map<String, Object> map = new HashMap<>();
//是否选择记住我
long exp = dto.isRemember() ? JwtTokenUtil.REMEMBER_EXPIRATION_TIME : JwtTokenUtil.EXPIRATION_TIME;
List<String> roles = new ArrayList<>();
roles.add(Roles.ROLE_USER);
map.put("token", JwtTokenUtil.createToken(dto.getUsername(), roles, exp));
map.put("user", user);
return map;
}
@GetMapping("")
@ApiOperation(value = "查找所有用户")
public List<User> findAll() {
return userService.findAll();
}
@PutMapping("")
@ApiOperation(value = "更新用户")
public User updateUser(@RequestBody User user) {
return userService.update(user);
}
@GetMapping("/{id}")
private RoleService roleService;
@GetMapping("/system")
@ApiOperation("查看系统设置有哪些权限")
@PreAuthorize("hasAnyRole('ROLE_ADMIN')")
public String[] listSystemRoles() {
return Roles.roles;
}
@PostMapping("")
@ApiOperation("添加权限")
@PreAuthorize("hasAnyRole('ROLE_ADMIN')")
public Role create(@RequestBody Role role) throws Exception {
return roleService.create(role);
}
@GetMapping("")
@ApiOperation("查询员工的权限")
@PreAuthorize("hasAnyRole('ROLE_ADMIN')")
public List<Role> listByWorkerId(String wid) {
return roleService.listRolesByWorkerId(wid);
}
@DeleteMapping("/{id}")
@ApiOperation("删除权限")
@PreAuthorize("hasAnyRole('ROLE_ADMIN')")
public void delete(@PathVariable String id) throws Exception {
roleService.deleteById(id);
}
}
@RestController
@Api(tags = "订单接口")
@RequestMapping("/api/order")
public class OrderController {
@Resource
private OrderService orderService;
@PostMapping("")
@DeleteMapping("/{id}")
@ApiOperation("删除权限")
@PreAuthorize("hasAnyRole('ROLE_ADMIN')")
public void delete(@PathVariable String id) throws Exception {
roleService.deleteById(id);
}
}
@RestController
@Api(tags = "订单接口")
@RequestMapping("/api/order")
public class OrderController {
@Resource
private OrderService orderService;
@PostMapping("")
@ApiOperation(value = "创建订单")
public void save(@RequestBody Cart cart) throws Exception {
orderService.create(cart);
}
@GetMapping("")
@ApiOperation(value = "查询所有订单")
public List<OrderVO> findAll() {
return orderService.findAll();
}
@PutMapping("")
@RestController
@Api(tags = "用户接口")
@RequestMapping("/api/user")
public class UserController {
@Resource
private UserService userService;
@PostMapping("/login")
@ApiOperation("用户登录")
public Map<String, Object> login(@RequestBody LoginDto dto) throws Exception {
User user = userService.login(dto);
Map<String, Object> map = new HashMap<>();
//是否选择记住我
long exp = dto.isRemember() ? JwtTokenUtil.REMEMBER_EXPIRATION_TIME : JwtTokenUtil.EXPIRATION_TIME;
List<String> roles = new ArrayList<>();
roles.add(Roles.ROLE_USER);
map.put("token", JwtTokenUtil.createToken(dto.getUsername(), roles, exp));
map.put("user", user);
return map;
}
@GetMapping("")
@ApiOperation(value = "查找所有用户")
public List<User> findAll() {
return userService.findAll();
}
@PutMapping("")
@ApiOperation(value = "更新用户")
public User updateUser(@RequestBody User user) {
return userService.update(user);
}
@GetMapping("/{id}")
/**
* Authorization 授权 发放token
*/
public class AuthorizationFilter extends BasicAuthenticationFilter {
public AuthorizationFilter(AuthenticationManager authenticationManager) {
super(authenticationManager);
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws IOException, ServletException {
//从Request Header 取出Token
String token = request.getHeader(JwtTokenUtil.TOKEN_HEADER);
//Token为空放行
//如果接下来进入的URL不是公共的地址SpringSecurity会返回403的错误
if (token == null || "null".equals(token)) {
chain.doFilter(request, response);
return;
}
//判断JWT Token是否过期
if (JwtTokenUtil.isExpiration(token)) {
ResponseUtil.writeJson(response, new ResponseResult<>(403, "令牌已过期, 请重新登录"));
@Resource
private UploadService uploadService;
@Resource
private UploadMapper uploadMapper;
@PostMapping("")
@ApiOperation(value = "上传图片")
@PreAuthorize("hasAnyRole('ROLE_ADMIN', 'ROLE_USER', 'ROLE_WORKER')")
@DisableBaseResponse
public String upload(MultipartFile file) throws Exception {
if (file == null) throw new Exception("请求参数缺失");
if (file.isEmpty()) {
throw new Exception("上传失败,请选择文件");
}
return "http://localhost:" + serverPort + "/api/upload?id=" + uploadService.checkAndSaveUpload(file);
}
@DeleteMapping("")
@ApiOperation(value = "删除图片")
public void delete(@RequestParam("id") String id) {
uploadService.deleteById(id);
}
@GetMapping("")
@ApiOperation(value = "获取图片")
@PermitAll
@DisableBaseResponse
public void get(@RequestParam("id") String id, HttpServletResponse response) throws Exception {
if ("".equals(id)) {
return;
}
Upload upload = uploadMapper.selectById(id);
if (upload == null) {
throw new Exception("图片不存在");
}
byte[] data = upload.getBytes();
response.setContentType("image/jpeg");
response.setCharacterEncoding("UTF-8");
OutputStream outputStream = response.getOutputStream();
InputStream in = new ByteArrayInputStream(data);
int len;
return leavingMessageService.findAll();
}
@GetMapping("/active")
@ApiOperation("获取活跃留言的用户")
public List<ActiveUserVO> findActiveUsers() {
return leavingMessageService.findActiveUsers();
}
}
@RestController
@Api(tags = "活动接口")
@RequestMapping("/api/activity")
public class ActivityController {
@Resource
private ActivityService activityService;
@PostMapping("")
@ApiOperation("新增活动")
public void create(@RequestBody Activity activity) {
activityService.create(activity);
}
@GetMapping("")
@ApiOperation("获取全部活动")
public List<Activity> findAll() {
return activityService.findAll();
}
@GetMapping("{id}")
@ApiOperation("根据id查找活动")
public Activity findById(@PathVariable String id) {
return activityService.findById(id);
}
@DeleteMapping("{id}")
@ApiOperation("删除活动")
public void delete(@PathVariable String id) {
activityService.deleteById(id);
}
}
@RestController
@Api(tags = "订单接口")
@RequestMapping("/api/order")
public class OrderController {
@Resource
private OrderService orderService;
@PostMapping("")
@ApiOperation(value = "创建订单")
public void save(@RequestBody Cart cart) throws Exception {
orderService.create(cart);
}
@GetMapping("")
@ApiOperation(value = "查询所有订单")
public List<OrderVO> findAll() {
return orderService.findAll();
}
@PutMapping("")
@ApiOperation(value = "查询所有订单")
public void update(@RequestBody Order order) {
orderService.update(order);
}
@GetMapping("/user/{id}")
@ApiOperation(value = "查询用户订单")
public List<OrderVO> findByUser(@PathVariable String id) {
return orderService.findByUser(id);
}
@GetMapping("/pay")
@ApiOperation(value = "支付订单")
public Order save(String id) throws Exception {
return orderService.pay(id);
}
}
}
@GetMapping("/{id}")
@ApiOperation("查询拍片")
public Map<String, Object> findById(@PathVariable String id) {
HashMap<String, Object> map = new HashMap<>();
Arrangement arrangement = arrangementService.findById(id);
map.put("film", filmService.findById(arrangement.getFid()));
map.put("arrangement", arrangement);
return map;
}
@GetMapping("/getSeats")
@ApiOperation("获取座位情况")
public List<Integer> getSeats(String id) {
return arrangementService.getSeatsHaveSelected(id);
}
@GetMapping("/film/{fid}")
@ApiOperation("查询某个电影的所有拍片")
public ArrangementVO findByFilmId(@PathVariable String fid) {
return arrangementService.findByFilmId(fid);
}
}
@RestController
@Api(tags = "用户接口")
@RequestMapping("/api/user")
public class UserController {
@Resource
private UserService userService;
}
@GetMapping("/{id}")
@ApiOperation(value = "查找用户")
public User findById(@PathVariable String id) {
return userService.findById(id);
}
@PostMapping("/register")
@ApiOperation(value = "用户注册")
public User save(@RequestBody User user) throws Exception {
return userService.save(user);
}
}
@RestController
@Api(tags = "电影接口")
@RequestMapping("/api/film")
public class FilmController {
@Resource
private FilmService filmService;
@PostMapping("")
@ApiOperation(value = "保存电影")
public void save(@RequestBody Film film) {
filmService.save(film);
}
@GetMapping("")
@ApiOperation("列出所有电影")
public List<Film> list(String region, String type) {