├── .gitignore ├── README.assets ├── image-1.png ├── image-2.png ├── image-20220526180504178.png ├── image-3.png ├── image-4.png ├── image-5.png ├── image-6.png └── image.png ├── README.md └── api ├── api.iml ├── pom.xml └── src └── main ├── java └── com │ └── movie │ └── api │ ├── ApiApplication.java │ ├── annotation │ └── DisableBaseResponse.java │ ├── auth │ └── AuthorizationFilter.java │ ├── config │ ├── SecurityConfiguration.java │ └── SwaggerConfiguration.java │ ├── constant │ ├── FilmStatus.java │ ├── OrderStatus.java │ └── Roles.java │ ├── controller │ ├── ActivityController.java │ ├── AdminController.java │ ├── ArrangementController.java │ ├── CartController.java │ ├── DailyWorkController.java │ ├── FilmController.java │ ├── FilmEvaluateController.java │ ├── LeavingMessageController.java │ ├── OrderController.java │ ├── OrderExceptionController.java │ ├── PosterController.java │ ├── RegistrationController.java │ ├── RoleController.java │ ├── UploadController.java │ ├── UserController.java │ ├── WorkerController.java │ └── WorkerEvaluateController.java │ ├── handler │ ├── GlobalExceptionHandler.java │ └── GlobalResponseHandler.java │ ├── mapper │ ├── ActivityMapper.java │ ├── AdminMapper.java │ ├── ArrangementMapper.java │ ├── CartMapper.java │ ├── DailyWorkMapper.java │ ├── FilmEvaluateMapper.java │ ├── FilmMapper.java │ ├── LeavingMessageMapper.java │ ├── OrderExceptionMapper.java │ ├── OrderMapper.java │ ├── PosterMapper.java │ ├── RegistrationMapper.java │ ├── RoleMapper.java │ ├── UploadMapper.java │ ├── UserMapper.java │ ├── WorkerEvaluateMapper.java │ └── WorkerMapper.java │ ├── model │ ├── dto │ │ ├── CreateCartDto.java │ │ ├── LoginDto.java │ │ └── UpdateRolesDto.java │ ├── entity │ │ ├── Activity.java │ │ ├── Admin.java │ │ ├── Arrangement.java │ │ ├── Cart.java │ │ ├── DailyWork.java │ │ ├── Film.java │ │ ├── FilmEvaluate.java │ │ ├── LeavingMessage.java │ │ ├── Order.java │ │ ├── OrderException.java │ │ ├── Poster.java │ │ ├── Registration.java │ │ ├── Role.java │ │ ├── Upload.java │ │ ├── User.java │ │ ├── Worker.java │ │ └── WorkerEvaluate.java │ ├── support │ │ └── ResponseResult.java │ └── vo │ │ ├── ActiveUserVO.java │ │ ├── ArrangementVO.java │ │ ├── CartVO.java │ │ ├── FilmEvaluateVO.java │ │ ├── LeavingMessageVO.java │ │ ├── OrderVO.java │ │ └── WorkerEvaluateVO.java │ ├── service │ ├── ActivityService.java │ ├── AdminService.java │ ├── ArrangementService.java │ ├── CartService.java │ ├── DailyWorkService.java │ ├── FilmEvaluateService.java │ ├── FilmService.java │ ├── LeavingMessageService.java │ ├── OrderExceptionService.java │ ├── OrderService.java │ ├── PosterService.java │ ├── RegistrationService.java │ ├── RoleService.java │ ├── UploadService.java │ ├── UserService.java │ ├── WorkerEvaluateService.java │ ├── WorkerService.java │ └── impl │ │ ├── ActivityServiceImpl.java │ │ ├── AdminServiceImpl.java │ │ ├── ArrangementServiceImpl.java │ │ ├── CartServiceImpl.java │ │ ├── DailyWorkServiceImpl.java │ │ ├── FilmEvaluateServiceImpl.java │ │ ├── FilmServiceImpl.java │ │ ├── LeavingMessageServiceImpl.java │ │ ├── OrderExceptionServiceImpl.java │ │ ├── OrderServiceImpl.java │ │ ├── PosterServiceImpl.java │ │ ├── RegistrationServiceImpl.java │ │ ├── RoleServiceImpl.java │ │ ├── UploadServiceImpl.java │ │ ├── UserServiceImpl.java │ │ ├── WorkerEvaluateServiceImpl.java │ │ └── WorkerServiceImpl.java │ └── utils │ ├── DataTimeUtil.java │ ├── JwtTokenUtil.java │ └── ResponseUtil.java └── resources └── application.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /README.assets/image-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i-ku/movie/6d1e8ac4894aee9050dc2191db8c5a61c91e407f/README.assets/image-1.png -------------------------------------------------------------------------------- /README.assets/image-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i-ku/movie/6d1e8ac4894aee9050dc2191db8c5a61c91e407f/README.assets/image-2.png -------------------------------------------------------------------------------- /README.assets/image-20220526180504178.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i-ku/movie/6d1e8ac4894aee9050dc2191db8c5a61c91e407f/README.assets/image-20220526180504178.png -------------------------------------------------------------------------------- /README.assets/image-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i-ku/movie/6d1e8ac4894aee9050dc2191db8c5a61c91e407f/README.assets/image-3.png -------------------------------------------------------------------------------- /README.assets/image-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i-ku/movie/6d1e8ac4894aee9050dc2191db8c5a61c91e407f/README.assets/image-4.png -------------------------------------------------------------------------------- /README.assets/image-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i-ku/movie/6d1e8ac4894aee9050dc2191db8c5a61c91e407f/README.assets/image-5.png -------------------------------------------------------------------------------- /README.assets/image-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i-ku/movie/6d1e8ac4894aee9050dc2191db8c5a61c91e407f/README.assets/image-6.png -------------------------------------------------------------------------------- /README.assets/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i-ku/movie/6d1e8ac4894aee9050dc2191db8c5a61c91e407f/README.assets/image.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 影院选座购票系统 2 | 3 | ## 系统设计 4 | 5 | 基于SpringBoot+MyBatis-Plus 的前后端电影项目,前端使用Vue+element ui,主要有影视管理、院线拍片、选座购票、影视管理、订单管理等功能,系统功能完善,界面美观大方。 6 | 7 | ## 功能介绍 8 | 9 | ### 前台功能 10 | 11 | 前台首页展示 12 | 13 | ![img](README.assets/image.png) 14 | 15 | 前台登录界面 16 | 17 | ![img](README.assets/image-1.png) 18 | 19 | 用户选择电影后进入购票页面 20 | 21 | ![img](README.assets/image-2.png) 22 | 23 | 点击选座购票,选择喜欢的座位后,可以加入到购物车 24 | 25 | ![img](README.assets/image-3.png) 26 | 27 | ![img](README.assets/image-4.png) 28 | 29 | 随后点击全部结算,支付成功后可以在订单页面中查看 30 | 31 | ![img](README.assets/image-5.png) 32 | 33 | ### 后台管理 34 | 35 | ![image-20220526180504178](README.assets/image-20220526180504178.png) 36 | 37 | 后台管理主要有影视管理、用户管理、订单管理等功能,不再一一展开。代码已经开源,对项目部署运行有什么疑问,可以添加微信交流,微信:beyond-expression 38 | 39 | -------------------------------------------------------------------------------- /api/api.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.movie 6 | api 7 | 0.0.1-SNAPSHOT 8 | 9 | 10 | org.springframework.boot 11 | spring-boot-starter-parent 12 | 2.4.2 13 | 14 | 15 | 16 | 8 17 | 2.9.2 18 | 0.9.1 19 | 3.4.2 20 | 1.2.73 21 | 1.4.7.RELEASE 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-web 30 | 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-data-redis 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-security 42 | 43 | 44 | 45 | 46 | io.jsonwebtoken 47 | jjwt 48 | ${jwt.version} 49 | 50 | 51 | 52 | 53 | com.baomidou 54 | mybatis-plus-boot-starter 55 | ${mybatis-plus.version} 56 | 57 | 58 | 59 | 60 | mysql 61 | mysql-connector-java 62 | runtime 63 | 64 | 65 | 66 | 67 | org.projectlombok 68 | lombok 69 | true 70 | 71 | 72 | 73 | 74 | io.springfox 75 | springfox-swagger2 76 | ${swagger.version} 77 | 78 | 79 | 80 | 81 | io.springfox 82 | springfox-swagger-ui 83 | ${swagger.version} 84 | 85 | 86 | 87 | 88 | com.alibaba 89 | fastjson 90 | ${fastjson.version} 91 | 92 | 93 | 94 | 95 | 96 | javax.xml.bind 97 | jaxb-api 98 | 2.3.0 99 | 100 | 101 | com.sun.xml.bind 102 | jaxb-impl 103 | 2.3.0 104 | 105 | 106 | com.sun.xml.bind 107 | jaxb-core 108 | 2.3.0 109 | 110 | 111 | javax.activation 112 | activation 113 | 1.1.1 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | org.springframework.boot 122 | spring-boot-maven-plugin 123 | 124 | 125 | 126 | org.projectlombok 127 | lombok 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | maven-ali 139 | http://maven.aliyun.com/nexus/content/groups/public// 140 | 141 | true 142 | 143 | 144 | true 145 | always 146 | fail 147 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/ApiApplication.java: -------------------------------------------------------------------------------- 1 | package com.movie.api; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cache.annotation.EnableCaching; 7 | 8 | //@EnableCaching 9 | @SpringBootApplication 10 | @MapperScan("com.movie.api.mapper") 11 | public class ApiApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(ApiApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/annotation/DisableBaseResponse.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * 作用: 不需要GlobalResponseHandler统一拦截返回JSON的方法 7 | * 例如: 获取二进制图片 Response需要写入文件流 不需要返回json 8 | */ 9 | @Target(ElementType.METHOD) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | public @interface DisableBaseResponse { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/auth/AuthorizationFilter.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.auth; 2 | 3 | import com.movie.api.model.support.ResponseResult; 4 | import com.movie.api.utils.JwtTokenUtil; 5 | import com.movie.api.utils.ResponseUtil; 6 | import org.springframework.security.authentication.AuthenticationManager; 7 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 8 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 9 | import org.springframework.security.core.context.SecurityContextHolder; 10 | import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; 11 | 12 | import javax.servlet.FilterChain; 13 | import javax.servlet.ServletException; 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | import java.io.IOException; 17 | import java.util.ArrayList; 18 | 19 | /** 20 | * Authorization 授权 发放token 21 | */ 22 | public class AuthorizationFilter extends BasicAuthenticationFilter { 23 | 24 | public AuthorizationFilter(AuthenticationManager authenticationManager) { 25 | super(authenticationManager); 26 | } 27 | 28 | @Override 29 | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) 30 | throws IOException, ServletException { 31 | 32 | //从Request Header 取出Token 33 | String token = request.getHeader(JwtTokenUtil.TOKEN_HEADER); 34 | 35 | //Token为空放行 36 | //如果接下来进入的URL不是公共的地址SpringSecurity会返回403的错误 37 | if (token == null || "null".equals(token)) { 38 | chain.doFilter(request, response); 39 | return; 40 | } 41 | 42 | //判断JWT Token是否过期 43 | if (JwtTokenUtil.isExpiration(token)) { 44 | ResponseUtil.writeJson(response, new ResponseResult<>(403, "令牌已过期, 请重新登录")); 45 | return; 46 | } 47 | 48 | //解析JWT获取用户信息 49 | String username = JwtTokenUtil.getUsername(token); 50 | ArrayList authorities = new ArrayList<>(); 51 | for (String role : JwtTokenUtil.getTokenRoles(token)) { 52 | authorities.add(new SimpleGrantedAuthority(role)); 53 | } 54 | 55 | //向SpringSecurity的Context中加入认证信息 56 | SecurityContextHolder.getContext().setAuthentication( 57 | new UsernamePasswordAuthenticationToken(username, null, authorities)); 58 | super.doFilterInternal(request, response, chain); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/config/SecurityConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.config; 2 | 3 | import com.movie.api.auth.AuthorizationFilter; 4 | import com.movie.api.model.support.ResponseResult; 5 | import com.movie.api.utils.ResponseUtil; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 9 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 10 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 11 | import org.springframework.security.config.http.SessionCreationPolicy; 12 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 13 | import org.springframework.web.cors.CorsConfiguration; 14 | import org.springframework.web.cors.CorsConfigurationSource; 15 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; 16 | 17 | /** 18 | * SpringSecurity配置 19 | */ 20 | @Configuration 21 | @EnableGlobalMethodSecurity(prePostEnabled = true) 22 | public class SecurityConfiguration extends WebSecurityConfigurerAdapter { 23 | 24 | @Bean 25 | public BCryptPasswordEncoder bCryptPasswordEncoder() { 26 | return new BCryptPasswordEncoder(); 27 | } 28 | 29 | /** 30 | * HTTP验证规则 31 | * 32 | * @param http h 33 | * @throws Exception e 34 | */ 35 | @Override 36 | protected void configure(HttpSecurity http) throws Exception { 37 | 38 | //开启跨域 39 | http.csrf().disable().cors(); 40 | 41 | //允许跨域使用iframe 42 | http.headers().frameOptions().disable(); 43 | 44 | //禁用session 45 | http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); 46 | 47 | //身份验证失败 48 | http.exceptionHandling().authenticationEntryPoint((request, response, authException) -> { 49 | ResponseUtil.writeJson(response, new ResponseResult<>(403, "身份认证失败, 请重新登录")); 50 | }); 51 | 52 | http.addFilter(new AuthorizationFilter(authenticationManagerBean())); 53 | 54 | } 55 | 56 | /** 57 | * SpringSecurity有默认的跨域配置 会无法放行RequestHeader带有"Authorization"请求 58 | * 防止前端请求api报出cors error 59 | * 60 | * @return * 61 | */ 62 | @Bean 63 | CorsConfigurationSource corsConfigurationSource() { 64 | final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); 65 | final CorsConfiguration corsConfiguration = new CorsConfiguration(); 66 | corsConfiguration.addAllowedHeader("*"); 67 | corsConfiguration.addAllowedHeader("DELETE"); 68 | corsConfiguration.addAllowedMethod("*"); 69 | corsConfiguration.addAllowedOrigin("*"); 70 | source.registerCorsConfiguration("/**", corsConfiguration); 71 | return source; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/config/SwaggerConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.ApiInfoBuilder; 6 | import springfox.documentation.builders.PathSelectors; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.spi.DocumentationType; 9 | import springfox.documentation.spring.web.plugins.Docket; 10 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 11 | 12 | /** 13 | * swagger配置 14 | */ 15 | @Configuration 16 | @EnableSwagger2 17 | public class SwaggerConfiguration { 18 | 19 | @Bean 20 | public Docket docket(){ 21 | return new Docket(DocumentationType.SWAGGER_2) 22 | .select() 23 | .apis(RequestHandlerSelectors.basePackage("com.movie.api.controller")) 24 | .paths(PathSelectors.any()) 25 | .build() 26 | .apiInfo(new ApiInfoBuilder().title("movie电影系统 - api文档").version("v1.0").build()); 27 | } 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/constant/FilmStatus.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.constant; 2 | 3 | /** 4 | * 电影状态 5 | */ 6 | public final class FilmStatus { 7 | 8 | //上架 9 | public final static Integer ON_SHELF = 2; 10 | 11 | //审核 12 | public final static Integer TO_EXAMINE = 1; 13 | 14 | //下架 15 | public final static Integer OFF_SHELF = 0; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/constant/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.constant; 2 | 3 | /** 4 | * 订单状态 5 | */ 6 | public final class OrderStatus { 7 | 8 | //15分钟未支付 支付失败 9 | public final static long EXPIRATION_TIME = 1000 * 60 * 15; 10 | 11 | //初始化订单 等待支付 12 | public final static Integer PAYMENT_WAITING = 0; 13 | 14 | //支付失败 15 | public final static Integer PAYMENT_FAILED = 1; 16 | 17 | //支付成功 18 | public final static Integer PAYMENT_SUCCESSFUL = 2; 19 | 20 | //被管理员撤销 21 | public final static Integer COUNTERMAND = 3; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/constant/Roles.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.constant; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 权限常量 7 | * SpringSecurity 要求加上 "ROLE_" 前缀 8 | */ 9 | public final class Roles { 10 | 11 | //管理员 12 | public final static String ROLE_ADMIN = "ROLE_ADMIN"; 13 | 14 | //普通用户 15 | public final static String ROLE_USER = "ROLE_USER"; 16 | 17 | //普通员工 18 | public final static String ROLE_WORKER = "ROLE_WORKER"; 19 | 20 | //查询用户 21 | public final static String ROLE_FIND_USER = "ROLE_FIND_USER"; 22 | 23 | //新增电影 24 | public final static String ROLE_ADD_FILM = "ROLE_ADD_FILM"; 25 | 26 | //添加拍片 27 | public final static String ROLE_ADD_ARRANGEMENT = "ROLE_ADD_ARRANGEMENT"; 28 | 29 | //删除电影 30 | public final static String ROLE_DELETE_FILM = "ROLE_DELETE_FILM"; 31 | 32 | public final static String[] roles = { 33 | ROLE_FIND_USER, 34 | ROLE_ADD_FILM, 35 | ROLE_DELETE_FILM, 36 | ROLE_ADD_ARRANGEMENT, 37 | }; 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/ActivityController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.model.entity.Activity; 4 | import com.movie.api.service.ActivityService; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | 12 | @RestController 13 | @Api(tags = "活动接口") 14 | @RequestMapping("/api/activity") 15 | public class ActivityController { 16 | 17 | @Resource 18 | private ActivityService activityService; 19 | 20 | @PostMapping("") 21 | @ApiOperation("新增活动") 22 | public void create(@RequestBody Activity activity) { 23 | activityService.create(activity); 24 | } 25 | 26 | @GetMapping("") 27 | @ApiOperation("获取全部活动") 28 | public List findAll() { 29 | return activityService.findAll(); 30 | } 31 | 32 | @GetMapping("{id}") 33 | @ApiOperation("根据id查找活动") 34 | public Activity findById(@PathVariable String id) { 35 | return activityService.findById(id); 36 | } 37 | 38 | @DeleteMapping("{id}") 39 | @ApiOperation("删除活动") 40 | public void delete(@PathVariable String id) { 41 | activityService.deleteById(id); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/AdminController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.model.dto.LoginDto; 4 | import com.movie.api.service.AdminService; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | @RestController 14 | @Api(tags = "管理员接口") 15 | @RequestMapping("/api/admin") 16 | public class AdminController { 17 | 18 | @Resource 19 | private AdminService adminService; 20 | 21 | @PostMapping("/login") 22 | @ApiOperation("管理员登陆") 23 | public Map login(@RequestBody LoginDto loginDto) throws Exception { 24 | HashMap map = new HashMap<>(); 25 | map.put("token", adminService.login(loginDto)); 26 | return map; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/ArrangementController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.model.entity.Arrangement; 4 | import com.movie.api.model.vo.ArrangementVO; 5 | import com.movie.api.service.ArrangementService; 6 | import com.movie.api.service.FilmService; 7 | import io.swagger.annotations.Api; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.HashMap; 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | @RestController 17 | @Api(tags = "电影排片场次接口") 18 | @RequestMapping("/api/arrangement") 19 | public class ArrangementController { 20 | 21 | @Resource 22 | private ArrangementService arrangementService; 23 | 24 | @Resource 25 | private FilmService filmService; 26 | 27 | @PostMapping("") 28 | @ApiOperation("新增电影场次") 29 | public void save(@RequestBody Arrangement arrangement) { 30 | arrangementService.save(arrangement); 31 | } 32 | 33 | @PutMapping("") 34 | @ApiOperation("修改排片信息") 35 | public Arrangement update(@RequestBody Arrangement arrangement) { 36 | return arrangementService.Update(arrangement); 37 | } 38 | 39 | @DeleteMapping("") 40 | @ApiOperation("根据id删除排片") 41 | public void delete(@RequestParam String id) { 42 | arrangementService.deleteById(id); 43 | } 44 | 45 | @GetMapping("") 46 | @ApiOperation("列出电影排片") 47 | public List list() { 48 | return arrangementService.findAll(); 49 | } 50 | 51 | @GetMapping("/{id}") 52 | @ApiOperation("查询拍片") 53 | public Map findById(@PathVariable String id) { 54 | HashMap map = new HashMap<>(); 55 | Arrangement arrangement = arrangementService.findById(id); 56 | map.put("film", filmService.findById(arrangement.getFid())); 57 | map.put("arrangement", arrangement); 58 | return map; 59 | } 60 | 61 | @GetMapping("/getSeats") 62 | @ApiOperation("获取座位情况") 63 | public List getSeats(String id) { 64 | return arrangementService.getSeatsHaveSelected(id); 65 | } 66 | 67 | @GetMapping("/film/{fid}") 68 | @ApiOperation("查询某个电影的所有拍片") 69 | public ArrangementVO findByFilmId(@PathVariable String fid) { 70 | return arrangementService.findByFilmId(fid); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/CartController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.model.entity.Cart; 4 | import com.movie.api.model.vo.CartVO; 5 | import com.movie.api.service.CartService; 6 | import io.swagger.annotations.Api; 7 | import io.swagger.annotations.ApiOperation; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | import javax.annotation.Resource; 11 | import java.util.List; 12 | 13 | @RestController 14 | @Api(tags = "用户购物车接口") 15 | @RequestMapping("/api/cart") 16 | public class CartController { 17 | 18 | @Resource 19 | private CartService cartService; 20 | 21 | @PostMapping 22 | @ApiOperation("添加购物车") 23 | public void save(@RequestBody Cart cart) throws Exception { 24 | cartService.save(cart); 25 | } 26 | 27 | @GetMapping("") 28 | @ApiOperation("根据用户id查询购物车") 29 | public List list(@RequestParam String uid) { 30 | return cartService.findAllByUserId(uid); 31 | } 32 | 33 | @DeleteMapping("") 34 | @ApiOperation("删除购物车") 35 | public void delete(String id) { 36 | cartService.deleteById(id); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/DailyWorkController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.model.entity.DailyWork; 4 | import com.movie.api.service.DailyWorkService; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | 12 | @RestController 13 | @Api(tags = "每日工作接口") 14 | @RequestMapping("/api/daily") 15 | public class DailyWorkController { 16 | 17 | @Resource 18 | private DailyWorkService dailyWorkService; 19 | 20 | @PostMapping("") 21 | @ApiOperation("添加每日工作") 22 | public void create(@RequestBody DailyWork dailyWork){ 23 | dailyWorkService.save(dailyWork); 24 | } 25 | 26 | @DeleteMapping("/{id}") 27 | @ApiOperation("根据id删除每日工作") 28 | public void delete(@PathVariable String id){ 29 | dailyWorkService.deleteById(id); 30 | } 31 | 32 | @GetMapping("") 33 | @ApiOperation("查询所有") 34 | public List findAll(){ 35 | return dailyWorkService.findAll(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/FilmController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.model.entity.Film; 4 | import com.movie.api.service.FilmService; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | 12 | @RestController 13 | @Api(tags = "电影接口") 14 | @RequestMapping("/api/film") 15 | public class FilmController { 16 | 17 | @Resource 18 | private FilmService filmService; 19 | 20 | @PostMapping("") 21 | @ApiOperation(value = "保存电影") 22 | public void save(@RequestBody Film film) { 23 | filmService.save(film); 24 | } 25 | 26 | @GetMapping("") 27 | @ApiOperation("列出所有电影") 28 | public List list(String region, String type) { 29 | if (region != null && type != null) { 30 | return filmService.findByRegionAndType(region, type); 31 | } 32 | return filmService.findAll(); 33 | } 34 | 35 | @GetMapping("/hot/{limit}") 36 | @ApiOperation("获取热榜电影") 37 | public List listHots(@PathVariable Integer limit) { 38 | return filmService.findHots(limit); 39 | } 40 | 41 | @GetMapping("/name/{name}") 42 | @ApiOperation("搜索电影") 43 | public List search(@PathVariable String name) { 44 | return filmService.findLikeName(name); 45 | } 46 | 47 | @GetMapping("/{id}") 48 | @ApiOperation(value = "根据id查找电影") 49 | public Film findById(@PathVariable String id) { 50 | return filmService.findById(id); 51 | } 52 | 53 | @PutMapping("") 54 | @ApiOperation(value = "更新电影") 55 | public void update(@RequestBody Film film) { 56 | filmService.update(film); 57 | } 58 | 59 | @DeleteMapping("/{id}") 60 | @ApiOperation(value = "根据id删除电影") 61 | public void deleteById(@PathVariable String id) { 62 | filmService.deleteById(id); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/FilmEvaluateController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.model.entity.FilmEvaluate; 4 | import com.movie.api.model.vo.FilmEvaluateVO; 5 | import com.movie.api.service.FilmEvaluateService; 6 | import io.swagger.annotations.Api; 7 | import io.swagger.annotations.ApiOperation; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | import javax.annotation.Resource; 11 | import java.util.List; 12 | 13 | @RestController 14 | @Api(tags = "电影评价接口") 15 | @RequestMapping("/api/fe") 16 | public class FilmEvaluateController { 17 | 18 | @Resource 19 | private FilmEvaluateService filmEvaluateService; 20 | 21 | @PostMapping("") 22 | @ApiOperation("评论电影") 23 | public void save(@RequestBody FilmEvaluate filmEvaluate) throws Exception { 24 | filmEvaluateService.save(filmEvaluate); 25 | } 26 | 27 | @GetMapping("") 28 | @ApiOperation("获取电影评论") 29 | public List list(@RequestParam(name = "fid") String fid) { 30 | if (fid != null) { 31 | return filmEvaluateService.findAllByFilmId(fid); 32 | } 33 | return null; 34 | } 35 | 36 | @DeleteMapping("/{id}") 37 | @ApiOperation("根据id删除评论") 38 | public void remove(@PathVariable String id) { 39 | filmEvaluateService.deleteById(id); 40 | } 41 | 42 | @DeleteMapping("") 43 | @ApiOperation("删除该电影的所有评分") 44 | public void removeAll(@RequestParam(name = "fid") String fid) { 45 | filmEvaluateService.deleteAllByFilmId(fid); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/LeavingMessageController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.model.entity.LeavingMessage; 4 | import com.movie.api.model.vo.ActiveUserVO; 5 | import com.movie.api.model.vo.LeavingMessageVO; 6 | import com.movie.api.service.LeavingMessageService; 7 | import io.swagger.annotations.Api; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | 14 | @RestController 15 | @Api(tags = "留言接口") 16 | @RequestMapping("/api/lm") 17 | public class LeavingMessageController { 18 | 19 | @Resource 20 | private LeavingMessageService leavingMessageService; 21 | 22 | @PostMapping("") 23 | @ApiOperation(value = "新增留言接口") 24 | public void save(@RequestBody LeavingMessage leavingMessage) { 25 | leavingMessageService.save(leavingMessage); 26 | } 27 | 28 | @PutMapping("") 29 | @ApiOperation("回复留言") 30 | public void reply(@RequestBody LeavingMessage leavingMessage) { 31 | leavingMessageService.reply(leavingMessage); 32 | } 33 | 34 | @GetMapping("") 35 | @ApiOperation("获取所有影院留言") 36 | public List list() { 37 | return leavingMessageService.findAll(); 38 | } 39 | 40 | @GetMapping("/active") 41 | @ApiOperation("获取活跃留言的用户") 42 | public List findActiveUsers() { 43 | return leavingMessageService.findActiveUsers(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.model.entity.Cart; 4 | import com.movie.api.model.entity.Order; 5 | import com.movie.api.model.vo.OrderVO; 6 | import com.movie.api.service.OrderService; 7 | import io.swagger.annotations.Api; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | 14 | @RestController 15 | @Api(tags = "订单接口") 16 | @RequestMapping("/api/order") 17 | public class OrderController { 18 | 19 | @Resource 20 | private OrderService orderService; 21 | 22 | @PostMapping("") 23 | @ApiOperation(value = "创建订单") 24 | public void save(@RequestBody Cart cart) throws Exception { 25 | orderService.create(cart); 26 | } 27 | 28 | @GetMapping("") 29 | @ApiOperation(value = "查询所有订单") 30 | public List findAll() { 31 | return orderService.findAll(); 32 | } 33 | 34 | @PutMapping("") 35 | @ApiOperation(value = "查询所有订单") 36 | public void update(@RequestBody Order order) { 37 | orderService.update(order); 38 | } 39 | 40 | @GetMapping("/user/{id}") 41 | @ApiOperation(value = "查询用户订单") 42 | public List findByUser(@PathVariable String id) { 43 | return orderService.findByUser(id); 44 | } 45 | 46 | @GetMapping("/pay") 47 | @ApiOperation(value = "支付订单") 48 | public Order save(String id) throws Exception { 49 | return orderService.pay(id); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/OrderExceptionController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.model.entity.OrderException; 4 | import com.movie.api.service.OrderExceptionService; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | 12 | @RestController 13 | @Api(tags = "订单异常上报接口") 14 | @RequestMapping("/api/oe") 15 | public class OrderExceptionController { 16 | 17 | @Resource 18 | private OrderExceptionService orderExceptionService; 19 | 20 | @PostMapping("") 21 | @ApiOperation("添加异常订单") 22 | public OrderException create(@RequestBody OrderException orderException) { 23 | return orderExceptionService.create(orderException); 24 | } 25 | 26 | @GetMapping("") 27 | @ApiOperation("查询所有异常订单") 28 | public List findAll() { 29 | return orderExceptionService.findAll(); 30 | } 31 | 32 | @PutMapping("") 33 | @ApiOperation("工作人员处理异常订单") 34 | public void handle(@RequestBody OrderException orderException) { 35 | orderExceptionService.handleException(orderException); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/PosterController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.model.entity.Poster; 4 | import com.movie.api.service.PosterService; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | 12 | @RestController 13 | @Api(tags = "首页海报接口") 14 | @RequestMapping("/api/poster") 15 | public class PosterController { 16 | 17 | @Resource 18 | private PosterService posterService; 19 | 20 | @PostMapping("") 21 | @ApiOperation("添加首页海报") 22 | public void save(@RequestBody Poster poster) { 23 | posterService.save(poster); 24 | } 25 | 26 | @PutMapping("") 27 | @ApiOperation("更新海报") 28 | public void update(@RequestBody Poster poster) { 29 | posterService.update(poster); 30 | } 31 | 32 | @GetMapping("") 33 | @ApiOperation("获取所有海报") 34 | public List list(String status) { 35 | if (status != null) { 36 | return posterService.findByStatus(Boolean.parseBoolean(status)); 37 | } 38 | return posterService.findAll(); 39 | } 40 | 41 | @DeleteMapping("/{id}") 42 | @ApiOperation(("删除海报")) 43 | public void delete(@PathVariable String id) { 44 | posterService.deleteById(id); 45 | } 46 | 47 | @DeleteMapping("") 48 | @ApiOperation(("删除所有海报")) 49 | public void deleteAll() { 50 | posterService.deleteAll(); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/RegistrationController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.model.entity.Registration; 4 | import com.movie.api.service.RegistrationService; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | 12 | @RestController 13 | @Api(tags = "活动接口") 14 | @RequestMapping("/api/registration") 15 | public class RegistrationController { 16 | 17 | @Resource 18 | private RegistrationService registrationService; 19 | 20 | @PostMapping("") 21 | @ApiOperation("报名活动") 22 | public void create(@RequestBody Registration registration) throws Exception { 23 | registrationService.create(registration); 24 | } 25 | 26 | @GetMapping("") 27 | @ApiOperation("查询所有报名信息") 28 | public List create() { 29 | return registrationService.findAll(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/RoleController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.constant.Roles; 4 | import com.movie.api.model.entity.Role; 5 | import com.movie.api.service.RoleService; 6 | import io.swagger.annotations.Api; 7 | import io.swagger.annotations.ApiOperation; 8 | import org.springframework.security.access.prepost.PreAuthorize; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | 14 | /** 15 | * 对工作人员的权限管理 16 | * 所有接口都需要管理员权限验证 17 | */ 18 | @RestController 19 | @Api(tags = "权限接口") 20 | @RequestMapping("/api/role") 21 | public class RoleController { 22 | 23 | @Resource 24 | private RoleService roleService; 25 | 26 | @GetMapping("/system") 27 | @ApiOperation("查看系统设置有哪些权限") 28 | @PreAuthorize("hasAnyRole('ROLE_ADMIN')") 29 | public String[] listSystemRoles() { 30 | return Roles.roles; 31 | } 32 | 33 | @PostMapping("") 34 | @ApiOperation("添加权限") 35 | @PreAuthorize("hasAnyRole('ROLE_ADMIN')") 36 | public Role create(@RequestBody Role role) throws Exception { 37 | return roleService.create(role); 38 | } 39 | 40 | @GetMapping("") 41 | @ApiOperation("查询员工的权限") 42 | @PreAuthorize("hasAnyRole('ROLE_ADMIN')") 43 | public List listByWorkerId(String wid) { 44 | return roleService.listRolesByWorkerId(wid); 45 | } 46 | 47 | @DeleteMapping("/{id}") 48 | @ApiOperation("删除权限") 49 | @PreAuthorize("hasAnyRole('ROLE_ADMIN')") 50 | public void delete(@PathVariable String id) throws Exception { 51 | roleService.deleteById(id); 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/UploadController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.annotation.DisableBaseResponse; 4 | import com.movie.api.mapper.UploadMapper; 5 | import com.movie.api.model.entity.Upload; 6 | import com.movie.api.service.UploadService; 7 | import io.swagger.annotations.Api; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.security.access.prepost.PreAuthorize; 11 | import org.springframework.web.bind.annotation.*; 12 | import org.springframework.web.multipart.MultipartFile; 13 | 14 | import javax.annotation.Resource; 15 | import javax.annotation.security.PermitAll; 16 | import javax.servlet.http.HttpServletResponse; 17 | import java.io.ByteArrayInputStream; 18 | import java.io.InputStream; 19 | import java.io.OutputStream; 20 | 21 | /** 22 | * 上传图片存放为二进制到mysql 23 | */ 24 | @RestController 25 | @Api(tags = "上传接口") 26 | @RequestMapping("/api/upload") 27 | public class UploadController { 28 | 29 | @Value("${server.port}") 30 | private String serverPort; 31 | 32 | @Resource 33 | private UploadService uploadService; 34 | 35 | @Resource 36 | private UploadMapper uploadMapper; 37 | 38 | @PostMapping("") 39 | @ApiOperation(value = "上传图片") 40 | @PreAuthorize("hasAnyRole('ROLE_ADMIN', 'ROLE_USER', 'ROLE_WORKER')") 41 | @DisableBaseResponse 42 | public String upload(MultipartFile file) throws Exception { 43 | if (file == null) throw new Exception("请求参数缺失"); 44 | if (file.isEmpty()) { 45 | throw new Exception("上传失败,请选择文件"); 46 | } 47 | return "http://localhost:" + serverPort + "/api/upload?id=" + uploadService.checkAndSaveUpload(file); 48 | } 49 | 50 | @DeleteMapping("") 51 | @ApiOperation(value = "删除图片") 52 | public void delete(@RequestParam("id") String id) { 53 | uploadService.deleteById(id); 54 | } 55 | 56 | @GetMapping("") 57 | @ApiOperation(value = "获取图片") 58 | @PermitAll 59 | @DisableBaseResponse 60 | public void get(@RequestParam("id") String id, HttpServletResponse response) throws Exception { 61 | if ("".equals(id)) { 62 | return; 63 | } 64 | Upload upload = uploadMapper.selectById(id); 65 | if (upload == null) { 66 | throw new Exception("图片不存在"); 67 | } 68 | byte[] data = upload.getBytes(); 69 | response.setContentType("image/jpeg"); 70 | response.setCharacterEncoding("UTF-8"); 71 | OutputStream outputStream = response.getOutputStream(); 72 | InputStream in = new ByteArrayInputStream(data); 73 | int len; 74 | byte[] buf = new byte[1024]; 75 | while ((len = in.read(buf, 0, 1024)) != -1) { 76 | outputStream.write(buf, 0, len); 77 | } 78 | outputStream.close(); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.constant.Roles; 4 | import com.movie.api.model.dto.LoginDto; 5 | import com.movie.api.model.entity.User; 6 | import com.movie.api.service.UserService; 7 | import com.movie.api.utils.JwtTokenUtil; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.ArrayList; 15 | import java.util.HashMap; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | @RestController 20 | @Api(tags = "用户接口") 21 | @RequestMapping("/api/user") 22 | public class UserController { 23 | 24 | @Resource 25 | private UserService userService; 26 | 27 | @Resource 28 | private BCryptPasswordEncoder bCryptPasswordEncoder; 29 | 30 | @PostMapping("/login") 31 | @ApiOperation("用户登录") 32 | public Map login(@RequestBody LoginDto dto) throws Exception { 33 | User user = userService.login(dto); 34 | Map map = new HashMap<>(); 35 | //是否选择记住我 36 | long exp = dto.isRemember() ? JwtTokenUtil.REMEMBER_EXPIRATION_TIME : JwtTokenUtil.EXPIRATION_TIME; 37 | List roles = new ArrayList<>(); 38 | roles.add(Roles.ROLE_USER); 39 | map.put("token", JwtTokenUtil.createToken(dto.getUsername(), roles, exp)); 40 | map.put("user", user); 41 | return map; 42 | } 43 | 44 | @GetMapping("") 45 | @ApiOperation(value = "查找所有用户") 46 | public List findAll() { 47 | return userService.findAll(); 48 | } 49 | 50 | @PutMapping("") 51 | @ApiOperation(value = "更新用户") 52 | public User updateUser(@RequestBody User user) { 53 | return userService.update(user); 54 | } 55 | 56 | @GetMapping("/{id}") 57 | @ApiOperation(value = "查找用户") 58 | public User findById(@PathVariable String id) { 59 | return userService.findById(id); 60 | } 61 | 62 | @PostMapping("/register") 63 | @ApiOperation(value = "用户注册") 64 | public User save(@RequestBody User user) throws Exception { 65 | return userService.save(user); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/WorkerController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.constant.Roles; 4 | import com.movie.api.model.dto.LoginDto; 5 | import com.movie.api.model.entity.Role; 6 | import com.movie.api.model.entity.Worker; 7 | import com.movie.api.service.RoleService; 8 | import com.movie.api.service.WorkerService; 9 | import com.movie.api.utils.JwtTokenUtil; 10 | import io.swagger.annotations.Api; 11 | import io.swagger.annotations.ApiOperation; 12 | import org.springframework.web.bind.annotation.*; 13 | 14 | import javax.annotation.Resource; 15 | import java.util.ArrayList; 16 | import java.util.HashMap; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | @RestController 21 | @Api(tags = "员工接口") 22 | @RequestMapping("/api/worker") 23 | public class WorkerController { 24 | 25 | @Resource 26 | private WorkerService workerService; 27 | 28 | @Resource 29 | private RoleService roleService; 30 | 31 | @PostMapping("/login") 32 | @ApiOperation("员工登录") 33 | public Map login(@RequestBody LoginDto dto) throws Exception { 34 | Worker worker = workerService.login(dto); 35 | Map map = new HashMap<>(); 36 | //是否选择记住我 37 | long exp = dto.isRemember() ? JwtTokenUtil.REMEMBER_EXPIRATION_TIME : JwtTokenUtil.EXPIRATION_TIME; 38 | 39 | //查询登录的客服具有哪些权限 40 | List roles = new ArrayList<>(); 41 | //添加最基本的客服权限 42 | roles.add(Roles.ROLE_WORKER); 43 | 44 | for (Role role : roleService.listRolesByWorkerId(worker.getId())){ 45 | roles.add(role.getValue()); 46 | } 47 | map.put("token", JwtTokenUtil.createToken(dto.getUsername(), roles, exp)); 48 | map.put("worker", worker); 49 | return map; 50 | } 51 | 52 | @PostMapping("") 53 | @ApiOperation("添加员工") 54 | public Worker create(@RequestBody Worker worker) throws Exception { 55 | return workerService.create(worker); 56 | } 57 | 58 | @GetMapping("") 59 | @ApiOperation("查询全部员工") 60 | public List list(){ 61 | return workerService.findAll(); 62 | } 63 | 64 | @GetMapping("/{id}") 65 | @ApiOperation("根据id查询员工") 66 | public Worker findById(@PathVariable String id){ 67 | return workerService.findById(id); 68 | } 69 | 70 | @DeleteMapping("/{id}") 71 | @ApiOperation("根据id删除员工") 72 | public void deleteById(@PathVariable String id){ 73 | workerService.deleteById(id); 74 | } 75 | 76 | @PutMapping("") 77 | @ApiOperation("更新员工信息") 78 | public void update(@RequestBody Worker worker) throws Exception { 79 | workerService.update(worker); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/controller/WorkerEvaluateController.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.controller; 2 | 3 | import com.movie.api.model.entity.WorkerEvaluate; 4 | import com.movie.api.service.WorkerEvaluateService; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | 12 | @RestController 13 | @Api(tags = "客服评价接口") 14 | @RequestMapping("/api/we") 15 | public class WorkerEvaluateController { 16 | 17 | @Resource 18 | private WorkerEvaluateService workerEvaluateService; 19 | 20 | @PostMapping("") 21 | @ApiOperation(value = "保存客服评价") 22 | public void save(@RequestBody WorkerEvaluate workerEvaluate) { 23 | workerEvaluateService.save(workerEvaluate); 24 | } 25 | 26 | @GetMapping("") 27 | @ApiOperation(value = "查看客服评价") 28 | public List save(String id) { 29 | return workerEvaluateService.findByWorkerId(id); 30 | } 31 | 32 | @DeleteMapping("{id}") 33 | @ApiOperation(value = "删除客服评价") 34 | public void deleteById(@PathVariable String id) { 35 | workerEvaluateService.deleteById(id); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/handler/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.handler; 2 | 3 | import com.movie.api.annotation.DisableBaseResponse; 4 | import com.movie.api.model.support.ResponseResult; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.security.access.AccessDeniedException; 8 | import org.springframework.web.bind.annotation.ExceptionHandler; 9 | import org.springframework.web.bind.annotation.ResponseBody; 10 | import org.springframework.web.bind.annotation.RestControllerAdvice; 11 | 12 | /** 13 | * 捕获controller异常 14 | * controller抛出异常执行下边的函数 15 | * 返回Response写入ApiResult 16 | */ 17 | @ResponseBody 18 | @RestControllerAdvice 19 | public class GlobalExceptionHandler { 20 | 21 | private final Logger logger = LoggerFactory.getLogger(getClass()); 22 | 23 | @ExceptionHandler(value = Exception.class) 24 | @DisableBaseResponse 25 | public Object handleException(Exception e) { 26 | if (e.getClass().equals(AccessDeniedException.class)){ 27 | return new ResponseResult<>(403, "你没有访问权限"); 28 | } 29 | logger.error(e.getMessage()); 30 | return new ResponseResult<>(400, e.getMessage()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/handler/GlobalResponseHandler.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.handler; 2 | 3 | import com.movie.api.annotation.DisableBaseResponse; 4 | import com.movie.api.model.support.ResponseResult; 5 | import org.springframework.core.MethodParameter; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.http.server.ServerHttpRequest; 8 | import org.springframework.http.server.ServerHttpResponse; 9 | import org.springframework.web.bind.annotation.ControllerAdvice; 10 | import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; 11 | 12 | /** 13 | * 统一拦截Controller中所有方法的返回值 14 | * 封装后返回ResponseResult 15 | */ 16 | @ControllerAdvice(basePackages = "com.movie.api") 17 | public class GlobalResponseHandler implements ResponseBodyAdvice { 18 | 19 | @Override 20 | public boolean supports(MethodParameter methodParameter, Class c) { 21 | //如果方法上带有DisableBaseResponse注解, 不处理返回false 22 | return !methodParameter.hasMethodAnnotation(DisableBaseResponse.class); 23 | } 24 | 25 | @Override 26 | public ResponseResult beforeBodyWrite(Object o, MethodParameter methodParameter, MediaType mediaType, Class aClass, 27 | ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) { 28 | if (o == null) { 29 | return new ResponseResult<>(); 30 | } 31 | return new ResponseResult<>(o); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/ActivityMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.Activity; 5 | import org.mapstruct.Mapper; 6 | 7 | @Mapper 8 | public interface ActivityMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/AdminMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.Admin; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface AdminMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/ArrangementMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.Arrangement; 5 | import org.mapstruct.Mapper; 6 | 7 | @Mapper 8 | public interface ArrangementMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/CartMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.Cart; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface CartMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/DailyWorkMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.DailyWork; 5 | import org.mapstruct.Mapper; 6 | 7 | @Mapper 8 | public interface DailyWorkMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/FilmEvaluateMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.FilmEvaluate; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface FilmEvaluateMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/FilmMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.Film; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface FilmMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/LeavingMessageMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.LeavingMessage; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface LeavingMessageMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/OrderExceptionMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.OrderException; 5 | import org.mapstruct.Mapper; 6 | 7 | @Mapper 8 | public interface OrderExceptionMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/OrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.Order; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface OrderMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/PosterMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.Poster; 5 | import org.mapstruct.Mapper; 6 | 7 | @Mapper 8 | public interface PosterMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/RegistrationMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.Registration; 5 | import org.mapstruct.Mapper; 6 | 7 | @Mapper 8 | public interface RegistrationMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.Role; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface RoleMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/UploadMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.Upload; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface UploadMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.User; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface UserMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/WorkerEvaluateMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.WorkerEvaluate; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface WorkerEvaluateMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/mapper/WorkerMapper.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.movie.api.model.entity.Worker; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface WorkerMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/dto/CreateCartDto.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.dto; 2 | 3 | public class CreateCartDto { 4 | } 5 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/dto/LoginDto.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.dto; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class LoginDto { 7 | 8 | private String username; 9 | 10 | private String password; 11 | 12 | private boolean remember; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/dto/UpdateRolesDto.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.dto; 2 | 3 | import com.movie.api.model.entity.Role; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | @Data 9 | public class UpdateRolesDto { 10 | 11 | private String uid; 12 | 13 | private List roles; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/Activity.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 影院活动 11 | */ 12 | @Data 13 | @TableName("t_activity") 14 | @NoArgsConstructor 15 | public class Activity implements Serializable { 16 | 17 | private String id; 18 | 19 | private String content; 20 | 21 | private Integer number; 22 | 23 | private String startTime; 24 | 25 | private String endTime; 26 | 27 | private String createAt; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/Admin.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 管理员 12 | */ 13 | @Data 14 | @TableName("t_admin") 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class Admin implements Serializable { 18 | 19 | private String id; 20 | 21 | private String username; 22 | 23 | private String password; 24 | 25 | private String avatar; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/Arrangement.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 电影的排片 播放场次 开放多少个座位 12 | */ 13 | @Data 14 | @TableName("t_arrangement") 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class Arrangement implements Serializable { 18 | 19 | private String id; 20 | 21 | //电影id 22 | private String fid; 23 | 24 | //电影名 25 | private String name; 26 | 27 | //开放多少座位 28 | private Integer seatNumber; 29 | 30 | //价格 31 | private double price; 32 | 33 | //放映类型 2D 3D 34 | private String type; 35 | 36 | //电影开始时间 2021-01-01 37 | private String date; 38 | 39 | //电影开始时间 19:30:00 40 | private String startTime; 41 | 42 | //票房统计 43 | private Integer boxOffice; 44 | 45 | //结束时间 46 | private String endTime; 47 | 48 | //创建人 49 | private String founder; 50 | 51 | //创建时间 52 | private String createAt; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/Cart.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 购物车 11 | */ 12 | @Data 13 | @TableName("t_cart") 14 | @NoArgsConstructor 15 | public class Cart implements Serializable { 16 | 17 | private String id; 18 | 19 | //用户id 20 | private String uid; 21 | 22 | //场次id 23 | private String aid; 24 | 25 | //座位号 26 | private String seats; 27 | 28 | private String phone; 29 | 30 | private Integer status; 31 | 32 | //金额 33 | private double price; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/DailyWork.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 员工的每日工作 10 | */ 11 | @Data 12 | @TableName("t_daily_work") 13 | public class DailyWork implements Serializable { 14 | 15 | private String id; 16 | 17 | //重要 一般 非常重要 18 | private int type; 19 | 20 | //工作内容 21 | private String content; 22 | 23 | //上传时间 24 | private String createAt; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/Film.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 电影 12 | */ 13 | @Data 14 | @TableName("t_film") 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class Film implements Serializable { 18 | 19 | private String id; 20 | 21 | private String name; 22 | 23 | //上映时间 24 | private String releaseTime; 25 | 26 | //类型 27 | private String type; 28 | 29 | //状态 30 | private boolean status; 31 | 32 | //地区 中国,美国,韩国 ...... 33 | private String region; 34 | 35 | //电影简介 36 | private String introduction; 37 | 38 | //热度 39 | private Integer hot; 40 | 41 | //封面图片 42 | private String cover; 43 | 44 | //电影时长 单位:分钟 45 | private Integer duration; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/FilmEvaluate.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 电影评价 11 | */ 12 | @Data 13 | @TableName("t_film_evaluate") 14 | @NoArgsConstructor 15 | public class FilmEvaluate implements Serializable { 16 | 17 | private String id; 18 | 19 | //电影id 20 | private String fid; 21 | 22 | //用户id 23 | private String uid; 24 | 25 | //星级 26 | private Integer star; 27 | 28 | //评语 29 | private String comment; 30 | 31 | private String createAt; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/LeavingMessage.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 留言 11 | */ 12 | @Data 13 | @TableName("t_leaving_message") 14 | @NoArgsConstructor 15 | public class LeavingMessage implements Serializable { 16 | 17 | private String id; 18 | 19 | //用户ID 20 | private String uid; 21 | 22 | private String reply; 23 | 24 | //内容 25 | private String content; 26 | 27 | private String createAt; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/Order.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 订单 12 | */ 13 | @Data 14 | @TableName("t_order") 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class Order implements Serializable { 18 | 19 | private String id; 20 | 21 | //用户id 22 | private String uid; 23 | 24 | //取票电话 25 | private String phone; 26 | 27 | //场次id 28 | private String aid; 29 | 30 | //座位 31 | private String seats; 32 | 33 | //金额 34 | private double price; 35 | 36 | //状态 37 | private Integer status; 38 | 39 | //创建时间 40 | private String createAt; 41 | 42 | //更新时间 43 | private String payAt; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/OrderException.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 订单异常 12 | */ 13 | @Data 14 | @TableName("t_order_exception") 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class OrderException implements Serializable { 18 | 19 | private String id; 20 | 21 | //订单id 22 | private String oid; 23 | 24 | //异常原因 25 | private String reason; 26 | 27 | //审核人 申报人 28 | private String reviewer; 29 | 30 | //true 已处理 31 | //false 待处理 32 | private boolean status; 33 | 34 | private String result; 35 | 36 | private String createAt; 37 | 38 | private String endAt; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/Poster.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 首页海报 10 | */ 11 | @Data 12 | @TableName("t_poster") 13 | public class Poster implements Serializable { 14 | 15 | private String id; 16 | 17 | private String title; 18 | 19 | private String url; 20 | 21 | //上架 下架 22 | private boolean status; 23 | 24 | private String createAt; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/Registration.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 活动报名 10 | */ 11 | @Data 12 | @TableName("t_registration") 13 | public class Registration implements Serializable { 14 | 15 | private String id; 16 | 17 | //活动id 18 | private String aid; 19 | 20 | //报名用户id 21 | private String uid; 22 | 23 | private String createAt; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/Role.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 权限角色 12 | */ 13 | @Data 14 | @TableName("t_role") 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class Role implements Serializable { 18 | 19 | private String id; 20 | 21 | private String wid; 22 | 23 | private String value; 24 | 25 | private String createAt; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/Upload.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 上传的图片 12 | */ 13 | @Data 14 | @TableName("t_upload") 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class Upload implements Serializable { 18 | 19 | private String id; 20 | 21 | private byte[] bytes; 22 | 23 | //文件的md5值 24 | private String md5; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 用户 12 | */ 13 | @Data 14 | @TableName("t_user") 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class User implements Serializable { 18 | 19 | private String id; 20 | 21 | private String username; 22 | 23 | private String password; 24 | 25 | //昵称 26 | private String nickname; 27 | 28 | //邮箱 29 | private String email; 30 | 31 | //生日 32 | private String birthday; 33 | 34 | //性别 35 | private String gender; 36 | 37 | //个人简介 38 | private String info; 39 | 40 | //用户头像URL 41 | private String avatar; 42 | 43 | private String createAt; 44 | 45 | private String updateAt; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/Worker.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 影院客服 12 | */ 13 | @Data 14 | @TableName("t_worker") 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class Worker implements Serializable { 18 | 19 | private String id; 20 | 21 | private String username; 22 | 23 | private String password; 24 | 25 | private String nickname; 26 | 27 | private String gender; 28 | 29 | private String phone; 30 | 31 | private String avatar; 32 | 33 | //入职 34 | private boolean entry; 35 | 36 | //部门 37 | private String department; 38 | 39 | private String createAt; 40 | 41 | private String updateAt; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/entity/WorkerEvaluate.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 客服评价 11 | */ 12 | @Data 13 | @TableName("t_worker_evaluate") 14 | @NoArgsConstructor 15 | public class WorkerEvaluate implements Serializable { 16 | 17 | private String id; 18 | 19 | //客服id 20 | private String wid; 21 | 22 | //评价的用户id 23 | private String uid; 24 | 25 | //评价内容 26 | private String content; 27 | 28 | //满意 非常满意 29 | private String type; 30 | 31 | private String createAt; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/support/ResponseResult.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.support; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | 7 | @Data 8 | @ApiModel(value = "api返回结果") 9 | @AllArgsConstructor 10 | public class ResponseResult { 11 | 12 | private Integer code; 13 | 14 | private boolean success; 15 | 16 | private String msg; 17 | 18 | private T data; 19 | 20 | public ResponseResult() { 21 | this.code = 200; 22 | this.success = true; 23 | this.msg = null; 24 | this.data = null; 25 | } 26 | 27 | //不附带msg返回数据 28 | public ResponseResult(T data) { 29 | this.code = 200; 30 | this.success = true; 31 | this.msg = null; 32 | this.data = data; 33 | } 34 | 35 | //默认附带msg返回数据 36 | public ResponseResult(String msg, T data) { 37 | this.code = 200; 38 | this.success = true; 39 | this.msg = msg; 40 | this.data = data; 41 | } 42 | 43 | //默认的错误返回 44 | public ResponseResult(Integer code, String msg) { 45 | this.code = code; 46 | this.success = false; 47 | this.msg = msg; 48 | this.data = null; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/vo/ActiveUserVO.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.vo; 2 | 3 | import com.movie.api.model.entity.User; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class ActiveUserVO { 12 | 13 | private User user; 14 | 15 | private Integer Number; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/vo/ArrangementVO.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.vo; 2 | 3 | import com.movie.api.model.entity.Arrangement; 4 | import com.movie.api.model.entity.Film; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | 8 | import java.util.List; 9 | 10 | @Data 11 | @AllArgsConstructor 12 | public class ArrangementVO { 13 | 14 | private List arrangements; 15 | 16 | private Film film; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/vo/CartVO.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.vo; 2 | 3 | import com.movie.api.model.entity.Arrangement; 4 | import com.movie.api.model.entity.Cart; 5 | import com.movie.api.model.entity.Film; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | /** 11 | * 购物车前端展示 12 | */ 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | public class CartVO { 17 | 18 | private Film film; 19 | 20 | private Arrangement arrangement; 21 | 22 | private Cart cart; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/vo/FilmEvaluateVO.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.vo; 2 | 3 | import com.movie.api.model.entity.FilmEvaluate; 4 | import com.movie.api.model.entity.User; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | * 电影评分前端展示 13 | */ 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | public class FilmEvaluateVO implements Serializable { 18 | 19 | private String id; 20 | 21 | private FilmEvaluate filmEvaluate; 22 | 23 | private User user; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/vo/LeavingMessageVO.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.vo; 2 | 3 | import com.movie.api.model.entity.LeavingMessage; 4 | import com.movie.api.model.entity.User; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | 8 | import java.io.Serializable; 9 | 10 | @Data 11 | @AllArgsConstructor 12 | public class LeavingMessageVO implements Serializable { 13 | 14 | private String id; 15 | 16 | private LeavingMessage leavingMessage; 17 | 18 | private User user; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/vo/OrderVO.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.vo; 2 | 3 | import com.movie.api.model.entity.Arrangement; 4 | import com.movie.api.model.entity.Film; 5 | import com.movie.api.model.entity.Order; 6 | import com.movie.api.model.entity.User; 7 | import lombok.Data; 8 | 9 | @Data 10 | public class OrderVO { 11 | 12 | private Order order; 13 | 14 | private User user; 15 | 16 | private Film film; 17 | 18 | private Arrangement arrangement; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/model/vo/WorkerEvaluateVO.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.model.vo; 2 | 3 | import com.movie.api.model.entity.User; 4 | import com.movie.api.model.entity.WorkerEvaluate; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @Data 10 | public class WorkerEvaluateVO implements Serializable { 11 | 12 | private String id; 13 | 14 | private WorkerEvaluate workerEvaluate; 15 | 16 | private User user; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/ActivityService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.entity.Activity; 4 | 5 | import java.util.List; 6 | 7 | public interface ActivityService { 8 | 9 | void create(Activity activity); 10 | 11 | Activity findById(String id); 12 | 13 | List findAll(); 14 | 15 | void deleteById(String id); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/AdminService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.dto.LoginDto; 4 | 5 | public interface AdminService { 6 | 7 | String login(LoginDto loginDto) throws Exception; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/ArrangementService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.entity.Arrangement; 4 | import com.movie.api.model.vo.ArrangementVO; 5 | 6 | import java.util.List; 7 | 8 | public interface ArrangementService { 9 | 10 | void save(Arrangement arrangement); 11 | 12 | List findAll(); 13 | 14 | ArrangementVO findByFilmId(String fid); 15 | 16 | List getSeatsHaveSelected(String id); 17 | 18 | Arrangement findById(String id); 19 | 20 | void deleteById(String id); 21 | 22 | Arrangement Update(Arrangement arrangement); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/CartService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.entity.Cart; 4 | import com.movie.api.model.vo.CartVO; 5 | 6 | import java.util.List; 7 | 8 | public interface CartService { 9 | 10 | void save(Cart cart) throws Exception; 11 | 12 | void deleteById(String id); 13 | 14 | void deleteAllByUserId(String uid); 15 | 16 | List findAllByUserId(String uid); 17 | 18 | //删除用户选中的购物车 19 | void deleteCarts(List carts); 20 | 21 | //结算用户选中的购物车 22 | void settleCarts(List carts) throws Exception; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/DailyWorkService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.entity.DailyWork; 4 | 5 | import java.util.List; 6 | 7 | public interface DailyWorkService { 8 | 9 | void save(DailyWork dailyWork); 10 | 11 | List findAll(); 12 | 13 | void deleteById(String id); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/FilmEvaluateService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.entity.FilmEvaluate; 4 | import com.movie.api.model.vo.FilmEvaluateVO; 5 | 6 | import java.util.List; 7 | 8 | public interface FilmEvaluateService { 9 | 10 | void save(FilmEvaluate filmEvaluate) throws Exception; 11 | 12 | List findAllByFilmId(String fid); 13 | 14 | void deleteAllByFilmId(String fid); 15 | 16 | void deleteById(String id); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/FilmService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.entity.Film; 4 | 5 | import java.util.List; 6 | 7 | public interface FilmService { 8 | 9 | void save(Film film); 10 | 11 | void deleteById(String id); 12 | 13 | List findAll(); 14 | 15 | List findByRegionAndType(String region, String type); 16 | 17 | //获取热门电影 18 | List findHots(Integer limit); 19 | 20 | //根据电影名模糊查询 21 | List findLikeName(String name); 22 | 23 | Film findById(String id); 24 | 25 | Film update(Film film); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/LeavingMessageService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.entity.LeavingMessage; 4 | import com.movie.api.model.entity.User; 5 | import com.movie.api.model.vo.ActiveUserVO; 6 | import com.movie.api.model.vo.LeavingMessageVO; 7 | 8 | import java.util.List; 9 | 10 | public interface LeavingMessageService { 11 | 12 | void save(LeavingMessage leavingMessage); 13 | 14 | void reply(LeavingMessage leavingMessage); 15 | 16 | List findAll(); 17 | 18 | //获取活跃留言的用户 19 | List findActiveUsers(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/OrderExceptionService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.entity.OrderException; 4 | 5 | import java.util.List; 6 | 7 | public interface OrderExceptionService { 8 | 9 | OrderException create(OrderException orderException); 10 | 11 | List findAll(); 12 | 13 | void handleException(OrderException orderException); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.entity.Cart; 4 | import com.movie.api.model.entity.Order; 5 | import com.movie.api.model.vo.OrderVO; 6 | 7 | import java.util.List; 8 | 9 | public interface OrderService { 10 | 11 | Order create(Cart cart) throws Exception; 12 | 13 | Order pay(String id) throws Exception; 14 | 15 | void update(Order order); 16 | 17 | List findAll(); 18 | 19 | List findByUser(String uid); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/PosterService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.entity.Poster; 4 | 5 | import java.util.List; 6 | 7 | public interface PosterService { 8 | 9 | void save(Poster poster); 10 | 11 | void update(Poster poster); 12 | 13 | List findAll(); 14 | 15 | List findByStatus(boolean status); 16 | 17 | void deleteById(String id); 18 | 19 | void deleteAll(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/RegistrationService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.entity.Registration; 4 | 5 | import java.util.List; 6 | 7 | public interface RegistrationService { 8 | 9 | void create(Registration registration) throws Exception; 10 | 11 | Registration findById(String id); 12 | 13 | List findAll(); 14 | 15 | void deleteById(String id); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.entity.Role; 4 | 5 | import java.util.List; 6 | 7 | public interface RoleService { 8 | 9 | Role create(Role role) throws Exception; 10 | 11 | void deleteById(String id) throws Exception; 12 | 13 | List listRolesByWorkerId(String wid); 14 | 15 | void deleteWorkerAllRoles(String wid); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/UploadService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import org.springframework.web.multipart.MultipartFile; 4 | 5 | public interface UploadService { 6 | 7 | //检验文件并且保存 返回值为Upload字段的id 8 | String checkAndSaveUpload(MultipartFile file); 9 | 10 | void deleteById(String id); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.dto.LoginDto; 4 | import com.movie.api.model.entity.User; 5 | 6 | import java.util.List; 7 | 8 | public interface UserService { 9 | 10 | User login(LoginDto dto) throws Exception; 11 | 12 | List findAll(); 13 | 14 | User findById(String id); 15 | 16 | User update(User user); 17 | 18 | User save(User user) throws Exception; 19 | 20 | User findByUsername(String username); 21 | 22 | void deleteById(String id); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/WorkerEvaluateService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.entity.WorkerEvaluate; 4 | 5 | import java.util.List; 6 | 7 | public interface WorkerEvaluateService { 8 | 9 | void save(WorkerEvaluate workerEvaluate); 10 | 11 | void deleteById(String id); 12 | 13 | //删除该客服的所有评价 14 | void deleteAllByWid(String wid); 15 | 16 | //根据客服id查询他的所有评价 17 | List findByWorkerId(String wid); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/WorkerService.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service; 2 | 3 | import com.movie.api.model.dto.LoginDto; 4 | import com.movie.api.model.entity.Worker; 5 | 6 | import java.util.List; 7 | 8 | public interface WorkerService { 9 | 10 | Worker create(Worker worker) throws Exception; 11 | 12 | Worker login(LoginDto dto) throws Exception; 13 | 14 | void update(Worker worker) throws Exception; 15 | 16 | List findAll(); 17 | 18 | Worker findById(String id); 19 | 20 | void deleteById(String id); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/ActivityServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.movie.api.mapper.ActivityMapper; 4 | import com.movie.api.model.entity.Activity; 5 | import com.movie.api.service.ActivityService; 6 | import com.movie.api.utils.DataTimeUtil; 7 | import org.springframework.stereotype.Service; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | import java.util.UUID; 12 | 13 | @Service 14 | public class ActivityServiceImpl implements ActivityService { 15 | 16 | @Resource 17 | private ActivityMapper activityMapper; 18 | 19 | @Override 20 | public void create(Activity activity) { 21 | activity.setId(UUID.randomUUID().toString()); 22 | activity.setCreateAt(DataTimeUtil.getNowTimeString()); 23 | activityMapper.insert(activity); 24 | } 25 | 26 | @Override 27 | public Activity findById(String id) { 28 | return activityMapper.selectById(id); 29 | } 30 | 31 | @Override 32 | public List findAll() { 33 | return activityMapper.selectList(null); 34 | } 35 | 36 | @Override 37 | public void deleteById(String id) { 38 | activityMapper.deleteById(id); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/AdminServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.movie.api.constant.Roles; 5 | import com.movie.api.mapper.AdminMapper; 6 | import com.movie.api.model.dto.LoginDto; 7 | import com.movie.api.model.entity.Admin; 8 | import com.movie.api.service.AdminService; 9 | import com.movie.api.utils.JwtTokenUtil; 10 | import org.springframework.stereotype.Service; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | @Service 17 | public class AdminServiceImpl implements AdminService { 18 | 19 | @Resource 20 | private AdminMapper adminMapper; 21 | 22 | @Override 23 | public String login(LoginDto loginDto) throws Exception { 24 | QueryWrapper wrapper = new QueryWrapper<>(); 25 | wrapper.in("username", loginDto.getUsername()); 26 | wrapper.in("password", loginDto.getPassword()); 27 | Admin admin = adminMapper.selectOne(wrapper); 28 | if (admin == null) throw new Exception("用户名密码错误"); 29 | //是否选择记住我 30 | long exp = loginDto.isRemember() ? JwtTokenUtil.REMEMBER_EXPIRATION_TIME : JwtTokenUtil.EXPIRATION_TIME; 31 | List roles = new ArrayList<>(); 32 | roles.add(Roles.ROLE_ADMIN); 33 | return JwtTokenUtil.createToken(loginDto.getUsername(), roles, exp); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/ArrangementServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.movie.api.mapper.ArrangementMapper; 5 | import com.movie.api.mapper.FilmMapper; 6 | import com.movie.api.mapper.OrderMapper; 7 | import com.movie.api.model.entity.Arrangement; 8 | import com.movie.api.model.entity.Order; 9 | import com.movie.api.model.vo.ArrangementVO; 10 | import com.movie.api.service.ArrangementService; 11 | import com.movie.api.utils.DataTimeUtil; 12 | import org.springframework.stereotype.Service; 13 | 14 | import javax.annotation.Resource; 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | @Service 19 | public class ArrangementServiceImpl implements ArrangementService { 20 | 21 | @Resource 22 | private ArrangementMapper arrangementMapper; 23 | 24 | @Resource 25 | private FilmMapper filmMapper; 26 | 27 | @Resource 28 | private OrderMapper orderMapper; 29 | 30 | @Override 31 | public void save(Arrangement arrangement) { 32 | arrangement.setBoxOffice(0); 33 | arrangement.setCreateAt(DataTimeUtil.getNowTimeString()); 34 | arrangementMapper.insert(arrangement); 35 | } 36 | 37 | @Override 38 | public List findAll() { 39 | return arrangementMapper.selectList(null); 40 | } 41 | 42 | @Override 43 | public ArrangementVO findByFilmId(String fid) { 44 | List list = arrangementMapper.selectList(new QueryWrapper().in("fid", fid)); 45 | return new ArrangementVO(list, filmMapper.selectById(fid)); 46 | } 47 | 48 | @Override 49 | public List getSeatsHaveSelected(String id) { 50 | List orders = orderMapper.selectList(new QueryWrapper().in("aid", id)); 51 | List seats = new ArrayList<>(); 52 | for (Order o : orders) { 53 | String[] split = o.getSeats().split("号"); 54 | for (String s : split) { 55 | seats.add(Integer.parseInt(s)); 56 | } 57 | } 58 | return seats; 59 | } 60 | 61 | @Override 62 | public Arrangement findById(String id) { 63 | return arrangementMapper.selectById(id); 64 | } 65 | 66 | @Override 67 | public void deleteById(String id) { 68 | arrangementMapper.deleteById(id); 69 | } 70 | 71 | @Override 72 | public Arrangement Update(Arrangement arrangement) { 73 | arrangementMapper.updateById(arrangement); 74 | return arrangement; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/CartServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.movie.api.mapper.ArrangementMapper; 5 | import com.movie.api.mapper.CartMapper; 6 | import com.movie.api.mapper.FilmMapper; 7 | import com.movie.api.model.entity.Arrangement; 8 | import com.movie.api.model.entity.Cart; 9 | import com.movie.api.model.entity.Film; 10 | import com.movie.api.model.entity.Order; 11 | import com.movie.api.model.vo.CartVO; 12 | import com.movie.api.service.CartService; 13 | import com.movie.api.service.OrderService; 14 | import org.springframework.cache.annotation.CacheConfig; 15 | import org.springframework.cache.annotation.CacheEvict; 16 | import org.springframework.cache.annotation.Cacheable; 17 | import org.springframework.stereotype.Service; 18 | 19 | import javax.annotation.Resource; 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | @Service 24 | @CacheConfig(cacheNames = "cart") 25 | public class CartServiceImpl implements CartService { 26 | 27 | @Resource 28 | private CartMapper cartMapper; 29 | 30 | @Resource 31 | private OrderService orderService; 32 | 33 | @Resource 34 | private ArrangementMapper arrangementMapper; 35 | 36 | @Resource 37 | private FilmMapper filmMapper; 38 | 39 | @Override 40 | public void save(Cart cart) throws Exception { 41 | cartMapper.insert(cart); 42 | } 43 | 44 | @Override 45 | @CacheEvict 46 | public void deleteById(String id) { 47 | cartMapper.deleteById(id); 48 | } 49 | 50 | @Override 51 | @CacheEvict 52 | public void deleteAllByUserId(String uid) { 53 | cartMapper.delete(new QueryWrapper().in("uid", uid)); 54 | } 55 | 56 | @Override 57 | @Cacheable 58 | public List findAllByUserId(String uid) { 59 | List result = new ArrayList<>(); 60 | List carts = cartMapper.selectList(new QueryWrapper().in("uid", uid)); 61 | for (Cart c : carts) { 62 | Arrangement arrangement = arrangementMapper.selectById(c.getAid()); 63 | Film film = filmMapper.selectById(arrangement.getFid()); 64 | CartVO cartVO = new CartVO(film, arrangement, c); 65 | result.add(cartVO); 66 | } 67 | return result; 68 | } 69 | 70 | @Override 71 | public void deleteCarts(List carts) { 72 | for (Cart c : carts) { 73 | cartMapper.deleteById(c.getId()); 74 | } 75 | } 76 | 77 | @Override 78 | public void settleCarts(List carts) throws Exception { 79 | for (Cart c : carts) { 80 | orderService.create(c); 81 | } 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/DailyWorkServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.movie.api.mapper.DailyWorkMapper; 4 | import com.movie.api.model.entity.DailyWork; 5 | import com.movie.api.service.DailyWorkService; 6 | import com.movie.api.utils.DataTimeUtil; 7 | import org.springframework.stereotype.Service; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | import java.util.UUID; 12 | 13 | @Service 14 | public class DailyWorkServiceImpl implements DailyWorkService { 15 | 16 | @Resource 17 | private DailyWorkMapper dailyWorkMapper; 18 | 19 | @Override 20 | public void save(DailyWork dailyWork) { 21 | dailyWork.setId(UUID.randomUUID().toString()); 22 | dailyWork.setCreateAt(DataTimeUtil.getNowTimeString()); 23 | dailyWorkMapper.insert(dailyWork); 24 | } 25 | 26 | @Override 27 | public List findAll() { 28 | return dailyWorkMapper.selectList(null); 29 | } 30 | 31 | @Override 32 | public void deleteById(String id) { 33 | dailyWorkMapper.deleteById(id); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/FilmEvaluateServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.movie.api.mapper.FilmEvaluateMapper; 5 | import com.movie.api.mapper.FilmMapper; 6 | import com.movie.api.mapper.UserMapper; 7 | import com.movie.api.model.entity.Film; 8 | import com.movie.api.model.entity.FilmEvaluate; 9 | import com.movie.api.model.vo.FilmEvaluateVO; 10 | import com.movie.api.service.FilmEvaluateService; 11 | import com.movie.api.utils.DataTimeUtil; 12 | import org.springframework.cache.annotation.CacheConfig; 13 | import org.springframework.stereotype.Service; 14 | 15 | import javax.annotation.Resource; 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | @Service 20 | @CacheConfig(cacheNames = "filmEvaluate") 21 | public class FilmEvaluateServiceImpl implements FilmEvaluateService { 22 | 23 | @Resource 24 | private FilmEvaluateMapper filmEvaluateMapper; 25 | 26 | @Resource 27 | private FilmMapper filmMapper; 28 | 29 | @Resource 30 | private UserMapper userMapper; 31 | 32 | @Override 33 | public void save(FilmEvaluate filmEvaluate) throws Exception { 34 | QueryWrapper wrapper = new QueryWrapper<>(); 35 | wrapper.in("fid", filmEvaluate.getFid()); 36 | wrapper.in("uid", filmEvaluate.getUid()); 37 | FilmEvaluate one = filmEvaluateMapper.selectOne(wrapper); 38 | if (one != null) { 39 | throw new Exception("感谢您的参与,但是您已评分请不要重复操作!"); 40 | } 41 | filmEvaluate.setCreateAt(DataTimeUtil.getNowTimeString()); 42 | filmEvaluateMapper.insert(filmEvaluate); 43 | //为电影添加热度 44 | Film film = filmMapper.selectById(filmEvaluate.getFid()); 45 | film.setHot(film.getHot() + 1); 46 | filmMapper.updateById(film); 47 | } 48 | 49 | @Override 50 | public List findAllByFilmId(String fid) { 51 | List result = new ArrayList<>(); 52 | List filmEvaluates = filmEvaluateMapper.selectList(new QueryWrapper().in("fid", fid)); 53 | for (FilmEvaluate f : filmEvaluates) { 54 | FilmEvaluateVO filmEvaluateVO = new FilmEvaluateVO(); 55 | filmEvaluateVO.setUser(userMapper.selectById(f.getUid())); 56 | filmEvaluateVO.setFilmEvaluate(f); 57 | filmEvaluateVO.setId(f.getId()); 58 | result.add(filmEvaluateVO); 59 | } 60 | return result; 61 | } 62 | 63 | @Override 64 | public void deleteAllByFilmId(String fid) { 65 | filmEvaluateMapper.delete(new QueryWrapper().in("fid", fid)); 66 | } 67 | 68 | @Override 69 | public void deleteById(String id) { 70 | filmEvaluateMapper.deleteById(id); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/FilmServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.movie.api.mapper.FilmMapper; 5 | import com.movie.api.model.entity.Film; 6 | import com.movie.api.service.FilmService; 7 | import org.springframework.cache.annotation.CacheConfig; 8 | import org.springframework.cache.annotation.CacheEvict; 9 | import org.springframework.cache.annotation.Cacheable; 10 | import org.springframework.stereotype.Service; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | 15 | @Service 16 | @CacheConfig(cacheNames = "film") 17 | public class FilmServiceImpl implements FilmService { 18 | 19 | @Resource 20 | private FilmMapper filmMapper; 21 | 22 | @Override 23 | public void save(Film film) { 24 | film.setHot(0); 25 | filmMapper.insert(film); 26 | } 27 | 28 | @CacheEvict 29 | @Override 30 | public void deleteById(String id) { 31 | filmMapper.deleteById(id); 32 | } 33 | 34 | @Cacheable 35 | @Override 36 | public List findAll() { 37 | return filmMapper.selectList(null); 38 | } 39 | 40 | @Override 41 | public List findByRegionAndType(String region, String type) { 42 | QueryWrapper wrapper = new QueryWrapper<>(); 43 | if (!region.equals("全部")) { 44 | wrapper.in("region", region); 45 | } 46 | if (!type.equals("全部")) { 47 | wrapper.in("type", type); 48 | } 49 | return filmMapper.selectList(wrapper); 50 | } 51 | 52 | @Override 53 | public List findHots(Integer limit) { 54 | QueryWrapper wrapper = new QueryWrapper<>(); 55 | wrapper.orderByDesc("hot").last("limit " + limit); 56 | return filmMapper.selectList(wrapper); 57 | } 58 | 59 | @Cacheable 60 | @Override 61 | public List findLikeName(String name) { 62 | QueryWrapper wrapper = new QueryWrapper<>(); 63 | wrapper.like("name", name); 64 | return filmMapper.selectList(wrapper); 65 | } 66 | 67 | @Cacheable 68 | @Override 69 | public Film findById(String id) { 70 | return filmMapper.selectById(id); 71 | } 72 | 73 | @CacheEvict 74 | @Override 75 | public Film update(Film film) { 76 | filmMapper.updateById(film); 77 | return film; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/LeavingMessageServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.movie.api.mapper.LeavingMessageMapper; 5 | import com.movie.api.mapper.UserMapper; 6 | import com.movie.api.model.entity.LeavingMessage; 7 | import com.movie.api.model.entity.User; 8 | import com.movie.api.model.vo.ActiveUserVO; 9 | import com.movie.api.model.vo.LeavingMessageVO; 10 | import com.movie.api.service.LeavingMessageService; 11 | import com.movie.api.utils.DataTimeUtil; 12 | import org.springframework.cache.annotation.CacheConfig; 13 | import org.springframework.stereotype.Service; 14 | 15 | import javax.annotation.Resource; 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | @Service 20 | @CacheConfig(cacheNames = "leavingMessage") 21 | public class LeavingMessageServiceImpl implements LeavingMessageService { 22 | 23 | @Resource 24 | private LeavingMessageMapper leavingMessageMapper; 25 | 26 | @Resource 27 | private UserMapper userMapper; 28 | 29 | @Override 30 | public void save(LeavingMessage leavingMessage) { 31 | leavingMessage.setCreateAt(DataTimeUtil.getNowTimeString()); 32 | leavingMessageMapper.insert(leavingMessage); 33 | } 34 | 35 | @Override 36 | public void reply(LeavingMessage leavingMessage) { 37 | leavingMessageMapper.updateById(leavingMessage); 38 | } 39 | 40 | @Override 41 | public List findAll() { 42 | List list = leavingMessageMapper.selectList(null); 43 | List result = new ArrayList<>(); 44 | for (LeavingMessage m : list) { 45 | User user = userMapper.selectById(m.getUid()); 46 | result.add(new LeavingMessageVO(m.getId(), m, user)); 47 | } 48 | return result; 49 | } 50 | 51 | @Override 52 | public List findActiveUsers() { 53 | List result = new ArrayList<>(); 54 | List users = userMapper.selectList(null); 55 | for (User user : users) { 56 | ActiveUserVO activeUserVO = new ActiveUserVO(); 57 | activeUserVO.setUser(user); 58 | activeUserVO.setNumber(leavingMessageMapper.selectList( 59 | new QueryWrapper().in("uid", user.getId())).size()); 60 | result.add(activeUserVO); 61 | } 62 | //按留言数量排序 63 | result.sort((v1, v2) -> v2.getNumber().compareTo(v1.getNumber())); 64 | return result; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/OrderExceptionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.movie.api.constant.OrderStatus; 4 | import com.movie.api.mapper.OrderExceptionMapper; 5 | import com.movie.api.mapper.OrderMapper; 6 | import com.movie.api.model.entity.Order; 7 | import com.movie.api.model.entity.OrderException; 8 | import com.movie.api.service.OrderExceptionService; 9 | import com.movie.api.utils.DataTimeUtil; 10 | import org.springframework.stereotype.Service; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | import java.util.UUID; 15 | 16 | @Service 17 | public class OrderExceptionServiceImpl implements OrderExceptionService { 18 | 19 | @Resource 20 | private OrderExceptionMapper orderExceptionMapper; 21 | 22 | @Override 23 | public OrderException create(OrderException orderException) { 24 | orderException.setStatus(false); 25 | orderException.setId(UUID.randomUUID().toString()); 26 | orderException.setCreateAt(DataTimeUtil.getNowTimeString()); 27 | orderExceptionMapper.insert(orderException); 28 | return orderException; 29 | } 30 | 31 | @Override 32 | public List findAll() { 33 | return orderExceptionMapper.selectList(null); 34 | } 35 | 36 | @Override 37 | public void handleException(OrderException orderException) { 38 | orderException.setEndAt(DataTimeUtil.getNowTimeString()); 39 | orderExceptionMapper.updateById(orderException); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/OrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.movie.api.constant.OrderStatus; 5 | import com.movie.api.mapper.FilmMapper; 6 | import com.movie.api.mapper.OrderMapper; 7 | import com.movie.api.mapper.UserMapper; 8 | import com.movie.api.model.entity.Arrangement; 9 | import com.movie.api.model.entity.Cart; 10 | import com.movie.api.model.entity.Film; 11 | import com.movie.api.model.entity.Order; 12 | import com.movie.api.model.vo.OrderVO; 13 | import com.movie.api.service.ArrangementService; 14 | import com.movie.api.service.OrderService; 15 | import com.movie.api.utils.DataTimeUtil; 16 | import org.springframework.cache.annotation.CacheConfig; 17 | import org.springframework.stereotype.Service; 18 | 19 | import javax.annotation.Resource; 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | import java.util.UUID; 23 | 24 | @Service 25 | @CacheConfig(cacheNames = "order") 26 | public class OrderServiceImpl implements OrderService { 27 | 28 | @Resource 29 | private OrderMapper orderMapper; 30 | 31 | @Resource 32 | private ArrangementService arrangementService; 33 | 34 | @Resource 35 | private UserMapper userMapper; 36 | 37 | @Resource 38 | private FilmMapper filmMapper; 39 | 40 | @Override 41 | public Order create(Cart cart) throws Exception { 42 | List seats = arrangementService.getSeatsHaveSelected(cart.getAid()); 43 | String[] split = cart.getSeats().split("号"); 44 | for (String s : split) { 45 | if (seats.contains(Integer.parseInt(s))) throw new Exception("影片在购物车中躺了太长时间了,座位已被其他用户预订并支付了"); 46 | } 47 | Order order = new Order(); 48 | //生成订单id 49 | order.setId(UUID.randomUUID().toString()); 50 | //写入用户id 51 | order.setUid(cart.getUid()); 52 | //写入用户电话 53 | order.setPhone(cart.getPhone()); 54 | //写入场次id 55 | order.setAid(cart.getAid()); 56 | //写入座位信息 57 | order.setStatus(cart.getStatus()); 58 | order.setSeats(cart.getSeats()); 59 | if (cart.getStatus() == 2) order.setPayAt(DataTimeUtil.getNowTimeString()); 60 | order.setPrice(cart.getPrice()); 61 | order.setCreateAt(DataTimeUtil.getNowTimeString()); 62 | orderMapper.insert(order); 63 | 64 | //订了几个座位就添加多少热度 65 | Film film = filmMapper.selectById(arrangementService.findById(cart.getAid()).getFid()); 66 | film.setHot(film.getHot() + split.length); 67 | filmMapper.updateById(film); 68 | return order; 69 | } 70 | 71 | @Override 72 | public Order pay(String id) throws Exception { 73 | Order order = orderMapper.selectById(id); 74 | if (order == null) throw new Exception("不存在的订单id"); 75 | 76 | if (DataTimeUtil.parseTimeStamp(order.getCreateAt()) + OrderStatus.EXPIRATION_TIME 77 | < System.currentTimeMillis()) { 78 | order.setStatus(OrderStatus.PAYMENT_FAILED); 79 | orderMapper.updateById(order); 80 | throw new Exception("订单支付超时"); 81 | } 82 | 83 | order.setStatus(OrderStatus.PAYMENT_SUCCESSFUL); 84 | order.setPayAt(DataTimeUtil.getNowTimeString()); 85 | orderMapper.updateById(order); 86 | return order; 87 | } 88 | 89 | @Override 90 | public void update(Order order) { 91 | orderMapper.updateById(order); 92 | } 93 | 94 | @Override 95 | public List findAll() { 96 | return findByWrapper(new QueryWrapper<>()); 97 | } 98 | 99 | @Override 100 | public List findByUser(String uid) { 101 | QueryWrapper wrapper = new QueryWrapper<>(); 102 | wrapper.in("uid", uid); 103 | return findByWrapper(wrapper); 104 | } 105 | 106 | private List findByWrapper(QueryWrapper wrapper) { 107 | List orders = orderMapper.selectList(wrapper); 108 | List result = new ArrayList<>(); 109 | for (Order o : orders) { 110 | OrderVO orderVO = new OrderVO(); 111 | orderVO.setOrder(o); 112 | orderVO.setUser(userMapper.selectById(o.getUid())); 113 | Arrangement arrangement = arrangementService.findById(o.getAid()); 114 | orderVO.setArrangement(arrangement); 115 | orderVO.setFilm(filmMapper.selectById(arrangement.getFid())); 116 | result.add(orderVO); 117 | } 118 | return result; 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/PosterServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.movie.api.mapper.PosterMapper; 5 | import com.movie.api.model.entity.Poster; 6 | import com.movie.api.service.PosterService; 7 | import com.movie.api.utils.DataTimeUtil; 8 | import org.springframework.stereotype.Service; 9 | 10 | import javax.annotation.Resource; 11 | import java.util.List; 12 | import java.util.UUID; 13 | 14 | @Service 15 | public class PosterServiceImpl implements PosterService { 16 | 17 | @Resource 18 | private PosterMapper posterMapper; 19 | 20 | @Override 21 | public void save(Poster poster) { 22 | poster.setId(UUID.randomUUID().toString()); 23 | poster.setCreateAt(DataTimeUtil.getNowTimeString()); 24 | posterMapper.insert(poster); 25 | } 26 | 27 | @Override 28 | public void update(Poster poster) { 29 | posterMapper.updateById(poster); 30 | } 31 | 32 | @Override 33 | public List findAll() { 34 | return posterMapper.selectList(null); 35 | } 36 | 37 | @Override 38 | public List findByStatus(boolean status) { 39 | QueryWrapper wrapper = new QueryWrapper<>(); 40 | wrapper.in("status", status); 41 | return posterMapper.selectList(wrapper); 42 | } 43 | 44 | @Override 45 | public void deleteById(String id) { 46 | posterMapper.deleteById(id); 47 | } 48 | 49 | @Override 50 | public void deleteAll() { 51 | posterMapper.delete(null); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/RegistrationServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.movie.api.mapper.ActivityMapper; 5 | import com.movie.api.mapper.RegistrationMapper; 6 | import com.movie.api.model.entity.Activity; 7 | import com.movie.api.model.entity.Registration; 8 | import com.movie.api.service.RegistrationService; 9 | import com.movie.api.utils.DataTimeUtil; 10 | import org.springframework.stereotype.Service; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | 15 | @Service 16 | public class RegistrationServiceImpl implements RegistrationService { 17 | 18 | @Resource 19 | private RegistrationMapper registrationMapper; 20 | 21 | @Resource 22 | private ActivityMapper activityMapper; 23 | 24 | @Override 25 | public void create(Registration registration) throws Exception { 26 | //获取要参加的活动id 27 | String activityId = registration.getAid(); 28 | Activity activity = activityMapper.selectById(activityId); 29 | if (activity == null) throw new Exception("请求参数错误"); 30 | 31 | //查找用户是否已经参加 32 | QueryWrapper wrapper = new QueryWrapper<>(); 33 | wrapper.in("aid", activityId); 34 | wrapper.in("uid", registration.getUid()); 35 | if (registrationMapper.selectOne(wrapper) != null) { 36 | throw new Exception("您已经参加过此活动哦"); 37 | } 38 | 39 | //判断活动是否未开始 40 | if (DataTimeUtil.isAfterNow(activity.getStartTime())) { 41 | throw new Exception("活动还没有开始"); 42 | } 43 | //判断时候结束 44 | if (!DataTimeUtil.isAfterNow(activity.getEndTime())) { 45 | throw new Exception("活动已经结束了"); 46 | } 47 | activity.setNumber(activity.getNumber() + 1); 48 | activityMapper.updateById(activity); 49 | registration.setCreateAt(DataTimeUtil.getNowTimeString()); 50 | registrationMapper.insert(registration); 51 | } 52 | 53 | @Override 54 | public Registration findById(String id) { 55 | return registrationMapper.selectById(id); 56 | } 57 | 58 | @Override 59 | public List findAll() { 60 | return registrationMapper.selectList(null); 61 | } 62 | 63 | @Override 64 | public void deleteById(String id) { 65 | registrationMapper.deleteById(id); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.movie.api.constant.Roles; 5 | import com.movie.api.mapper.RoleMapper; 6 | import com.movie.api.model.entity.Role; 7 | import com.movie.api.service.RoleService; 8 | import com.movie.api.utils.DataTimeUtil; 9 | import org.springframework.cache.annotation.CacheConfig; 10 | import org.springframework.stereotype.Service; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | import java.util.UUID; 15 | 16 | @Service 17 | @CacheConfig(cacheNames = "role") 18 | public class RoleServiceImpl implements RoleService { 19 | 20 | @Resource 21 | private RoleMapper roleMapper; 22 | 23 | @Override 24 | public Role create(Role role) throws Exception { 25 | QueryWrapper wrapper = new QueryWrapper<>(); 26 | wrapper.in("wid", role.getWid()); 27 | wrapper.in("value", role.getValue()); 28 | if (roleMapper.selectOne(wrapper) != null) { 29 | throw new Exception("该员工已拥有该权限, 请不要重复添加"); 30 | } 31 | role.setId(UUID.randomUUID().toString()); 32 | role.setCreateAt(DataTimeUtil.getNowTimeString()); 33 | roleMapper.insert(role); 34 | return role; 35 | } 36 | 37 | @Override 38 | public void deleteById(String id) throws Exception { 39 | Role role = roleMapper.selectById(id); 40 | if (role.getValue().equals(Roles.ROLE_WORKER)) throw new Exception("员工的基本权限不能删除"); 41 | roleMapper.deleteById(id); 42 | } 43 | 44 | @Override 45 | public List listRolesByWorkerId(String wid) { 46 | QueryWrapper wrapper = new QueryWrapper<>(); 47 | wrapper.in("wid", wid); 48 | return roleMapper.selectList(wrapper); 49 | } 50 | 51 | @Override 52 | public void deleteWorkerAllRoles(String wid) { 53 | roleMapper.delete(new QueryWrapper().in("wid", wid)); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/UploadServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.movie.api.mapper.UploadMapper; 5 | import com.movie.api.model.entity.Upload; 6 | import com.movie.api.service.UploadService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.util.DigestUtils; 9 | import org.springframework.web.multipart.MultipartFile; 10 | 11 | import javax.annotation.Resource; 12 | import java.io.IOException; 13 | import java.io.InputStream; 14 | import java.util.UUID; 15 | 16 | @Service 17 | public class UploadServiceImpl implements UploadService { 18 | 19 | @Resource 20 | private UploadMapper uploadMapper; 21 | 22 | @Override 23 | public String checkAndSaveUpload(MultipartFile file) { 24 | try { 25 | InputStream is = file.getInputStream(); 26 | byte[] data = new byte[(int) file.getSize()]; 27 | int i = is.read(data); 28 | System.out.println("上传的文件大小=" + i); 29 | String md5 = DigestUtils.md5DigestAsHex(data); 30 | 31 | //判断是否有相同md5值的文件 32 | Upload one = uploadMapper.selectOne(new QueryWrapper().eq("md5", md5)); 33 | 34 | //如果存在则直接返回已存在的文件id 35 | if (one != null) return one.getId(); 36 | 37 | //不存在则存入数据库 38 | String id = UUID.randomUUID().toString(); 39 | uploadMapper.insert(new Upload(id, data, md5)); 40 | return id; 41 | } catch (IOException e) { 42 | e.printStackTrace(); 43 | } 44 | return null; 45 | } 46 | 47 | @Override 48 | public void deleteById(String id) { 49 | uploadMapper.deleteById(id); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.movie.api.mapper.UserMapper; 5 | import com.movie.api.model.dto.LoginDto; 6 | import com.movie.api.model.entity.User; 7 | import com.movie.api.service.UserService; 8 | import com.movie.api.utils.DataTimeUtil; 9 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 10 | import org.springframework.stereotype.Service; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | import java.util.UUID; 15 | 16 | @Service 17 | public class UserServiceImpl implements UserService { 18 | 19 | @Resource 20 | private UserMapper userMapper; 21 | 22 | @Resource 23 | private BCryptPasswordEncoder bCryptPasswordEncoder; 24 | 25 | @Override 26 | public User login(LoginDto dto) throws Exception { 27 | QueryWrapper wrapper = new QueryWrapper<>(); 28 | wrapper.in("username", dto.getUsername()); 29 | User user = userMapper.selectOne(wrapper); 30 | if (user == null){ 31 | throw new Exception("用户名或密码错误"); 32 | } 33 | if (!bCryptPasswordEncoder.matches(dto.getPassword(), user.getPassword())) { 34 | throw new Exception("用户名或密码错误"); 35 | } 36 | return user; 37 | } 38 | 39 | @Override 40 | public List findAll() { 41 | return userMapper.selectList(null); 42 | } 43 | 44 | @Override 45 | public User findById(String id) { 46 | return userMapper.selectById(id); 47 | } 48 | 49 | @Override 50 | public User update(User user) { 51 | user.setPassword(bCryptPasswordEncoder.encode(user.getPassword())); 52 | userMapper.updateById(user); 53 | return user; 54 | } 55 | 56 | @Override 57 | public User save(User user) throws Exception { 58 | if (findByUsername(user.getUsername()) != null) { 59 | throw new Exception("用户名已注册"); 60 | } 61 | String now = DataTimeUtil.getNowTimeString(); 62 | user.setId(UUID.randomUUID().toString()); 63 | user.setCreateAt(now); 64 | user.setUpdateAt(now); 65 | user.setPassword(bCryptPasswordEncoder.encode(user.getPassword())); 66 | userMapper.insert(user); 67 | return user; 68 | } 69 | 70 | @Override 71 | public User findByUsername(String username) { 72 | QueryWrapper queryWrapper = new QueryWrapper<>(); 73 | queryWrapper.in("username", username); 74 | return userMapper.selectOne(queryWrapper); 75 | } 76 | 77 | @Override 78 | public void deleteById(String id) { 79 | userMapper.deleteById(id); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/WorkerEvaluateServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.movie.api.mapper.WorkerEvaluateMapper; 5 | import com.movie.api.model.entity.WorkerEvaluate; 6 | import com.movie.api.service.WorkerEvaluateService; 7 | import com.movie.api.utils.DataTimeUtil; 8 | import org.springframework.cache.annotation.CacheConfig; 9 | import org.springframework.cache.annotation.CacheEvict; 10 | import org.springframework.stereotype.Service; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | import java.util.UUID; 15 | 16 | @Service 17 | @CacheConfig(cacheNames = "workerEvaluate") 18 | public class WorkerEvaluateServiceImpl implements WorkerEvaluateService { 19 | 20 | @Resource 21 | private WorkerEvaluateMapper workerEvaluateMapper; 22 | 23 | @Override 24 | public void save(WorkerEvaluate workerEvaluate) { 25 | workerEvaluate.setCreateAt(DataTimeUtil.getNowTimeString()); 26 | workerEvaluate.setId(UUID.randomUUID().toString()); 27 | workerEvaluateMapper.insert(workerEvaluate); 28 | } 29 | 30 | @CacheEvict 31 | @Override 32 | public void deleteById(String id) { 33 | workerEvaluateMapper.deleteById(id); 34 | } 35 | 36 | @CacheEvict 37 | @Override 38 | public void deleteAllByWid(String wid) { 39 | workerEvaluateMapper.delete(new QueryWrapper().in("wid", wid)); 40 | } 41 | 42 | @Override 43 | public List findByWorkerId(String wid) { 44 | return workerEvaluateMapper.selectList(new QueryWrapper().in("wid", wid)); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/service/impl/WorkerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.movie.api.constant.Roles; 5 | import com.movie.api.mapper.RoleMapper; 6 | import com.movie.api.mapper.WorkerMapper; 7 | import com.movie.api.model.dto.LoginDto; 8 | import com.movie.api.model.entity.Role; 9 | import com.movie.api.model.entity.Worker; 10 | import com.movie.api.service.RoleService; 11 | import com.movie.api.service.WorkerService; 12 | import com.movie.api.utils.DataTimeUtil; 13 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 14 | import org.springframework.stereotype.Service; 15 | 16 | import javax.annotation.Resource; 17 | import java.util.List; 18 | import java.util.UUID; 19 | 20 | @Service 21 | public class WorkerServiceImpl implements WorkerService { 22 | 23 | @Resource 24 | private WorkerMapper workerMapper; 25 | 26 | @Resource 27 | private RoleService roleService; 28 | 29 | @Resource 30 | private RoleMapper roleMapper; 31 | 32 | @Resource 33 | private BCryptPasswordEncoder bCryptPasswordEncoder; 34 | 35 | @Override 36 | public Worker create(Worker worker) throws Exception { 37 | if (workerMapper.selectOne(new QueryWrapper().in("username", worker.getUsername())) != null) { 38 | throw new Exception("已存在的用户名"); 39 | } 40 | String now = DataTimeUtil.getNowTimeString(); 41 | worker.setEntry(true); 42 | worker.setPassword(bCryptPasswordEncoder.encode(worker.getPassword())); 43 | worker.setId(UUID.randomUUID().toString()); 44 | worker.setCreateAt(now); 45 | worker.setUpdateAt(now); 46 | workerMapper.insert(worker); 47 | //添加worker权限 48 | roleMapper.insert(new Role(UUID.randomUUID().toString(), worker.getId(), Roles.ROLE_WORKER, now)); 49 | return worker; 50 | } 51 | 52 | @Override 53 | public Worker login(LoginDto dto) throws Exception { 54 | QueryWrapper wrapper = new QueryWrapper<>(); 55 | wrapper.in("username", dto.getUsername()); 56 | Worker worker = workerMapper.selectOne(wrapper); 57 | if (worker == null) throw new Exception("用户名或密码错误"); 58 | if (!bCryptPasswordEncoder.matches(dto.getPassword(), worker.getPassword())) throw new Exception("用户名或密码错误"); 59 | return worker; 60 | } 61 | 62 | @Override 63 | public void update(Worker worker) throws Exception { 64 | Worker one = workerMapper.selectOne(new QueryWrapper().in("username", worker.getUsername())); 65 | if (one != null && !one.getId().equals(worker.getId())) { 66 | throw new Exception("已存在的用户名"); 67 | } 68 | worker.setPassword(bCryptPasswordEncoder.encode(worker.getPassword())); 69 | worker.setUpdateAt(DataTimeUtil.getNowTimeString()); 70 | workerMapper.updateById(worker); 71 | } 72 | 73 | @Override 74 | public List findAll() { 75 | return workerMapper.selectList(null); 76 | } 77 | 78 | @Override 79 | public Worker findById(String id) { 80 | return workerMapper.selectById(id); 81 | } 82 | 83 | @Override 84 | public void deleteById(String id) { 85 | workerMapper.deleteById(id); 86 | //删除所有权限 87 | roleService.deleteWorkerAllRoles(id); 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/utils/DataTimeUtil.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.utils; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | 6 | public final class DataTimeUtil { 7 | 8 | public static String getNowTimeString() { 9 | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 10 | return df.format(System.currentTimeMillis()); 11 | } 12 | 13 | public static long parseTimeStamp(String s) { 14 | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 15 | long t = 0; 16 | try { 17 | t = df.parse(s).getTime(); 18 | } catch (ParseException e) { 19 | e.printStackTrace(); 20 | } 21 | return t; 22 | } 23 | 24 | public static boolean isAfterNow(String time) { 25 | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); 26 | long t = 0; 27 | try { 28 | t = df.parse(time).getTime(); 29 | } catch (ParseException e) { 30 | e.printStackTrace(); 31 | } 32 | return t > System.currentTimeMillis(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/utils/JwtTokenUtil.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.utils; 2 | 3 | import io.jsonwebtoken.Claims; 4 | import io.jsonwebtoken.ExpiredJwtException; 5 | import io.jsonwebtoken.Jwts; 6 | import io.jsonwebtoken.SignatureAlgorithm; 7 | 8 | import java.util.*; 9 | 10 | public final class JwtTokenUtil { 11 | 12 | //在http header中的名字 13 | public final static String TOKEN_HEADER = "Authorization"; 14 | 15 | //一个星期过期 16 | public final static long REMEMBER_EXPIRATION_TIME = 1000 * 60 * 60 * 24 * 7; 17 | 18 | //一天过期 19 | public final static long EXPIRATION_TIME = 1000 * 60 * 60 * 24; 20 | 21 | // 应用密钥 22 | private static final String APP_SECRET = "movie.api"; 23 | 24 | // 角色权限声明 25 | private static final String ROLE_CLAIMS = "roles"; 26 | 27 | /** 28 | * 生成Token 29 | */ 30 | public static String createToken(String username, List roles, long expiration) { 31 | Map map = new HashMap<>(); 32 | map.put(ROLE_CLAIMS, roles); 33 | return Jwts.builder() 34 | .setSubject(username) 35 | .setClaims(map) 36 | .setIssuedAt(new Date()) 37 | .setExpiration(new Date(System.currentTimeMillis() + expiration)) 38 | .signWith(SignatureAlgorithm.HS256, APP_SECRET) 39 | .compact(); 40 | } 41 | 42 | /** 43 | * 获取token body 44 | */ 45 | private static Claims getTokenClaims(String token) { 46 | Claims claims; 47 | try { 48 | claims = Jwts.parser() 49 | .setSigningKey(APP_SECRET) 50 | .parseClaimsJws(token) 51 | .getBody(); 52 | } catch ( ExpiredJwtException e ) { 53 | claims = e.getClaims(); 54 | } 55 | return claims; 56 | } 57 | 58 | /** 59 | * 从Token中获取username 60 | */ 61 | public static String getUsername(String token) { 62 | return getTokenClaims(token).getSubject(); 63 | } 64 | 65 | /** 66 | * 从Token中获取用户角色 67 | */ 68 | public static List getTokenRoles(String token) { 69 | List roles = new ArrayList<>(); 70 | Object object = getTokenClaims(token).get(ROLE_CLAIMS); 71 | if (object instanceof ArrayList) { 72 | for (Object o : (List) object) { 73 | roles.add((String) o); 74 | } 75 | } 76 | return roles; 77 | } 78 | 79 | /** 80 | * 校验Token是否过期 81 | */ 82 | public static boolean isExpiration(String token) { 83 | return getTokenClaims(token).getExpiration().before(new Date()); 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /api/src/main/java/com/movie/api/utils/ResponseUtil.java: -------------------------------------------------------------------------------- 1 | package com.movie.api.utils; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | 5 | import javax.servlet.http.HttpServletResponse; 6 | import java.io.IOException; 7 | import java.io.PrintWriter; 8 | 9 | public final class ResponseUtil { 10 | 11 | public static void writeJson(HttpServletResponse response, Object o) { 12 | response.setHeader("Access-Control-Allow-Origin", "*"); 13 | response.setHeader("Access-Control-Allow-Credentials", "true"); 14 | response.setHeader("Access-Control-Allow-Methods", "POST, GET, PATCH, DELETE, PUT"); 15 | response.setHeader("Access-Control-Max-Age", "3600"); 16 | response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); 17 | response.setContentType("application/json;charset=utf-8"); 18 | response.setStatus(200); 19 | try { 20 | PrintWriter writer = response.getWriter(); 21 | writer.write(JSON.toJSONString(o)); 22 | writer.flush(); 23 | writer.close(); 24 | } catch (IOException e) { 25 | System.out.println("write json error"); 26 | e.printStackTrace(); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /api/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8888 3 | spring: 4 | datasource: 5 | driver-class-name: com.mysql.cj.jdbc.Driver 6 | url: jdbc:mysql://localhost:3306/movie?characterEncoding=utf8&serverTimezone=UTC 7 | username: root 8 | password: 123456 9 | cache: 10 | redis: 11 | #使用前缀 12 | use-key-prefix: true 13 | #redis过期时间 14 | time-to-live: 60s 15 | mybatis-plus: 16 | global-config: 17 | db-config: 18 | id-type: uuid 19 | #schema: classpath:/sql/schema.sql 20 | type-aliases-package: com.movie.api.model.entity --------------------------------------------------------------------------------