基于javaweb+mysql的springboot电影购票管理系统(java+springboot+vue+maven+mysql)

基于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 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。

项目技术:

Spring + SpringBoot+ mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。

    }

    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查找电影")
    public Film findById(@PathVariable String id) {
        return filmService.findById(id);
    }

    @PutMapping("")
    @ApiOperation(value = "更新电影")
    public void update(@RequestBody Film film) {
        filmService.update(film);
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "根据id删除电影")
    public void deleteById(@PathVariable String id) {
        filmService.deleteById(id);
    }

}

/**
 * 对工作人员的权限管理
 * 所有接口都需要管理员权限验证
 */
@RestController
@Api(tags = "权限接口")
@RequestMapping("/api/role")
public class RoleController {

    @Resource
    private RoleService roleService;

    @GetMapping("/system")
    @ApiOperation("查看系统设置有哪些权限")
    @PreAuthorize("hasAnyRole('ROLE_ADMIN')")
    public String[] listSystemRoles() {
        return Roles.roles;
    }
    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 {

    @Resource
    private ActivityService activityService;

    @PostMapping("")
    @ApiOperation("新增活动")
    public void create(@RequestBody Activity activity) {
        activityService.create(activity);
}

/**
 * 对工作人员的权限管理
 * 所有接口都需要管理员权限验证
 */
@RestController
@Api(tags = "权限接口")
@RequestMapping("/api/role")
public class RoleController {

    @Resource
    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);
    }

    @PostMapping("")
    @ApiOperation("添加首页海报")
    public void save(@RequestBody Poster poster) {
        posterService.save(poster);
    }

    @PutMapping("")
    @ApiOperation("更新海报")
    public void update(@RequestBody Poster poster) {
        posterService.update(poster);
    }

    @GetMapping("")
    @ApiOperation("获取所有海报")
    public List<Poster> list(String status) {
        if (status != null) {
            return posterService.findByStatus(Boolean.parseBoolean(status));
        }
        return posterService.findAll();
    }

    @DeleteMapping("/{id}")
    @ApiOperation(("删除海报"))
    public void delete(@PathVariable String id) {
        posterService.deleteById(id);
    }

    @DeleteMapping("")
    @ApiOperation(("删除所有海报"))
    public void deleteAll() {
        posterService.deleteAll();
    }

}

/**

        //解析JWT获取用户信息
        String username = JwtTokenUtil.getUsername(token);
        ArrayList<SimpleGrantedAuthority> authorities = new ArrayList<>();
        for (String role : JwtTokenUtil.getTokenRoles(token)) {
            authorities.add(new SimpleGrantedAuthority(role));
        }

        //向SpringSecurity的Context中加入认证信息
        SecurityContextHolder.getContext().setAuthentication(
                new UsernamePasswordAuthenticationToken(username, null, authorities));
        super.doFilterInternal(request, response, chain);
    }

}

@RestController
@Api(tags = "电影排片场次接口")
@RequestMapping("/api/arrangement")
public class ArrangementController {

    @Resource
    private ArrangementService arrangementService;

    @Resource
    private FilmService filmService;
        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 {

        //从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, "令牌已过期, 请重新登录"));
            return;
        }

    }

}

@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);
    public boolean supports(MethodParameter methodParameter, Class c) {
        //如果方法上带有DisableBaseResponse注解, 不处理返回false
        return !methodParameter.hasMethodAnnotation(DisableBaseResponse.class);
    }

    @Override
    public ResponseResult<Object> beforeBodyWrite(Object o, MethodParameter methodParameter, MediaType mediaType, Class aClass,
                                  ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) {
        if (o == null) {
            return new ResponseResult<>();
        }
        return new ResponseResult<>(o);
    }

}

@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();
 * 上传图片存放为二进制到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)) {
            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);

/**
 * 上传图片存放为二进制到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)) {
            return;
        }
        Upload upload = uploadMapper.selectById(id);
        if (upload == null) {
@Api(tags = "员工接口")
@RequestMapping("/api/worker")
public class WorkerController {

    @Resource
    private WorkerService workerService;

    @Resource
    private RoleService roleService;

    @PostMapping("/login")
    @ApiOperation("员工登录")
    public Map<String, Object> login(@RequestBody LoginDto dto) throws Exception {
        Worker worker = workerService.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_WORKER);

        for (Role role : roleService.listRolesByWorkerId(worker.getId())){
            roles.add(role.getValue());
        }
        map.put("token", JwtTokenUtil.createToken(dto.getUsername(), roles, exp));
        map.put("worker", worker);
        return map;
    }

    @PostMapping("")
    @ApiOperation("添加员工")
    public Worker create(@RequestBody Worker worker) throws Exception {
        return workerService.create(worker);
    }

    @GetMapping("")
    @ApiOperation("查询全部员工")
    public List<Worker> list(){
        return workerService.findAll();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询员工")
    public Worker findById(@PathVariable String id){
        return workerService.findById(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
    private WorkerService workerService;

    @Resource
    @DeleteMapping("/{id}")
    @ApiOperation("根据id删除员工")
    public void deleteById(@PathVariable String 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 {

        //从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;
        }
@RestController
@Api(tags = "电影排片场次接口")
@RequestMapping("/api/arrangement")
public class ArrangementController {

    @Resource
    private ArrangementService arrangementService;

    @Resource
    private FilmService filmService;

    @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()));

@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

@RestController
@Api(tags = "员工接口")
@RequestMapping("/api/worker")
public class WorkerController {

    @Resource
    private WorkerService workerService;

    @Resource
    private RoleService roleService;

    @PostMapping("/login")
    @ApiOperation("员工登录")
    public Map<String, Object> login(@RequestBody LoginDto dto) throws Exception {
        Worker worker = workerService.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_WORKER);

        for (Role role : roleService.listRolesByWorkerId(worker.getId())){
            roles.add(role.getValue());
        }
        map.put("token", JwtTokenUtil.createToken(dto.getUsername(), roles, exp));
        map.put("worker", worker);
        return map;
    }

    @PostMapping("")
    @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 {

    @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);

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个基于 Activity 实现全局悬浮球的代码示例: ```java public class FloatingActivity extends Activity implements View.OnTouchListener { private WindowManager mWindowManager; private WindowManager.LayoutParams mLayoutParams; private ImageView mFloatingView; private int mStartX, mStartY; private int mLastX, mLastY; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_floating); // 设置窗口属性 mLayoutParams = new WindowManager.LayoutParams(); mLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; mLayoutParams.format = PixelFormat.RGBA_8888; mLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; mLayoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT; mLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT; mLayoutParams.gravity = Gravity.TOP | Gravity.START; // 添加悬浮球 View mFloatingView = new ImageView(this); mFloatingView.setImageResource(R.drawable.ic_floating_ball); mFloatingView.setOnTouchListener(this); mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE); mWindowManager.addView(mFloatingView, mLayoutParams); } @Override public boolean onTouch(View view, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: // 记录起始位置 mStartX = mLayoutParams.x; mStartY = mLayoutParams.y; // 记录上一次位置 mLastX = (int) event.getRawX(); mLastY = (int) event.getRawY(); break; case MotionEvent.ACTION_MOVE: // 计算移动距离 int dx = (int) (event.getRawX() - mLastX); int dy = (int) (event.getRawY() - mLastY); // 更新悬浮球位置 mLayoutParams.x = mStartX + dx; mLayoutParams.y = mStartY + dy; mWindowManager.updateViewLayout(mFloatingView, mLayoutParams); break; case MotionEvent.ACTION_UP: // 处理悬浮球点击事件 if (Math.abs(event.getRawX() - mLastX) < 10 && Math.abs(event.getRawY() - mLastY) < 10) { Intent intent = new Intent(this, FloatingBallClickActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); // 关闭悬浮球窗口 mWindowManager.removeView(mFloatingView); finish(); } break; } return true; } } ``` 在上面的代码中,我们创建了一个继承自 Activity 的类 FloatingActivity,作为悬浮球的容器。在 onCreate 方法中,我们设置了容器的布局、位置等属性,并添加了一个 ImageView 作为悬浮球 View。在 onTouch 方法中,我们实现了悬浮球的拖动和点击事件,并使用 WindowManager 来更新悬浮球的位置。在悬浮球点击事件中,我们启动了一个新的 Activity 处理点击事件,并关闭了悬浮球窗口。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值