├── .gitignore ├── Dockerfile-nacos ├── LICENSE ├── README.MD ├── README_JP.MD ├── common ├── common_utils │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── github │ │ └── utils │ │ ├── JwtUtils.java │ │ ├── ResponseUtil.java │ │ └── ResultCommon.java ├── pom.xml ├── service_base │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── github │ │ └── servicebase │ │ ├── cache │ │ └── MybatisRedisCacheConfig.java │ │ ├── config │ │ ├── DateFormatConfig.java │ │ ├── RedisConfig.java │ │ └── SwaggerConfig.java │ │ ├── entity │ │ ├── CourseWebInfoCommon.java │ │ └── UcenterMemberCommon.java │ │ ├── exception │ │ └── GlobalExceptionHandler.java │ │ └── handler │ │ └── TheMetaObjectHandler.java └── spring_security │ ├── pom.xml │ └── src │ └── main │ └── java │ └── com │ └── github │ └── security │ ├── config │ └── SecurityConfig.java │ ├── entity │ ├── SecurityUser.java │ └── User.java │ ├── filter │ ├── AuthFilter.java │ └── LoginFilter.java │ └── handler │ ├── DefaultPasswordEncoder.java │ ├── TokenLogoutHandler.java │ └── UnAuthHandler.java ├── doc ├── seata │ └── config │ │ └── registry.conf └── sql │ ├── nacos_config.sql │ ├── online.sql │ └── seata.sql ├── docker-compose.yml ├── image ├── admin.png ├── architect.png └── web.png ├── infrastructure ├── api_gateway80 │ ├── Dockerfile │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── gateway │ │ │ ├── Filter │ │ │ └── AuthFilter.java │ │ │ ├── GatewayMain80.java │ │ │ └── config │ │ │ └── CorsConfig.java │ │ └── resources │ │ ├── application.yml │ │ └── bootstrap.yml └── pom.xml ├── pom.xml ├── service ├── pom.xml ├── service_acl8008 │ ├── Dockerfile │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── github │ │ │ │ └── acl │ │ │ │ ├── AclApplicationMain8008.java │ │ │ │ ├── config │ │ │ │ └── MybatisPlusConfiguration.java │ │ │ │ ├── controller │ │ │ │ ├── LoginLogoutController.java │ │ │ │ ├── PermissionController.java │ │ │ │ ├── RoleController.java │ │ │ │ └── UserController.java │ │ │ │ ├── entity │ │ │ │ ├── Permission.java │ │ │ │ ├── Role.java │ │ │ │ ├── RolePermission.java │ │ │ │ └── UserRole.java │ │ │ │ ├── mapper │ │ │ │ ├── PermissionMapper.java │ │ │ │ ├── RoleMapper.java │ │ │ │ ├── RolePermissionMapper.java │ │ │ │ ├── UserMapper.java │ │ │ │ └── UserRoleMapper.java │ │ │ │ ├── security │ │ │ │ └── UserDetailsServiceImpl.java │ │ │ │ └── service │ │ │ │ ├── LoginLogoutService.java │ │ │ │ ├── PermissionService.java │ │ │ │ ├── RolePermissionService.java │ │ │ │ ├── RoleService.java │ │ │ │ ├── UserRoleService.java │ │ │ │ └── UserService.java │ │ └── resources │ │ │ ├── application.yml │ │ │ ├── bootstrap.yml │ │ │ └── mapper │ │ │ ├── PermissionMapper.xml │ │ │ ├── RoleMapper.xml │ │ │ ├── RolePermissionMapper.xml │ │ │ ├── UserMapper.xml │ │ │ └── UserRoleMapper.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── github │ │ └── generator │ │ └── CodeGenerator.java ├── service_center8005 │ ├── Dockerfile │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── github │ │ │ │ └── center │ │ │ │ ├── UserCenterMain8005.java │ │ │ │ ├── aspect │ │ │ │ ├── LoginAspect.java │ │ │ │ └── RegisterAspect.java │ │ │ │ ├── config │ │ │ │ ├── BeanConfig.java │ │ │ │ └── MybatisPlusConfiguration.java │ │ │ │ ├── controller │ │ │ │ ├── EmailController.java │ │ │ │ ├── GithubController.java │ │ │ │ └── UcenterMemberController.java │ │ │ │ ├── entity │ │ │ │ └── UcenterMember.java │ │ │ │ ├── mapper │ │ │ │ ├── EmailMapper.java │ │ │ │ ├── GithubMapper.java │ │ │ │ └── UcenterMemberMapper.java │ │ │ │ ├── service │ │ │ │ ├── EmailService.java │ │ │ │ ├── GithubService.java │ │ │ │ └── UcenterMemberService.java │ │ │ │ ├── thirdparty │ │ │ │ ├── Email.java │ │ │ │ └── Github.java │ │ │ │ └── vo │ │ │ │ └── UserRegister.java │ │ └── resources │ │ │ ├── application.yml │ │ │ ├── bootstrap.yml │ │ │ └── mapper │ │ │ └── UcenterMemberMapper.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── github │ │ └── generator │ │ └── CodeGenerator.java ├── service_cms8004 │ ├── Dockerfile │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── github │ │ │ │ └── cms │ │ │ │ ├── CmsApplicationMain8004.java │ │ │ │ ├── config │ │ │ │ └── MybatisPlusConfiguration.java │ │ │ │ ├── controller │ │ │ │ └── CrmBannerController.java │ │ │ │ ├── entity │ │ │ │ └── CrmBanner.java │ │ │ │ ├── mapper │ │ │ │ └── CrmBannerMapper.java │ │ │ │ └── service │ │ │ │ └── CrmBannerService.java │ │ └── resources │ │ │ ├── application.yml │ │ │ ├── bootstrap.yml │ │ │ └── mapper │ │ │ └── CrmBannerMapper.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── github │ │ └── generator │ │ └── CodeGenerator.java ├── service_edu8001 │ ├── Dockerfile │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── github │ │ │ │ └── eduservice │ │ │ │ ├── EduServiceMain8001.java │ │ │ │ ├── aspect │ │ │ │ └── FrontCourseAspect.java │ │ │ │ ├── config │ │ │ │ ├── EduConfiguration.java │ │ │ │ └── MybatisPlusConfiguration.java │ │ │ │ ├── controller │ │ │ │ ├── EduChapterController.java │ │ │ │ ├── EduCommentController.java │ │ │ │ ├── EduCourseController.java │ │ │ │ ├── EduFrontIndexController.java │ │ │ │ ├── EduLoginController.java │ │ │ │ ├── EduSubjectController.java │ │ │ │ ├── EduTeacherController.java │ │ │ │ ├── EduVideoController.java │ │ │ │ ├── FrontCourseController.java │ │ │ │ └── FrontTeacherController.java │ │ │ │ ├── entity │ │ │ │ ├── EduChapter.java │ │ │ │ ├── EduComment.java │ │ │ │ ├── EduCourse.java │ │ │ │ ├── EduCourseDescription.java │ │ │ │ ├── EduSubject.java │ │ │ │ ├── EduTeacher.java │ │ │ │ ├── EduVideo.java │ │ │ │ ├── chapter │ │ │ │ │ └── Chapter.java │ │ │ │ ├── excel │ │ │ │ │ └── ExcelSubjectData.java │ │ │ │ └── subject │ │ │ │ │ └── Subject.java │ │ │ │ ├── feign │ │ │ │ ├── VodClient.java │ │ │ │ └── fallback │ │ │ │ │ └── VodClientFallback.java │ │ │ │ ├── listener │ │ │ │ └── SubjectExcelListener.java │ │ │ │ ├── mapper │ │ │ │ ├── EduChapterMapper.java │ │ │ │ ├── EduCommentMapper.java │ │ │ │ ├── EduCourseDescriptionMapper.java │ │ │ │ ├── EduCourseMapper.java │ │ │ │ ├── EduSubjectMapper.java │ │ │ │ ├── EduTeacherMapper.java │ │ │ │ └── EduVideoMapper.java │ │ │ │ ├── rabbitmq │ │ │ │ └── BuyCount.java │ │ │ │ ├── service │ │ │ │ ├── EduChapterService.java │ │ │ │ ├── EduCommentService.java │ │ │ │ ├── EduCourseDescriptionService.java │ │ │ │ ├── EduCourseService.java │ │ │ │ ├── EduSubjectService.java │ │ │ │ ├── EduTeacherService.java │ │ │ │ ├── EduVideoService.java │ │ │ │ └── impl │ │ │ │ │ ├── EduChapterServiceImpl.java │ │ │ │ │ ├── EduCommentServiceImpl.java │ │ │ │ │ ├── EduCourseDescriptionServiceImpl.java │ │ │ │ │ ├── EduCourseServiceImpl.java │ │ │ │ │ ├── EduSubjectServiceImpl.java │ │ │ │ │ ├── EduTeacherServiceImpl.java │ │ │ │ │ └── EduVideoServiceImpl.java │ │ │ │ └── vo │ │ │ │ ├── CourseFrontInfo.java │ │ │ │ ├── CourseInfo.java │ │ │ │ ├── CourseQuery.java │ │ │ │ ├── CourseWebInfo.java │ │ │ │ ├── PublishInfo.java │ │ │ │ └── TeacherQuery.java │ │ └── resources │ │ │ ├── application.yml │ │ │ ├── bootstrap.yml │ │ │ ├── excel │ │ │ └── subject.xlsx │ │ │ └── mapper │ │ │ ├── EduChapterMapper.xml │ │ │ ├── EduCommentMapper.xml │ │ │ ├── EduCourseDescriptionMapper.xml │ │ │ ├── EduCourseMapper.xml │ │ │ ├── EduSubjectMapper.xml │ │ │ ├── EduTeacherMapper.xml │ │ │ └── EduVideoMapper.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── github │ │ ├── eduservice │ │ └── excel │ │ │ ├── ExcelListener.java │ │ │ ├── Student.java │ │ │ ├── TestExcelRead.java │ │ │ └── TestExcelWrite.java │ │ └── generator │ │ └── CodeGenerator.java ├── service_order8006 │ ├── Dockerfile │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── github │ │ │ │ └── order │ │ │ │ ├── OrderApplicationMain8006.java │ │ │ │ ├── aspect │ │ │ │ └── OrderAspect.java │ │ │ │ ├── config │ │ │ │ ├── MybatisPlusConfiguration.java │ │ │ │ └── ThreadPoolConfig.java │ │ │ │ ├── controller │ │ │ │ ├── OrderController.java │ │ │ │ └── PayLogController.java │ │ │ │ ├── entity │ │ │ │ ├── Order.java │ │ │ │ └── PayLog.java │ │ │ │ ├── feign │ │ │ │ ├── EduFeign.java │ │ │ │ └── UcenterFeign.java │ │ │ │ ├── mapper │ │ │ │ ├── OrderMapper.java │ │ │ │ └── PayLogMapper.java │ │ │ │ └── service │ │ │ │ ├── OrderService.java │ │ │ │ └── PayLogService.java │ │ └── resources │ │ │ ├── application.yml │ │ │ ├── bootstrap.yml │ │ │ └── mapper │ │ │ ├── OrderMapper.xml │ │ │ └── PayLogMapper.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── github │ │ └── generator │ │ └── CodeGenerator.java ├── service_oss8002 │ ├── Dockerfile │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── oss │ │ │ ├── OssApplicationMain8002.java │ │ │ ├── controller │ │ │ └── OssController.java │ │ │ ├── mapper │ │ │ └── OssMapper.java │ │ │ ├── properties │ │ │ └── ConstantProperties.java │ │ │ └── service │ │ │ └── OssService.java │ │ └── resources │ │ ├── application.yml │ │ └── bootstrap.yml ├── service_statistic8007 │ ├── Dockerfile │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── github │ │ │ │ └── stat │ │ │ │ ├── StatisticMain8007.java │ │ │ │ ├── config │ │ │ │ └── MybatisPlusConfiguration.java │ │ │ │ ├── controller │ │ │ │ └── StatisticsDailyController.java │ │ │ │ ├── entity │ │ │ │ └── StatisticsDaily.java │ │ │ │ ├── feign │ │ │ │ └── UcenterClient.java │ │ │ │ ├── mapper │ │ │ │ └── StatisticsDailyMapper.java │ │ │ │ ├── rabbitmq │ │ │ │ ├── CourseViewCount.java │ │ │ │ ├── LoginCount.java │ │ │ │ ├── RegisterCount.java │ │ │ │ └── VideoViewCount.java │ │ │ │ ├── schedule │ │ │ │ └── StatCountSchedule.java │ │ │ │ └── service │ │ │ │ └── StatisticsDailyService.java │ │ └── resources │ │ │ ├── application.yml │ │ │ ├── bootstrap.yml │ │ │ └── mapper │ │ │ └── StatisticsDailyMapper.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── github │ │ └── generator │ │ └── CodeGenerator.java └── service_vod8003 │ ├── Dockerfile │ ├── lib │ └── aliyun-java-vod-upload-1.4.13.jar │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── vod │ │ │ ├── VodApplicationMain8003.java │ │ │ ├── aspect │ │ │ └── VodAspect.java │ │ │ ├── config │ │ │ └── ThreadPoolConfig.java │ │ │ ├── controller │ │ │ └── VodController.java │ │ │ ├── mapper │ │ │ └── VodMapper.java │ │ │ ├── properties │ │ │ └── VodProperties.java │ │ │ ├── service │ │ │ └── VodService.java │ │ │ └── utils │ │ │ └── InitVodClient.java │ └── resources │ │ ├── application.yml │ │ └── bootstrap.yml │ └── test │ └── java │ └── com │ └── github │ └── vod │ ├── InitVodClient.java │ └── VodTest.java └── wait-for-it.sh /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | out 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | !**/src/main/**/build/ 31 | !**/src/test/**/build/ 32 | 33 | ### VS Code ### 34 | .vscode/ -------------------------------------------------------------------------------- /Dockerfile-nacos: -------------------------------------------------------------------------------- 1 | FROM nacos/nacos-server:1.4.0 2 | COPY wait-for-it.sh //home/nacos 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-present PanJiaChen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /common/common_utils/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | common 7 | com.github 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | common_utils 13 | 14 | 15 | 15 16 | 15 17 | 18 | 19 | -------------------------------------------------------------------------------- /common/common_utils/src/main/java/com/github/utils/ResponseUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.utils; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import org.springframework.http.HttpStatus; 5 | import org.springframework.http.MediaType; 6 | 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | public class ResponseUtil { 11 | 12 | public static void out(HttpServletResponse response, ResultCommon resultCommon) { 13 | ObjectMapper mapper = new ObjectMapper(); 14 | response.setStatus(HttpStatus.OK.value()); 15 | response.setContentType(MediaType.APPLICATION_JSON_VALUE); 16 | try { 17 | mapper.writeValue(response.getWriter(), resultCommon); 18 | } catch (IOException e) { 19 | e.printStackTrace(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /common/common_utils/src/main/java/com/github/utils/ResultCommon.java: -------------------------------------------------------------------------------- 1 | package com.github.utils; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | import lombok.experimental.Accessors; 6 | 7 | import java.io.Serial; 8 | import java.io.Serializable; 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | /** 13 | * @author HAN 14 | * @version 1.0 15 | * @create 2021/4/5 16 | */ 17 | @Data 18 | @Accessors(chain = true) 19 | public class ResultCommon implements Serializable { 20 | 21 | @Serial 22 | private static final long serialVersionUID = 1L; 23 | 24 | public static int SUCCESS = 200; 25 | // 表示操作失败 26 | public static int ERROR = 404; 27 | 28 | @ApiModelProperty("返回码") 29 | private int code; 30 | 31 | @ApiModelProperty("返回信息") 32 | private String message; 33 | 34 | @ApiModelProperty("返回数据") 35 | private Map data = new HashMap<>(); 36 | 37 | private ResultCommon(){} 38 | 39 | public static ResultCommon success() { 40 | ResultCommon resultCommon = new ResultCommon(); 41 | 42 | resultCommon.setCode(SUCCESS); 43 | resultCommon.setMessage("成功"); 44 | return resultCommon; 45 | } 46 | 47 | public static ResultCommon fail() { 48 | ResultCommon resultCommon = new ResultCommon(); 49 | 50 | resultCommon.setCode(ERROR); 51 | resultCommon.setMessage("失败"); 52 | return resultCommon; 53 | } 54 | 55 | public ResultCommon setData(String key, Object value) { 56 | this.getData().put(key, value); 57 | return this; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | education_parent 7 | com.github 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | common 13 | pom 14 | 15 | service_base 16 | common_utils 17 | spring_security 18 | 19 | 20 | 21 | 15 22 | 15 23 | 24 | 25 | 26 | 27 | io.springfox 28 | springfox-boot-starter 29 | 30 | 31 | 32 | org.projectlombok 33 | lombok 34 | 35 | 36 | 37 | org.apache.commons 38 | commons-pool2 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-starter-web 44 | 45 | 46 | 47 | 48 | io.jsonwebtoken 49 | jjwt 50 | 51 | 52 | 53 | cn.hutool 54 | hutool-all 55 | 56 | 57 | 58 | 59 | 60 | 61 | org.springframework.boot 62 | spring-boot-maven-plugin 63 | 64 | true 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /common/service_base/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | common 7 | com.github 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | service_base 13 | 14 | 15 | 15 16 | 15 17 | 18 | 19 | 20 | 21 | com.github 22 | common_utils 23 | 0.0.1-SNAPSHOT 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-data-redis 29 | 30 | 31 | com.baomidou 32 | mybatis-plus-boot-starter 33 | 34 | 35 | 36 | com.alibaba.cloud 37 | spring-cloud-starter-alibaba-seata 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /common/service_base/src/main/java/com/github/servicebase/config/DateFormatConfig.java: -------------------------------------------------------------------------------- 1 | package com.github.servicebase.config; 2 | 3 | import com.fasterxml.jackson.databind.SerializationFeature; 4 | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; 7 | import org.springframework.boot.jackson.JsonComponent; 8 | import org.springframework.context.annotation.Bean; 9 | 10 | import java.text.DateFormat; 11 | import java.text.SimpleDateFormat; 12 | import java.time.LocalDateTime; 13 | import java.time.format.DateTimeFormatter; 14 | import java.util.TimeZone; 15 | 16 | /** 17 | * 全局格式化时间类 18 | * @author HAN 19 | * @version 1.0 20 | * @create 2021/4/9 21 | */ 22 | @JsonComponent 23 | public class DateFormatConfig { 24 | @Value("yyyy-MM-dd HH:mm:ss") 25 | private String pattern; 26 | 27 | @Bean 28 | public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilder() { 29 | return builder -> { 30 | TimeZone tz = TimeZone.getTimeZone("GMT+9"); 31 | DateFormat df = new SimpleDateFormat(pattern); 32 | df.setTimeZone(tz); 33 | builder.failOnEmptyBeans(false) 34 | .failOnUnknownProperties(false) 35 | .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).dateFormat(df); 36 | }; 37 | } 38 | 39 | @Bean 40 | public LocalDateTimeSerializer localDateTimeDeserializer() { 41 | return new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(pattern)); 42 | } 43 | 44 | @Bean 45 | public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer(LocalDateTimeSerializer localDateTimeSerializer) { 46 | return builder -> builder.serializerByType(LocalDateTime.class, localDateTimeSerializer); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /common/service_base/src/main/java/com/github/servicebase/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.github.servicebase.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.service.ApiInfo; 8 | import springfox.documentation.service.Contact; 9 | import springfox.documentation.spi.DocumentationType; 10 | import springfox.documentation.spring.web.plugins.Docket; 11 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 12 | 13 | import java.util.function.Predicate; 14 | 15 | /** 16 | * @author HAN 17 | * @version 1.0 18 | * @create 2021/4/4 19 | */ 20 | @Configuration 21 | @EnableSwagger2 // swagger注解 22 | public class SwaggerConfig { 23 | 24 | @Bean 25 | public Docket webApiConfig() { 26 | return new Docket(DocumentationType.SWAGGER_2) 27 | .groupName("webApi") 28 | .apiInfo(apiInfo()) 29 | .select() 30 | .paths(Predicate.not(PathSelectors.regex("/admin/.*"))) 31 | .paths(Predicate.not(PathSelectors.regex("/error.*"))) 32 | .build(); 33 | } 34 | 35 | public ApiInfo apiInfo() { 36 | return new ApiInfoBuilder() 37 | .title("课程中心Api文档") 38 | .description("本文档定义了课程中心微服务接口定义") 39 | .version("1.0") 40 | .contact(new Contact("HAN", null, "a1066079469@gmail.com")) 41 | .build(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /common/service_base/src/main/java/com/github/servicebase/entity/CourseWebInfoCommon.java: -------------------------------------------------------------------------------- 1 | package com.github.servicebase.entity; 2 | 3 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 4 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | import java.math.BigDecimal; 11 | 12 | /** 13 | * @author HAN 14 | * @version 1.0 15 | * @create 04-17-21:54 16 | */ 17 | @Data 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | public class CourseWebInfoCommon { 21 | @ApiModelProperty(value = "课程ID") 22 | @JsonSerialize(using = ToStringSerializer.class) 23 | private Long id; 24 | 25 | @ApiModelProperty(value = "课程标题") 26 | private String title; 27 | 28 | @ApiModelProperty(value = "课程销售价格,设置为0则可免费观看") 29 | private BigDecimal price; 30 | 31 | @ApiModelProperty(value = "总课时") 32 | private Integer lessonNum; 33 | 34 | @ApiModelProperty(value = "课程封面图片路径") 35 | private String cover; 36 | 37 | @ApiModelProperty(value = "销售数量") 38 | private Long buyCount; 39 | 40 | @ApiModelProperty(value = "浏览数量") 41 | private Long viewCount; 42 | 43 | @ApiModelProperty(value = "课程简介") 44 | private String description; 45 | 46 | @ApiModelProperty(value = "课程教师ID") 47 | @JsonSerialize(using = ToStringSerializer.class) 48 | private Long teacherId; 49 | 50 | @ApiModelProperty(value = "教师姓名") 51 | private String teacherName; 52 | 53 | @ApiModelProperty(value = "教师资历,一句话说明讲师") 54 | private String intro; 55 | 56 | @ApiModelProperty(value = "教师头像") 57 | private String avatar; 58 | 59 | @ApiModelProperty(value = "课程专业父级ID") 60 | @JsonSerialize(using = ToStringSerializer.class) 61 | private Long subjectParentId; 62 | 63 | @ApiModelProperty(value = "类别一级名称") 64 | private String subjectParentTitle; 65 | 66 | @ApiModelProperty(value = "课程专业ID") 67 | @JsonSerialize(using = ToStringSerializer.class) 68 | private Long subjectId; 69 | 70 | @ApiModelProperty(value = "类别二级名称") 71 | private String subjectTitle; 72 | } 73 | -------------------------------------------------------------------------------- /common/service_base/src/main/java/com/github/servicebase/entity/UcenterMemberCommon.java: -------------------------------------------------------------------------------- 1 | package com.github.servicebase.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | import java.io.Serializable; 12 | import java.time.LocalDateTime; 13 | 14 | /** 15 | *

16 | * 会员表 17 | *

18 | * 19 | * @author HAN 20 | * @since 2021-04-15 21 | */ 22 | @Data 23 | @EqualsAndHashCode(callSuper = false) 24 | @ApiModel(value="UcenterMember对象", description="会员表") 25 | public class UcenterMemberCommon implements Serializable { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | @ApiModelProperty(value = "会员id") 30 | @TableId(value = "id", type = IdType.ASSIGN_ID) 31 | @JsonSerialize(using = ToStringSerializer.class) 32 | private String id; 33 | 34 | @ApiModelProperty(value = "微信openid") 35 | private String openid; 36 | 37 | @ApiModelProperty(value = "邮箱号") 38 | private String email; 39 | 40 | @ApiModelProperty(value = "密码") 41 | private String password; 42 | 43 | @ApiModelProperty(value = "昵称") 44 | private String nickname; 45 | 46 | @ApiModelProperty(value = "性别 0 女,1 男") 47 | private Integer sex; 48 | 49 | @ApiModelProperty(value = "年龄") 50 | private Integer age; 51 | 52 | @ApiModelProperty(value = "用户头像") 53 | private String avatar; 54 | 55 | @ApiModelProperty(value = "用户签名") 56 | private String sign; 57 | 58 | @ApiModelProperty(value = "是否禁用 1(true)已禁用, 0(false)未禁用") 59 | private Boolean isDisabled; 60 | 61 | @ApiModelProperty(value = "逻辑删除 1(true)已删除, 0(false)未删除") 62 | @TableLogic 63 | private Boolean isDeleted; 64 | 65 | @ApiModelProperty(value = "创建时间") 66 | @TableField(fill = FieldFill.INSERT) 67 | private LocalDateTime gmtCreate; 68 | 69 | @ApiModelProperty(value = "更新时间") 70 | @TableField(fill = FieldFill.INSERT_UPDATE) 71 | private LocalDateTime gmtModified; 72 | 73 | 74 | } 75 | -------------------------------------------------------------------------------- /common/service_base/src/main/java/com/github/servicebase/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.github.servicebase.exception; 2 | 3 | import com.github.utils.ResultCommon; 4 | import io.seata.core.context.RootContext; 5 | import io.seata.core.exception.TransactionException; 6 | import io.seata.tm.api.GlobalTransactionContext; 7 | import org.springframework.util.ObjectUtils; 8 | import org.springframework.web.bind.annotation.ControllerAdvice; 9 | import org.springframework.web.bind.annotation.ExceptionHandler; 10 | import org.springframework.web.bind.annotation.ResponseBody; 11 | 12 | /** 13 | * @author HAN 14 | * @version 1.0 15 | * @create 2021/4/5 16 | */ 17 | @ControllerAdvice 18 | public class GlobalExceptionHandler { 19 | 20 | /** 21 | * 处理全局异常 22 | */ 23 | @ResponseBody 24 | @ExceptionHandler(Exception.class) 25 | public ResultCommon error(Exception e) { 26 | e.printStackTrace(); 27 | try { 28 | // 回滚分布式事务 29 | if (!ObjectUtils.isEmpty(RootContext.getXID())) { 30 | GlobalTransactionContext.reload(RootContext.getXID()).rollback(); 31 | } 32 | } catch (TransactionException transactionException) { 33 | transactionException.printStackTrace(); 34 | } 35 | return ResultCommon.fail().setMessage("发生了错误"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /common/service_base/src/main/java/com/github/servicebase/handler/TheMetaObjectHandler.java: -------------------------------------------------------------------------------- 1 | package com.github.servicebase.handler; 2 | 3 | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; 4 | import org.apache.ibatis.reflection.MetaObject; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.time.LocalDateTime; 8 | 9 | /** 10 | * @author HAN 11 | * @version 1.0 12 | * @create 2021/4/5 13 | */ 14 | @Component 15 | public class TheMetaObjectHandler implements MetaObjectHandler { 16 | @Override 17 | public void insertFill(MetaObject metaObject) { 18 | this.strictInsertFill(metaObject, "gmtCreate", LocalDateTime.class, LocalDateTime.now()); 19 | this.strictInsertFill(metaObject, "gmtModified", LocalDateTime.class, LocalDateTime.now()); 20 | } 21 | 22 | @Override 23 | public void updateFill(MetaObject metaObject) { 24 | this.strictInsertFill(metaObject, "gmtModified", LocalDateTime.class, LocalDateTime.now()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /common/spring_security/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | common 7 | com.github 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | spring_security 13 | 14 | 15 | 15 16 | 15 17 | 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-security 23 | 24 | 25 | com.github 26 | common_utils 27 | 0.0.1-SNAPSHOT 28 | 29 | 30 | com.github 31 | service_base 32 | 0.0.1-SNAPSHOT 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /common/spring_security/src/main/java/com/github/security/entity/SecurityUser.java: -------------------------------------------------------------------------------- 1 | package com.github.security.entity; 2 | 3 | import lombok.Data; 4 | import org.springframework.security.core.GrantedAuthority; 5 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 6 | import org.springframework.security.core.userdetails.UserDetails; 7 | import org.springframework.util.ObjectUtils; 8 | 9 | import java.util.ArrayList; 10 | import java.util.Collection; 11 | import java.util.List; 12 | 13 | /** 14 | * @author HAN 15 | * @version 1.0 16 | * @create 04-24-1:25 17 | */ 18 | @Data 19 | public class SecurityUser implements UserDetails { 20 | 21 | private User user; 22 | 23 | // 当前权限 24 | private List permissionList; 25 | 26 | public SecurityUser(User user, List permissionList) { 27 | this.user = user; 28 | this.permissionList = permissionList; 29 | } 30 | 31 | @Override 32 | public Collection getAuthorities() { 33 | List grantedAuthorities = new ArrayList<>(); 34 | permissionList.forEach(item -> { 35 | if (ObjectUtils.isEmpty(item)) { 36 | return; 37 | } 38 | SimpleGrantedAuthority authority = new SimpleGrantedAuthority(item); 39 | grantedAuthorities.add(authority); 40 | 41 | }); 42 | return grantedAuthorities; 43 | } 44 | 45 | @Override 46 | public String getPassword() { 47 | return user.getPassword(); 48 | } 49 | 50 | @Override 51 | public String getUsername() { 52 | return user.getUsername(); 53 | } 54 | 55 | @Override 56 | public boolean isAccountNonExpired() { 57 | return true; 58 | } 59 | 60 | @Override 61 | public boolean isAccountNonLocked() { 62 | return true; 63 | } 64 | 65 | @Override 66 | public boolean isCredentialsNonExpired() { 67 | return true; 68 | } 69 | 70 | @Override 71 | public boolean isEnabled() { 72 | return true; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /common/spring_security/src/main/java/com/github/security/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.github.security.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | import java.io.Serializable; 12 | import java.time.LocalDateTime; 13 | 14 | /** 15 | *

16 | * 用户表 17 | *

18 | * 19 | * @author HAN 20 | * @since 2021-04-22 21 | */ 22 | @Data 23 | @EqualsAndHashCode(callSuper = false) 24 | @TableName("acl_user") 25 | @ApiModel(value="User对象", description="用户表") 26 | public class User implements Serializable { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | @ApiModelProperty(value = "会员id") 31 | @TableId(value = "id", type = IdType.ASSIGN_ID) 32 | @JsonSerialize(using = ToStringSerializer.class) 33 | private Long id; 34 | 35 | @ApiModelProperty(value = "用户名") 36 | private String username; 37 | 38 | @ApiModelProperty(value = "密码") 39 | private String password; 40 | 41 | @ApiModelProperty(value = "昵称") 42 | private String nickName; 43 | 44 | @ApiModelProperty(value = "用户头像") 45 | private String avatar; 46 | 47 | @ApiModelProperty(value = "逻辑删除 1(true)已删除, 0(false)未删除") 48 | @TableLogic 49 | private Integer isDeleted; 50 | 51 | @ApiModelProperty(value = "创建时间") 52 | @TableField(fill = FieldFill.INSERT) 53 | private LocalDateTime gmtCreate; 54 | 55 | @ApiModelProperty(value = "更新时间") 56 | @TableField(fill = FieldFill.INSERT_UPDATE) 57 | private LocalDateTime gmtModified; 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /common/spring_security/src/main/java/com/github/security/handler/DefaultPasswordEncoder.java: -------------------------------------------------------------------------------- 1 | package com.github.security.handler; 2 | 3 | import cn.hutool.crypto.SecureUtil; 4 | import org.springframework.security.crypto.password.PasswordEncoder; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.Objects; 8 | 9 | /** 10 | * @author HAN 11 | * @version 1.0 12 | * @create 04-24-0:05 13 | */ 14 | @Component 15 | public class DefaultPasswordEncoder implements PasswordEncoder { 16 | 17 | /** 18 | * 对密码进行md5加密 19 | * @param rawPassword 密码 20 | * @return 加密后的密码 21 | */ 22 | @Override 23 | public String encode(CharSequence rawPassword) { 24 | return SecureUtil.md5(rawPassword.toString()); 25 | } 26 | 27 | /** 28 | * 进行密码比对 29 | * @param rawPassword 传入的密码 30 | * @param encodedPassword 加密后的密码 31 | * @return true 密码一致 32 | */ 33 | @Override 34 | public boolean matches(CharSequence rawPassword, String encodedPassword) { 35 | return Objects.equals(SecureUtil.md5(rawPassword.toString()), encodedPassword); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /common/spring_security/src/main/java/com/github/security/handler/TokenLogoutHandler.java: -------------------------------------------------------------------------------- 1 | package com.github.security.handler; 2 | 3 | import com.github.utils.JwtUtils; 4 | import com.github.utils.ResponseUtil; 5 | import com.github.utils.ResultCommon; 6 | import org.springframework.data.redis.core.RedisTemplate; 7 | import org.springframework.security.core.Authentication; 8 | import org.springframework.security.web.authentication.logout.LogoutHandler; 9 | 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | 13 | /** 14 | * @author HAN 15 | * @version 1.0 16 | * @create 04-24-0:17 17 | */ 18 | public class TokenLogoutHandler implements LogoutHandler { 19 | 20 | private RedisTemplate redisTemplate; 21 | 22 | public TokenLogoutHandler(RedisTemplate redisTemplate) { 23 | this.redisTemplate = redisTemplate; 24 | } 25 | 26 | @Override 27 | public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { 28 | // 获取会员名 29 | String username = JwtUtils.getMemberIdByJwtToken(request); 30 | // 从redis中移除user权限数据 31 | redisTemplate.delete(username); 32 | // 返回信息 33 | ResponseUtil.out(response, ResultCommon.success()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/spring_security/src/main/java/com/github/security/handler/UnAuthHandler.java: -------------------------------------------------------------------------------- 1 | package com.github.security.handler; 2 | 3 | import com.github.utils.ResponseUtil; 4 | import com.github.utils.ResultCommon; 5 | import org.springframework.security.core.AuthenticationException; 6 | import org.springframework.security.web.AuthenticationEntryPoint; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | /** 14 | * 无权限访问 15 | * @author HAN 16 | * @version 1.0 17 | * @create 04-24-0:55 18 | */ 19 | public class UnAuthHandler implements AuthenticationEntryPoint { 20 | @Override 21 | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { 22 | ResponseUtil.out(response, ResultCommon.fail()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /doc/seata/config/registry.conf: -------------------------------------------------------------------------------- 1 | registry { 2 | # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa 3 | type = "nacos" 4 | loadBalance = "RandomLoadBalance" 5 | loadBalanceVirtualNodes = 10 6 | 7 | nacos { 8 | application = "seata-server" 9 | serverAddr = "nacos:8848" 10 | group = "SEATA_GROUP" 11 | namespace = "b909e98d-d1c4-4319-879a-758981c15700" 12 | cluster = "default" 13 | username = "nacos" 14 | password = "nacos" 15 | } 16 | } 17 | 18 | config { 19 | # file、nacos 、apollo、zk、consul、etcd3 20 | type = "nacos" 21 | 22 | nacos { 23 | serverAddr = "nacos:8848" 24 | namespace = "" 25 | group = "SEATA_GROUP" 26 | username = "nacos" 27 | password = "nacos" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /image/admin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andochiwa/Online-Education-Backend/2e831abb1a88774737546295c9025c389fe2324f/image/admin.png -------------------------------------------------------------------------------- /image/architect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andochiwa/Online-Education-Backend/2e831abb1a88774737546295c9025c389fe2324f/image/architect.png -------------------------------------------------------------------------------- /image/web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andochiwa/Online-Education-Backend/2e831abb1a88774737546295c9025c389fe2324f/image/web.png -------------------------------------------------------------------------------- /infrastructure/api_gateway80/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM adoptopenjdk/openjdk15:ubi 2 | RUN mkdir /app 3 | COPY ./infrastructure/api_gateway80/target/api_gateway.jar /app 4 | COPY ./wait-for-it.sh /app 5 | WORKDIR /app 6 | CMD ["java", "-jar", "api_gateway.jar"] 7 | -------------------------------------------------------------------------------- /infrastructure/api_gateway80/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | infrastructure 7 | com.github 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | api_gateway80 13 | 14 | 15 | 15 16 | 15 17 | 18 | 19 | 20 | 21 | org.springframework.cloud 22 | spring-cloud-starter-gateway 23 | 24 | 25 | 26 | 27 | api_gateway 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /infrastructure/api_gateway80/src/main/java/com/github/gateway/Filter/AuthFilter.java: -------------------------------------------------------------------------------- 1 | package com.github.gateway.Filter; 2 | 3 | import com.google.gson.JsonObject; 4 | import org.springframework.cloud.gateway.filter.GatewayFilterChain; 5 | import org.springframework.cloud.gateway.filter.GlobalFilter; 6 | import org.springframework.core.Ordered; 7 | import org.springframework.core.io.buffer.DataBuffer; 8 | import org.springframework.http.server.reactive.ServerHttpRequest; 9 | import org.springframework.http.server.reactive.ServerHttpResponse; 10 | import org.springframework.stereotype.Component; 11 | import org.springframework.util.AntPathMatcher; 12 | import org.springframework.web.server.ServerWebExchange; 13 | import reactor.core.publisher.Mono; 14 | 15 | import java.nio.charset.StandardCharsets; 16 | import java.util.List; 17 | 18 | /** 19 | * 统一处理非会员不可访问路径 20 | * @author HAN 21 | * @version 1.0 22 | * @create 04-21-5:14 23 | */ 24 | @Component 25 | public class AuthFilter implements GlobalFilter, Ordered { 26 | 27 | private AntPathMatcher antPathMatcher = new AntPathMatcher(); 28 | 29 | @Override 30 | public int getOrder() { 31 | return 0; 32 | } 33 | 34 | public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { 35 | ServerHttpRequest request = exchange.getRequest(); 36 | String path = request.getURI().getPath(); 37 | // api接口,校验用户必须登录 38 | if(antPathMatcher.match("/api/**/auth/**", path)) { 39 | List tokenList = request.getHeaders().get("token"); 40 | ServerHttpResponse response = exchange.getResponse(); 41 | return out(response); 42 | } 43 | //内部服务接口,不允许外部访问 44 | if(antPathMatcher.match("/**/inner/**", path)) { 45 | ServerHttpResponse response = exchange.getResponse(); 46 | return out(response); 47 | } 48 | return chain.filter(exchange); 49 | } 50 | 51 | private Mono out(ServerHttpResponse response) { 52 | JsonObject message = new JsonObject(); 53 | message.addProperty("success", false); 54 | message.addProperty("code", 28004); 55 | message.addProperty("data", "鉴权失败"); 56 | byte[] bits = message.toString().getBytes(StandardCharsets.UTF_8); 57 | DataBuffer buffer = response.bufferFactory().wrap(bits); 58 | //response.setStatusCode(HttpStatus.UNAUTHORIZED); 59 | //指定编码,否则在浏览器中会中文乱码 60 | response.getHeaders().add("Content-Type", "application/json;charset=UTF-8"); 61 | return response.writeWith(Mono.just(buffer)); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /infrastructure/api_gateway80/src/main/java/com/github/gateway/GatewayMain80.java: -------------------------------------------------------------------------------- 1 | package com.github.gateway; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.context.annotation.ComponentScan; 7 | 8 | /** 9 | * @author HAN 10 | * @version 1.0 11 | * @create 04-21-4:16 12 | */ 13 | @SpringBootApplication 14 | @EnableFeignClients 15 | @ComponentScan("com.github") 16 | public class GatewayMain80 { 17 | 18 | public static void main(String[] args){ 19 | SpringApplication.run(GatewayMain80.class, args); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /infrastructure/api_gateway80/src/main/java/com/github/gateway/config/CorsConfig.java: -------------------------------------------------------------------------------- 1 | package com.github.gateway.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.cors.CorsConfiguration; 6 | import org.springframework.web.cors.reactive.CorsWebFilter; 7 | import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; 8 | import org.springframework.web.util.pattern.PathPatternParser; 9 | 10 | /** 11 | * 解决跨域问题 12 | * @author HAN 13 | * @version 1.0 14 | * @create 04-21-5:05 15 | */ 16 | @Configuration 17 | public class CorsConfig { 18 | 19 | @Bean 20 | public CorsWebFilter corsWebFilter() { 21 | CorsConfiguration configuration = new CorsConfiguration(); 22 | configuration.addAllowedHeader("*"); 23 | configuration.addAllowedOrigin("*"); 24 | configuration.addAllowedMethod("*"); 25 | 26 | 27 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser()); 28 | source.registerCorsConfiguration("/**", configuration); 29 | return new CorsWebFilter(source); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /infrastructure/api_gateway80/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 80 3 | spring: 4 | application: 5 | name: api-gateway 6 | cloud: 7 | gateway: 8 | # 跨域配置 9 | # globalcors: 10 | # corsConfigurations: 11 | # '[/**]': 12 | # #这里有个allowCredentials: true这个东西是设置允许访问携带cookie的,这点一定要和前端对应! 13 | # allowCredentials: true 14 | # #可以填写多个域名用","隔开 例如:"http://www.xiaolc.cn,https://spring.io" "*"代表允许所有 15 | # allowedOriginPatterns: "*" 16 | # allowedMethods: "*" 17 | # allowedHeaders: "*" 18 | discovery: 19 | locator: 20 | enabled: true 21 | routes: 22 | - id: service-edu 23 | uri: lb://service-edu 24 | predicates: 25 | - Path=/eduservice/** 26 | 27 | - id: service-oss 28 | uri: lb://service-oss 29 | predicates: 30 | - Path=/edu-oss/** 31 | 32 | - id: service-vod 33 | uri: lb://service-vod 34 | predicates: 35 | - Path=/edu-vod/** 36 | 37 | - id: service-cms 38 | uri: lb://service-cms 39 | predicates: 40 | - Path=/cms/** 41 | 42 | - id: service-center 43 | uri: lb://service-center 44 | predicates: 45 | - Path=/edu-center/**,/login/** 46 | 47 | - id: service-order 48 | uri: lb://service-order 49 | predicates: 50 | - Path=/order/** 51 | 52 | - id: service-statistic 53 | uri: lb://service-statistic 54 | predicates: 55 | - Path=/stat/** 56 | 57 | - id: service-acl 58 | uri: lb://service-acl 59 | predicates: 60 | - Path=/acl/** 61 | -------------------------------------------------------------------------------- /infrastructure/api_gateway80/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | cloud: 5 | nacos: 6 | config: 7 | namespace: b909e98d-d1c4-4319-879a-758981c15700 8 | file-extension: yaml 9 | extension-configs: 10 | - data-id: feign-sentinel.yml 11 | refresh: true 12 | - data-id: nacos-sentinel.yml 13 | refresh: true 14 | server-addr: nacos:8848 15 | -------------------------------------------------------------------------------- /service/service_acl8008/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM adoptopenjdk/openjdk15:ubi 2 | RUN mkdir /app 3 | COPY ./service/service_acl8008/target/service_acl.jar /app 4 | COPY ./wait-for-it.sh /app 5 | WORKDIR /app 6 | CMD ["java", "-jar", "service_acl.jar"] 7 | -------------------------------------------------------------------------------- /service/service_acl8008/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | service 7 | com.github 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | service_acl8008 13 | 14 | 15 | 15 16 | 15 17 | 18 | 19 | 20 | 21 | com.github 22 | spring_security 23 | 0.0.1-SNAPSHOT 24 | 25 | 26 | com.alibaba 27 | fastjson 28 | 29 | 30 | 31 | 32 | service_acl 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/java/com/github/acl/AclApplicationMain8008.java: -------------------------------------------------------------------------------- 1 | package com.github.acl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.context.annotation.ComponentScan; 7 | 8 | /** 9 | * @author HAN 10 | * @version 1.0 11 | * @create 04-22-0:54 12 | */ 13 | @SpringBootApplication 14 | @ComponentScan("com.github") 15 | @EnableFeignClients 16 | public class AclApplicationMain8008 { 17 | 18 | public static void main(String[] args){ 19 | SpringApplication.run(AclApplicationMain8008.class, args); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/java/com/github/acl/config/MybatisPlusConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.github.acl.config; 2 | 3 | import com.baomidou.mybatisplus.annotation.DbType; 4 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 5 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 6 | import org.mybatis.spring.annotation.MapperScan; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.transaction.annotation.EnableTransactionManagement; 10 | 11 | /** 12 | * @author HAN 13 | * @version 1.0 14 | * @create 04-22-2:41 15 | */ 16 | @Configuration 17 | @MapperScan("com.github.acl.mapper") 18 | @EnableTransactionManagement 19 | public class MybatisPlusConfiguration { 20 | 21 | @Bean 22 | public MybatisPlusInterceptor mybatisPlusInterceptor() { 23 | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); 24 | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); 25 | return interceptor; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/java/com/github/acl/controller/LoginLogoutController.java: -------------------------------------------------------------------------------- 1 | package com.github.acl.controller; 2 | 3 | import com.github.acl.service.LoginLogoutService; 4 | import com.github.utils.ResultCommon; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.security.core.context.SecurityContextHolder; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import java.util.Map; 14 | 15 | /** 16 | * @author HAN 17 | * @version 1.0 18 | * @create 04-26-16:13 19 | */ 20 | @RestController 21 | @RequestMapping("acl/index") 22 | @Api("security控制器") 23 | public class LoginLogoutController { 24 | 25 | @Autowired 26 | private LoginLogoutService loginLogoutService; 27 | 28 | /** 29 | * 获取user数据 30 | */ 31 | @GetMapping("info") 32 | @ApiOperation("获取用户数据") 33 | public ResultCommon getUserInfo() { 34 | // 获取登陆的用户 35 | String username = SecurityContextHolder.getContext().getAuthentication().getName(); 36 | System.out.println(username); 37 | Map map = loginLogoutService.getUserInfo(username); 38 | return ResultCommon.success().setData(map); 39 | } 40 | 41 | /** 42 | * 获得可访问菜单列表 43 | */ 44 | @GetMapping("menu") 45 | @ApiOperation("获得菜单列表") 46 | public ResultCommon getMenu() { 47 | // 获取登陆的用户 48 | String username = SecurityContextHolder.getContext().getAuthentication().getName(); 49 | Map permissions = loginLogoutService.getMenu(username); 50 | return ResultCommon.success().setData("items", permissions); 51 | } 52 | 53 | /** 54 | * 登出 55 | */ 56 | @GetMapping("logout") 57 | @ApiOperation("登出") 58 | public ResultCommon logout() { 59 | return ResultCommon.success(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/java/com/github/acl/entity/Permission.java: -------------------------------------------------------------------------------- 1 | package com.github.acl.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | import java.io.Serializable; 12 | import java.time.LocalDateTime; 13 | import java.util.List; 14 | 15 | /** 16 | *

17 | * 权限 18 | *

19 | * 20 | * @author HAN 21 | * @since 2021-04-22 22 | */ 23 | @Data 24 | @EqualsAndHashCode(callSuper = false) 25 | @TableName("acl_permission") 26 | @ApiModel(value="Permission对象", description="权限") 27 | public class Permission implements Serializable { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | @ApiModelProperty(value = "编号") 32 | @TableId(value = "id", type = IdType.ASSIGN_ID) 33 | @JsonSerialize(using = ToStringSerializer.class) 34 | private Long id; 35 | 36 | @ApiModelProperty(value = "所属上级") 37 | @JsonSerialize(using = ToStringSerializer.class) 38 | private Long pid; 39 | 40 | @ApiModelProperty("层级") 41 | @TableField(exist = false) 42 | private Integer level; 43 | 44 | @ApiModelProperty("下级") 45 | @TableField(exist = false) 46 | private List children; 47 | 48 | @ApiModelProperty(value = "名称") 49 | private String name; 50 | 51 | @ApiModelProperty(value = "类型(1:菜单,2:按钮)") 52 | private Integer type; 53 | 54 | @ApiModelProperty(value = "权限值") 55 | private String permissionValue; 56 | 57 | @ApiModelProperty(value = "访问路径") 58 | private String path; 59 | 60 | @ApiModelProperty(value = "组件路径") 61 | private String component; 62 | 63 | @ApiModelProperty(value = "图标") 64 | private String icon; 65 | 66 | @ApiModelProperty(value = "状态(0:禁止,1:正常)") 67 | private Integer status; 68 | 69 | @ApiModelProperty(value = "逻辑删除 1(true)已删除, 0(false)未删除") 70 | @TableLogic 71 | private Integer isDeleted; 72 | 73 | @ApiModelProperty(value = "创建时间") 74 | @TableField(fill = FieldFill.INSERT) 75 | private LocalDateTime gmtCreate; 76 | 77 | @ApiModelProperty(value = "更新时间") 78 | @TableField(fill = FieldFill.INSERT_UPDATE) 79 | private LocalDateTime gmtModified; 80 | 81 | 82 | } 83 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/java/com/github/acl/entity/Role.java: -------------------------------------------------------------------------------- 1 | package com.github.acl.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | import java.io.Serializable; 12 | import java.time.LocalDateTime; 13 | 14 | /** 15 | *

16 | * 17 | *

18 | * 19 | * @author HAN 20 | * @since 2021-04-22 21 | */ 22 | @Data 23 | @EqualsAndHashCode(callSuper = false) 24 | @TableName("acl_role") 25 | @ApiModel(value="Role对象", description="") 26 | public class Role implements Serializable { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | @ApiModelProperty(value = "角色id") 31 | @TableId(value = "id", type = IdType.ASSIGN_ID) 32 | @JsonSerialize(using = ToStringSerializer.class) 33 | private Long id; 34 | 35 | @ApiModelProperty(value = "角色名称") 36 | private String roleName; 37 | 38 | @ApiModelProperty(value = "角色编码") 39 | private String roleCode; 40 | 41 | @ApiModelProperty(value = "备注") 42 | private String remark; 43 | 44 | @ApiModelProperty(value = "逻辑删除 1(true)已删除, 0(false)未删除") 45 | @TableLogic 46 | private Integer isDeleted; 47 | 48 | @ApiModelProperty(value = "创建时间") 49 | @TableField(fill = FieldFill.INSERT) 50 | private LocalDateTime gmtCreate; 51 | 52 | @ApiModelProperty(value = "更新时间") 53 | @TableField(fill = FieldFill.INSERT_UPDATE) 54 | private LocalDateTime gmtModified; 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/java/com/github/acl/entity/RolePermission.java: -------------------------------------------------------------------------------- 1 | package com.github.acl.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | import java.io.Serializable; 12 | import java.time.LocalDateTime; 13 | 14 | /** 15 | *

16 | * 角色权限 17 | *

18 | * 19 | * @author HAN 20 | * @since 2021-04-22 21 | */ 22 | @Data 23 | @EqualsAndHashCode(callSuper = false) 24 | @TableName("acl_role_permission") 25 | @ApiModel(value="RolePermission对象", description="角色权限") 26 | public class RolePermission implements Serializable { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | @TableId(value = "id", type = IdType.ASSIGN_ID) 31 | @JsonSerialize(using = ToStringSerializer.class) 32 | private Long id; 33 | 34 | @JsonSerialize(using = ToStringSerializer.class) 35 | private Long roleId; 36 | 37 | @JsonSerialize(using = ToStringSerializer.class) 38 | private Long permissionId; 39 | 40 | @ApiModelProperty(value = "创建时间") 41 | @TableField(fill = FieldFill.INSERT) 42 | private LocalDateTime gmtCreate; 43 | 44 | @ApiModelProperty(value = "更新时间") 45 | @TableField(fill = FieldFill.INSERT_UPDATE) 46 | private LocalDateTime gmtModified; 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/java/com/github/acl/entity/UserRole.java: -------------------------------------------------------------------------------- 1 | package com.github.acl.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | import java.io.Serializable; 12 | import java.time.LocalDateTime; 13 | 14 | /** 15 | *

16 | * 17 | *

18 | * 19 | * @author HAN 20 | * @since 2021-04-22 21 | */ 22 | @Data 23 | @EqualsAndHashCode(callSuper = false) 24 | @TableName("acl_user_role") 25 | @ApiModel(value="UserRole对象", description="") 26 | public class UserRole implements Serializable { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | @ApiModelProperty(value = "主键id") 31 | @TableId(value = "id", type = IdType.ASSIGN_ID) 32 | @JsonSerialize(using = ToStringSerializer.class) 33 | private Long id; 34 | 35 | @ApiModelProperty(value = "角色id") 36 | @JsonSerialize(using = ToStringSerializer.class) 37 | private Long roleId; 38 | 39 | @ApiModelProperty(value = "用户id") 40 | @JsonSerialize(using = ToStringSerializer.class) 41 | private Long userId; 42 | 43 | @ApiModelProperty(value = "创建时间") 44 | @TableField(fill = FieldFill.INSERT) 45 | private LocalDateTime gmtCreate; 46 | 47 | @ApiModelProperty(value = "更新时间") 48 | @TableField(fill = FieldFill.INSERT_UPDATE) 49 | private LocalDateTime gmtModified; 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/java/com/github/acl/mapper/PermissionMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.acl.mapper; 2 | 3 | import com.github.acl.entity.Permission; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | import org.apache.ibatis.annotations.CacheNamespace; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | *

12 | * 权限 Mapper 接口 13 | *

14 | * 15 | * @author HAN 16 | * @since 2021-04-22 17 | */ 18 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 19 | public interface PermissionMapper extends BaseMapper { 20 | 21 | /** 22 | * 根据用户id查询权限 23 | * @param id 用户id 24 | * @return 权限列表 25 | */ 26 | List getPermissionByUserId(Long id); 27 | } 28 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/java/com/github/acl/mapper/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.acl.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.acl.entity.Role; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | 7 | import org.apache.ibatis.annotations.CacheNamespace; 8 | 9 | /** 10 | *

11 | * Mapper 接口 12 | *

13 | * 14 | * @author HAN 15 | * @since 2021-04-22 16 | */ 17 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 18 | public interface RoleMapper extends BaseMapper { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/java/com/github/acl/mapper/RolePermissionMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.acl.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.acl.entity.RolePermission; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | import org.apache.ibatis.annotations.CacheNamespace; 7 | 8 | /** 9 | *

10 | * 角色权限 Mapper 接口 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-04-22 15 | */ 16 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 17 | public interface RolePermissionMapper extends BaseMapper { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/java/com/github/acl/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.acl.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.security.entity.User; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | import org.apache.ibatis.annotations.CacheNamespace; 7 | 8 | /** 9 | *

10 | * 用户表 Mapper 接口 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-04-22 15 | */ 16 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 17 | public interface UserMapper extends BaseMapper { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/java/com/github/acl/mapper/UserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.acl.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.acl.entity.UserRole; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | 7 | import org.apache.ibatis.annotations.CacheNamespace; 8 | 9 | /** 10 | *

11 | * Mapper 接口 12 | *

13 | * 14 | * @author HAN 15 | * @since 2021-04-22 16 | */ 17 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 18 | public interface UserRoleMapper extends BaseMapper { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/java/com/github/acl/security/UserDetailsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.acl.security; 2 | 3 | import com.github.acl.service.PermissionService; 4 | import com.github.acl.service.UserService; 5 | import com.github.security.entity.SecurityUser; 6 | import com.github.security.entity.User; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.security.core.userdetails.UserDetails; 9 | import org.springframework.security.core.userdetails.UserDetailsService; 10 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 11 | import org.springframework.stereotype.Component; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * @author HAN 17 | * @version 1.0 18 | * @create 04-24-3:30 19 | */ 20 | @Component("userDetailsService") 21 | public class UserDetailsServiceImpl implements UserDetailsService { 22 | 23 | @Autowired 24 | private UserService userService; 25 | 26 | @Autowired 27 | private PermissionService permissionService; 28 | 29 | @Override 30 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 31 | // 根据用户名查询数据 32 | User user = userService.getByUsername(username); 33 | if (user == null) { 34 | throw new UsernameNotFoundException("用户不存在"); 35 | } 36 | // 根据用户id查询权限表 37 | List permissionList = permissionService.getPermissionByUserId(user.getId()); 38 | return new SecurityUser(user, permissionList); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: service-acl 4 | server: 5 | port: 8008 6 | 7 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | cloud: 5 | nacos: 6 | config: 7 | namespace: b909e98d-d1c4-4319-879a-758981c15700 8 | server-addr: nacos:8848 9 | file-extension: yaml 10 | extension-configs: 11 | - data-id: redis.yml 12 | refresh: true 13 | - data-id: mysql.yml 14 | refresh: true 15 | - data-id: mybatis-plus.yml 16 | refresh: true 17 | - data-id: nacos-sentinel.yml 18 | refresh: true 19 | - data-id: feign-sentinel.yml 20 | refresh: true 21 | - data-id: seata.yml 22 | refresh: true 23 | - data-id: rabbitmq.yml 24 | refresh: true 25 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/resources/mapper/PermissionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/resources/mapper/RoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/resources/mapper/RolePermissionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /service/service_acl8008/src/main/resources/mapper/UserRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /service/service_center8005/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM adoptopenjdk/openjdk15:ubi 2 | RUN mkdir /app 3 | COPY ./service/service_center8005/target/service_center.jar /app 4 | COPY ./wait-for-it.sh /app 5 | WORKDIR /app 6 | CMD ["java", "-jar", "service_center.jar"] 7 | -------------------------------------------------------------------------------- /service/service_center8005/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | service 7 | com.github 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | service_center8005 13 | 14 | 15 | 15 16 | 15 17 | 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-mail 23 | 24 | 25 | com.alibaba 26 | fastjson 27 | 28 | 29 | 30 | 31 | service_center 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/java/com/github/center/UserCenterMain8005.java: -------------------------------------------------------------------------------- 1 | package com.github.center; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.context.annotation.ComponentScan; 7 | 8 | /** 9 | * @author HAN 10 | * @version 1.0 11 | * @create 2021/4/15 12 | */ 13 | @SpringBootApplication 14 | @ComponentScan("com.github") 15 | @EnableFeignClients 16 | public class UserCenterMain8005 { 17 | 18 | public static void main(String[] args){ 19 | SpringApplication.run(UserCenterMain8005.class, args); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/java/com/github/center/aspect/LoginAspect.java: -------------------------------------------------------------------------------- 1 | package com.github.center.aspect; 2 | 3 | import org.aspectj.lang.annotation.Aspect; 4 | import org.aspectj.lang.annotation.Before; 5 | import org.aspectj.lang.annotation.Pointcut; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.cloud.stream.function.StreamBridge; 8 | import org.springframework.messaging.support.MessageBuilder; 9 | import org.springframework.stereotype.Component; 10 | 11 | import java.time.LocalDate; 12 | import java.util.concurrent.ThreadPoolExecutor; 13 | 14 | /** 15 | * @author HAN 16 | * @version 1.0 17 | * @create 04-30-16:57 18 | */ 19 | @Aspect 20 | @Component 21 | public class LoginAspect { 22 | 23 | @Autowired 24 | private ThreadPoolExecutor threadPoolExecutor; 25 | 26 | @Autowired 27 | private StreamBridge streamBridge; 28 | 29 | @Pointcut("execution(* com.github.center.controller.UcenterMemberController.loginUser(..))") 30 | public void loginUser() {} 31 | 32 | @Pointcut("execution(* com.github.center.controller.GithubController.loginUser(..))") 33 | public void loginGithub() {} 34 | 35 | /** 36 | * 统计登陆次数+1 37 | */ 38 | @Before("loginUser() || loginGithub()") 39 | public void loginCount() { 40 | threadPoolExecutor.execute(() -> { 41 | streamBridge.send("loginCount-out-0", 42 | MessageBuilder.withPayload(LocalDate.now().toString()).build()); 43 | }); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/java/com/github/center/aspect/RegisterAspect.java: -------------------------------------------------------------------------------- 1 | package com.github.center.aspect; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.aspectj.lang.annotation.Aspect; 5 | import org.aspectj.lang.annotation.Before; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.cloud.stream.function.StreamBridge; 8 | import org.springframework.messaging.support.MessageBuilder; 9 | import org.springframework.stereotype.Component; 10 | 11 | import java.time.LocalDate; 12 | import java.util.concurrent.ThreadPoolExecutor; 13 | 14 | /** 15 | * @author HAN 16 | * @version 1.0 17 | * @create 05-04-1:59 18 | */ 19 | @Aspect 20 | @Component 21 | @Slf4j 22 | public class RegisterAspect { 23 | 24 | @Autowired 25 | private StreamBridge streamBridge; 26 | 27 | @Autowired 28 | private ThreadPoolExecutor threadPoolExecutor; 29 | 30 | /** 31 | * 统计注册人数+1 32 | */ 33 | @Before("execution(* com.github.center.service.UcenterMemberService.register(..))") 34 | public void countRegister() { 35 | threadPoolExecutor.execute(() -> { 36 | streamBridge.send("registerCount-out-0", 37 | MessageBuilder.withPayload(LocalDate.now().toString()).build()); 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/java/com/github/center/config/BeanConfig.java: -------------------------------------------------------------------------------- 1 | package com.github.center.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import java.util.concurrent.*; 7 | 8 | /** 9 | * @author HAN 10 | * @version 1.0 11 | * @create 04-16-16:01 12 | */ 13 | @Configuration 14 | public class BeanConfig { 15 | 16 | @Bean 17 | public ThreadPoolExecutor threadPoolExecutor() { 18 | return new ThreadPoolExecutor( 19 | 3, 20 | 15, 21 | 3, 22 | TimeUnit.SECONDS, 23 | new ArrayBlockingQueue<>(15), 24 | Executors.defaultThreadFactory(), 25 | new ThreadPoolExecutor.DiscardOldestPolicy()); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/java/com/github/center/config/MybatisPlusConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.github.center.config; 2 | 3 | import com.baomidou.mybatisplus.annotation.DbType; 4 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 5 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 6 | import org.mybatis.spring.annotation.MapperScan; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.transaction.annotation.EnableTransactionManagement; 10 | 11 | /** 12 | * @author HAN 13 | * @version 1.0 14 | * @create 2021/4/13 15 | */ 16 | @Configuration 17 | @EnableTransactionManagement 18 | @MapperScan("com.github.center.mapper") 19 | public class MybatisPlusConfiguration { 20 | 21 | @Bean 22 | public MybatisPlusInterceptor mybatisPlusInterceptor() { 23 | MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); 24 | mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); 25 | // mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); 26 | return mybatisPlusInterceptor; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/java/com/github/center/controller/EmailController.java: -------------------------------------------------------------------------------- 1 | package com.github.center.controller; 2 | 3 | import com.github.center.service.EmailService; 4 | import com.github.utils.ResultCommon; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | /** 11 | * @author HAN 12 | * @version 1.0 13 | * @create 2021/4/15 14 | */ 15 | @RestController 16 | @RequestMapping("/edu-center/email") 17 | //@CrossOrigin 18 | @Api("发送邮箱") 19 | public class EmailController { 20 | 21 | @Autowired 22 | private EmailService emailService; 23 | 24 | /** 25 | * 发送邮箱 26 | * @param email 邮箱地址 27 | * @return 返回成功与否信息 28 | */ 29 | @GetMapping("{email}") 30 | @ApiOperation("发送邮箱") 31 | public ResultCommon sendEmail(@PathVariable("email") String email) { 32 | return emailService.sendEmail(email); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/java/com/github/center/entity/UcenterMember.java: -------------------------------------------------------------------------------- 1 | package com.github.center.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | import java.io.Serializable; 12 | import java.time.LocalDateTime; 13 | 14 | /** 15 | *

16 | * 会员表 17 | *

18 | * 19 | * @author HAN 20 | * @since 2021-04-15 21 | */ 22 | @Data 23 | @EqualsAndHashCode(callSuper = false) 24 | @ApiModel(value="UcenterMember对象", description="会员表") 25 | public class UcenterMember implements Serializable { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | @ApiModelProperty(value = "会员id") 30 | @TableId(value = "id", type = IdType.ASSIGN_ID) 31 | @JsonSerialize(using = ToStringSerializer.class) 32 | private String id; 33 | 34 | @ApiModelProperty(value = "openid") 35 | private String openid; 36 | 37 | @ApiModelProperty(value = "邮箱号") 38 | private String email; 39 | 40 | @ApiModelProperty(value = "密码") 41 | private String password; 42 | 43 | @ApiModelProperty(value = "昵称") 44 | private String nickname; 45 | 46 | @ApiModelProperty(value = "性别 0 女,1 男") 47 | private Integer sex; 48 | 49 | @ApiModelProperty(value = "年龄") 50 | private Integer age; 51 | 52 | @ApiModelProperty(value = "用户头像") 53 | private String avatar; 54 | 55 | @ApiModelProperty(value = "用户签名") 56 | private String sign; 57 | 58 | @ApiModelProperty(value = "是否禁用 1(true)已禁用, 0(false)未禁用") 59 | private Boolean isDisabled; 60 | 61 | @ApiModelProperty(value = "逻辑删除 1(true)已删除, 0(false)未删除") 62 | @TableLogic 63 | private Boolean isDeleted; 64 | 65 | @ApiModelProperty(value = "创建时间") 66 | @TableField(fill = FieldFill.INSERT) 67 | private LocalDateTime gmtCreate; 68 | 69 | @ApiModelProperty(value = "更新时间") 70 | @TableField(fill = FieldFill.INSERT_UPDATE) 71 | private LocalDateTime gmtModified; 72 | 73 | 74 | } 75 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/java/com/github/center/mapper/EmailMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.center.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.center.thirdparty.Email; 5 | 6 | /** 7 | * @author HAN 8 | * @version 1.0 9 | * @create 04-21-16:02 10 | */ 11 | public interface EmailMapper extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/java/com/github/center/mapper/GithubMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.center.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.center.thirdparty.Github; 5 | 6 | /** 7 | * @author HAN 8 | * @version 1.0 9 | * @create 04-16-22:06 10 | */ 11 | public interface GithubMapper extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/java/com/github/center/mapper/UcenterMemberMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.center.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.center.entity.UcenterMember; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | import org.apache.ibatis.annotations.CacheNamespace; 7 | 8 | /** 9 | *

10 | * 会员表 Mapper 接口 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-04-15 15 | */ 16 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 17 | public interface UcenterMemberMapper extends BaseMapper { 18 | 19 | int countRegister(String date); 20 | } 21 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/java/com/github/center/service/GithubService.java: -------------------------------------------------------------------------------- 1 | package com.github.center.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.github.center.mapper.GithubMapper; 5 | import com.github.center.thirdparty.Github; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * @author HAN 10 | * @version 1.0 11 | * @create 04-16-22:06 12 | */ 13 | @Service 14 | public class GithubService extends ServiceImpl { 15 | } 16 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/java/com/github/center/thirdparty/Email.java: -------------------------------------------------------------------------------- 1 | package com.github.center.thirdparty; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableField; 4 | import com.baomidou.mybatisplus.annotation.TableName; 5 | import lombok.Data; 6 | 7 | /** 8 | * @author HAN 9 | * @version 1.0 10 | * @create 04-21-15:59 11 | */ 12 | @Data 13 | @TableName("three_party_info") 14 | public class Email { 15 | 16 | @TableField("id") 17 | private String username; 18 | 19 | @TableField("secret") 20 | private String password; 21 | } 22 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/java/com/github/center/thirdparty/Github.java: -------------------------------------------------------------------------------- 1 | package com.github.center.thirdparty; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author HAN 8 | * @version 1.0 9 | * @create 04-16-22:00 10 | */ 11 | @Data 12 | @TableName("three_party_info") 13 | public class Github { 14 | 15 | private String id; 16 | 17 | private String secret; 18 | } 19 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/java/com/github/center/vo/UserRegister.java: -------------------------------------------------------------------------------- 1 | package com.github.center.vo; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author HAN 8 | * @version 1.0 9 | * @create 2021/4/15 10 | */ 11 | @Data 12 | public class UserRegister { 13 | 14 | @ApiModelProperty("昵称") 15 | private String nickName; 16 | 17 | @ApiModelProperty("邮箱") 18 | private String email; 19 | 20 | @ApiModelProperty("密码") 21 | private String password; 22 | 23 | @ApiModelProperty("验证码") 24 | private String code; 25 | } 26 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8005 3 | spring: 4 | application: 5 | name: service-center 6 | mail: 7 | port: 465 8 | host: smtp.gmail.com 9 | properties: 10 | "mail.smtp.ssl.enable": true 11 | cloud: 12 | stream: 13 | bindings: 14 | loginCount-out-0: 15 | destination: login-stat-exchange # 表示要使用的Exchange名称定义 16 | content-type: application/json # 消息类型 17 | binder: defaultRabbit # 要绑定的消息服务的具体设置 18 | registerCount-out-0: 19 | destination: register-stat-exchange # 表示要使用的Exchange名称定义 20 | content-type: application/json # 消息类型 21 | binder: defaultRabbit # 要绑定的消息服务的具体设置 22 | rabbit: 23 | bindings: 24 | loginCount-out-0: 25 | producer: 26 | ttl: 60000 #消息几秒不消费转入私信队列 27 | autoBindDlq: true #启动私信队列 28 | deadLetterExchange: dead-letter-exchange #绑定exchange 29 | registerCount-out-0: 30 | producer: 31 | autoBindDlq: true #启动私信队列 32 | deadLetterExchange: dead-letter-exchange #绑定exchange 33 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | cloud: 5 | nacos: 6 | config: 7 | namespace: b909e98d-d1c4-4319-879a-758981c15700 8 | server-addr: nacos:8848 9 | file-extension: yaml 10 | extension-configs: 11 | - data-id: redis.yml 12 | refresh: true 13 | - data-id: mysql.yml 14 | refresh: true 15 | - data-id: mybatis-plus.yml 16 | refresh: true 17 | - data-id: nacos-sentinel.yml 18 | refresh: true 19 | - data-id: feign-sentinel.yml 20 | refresh: true 21 | - data-id: rabbitmq.yml 22 | refresh: true 23 | - data-id: seata.yml 24 | refresh: true 25 | -------------------------------------------------------------------------------- /service/service_center8005/src/main/resources/mapper/UcenterMemberMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /service/service_cms8004/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM adoptopenjdk/openjdk15:ubi 2 | RUN mkdir /app 3 | COPY ./service/service_cms8004/target/service_cms.jar /app 4 | COPY ./wait-for-it.sh /app 5 | WORKDIR /app 6 | CMD ["java", "-jar", "service_cms.jar"] 7 | -------------------------------------------------------------------------------- /service/service_cms8004/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | service 7 | com.github 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | service_cms8004 13 | 14 | 15 | 15 16 | 15 17 | 18 | 19 | 20 | service_cms 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /service/service_cms8004/src/main/java/com/github/cms/CmsApplicationMain8004.java: -------------------------------------------------------------------------------- 1 | package com.github.cms; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.context.annotation.ComponentScan; 7 | 8 | /** 9 | * @author HAN 10 | * @version 1.0 11 | * @create 2021/4/13 12 | */ 13 | @SpringBootApplication 14 | @EnableFeignClients 15 | @ComponentScan(basePackages = "com.github") 16 | public class CmsApplicationMain8004 { 17 | 18 | public static void main(String[] args){ 19 | SpringApplication.run(CmsApplicationMain8004.class, args); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /service/service_cms8004/src/main/java/com/github/cms/config/MybatisPlusConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.github.cms.config; 2 | 3 | import com.baomidou.mybatisplus.annotation.DbType; 4 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 5 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 6 | import org.mybatis.spring.annotation.MapperScan; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.transaction.annotation.EnableTransactionManagement; 10 | 11 | /** 12 | * @author HAN 13 | * @version 1.0 14 | * @create 2021/4/13 15 | */ 16 | @Configuration 17 | @EnableTransactionManagement 18 | @MapperScan("com.github.cms.mapper") 19 | public class MybatisPlusConfiguration { 20 | 21 | @Bean 22 | public MybatisPlusInterceptor mybatisPlusInterceptor() { 23 | MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); 24 | mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); 25 | // mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); 26 | return mybatisPlusInterceptor; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /service/service_cms8004/src/main/java/com/github/cms/entity/CrmBanner.java: -------------------------------------------------------------------------------- 1 | package com.github.cms.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | import java.io.Serializable; 12 | import java.time.LocalDateTime; 13 | 14 | /** 15 | *

16 | * 首页banner表 17 | *

18 | * 19 | * @author HAN 20 | * @since 2021-04-13 21 | */ 22 | @Data 23 | @EqualsAndHashCode(callSuper = false) 24 | @ApiModel(value="CrmBanner对象", description="首页banner表") 25 | public class CrmBanner implements Serializable { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | @ApiModelProperty(value = "ID") 30 | @TableId(value = "id", type = IdType.ASSIGN_ID) 31 | @JsonSerialize(using = ToStringSerializer.class) 32 | private Long id; 33 | 34 | @ApiModelProperty(value = "标题") 35 | private String title; 36 | 37 | @ApiModelProperty(value = "图片地址") 38 | private String imageUrl; 39 | 40 | @ApiModelProperty(value = "链接地址") 41 | private String linkUrl; 42 | 43 | @ApiModelProperty(value = "排序") 44 | private Integer sort; 45 | 46 | @ApiModelProperty(value = "逻辑删除 1(true)已删除, 0(false)未删除") 47 | @TableLogic 48 | private Integer isDeleted; 49 | 50 | @ApiModelProperty(value = "创建时间") 51 | @TableField(fill = FieldFill.INSERT) 52 | private LocalDateTime gmtCreate; 53 | 54 | @ApiModelProperty(value = "更新时间") 55 | @TableField(fill = FieldFill.INSERT_UPDATE) 56 | private LocalDateTime gmtModified; 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /service/service_cms8004/src/main/java/com/github/cms/mapper/CrmBannerMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.cms.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.cms.entity.CrmBanner; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | import org.apache.ibatis.annotations.CacheNamespace; 7 | 8 | /** 9 | *

10 | * 首页banner表 Mapper 接口 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-04-13 15 | */ 16 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 17 | public interface CrmBannerMapper extends BaseMapper { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /service/service_cms8004/src/main/java/com/github/cms/service/CrmBannerService.java: -------------------------------------------------------------------------------- 1 | package com.github.cms.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.github.cms.entity.CrmBanner; 5 | import com.github.cms.mapper.CrmBannerMapper; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | *

10 | * 首页banner表 服务实现类 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-04-13 15 | */ 16 | @Service 17 | public class CrmBannerService extends ServiceImpl { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /service/service_cms8004/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8004 3 | spring: 4 | application: 5 | name: service-cms 6 | -------------------------------------------------------------------------------- /service/service_cms8004/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | cloud: 5 | nacos: 6 | config: 7 | namespace: b909e98d-d1c4-4319-879a-758981c15700 8 | server-addr: nacos:8848 9 | file-extension: yaml 10 | extension-configs: 11 | - data-id: redis.yml 12 | refresh: true 13 | - data-id: mysql.yml 14 | refresh: true 15 | - data-id: mybatis-plus.yml 16 | refresh: true 17 | - data-id: nacos-sentinel.yml 18 | refresh: true 19 | - data-id: feign-sentinel.yml 20 | refresh: true 21 | - data-id: seata.yml 22 | refresh: true 23 | - data-id: rabbitmq.yml 24 | refresh: true 25 | -------------------------------------------------------------------------------- /service/service_cms8004/src/main/resources/mapper/CrmBannerMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /service/service_edu8001/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM adoptopenjdk/openjdk15:ubi 2 | RUN mkdir /app 3 | COPY ./service/service_edu8001/target/service_edu.jar /app 4 | COPY ./wait-for-it.sh /app 5 | WORKDIR /app 6 | CMD ["java", "-jar", "service_edu.jar"] 7 | -------------------------------------------------------------------------------- /service/service_edu8001/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | service 7 | com.github 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | service_edu8001 13 | 14 | 15 | 15 16 | 15 17 | 18 | 19 | 20 | 21 | com.alibaba 22 | easyexcel 23 | 2.2.8 24 | 25 | 26 | 27 | 28 | service_edu 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/EduServiceMain8001.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.context.annotation.ComponentScan; 7 | 8 | /** 9 | * @author HAN 10 | * @version 1.0 11 | * @create 2021/4/4 12 | */ 13 | @SpringBootApplication 14 | @ComponentScan(basePackages = "com.github") 15 | @EnableFeignClients 16 | public class EduServiceMain8001 { 17 | 18 | public static void main(String[] args){ 19 | SpringApplication.run(EduServiceMain8001.class, args); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/aspect/FrontCourseAspect.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.aspect; 2 | 3 | import com.github.eduservice.service.EduCourseService; 4 | import org.aspectj.lang.JoinPoint; 5 | import org.aspectj.lang.annotation.After; 6 | import org.aspectj.lang.annotation.Aspect; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.cloud.stream.function.StreamBridge; 9 | import org.springframework.messaging.support.MessageBuilder; 10 | import org.springframework.stereotype.Component; 11 | 12 | import java.time.LocalDate; 13 | import java.util.concurrent.ThreadPoolExecutor; 14 | 15 | /** 16 | * @author HAN 17 | * @version 1.0 18 | * @create 04-30-1:33 19 | */ 20 | @Aspect 21 | @Component 22 | public class FrontCourseAspect { 23 | 24 | @Autowired 25 | private EduCourseService eduCourseService; 26 | 27 | @Autowired 28 | private ThreadPoolExecutor threadPoolExecutor; 29 | 30 | @Autowired 31 | private StreamBridge streamBridge; 32 | 33 | /** 34 | * 切面,切入课程信息之后,计算浏览数量 35 | */ 36 | @After("execution(* com.github.eduservice.controller.FrontCourseController.getCourseInfo(..))") 37 | public void buyCount(JoinPoint joinPoint) { 38 | threadPoolExecutor.execute(() -> { 39 | Object[] args = joinPoint.getArgs(); 40 | eduCourseService.viewCount((Long) args[0]); 41 | // 发送到消息队列统计数量 42 | streamBridge.send("courseViewCountStat-out-0", 43 | MessageBuilder.withPayload(LocalDate.now().toString()).build()); 44 | }); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/config/EduConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.config; 2 | 3 | import org.apache.tomcat.util.threads.ThreadPoolExecutor; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import java.util.concurrent.ArrayBlockingQueue; 8 | import java.util.concurrent.Executors; 9 | import java.util.concurrent.TimeUnit; 10 | 11 | /** 12 | * @author HAN 13 | * @version 1.0 14 | * @create 2021/4/4 15 | */ 16 | @Configuration 17 | public class EduConfiguration { 18 | 19 | @Bean 20 | public ThreadPoolExecutor threadPoolExecutor() { 21 | return new ThreadPoolExecutor(5, 22 | 30, 23 | 30, 24 | TimeUnit.SECONDS, 25 | new ArrayBlockingQueue<>(30), 26 | Executors.defaultThreadFactory(), 27 | new ThreadPoolExecutor.CallerRunsPolicy()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/config/MybatisPlusConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.config; 2 | 3 | import com.baomidou.mybatisplus.annotation.DbType; 4 | import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; 5 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 6 | import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; 7 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 8 | import org.mybatis.spring.annotation.MapperScan; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | import org.springframework.transaction.annotation.EnableTransactionManagement; 12 | 13 | /** 14 | * @author HAN 15 | * @version 1.0 16 | * @create 2021/4/5 17 | */ 18 | @Configuration 19 | @EnableTransactionManagement 20 | @MapperScan("com.github.eduservice.mapper") 21 | public class MybatisPlusConfiguration { 22 | 23 | @Bean 24 | public MybatisPlusInterceptor mybatisPlusInterceptor() { 25 | MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); 26 | mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); 27 | mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); 28 | return mybatisPlusInterceptor; 29 | } 30 | 31 | @Bean 32 | public ConfigurationCustomizer configurationCustomizer() { 33 | return configuration -> configuration.setUseDeprecatedExecutor(false); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/controller/EduCommentController.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.controller; 2 | 3 | 4 | import com.github.eduservice.entity.EduComment; 5 | import com.github.eduservice.service.EduCommentService; 6 | import com.github.utils.ResultCommon; 7 | import io.swagger.annotations.Api; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | *

16 | * 评论 前端控制器 17 | *

18 | * 19 | * @author HAN 20 | * @since 2021-05-01 21 | */ 22 | @RestController 23 | @RequestMapping("/eduservice/edu-comment") 24 | @Api(tags = "评论功能") 25 | public class EduCommentController { 26 | 27 | @Autowired 28 | private EduCommentService eduCommentService; 29 | 30 | /** 31 | * 获取评论信息 32 | * @param courseId 课程id 33 | */ 34 | @GetMapping("{courseId}") 35 | @ApiOperation("获取评论") 36 | public ResultCommon getComment(@PathVariable("courseId") Long courseId) { 37 | List commentList = eduCommentService.getComment(courseId); 38 | return ResultCommon.success().setData("items", commentList); 39 | } 40 | 41 | /** 42 | * 添加评论信息 43 | * @param comment 评论以及用户信息 44 | */ 45 | @PostMapping("{courseId}") 46 | @ApiOperation("添加一级评论信息") 47 | public ResultCommon saveCommentLevelOne(@RequestBody EduComment comment) { 48 | eduCommentService.save(comment); 49 | return ResultCommon.success(); 50 | } 51 | 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/controller/EduFrontIndexController.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.controller; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.github.eduservice.entity.EduCourse; 5 | import com.github.eduservice.entity.EduTeacher; 6 | import com.github.eduservice.service.EduCourseService; 7 | import com.github.eduservice.service.EduTeacherService; 8 | import com.github.utils.ResultCommon; 9 | import io.swagger.annotations.Api; 10 | import io.swagger.annotations.ApiOperation; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.cache.annotation.Cacheable; 13 | import org.springframework.web.bind.annotation.GetMapping; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RestController; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | * @author HAN 21 | * @version 1.0 22 | * @create 2021/4/13 23 | */ 24 | @RestController 25 | @RequestMapping("/eduservice/index") 26 | @Api("前台页面查询功能") 27 | //@CrossOrigin 28 | public class EduFrontIndexController { 29 | 30 | @Autowired 31 | private EduCourseService eduCourseService; 32 | 33 | @Autowired 34 | private EduTeacherService eduTeacherService; 35 | 36 | /** 37 | * 查询前8条热门课程,前4个热门教师 38 | */ 39 | @GetMapping 40 | @ApiOperation("查询前8条热门课程,前4个热门教师") 41 | @Cacheable(value = "banner", key = "'EduCourseTeacher'") 42 | public ResultCommon getTeacherCourse() { 43 | // 查询前8条热门课程 44 | QueryWrapper wrapperCourse = new QueryWrapper<>(); 45 | wrapperCourse.orderByDesc("view_count") 46 | .last("limit 8"); 47 | List eduCourses = eduCourseService.list(wrapperCourse); 48 | 49 | // 查询前4个热门教师 50 | QueryWrapper wrapperTeacher = new QueryWrapper<>(); 51 | wrapperTeacher.orderByDesc("sort") 52 | .last("limit 4"); 53 | List eduTeachers = eduTeacherService.list(wrapperTeacher); 54 | 55 | return ResultCommon.success().setData("courses", eduCourses).setData("teachers", eduTeachers); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/controller/EduLoginController.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.controller; 2 | 3 | import com.github.utils.ResultCommon; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.PostMapping; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | /** 10 | * @author HAN 11 | * @version 1.0 12 | * @create 2021/4/6 13 | */ 14 | @RestController 15 | @RequestMapping("/eduservice/user") 16 | public class EduLoginController { 17 | 18 | /** 19 | * login 20 | */ 21 | @PostMapping("login") 22 | public ResultCommon login() { 23 | return ResultCommon.success().setData("token", "admin"); 24 | } 25 | 26 | /** 27 | * info 28 | */ 29 | @GetMapping("info") 30 | public ResultCommon info() { 31 | return ResultCommon.success().setData("name", "admin").setData("avatar", "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif"); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/controller/EduSubjectController.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.controller; 2 | 3 | 4 | import com.github.eduservice.entity.subject.Subject; 5 | import com.github.eduservice.service.EduSubjectService; 6 | import com.github.utils.ResultCommon; 7 | import io.swagger.annotations.Api; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.*; 11 | import org.springframework.web.multipart.MultipartFile; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | *

17 | * 课程科目 前端控制器 18 | *

19 | * 20 | * @author HAN 21 | * @since 2021-04-08 22 | */ 23 | @RestController 24 | @RequestMapping("/eduservice/subject") 25 | //@CrossOrigin 26 | @Api("课程分类") 27 | public class EduSubjectController { 28 | 29 | @Autowired 30 | private EduSubjectService eduSubjectService; 31 | 32 | /** 33 | * 获取课程分类 34 | * 获取上传过来的文件,把文件内容读取出来 35 | * @param file excel文件 36 | */ 37 | @PostMapping 38 | @ApiOperation("从excel文件中获取课程分类") 39 | public ResultCommon saveSubject(@RequestPart("file") MultipartFile file) { 40 | 41 | eduSubjectService.saveSubject(file); 42 | 43 | return ResultCommon.success(); 44 | } 45 | 46 | /** 47 | * 课程分类的树形结构 48 | */ 49 | @GetMapping 50 | @ApiOperation("递归获取课程分类信息") 51 | public ResultCommon getSubject() { 52 | 53 | List list = eduSubjectService.getRecursionList(); 54 | 55 | return ResultCommon.success().setData("items", list); 56 | } 57 | 58 | } 59 | 60 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/controller/EduVideoController.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.controller; 2 | 3 | 4 | import com.github.eduservice.entity.EduVideo; 5 | import com.github.eduservice.service.EduVideoService; 6 | import com.github.utils.ResultCommon; 7 | import io.swagger.annotations.ApiOperation; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | /** 12 | *

13 | * 课程视频 前端控制器 14 | *

15 | * 16 | * @author HAN 17 | * @since 2021-04-09 18 | */ 19 | @RestController 20 | @RequestMapping("/eduservice/video") 21 | public class EduVideoController { 22 | 23 | @Autowired 24 | private EduVideoService eduVideoService; 25 | 26 | /** 27 | * 根据id获取小节 28 | * 29 | */ 30 | @GetMapping("{id}") 31 | @ApiOperation("根据id获取小节") 32 | public ResultCommon getVideoById(@PathVariable("id") Long id) { 33 | EduVideo eduVideo = eduVideoService.getById(id); 34 | 35 | return ResultCommon.success().setData("items", eduVideo); 36 | } 37 | 38 | /** 39 | * 添加小节 40 | * 41 | * @param eduVideo 小节信息 42 | */ 43 | @PostMapping 44 | @ApiOperation("添加小节") 45 | public ResultCommon saveVideo(@RequestBody EduVideo eduVideo) { 46 | eduVideoService.save(eduVideo); 47 | 48 | return ResultCommon.success(); 49 | } 50 | 51 | /** 52 | * 删除小节 53 | * 54 | * @param id 小节id 55 | */ 56 | @DeleteMapping("{id}") 57 | @ApiOperation("删除小节") 58 | public ResultCommon deleteVideo(@PathVariable("id") Long id) { 59 | eduVideoService.removeVideo(id); 60 | 61 | return ResultCommon.success(); 62 | } 63 | 64 | /** 65 | * 更新小节 66 | */ 67 | @PutMapping 68 | @ApiOperation("更新小节") 69 | public ResultCommon updateVideo(@RequestBody EduVideo eduVideo) { 70 | eduVideoService.updateById(eduVideo); 71 | 72 | return ResultCommon.success(); 73 | } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/controller/FrontTeacherController.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.controller; 2 | 3 | import com.github.eduservice.entity.EduCourse; 4 | import com.github.eduservice.entity.EduTeacher; 5 | import com.github.eduservice.service.EduCourseService; 6 | import com.github.eduservice.service.EduTeacherService; 7 | import com.github.utils.ResultCommon; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * @author HAN 17 | * @version 1.0 18 | * @create 04-17-15:59 19 | */ 20 | @RestController 21 | //@CrossOrigin 22 | @RequestMapping("/eduservice/front-teacher") 23 | @Api("查询前台教师内容") 24 | public class FrontTeacherController { 25 | 26 | @Autowired 27 | private EduTeacherService eduTeacherService; 28 | 29 | @Autowired 30 | private EduCourseService eduCourseService; 31 | 32 | /** 33 | * 根据id查询教师和教师负责的课程 34 | * 35 | * @param id 教师id 36 | */ 37 | @GetMapping("{id}") 38 | @ApiOperation("查询教师信息以及负责的课程信息") 39 | public ResultCommon getTeacherCourse(@PathVariable("id") Long id) { 40 | 41 | // 查询教师信息 42 | EduTeacher eduTeacher = eduTeacherService.getById(id); 43 | 44 | // 查询课程信息 45 | List eduCourses = eduCourseService.getByTeacherId(id); 46 | 47 | return ResultCommon.success().setData("teacher", eduTeacher).setData("courses", eduCourses); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/entity/EduChapter.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.FieldFill; 4 | import com.baomidou.mybatisplus.annotation.IdType; 5 | import com.baomidou.mybatisplus.annotation.TableField; 6 | import com.baomidou.mybatisplus.annotation.TableId; 7 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 8 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 9 | import io.swagger.annotations.ApiModel; 10 | import io.swagger.annotations.ApiModelProperty; 11 | import lombok.Data; 12 | import lombok.EqualsAndHashCode; 13 | 14 | import java.io.Serializable; 15 | import java.time.LocalDateTime; 16 | 17 | /** 18 | *

19 | * 课程 20 | *

21 | * 22 | * @author HAN 23 | * @since 2021-04-09 24 | */ 25 | @Data 26 | @EqualsAndHashCode(callSuper = false) 27 | @ApiModel(value="EduChapter对象", description="课程") 28 | public class EduChapter implements Serializable { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | @ApiModelProperty(value = "章节ID") 33 | @TableId(value = "id", type = IdType.ASSIGN_ID) 34 | @JsonSerialize(using = ToStringSerializer.class) 35 | private Long id; 36 | 37 | @ApiModelProperty(value = "课程ID") 38 | @JsonSerialize(using = ToStringSerializer.class) 39 | private Long courseId; 40 | 41 | @ApiModelProperty(value = "章节名称") 42 | private String title; 43 | 44 | @ApiModelProperty(value = "显示排序") 45 | private Integer sort; 46 | 47 | @ApiModelProperty(value = "创建时间") 48 | @TableField(fill = FieldFill.INSERT) 49 | @JsonSerialize(using = ToStringSerializer.class) 50 | private LocalDateTime gmtCreate; 51 | 52 | @ApiModelProperty(value = "更新时间") 53 | @TableField(fill = FieldFill.INSERT_UPDATE) 54 | @JsonSerialize(using = ToStringSerializer.class) 55 | private LocalDateTime gmtModified; 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/entity/EduComment.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | import java.io.Serializable; 12 | import java.time.LocalDateTime; 13 | import java.util.List; 14 | 15 | /** 16 | *

17 | * 评论 18 | *

19 | * 20 | * @author HAN 21 | * @since 2021-05-01 22 | */ 23 | @Data 24 | @EqualsAndHashCode(callSuper = false) 25 | @ApiModel(value="EduComment对象", description="评论") 26 | public class EduComment implements Serializable { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | @ApiModelProperty(value = "id") 31 | @TableId(value = "id", type = IdType.ASSIGN_ID) 32 | @JsonSerialize(using = ToStringSerializer.class) 33 | private Long id; 34 | 35 | @ApiModelProperty(value = "课程id") 36 | private String courseId; 37 | 38 | @ApiModelProperty(value = "父id(回复)") 39 | @JsonSerialize(using = ToStringSerializer.class) 40 | private Long parentId; 41 | 42 | @ApiModelProperty(value = "用户id") 43 | private String memberId; 44 | 45 | @ApiModelProperty(value = "用户昵称") 46 | private String nickname; 47 | 48 | @ApiModelProperty(value = "用户头像") 49 | private String avatar; 50 | 51 | @ApiModelProperty(value = "评论内容") 52 | private String content; 53 | 54 | @ApiModelProperty("子级信息") 55 | @TableField(exist = false) 56 | private List children; 57 | 58 | @ApiModelProperty(value = "逻辑删除 1(true)已删除, 0(false)未删除") 59 | @TableLogic 60 | private Integer isDeleted; 61 | 62 | @ApiModelProperty(value = "创建时间") 63 | @TableField(fill = FieldFill.INSERT) 64 | private LocalDateTime gmtCreate; 65 | 66 | @ApiModelProperty(value = "更新时间") 67 | @TableField(fill = FieldFill.INSERT_UPDATE) 68 | private LocalDateTime gmtModified; 69 | 70 | 71 | } 72 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/entity/EduCourseDescription.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.FieldFill; 4 | import com.baomidou.mybatisplus.annotation.IdType; 5 | import com.baomidou.mybatisplus.annotation.TableField; 6 | import com.baomidou.mybatisplus.annotation.TableId; 7 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 8 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 9 | import io.swagger.annotations.ApiModel; 10 | import io.swagger.annotations.ApiModelProperty; 11 | import lombok.Data; 12 | import lombok.EqualsAndHashCode; 13 | 14 | import java.io.Serializable; 15 | import java.time.LocalDateTime; 16 | 17 | /** 18 | *

19 | * 课程简介 20 | *

21 | * 22 | * @author HAN 23 | * @since 2021-04-09 24 | */ 25 | @Data 26 | @EqualsAndHashCode(callSuper = false) 27 | @ApiModel(value="EduCourseDescription对象", description="课程简介") 28 | public class EduCourseDescription implements Serializable { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | @ApiModelProperty(value = "课程ID") 33 | @TableId(value = "id", type = IdType.INPUT) 34 | @JsonSerialize(using = ToStringSerializer.class) 35 | private Long id; 36 | 37 | @ApiModelProperty(value = "课程简介") 38 | private String description; 39 | 40 | @ApiModelProperty(value = "创建时间") 41 | @TableField(fill = FieldFill.INSERT) 42 | private LocalDateTime gmtCreate; 43 | 44 | @ApiModelProperty(value = "更新时间") 45 | @TableField(fill = FieldFill.INSERT_UPDATE) 46 | private LocalDateTime gmtModified; 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/entity/EduSubject.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.FieldFill; 4 | import com.baomidou.mybatisplus.annotation.IdType; 5 | import com.baomidou.mybatisplus.annotation.TableField; 6 | import com.baomidou.mybatisplus.annotation.TableId; 7 | import com.fasterxml.jackson.annotation.JsonFormat; 8 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 9 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 10 | import io.swagger.annotations.ApiModel; 11 | import io.swagger.annotations.ApiModelProperty; 12 | import lombok.Data; 13 | import lombok.EqualsAndHashCode; 14 | 15 | import java.io.Serializable; 16 | import java.time.LocalDateTime; 17 | 18 | /** 19 | *

20 | * 课程科目 21 | *

22 | * 23 | * @author HAN 24 | * @since 2021-04-08 25 | */ 26 | @Data 27 | @EqualsAndHashCode(callSuper = false) 28 | @ApiModel(value="EduSubject对象", description="课程科目") 29 | public class EduSubject implements Serializable { 30 | 31 | private static final long serialVersionUID = 1L; 32 | 33 | @ApiModelProperty(value = "课程类别ID") 34 | @TableId(value = "id", type = IdType.ASSIGN_ID) 35 | @JsonSerialize(using = ToStringSerializer.class) 36 | private Long id; 37 | 38 | @ApiModelProperty(value = "类别名称") 39 | private String title; 40 | 41 | @ApiModelProperty(value = "父ID") 42 | private Long parentId; 43 | 44 | @ApiModelProperty(value = "排序字段") 45 | private Integer sort; 46 | 47 | @ApiModelProperty(value = "创建时间") 48 | @TableField(fill = FieldFill.INSERT) 49 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+9") 50 | private LocalDateTime gmtCreate; 51 | 52 | @TableField(fill = FieldFill.INSERT_UPDATE) 53 | @ApiModelProperty(value = "更新时间") 54 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+9") 55 | private LocalDateTime gmtModified; 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/entity/EduTeacher.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.annotation.JsonFormat; 5 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 6 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 7 | import io.swagger.annotations.ApiModel; 8 | import io.swagger.annotations.ApiModelProperty; 9 | import lombok.Data; 10 | import lombok.EqualsAndHashCode; 11 | 12 | import java.io.Serializable; 13 | import java.time.LocalDateTime; 14 | 15 | /** 16 | *

17 | * 讲师 18 | *

19 | * 20 | * @author HAN 21 | * @since 2021-04-04 22 | */ 23 | @Data 24 | @EqualsAndHashCode(callSuper = false) 25 | @ApiModel(value="EduTeacher对象", description="讲师") 26 | public class EduTeacher implements Serializable { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | @ApiModelProperty(value = "讲师ID") 31 | @TableId(value = "id", type = IdType.ASSIGN_ID) 32 | @JsonSerialize(using = ToStringSerializer.class) // 解决雪花算法js精度不足问题 33 | private Long id; 34 | 35 | @ApiModelProperty(value = "讲师姓名") 36 | private String name; 37 | 38 | @ApiModelProperty(value = "讲师简介") 39 | private String intro; 40 | 41 | @ApiModelProperty(value = "讲师资历,一句话说明讲师") 42 | private String career; 43 | 44 | @ApiModelProperty(value = "头衔 1高级讲师 2首席讲师") 45 | private Integer level; 46 | 47 | @ApiModelProperty(value = "讲师头像") 48 | private String avatar; 49 | 50 | @ApiModelProperty(value = "排序") 51 | private Integer sort; 52 | 53 | @ApiModelProperty(value = "逻辑删除 1(true)已删除, 0(false)未删除") 54 | @TableLogic 55 | private Integer isDeleted; 56 | 57 | @ApiModelProperty(value = "创建时间") 58 | @TableField(fill = FieldFill.INSERT) 59 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+9") 60 | private LocalDateTime gmtCreate; 61 | 62 | @ApiModelProperty(value = "更新时间") 63 | @TableField(fill = FieldFill.INSERT_UPDATE) 64 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+9") 65 | private LocalDateTime gmtModified; 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/entity/EduVideo.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | import java.io.Serializable; 12 | import java.time.LocalDateTime; 13 | 14 | /** 15 | *

16 | * 课程视频 17 | *

18 | * 19 | * @author HAN 20 | * @since 2021-04-09 21 | */ 22 | @Data 23 | @EqualsAndHashCode(callSuper = false) 24 | @ApiModel(value="EduVideo对象", description="课程视频") 25 | public class EduVideo implements Serializable { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | @ApiModelProperty(value = "视频ID") 30 | @TableId(value = "id", type = IdType.ASSIGN_ID) 31 | @JsonSerialize(using = ToStringSerializer.class) 32 | private Long id; 33 | 34 | @ApiModelProperty(value = "课程ID") 35 | @JsonSerialize(using = ToStringSerializer.class) 36 | private Long courseId; 37 | 38 | @ApiModelProperty(value = "章节ID") 39 | @JsonSerialize(using = ToStringSerializer.class) 40 | private Long chapterId; 41 | 42 | @ApiModelProperty(value = "节点名称") 43 | private String title; 44 | 45 | @ApiModelProperty(value = "云端视频资源") 46 | private String videoSourceId; 47 | 48 | @ApiModelProperty(value = "原始文件名称") 49 | private String videoOriginalName; 50 | 51 | @ApiModelProperty(value = "排序字段") 52 | private Integer sort; 53 | 54 | @ApiModelProperty(value = "播放次数") 55 | private Long playCount; 56 | 57 | @ApiModelProperty(value = "是否可以试听:0收费 1免费") 58 | private Integer isFree; 59 | 60 | @ApiModelProperty(value = "视频时长(秒)") 61 | private Float duration; 62 | 63 | @ApiModelProperty(value = "Empty未上传 Transcoding转码中 Normal正常") 64 | private String status; 65 | 66 | @ApiModelProperty(value = "视频源文件大小(字节)") 67 | private Long size; 68 | 69 | @ApiModelProperty(value = "乐观锁") 70 | @Version 71 | private Long version; 72 | 73 | @ApiModelProperty(value = "创建时间") 74 | @TableField(fill = FieldFill.INSERT) 75 | private LocalDateTime gmtCreate; 76 | 77 | @ApiModelProperty(value = "更新时间") 78 | @TableField(fill = FieldFill.INSERT_UPDATE) 79 | private LocalDateTime gmtModified; 80 | 81 | 82 | } 83 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/entity/chapter/Chapter.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.entity.chapter; 2 | 3 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 4 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author HAN 13 | * @version 1.0 14 | * @create 2021/4/10 15 | */ 16 | @Data 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | public class Chapter { 20 | 21 | @JsonSerialize(using = ToStringSerializer.class) 22 | private Long id; 23 | 24 | private String title; 25 | 26 | private String videoSourceId; 27 | 28 | private Integer isFree; 29 | 30 | private List children; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/entity/excel/ExcelSubjectData.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.entity.excel; 2 | 3 | import com.alibaba.excel.annotation.ExcelProperty; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author HAN 8 | * @version 1.0 9 | * @create 2021/4/8 10 | */ 11 | @Data 12 | public class ExcelSubjectData { 13 | 14 | @ExcelProperty(index = 0) 15 | private String firstSubjectName; 16 | 17 | @ExcelProperty(index = 1) 18 | private String secondSubjectName; 19 | } 20 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/entity/subject/Subject.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.entity.subject; 2 | 3 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 4 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | import java.io.Serializable; 10 | import java.util.List; 11 | 12 | /** 13 | * @author HAN 14 | * @version 1.0 15 | * @create 2021/4/9 16 | */ 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | @Data 20 | public class Subject implements Serializable { 21 | 22 | @JsonSerialize(using = ToStringSerializer.class) 23 | private Long id; 24 | 25 | private String title; 26 | 27 | private List children; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/feign/VodClient.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.feign; 2 | 3 | import com.github.eduservice.feign.fallback.VodClientFallback; 4 | import com.github.utils.ResultCommon; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.DeleteMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | 9 | /** 10 | * @author HAN 11 | * @version 1.0 12 | * @create 2021/4/13 13 | */ 14 | @FeignClient(value = "service-vod", fallback = VodClientFallback.class) 15 | public interface VodClient { 16 | 17 | @DeleteMapping("/edu-vod/video/{id}") 18 | ResultCommon deleteVideo(@PathVariable("id") String id); 19 | } 20 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/feign/fallback/VodClientFallback.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.feign.fallback; 2 | 3 | import com.github.eduservice.feign.VodClient; 4 | import com.github.utils.ResultCommon; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * @author HAN 9 | * @version 1.0 10 | * @create 2021/4/13 11 | */ 12 | @Component 13 | public class VodClientFallback implements VodClient { 14 | @Override 15 | public ResultCommon deleteVideo(String id) { 16 | return ResultCommon.fail().setMessage("删除视频熔断失败"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/mapper/EduChapterMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.eduservice.entity.EduChapter; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | import org.apache.ibatis.annotations.CacheNamespace; 7 | 8 | /** 9 | *

10 | * 课程 Mapper 接口 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-04-09 15 | */ 16 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 17 | public interface EduChapterMapper extends BaseMapper { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/mapper/EduCommentMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.mapper; 2 | 3 | import com.github.eduservice.entity.EduComment; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | import org.apache.ibatis.annotations.CacheNamespace; 7 | 8 | /** 9 | *

10 | * 评论 Mapper 接口 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-05-01 15 | */ 16 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 17 | public interface EduCommentMapper extends BaseMapper { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/mapper/EduCourseDescriptionMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.eduservice.entity.EduCourseDescription; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | import org.apache.ibatis.annotations.CacheNamespace; 7 | 8 | /** 9 | *

10 | * 课程简介 Mapper 接口 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-04-09 15 | */ 16 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 17 | public interface EduCourseDescriptionMapper extends BaseMapper { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/mapper/EduCourseMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.eduservice.entity.EduCourse; 5 | import com.github.eduservice.vo.CourseWebInfo; 6 | import com.github.eduservice.vo.PublishInfo; 7 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 8 | import org.apache.ibatis.annotations.CacheNamespace; 9 | 10 | /** 11 | *

12 | * 课程 Mapper 接口 13 | *

14 | * 15 | * @author HAN 16 | * @since 2021-04-09 17 | */ 18 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 19 | public interface EduCourseMapper extends BaseMapper { 20 | 21 | PublishInfo getPublishInfo(Long id); 22 | 23 | CourseWebInfo getBaseCourseInfo(Long courseId); 24 | 25 | void viewCount(Long courseId); 26 | 27 | void buyCount(Long courseId); 28 | } 29 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/mapper/EduSubjectMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.eduservice.entity.EduSubject; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | import org.apache.ibatis.annotations.CacheNamespace; 7 | 8 | /** 9 | *

10 | * 课程科目 Mapper 接口 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-04-08 15 | */ 16 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 17 | public interface EduSubjectMapper extends BaseMapper { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/mapper/EduTeacherMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.eduservice.entity.EduTeacher; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | import org.apache.ibatis.annotations.CacheNamespace; 7 | 8 | /** 9 | *

10 | * 讲师 Mapper 接口 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-04-04 15 | */ 16 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 17 | public interface EduTeacherMapper extends BaseMapper { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/mapper/EduVideoMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.eduservice.entity.EduVideo; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | import org.apache.ibatis.annotations.CacheNamespace; 7 | 8 | /** 9 | *

10 | * 课程视频 Mapper 接口 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-04-09 15 | */ 16 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 17 | public interface EduVideoMapper extends BaseMapper { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/rabbitmq/BuyCount.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.rabbitmq; 2 | 3 | import com.github.eduservice.service.EduCourseService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.function.Consumer; 9 | 10 | /** 11 | * @author HAN 12 | * @version 1.0 13 | * @create 04-30-4:58 14 | */ 15 | @Component 16 | public class BuyCount { 17 | 18 | @Autowired 19 | private EduCourseService eduCourseService; 20 | 21 | @Bean 22 | public Consumer buyCountCourse() { 23 | return courseId -> eduCourseService.buyCount(courseId); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/service/EduChapterService.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.github.eduservice.entity.EduChapter; 5 | import com.github.eduservice.entity.chapter.Chapter; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | *

11 | * 课程 服务类 12 | *

13 | * 14 | * @author HAN 15 | * @since 2021-04-09 16 | */ 17 | public interface EduChapterService extends IService { 18 | 19 | /** 20 | * 获取章节分类后的List 21 | * @param courseId 课程id 22 | */ 23 | List getChapter(Long courseId); 24 | 25 | /** 26 | * 如果有小节则先删除小节 27 | * @param chapterId 章节id 28 | */ 29 | void deleteById(Long chapterId); 30 | } 31 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/service/EduCommentService.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.github.eduservice.entity.EduComment; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | *

10 | * 评论 服务类 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-05-01 15 | */ 16 | public interface EduCommentService extends IService { 17 | 18 | /** 19 | * 获取评论信息 20 | * @param courseId 课程id 21 | * @return 封装好的评论信息 22 | */ 23 | List getComment(Long courseId); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/service/EduCourseDescriptionService.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.service; 2 | 3 | import com.github.eduservice.entity.EduCourseDescription; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 课程简介 服务类 9 | *

10 | * 11 | * @author HAN 12 | * @since 2021-04-09 13 | */ 14 | public interface EduCourseDescriptionService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/service/EduCourseService.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.service; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.github.eduservice.entity.EduCourse; 6 | import com.github.eduservice.vo.CourseFrontInfo; 7 | import com.github.eduservice.vo.CourseInfo; 8 | import com.github.eduservice.vo.CourseWebInfo; 9 | import com.github.eduservice.vo.PublishInfo; 10 | 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | /** 15 | *

16 | * 课程 服务类 17 | *

18 | * 19 | * @author HAN 20 | * @since 2021-04-09 21 | */ 22 | public interface EduCourseService extends IService { 23 | 24 | /** 25 | * 添加课程基本信息 26 | * @param courseInfo 前端返回的课程信息对象 27 | */ 28 | void saveCourseInfo(CourseInfo courseInfo); 29 | 30 | /** 31 | * 获取课程基本信息 32 | * @param courseId 课程id 33 | * @return 返回封装了课程基本信息以及课程简介的对象 34 | */ 35 | CourseInfo getCourseInfo(Long courseId); 36 | 37 | /** 38 | * 修改课程信息 39 | * @param courseInfo 课程信息对象 40 | */ 41 | void updateCourseInfo(CourseInfo courseInfo); 42 | 43 | /** 44 | * 获取发布时信息 45 | * @param courseId 课程id 46 | * @return 所需的发布时信息对象 47 | */ 48 | PublishInfo getPublishInfo(Long courseId); 49 | 50 | /** 51 | * 删除课程数据,包括章节和小节 52 | * @param courseId 课程id 53 | */ 54 | void deleteCourseInfo(Long courseId); 55 | 56 | /** 57 | * 根据教师id查询课程 58 | * @param id 教师id 59 | * @return 课程信息 60 | */ 61 | List getByTeacherId(Long id); 62 | 63 | /** 64 | * 根据条件查询分页课程 65 | * @param page 分页信息 66 | * @param courseFrontInfo 条件 67 | */ 68 | Map getPageCondition(Page page, CourseFrontInfo courseFrontInfo); 69 | 70 | /** 71 | * 查询课程以及其他详细信息 72 | * @param courseId 课程id 73 | */ 74 | CourseWebInfo getBaseCourseInfo(Long courseId); 75 | 76 | /** 77 | * 增加浏览数量 78 | * @param courseId 课程id 79 | */ 80 | void viewCount(Long courseId); 81 | 82 | /** 83 | * 增加购买数量 84 | * @param courseId 课程id 85 | */ 86 | void buyCount(Long courseId); 87 | } 88 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/service/EduSubjectService.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.service; 2 | 3 | import com.github.eduservice.entity.EduSubject; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.github.eduservice.entity.subject.Subject; 6 | import org.springframework.web.multipart.MultipartFile; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | *

12 | * 课程科目 服务类 13 | *

14 | * 15 | * @author HAN 16 | * @since 2021-04-08 17 | */ 18 | public interface EduSubjectService extends IService { 19 | 20 | /** 21 | * 添加课程分类 22 | * @param file excel文件 23 | */ 24 | void saveSubject(MultipartFile file); 25 | 26 | /** 27 | * 获取分类后的list 28 | * @return 递归分类完的list 29 | */ 30 | List getRecursionList(); 31 | } 32 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/service/EduTeacherService.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.service; 2 | 3 | import com.github.eduservice.entity.EduTeacher; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 讲师 服务类 9 | *

10 | * 11 | * @author HAN 12 | * @since 2021-04-04 13 | */ 14 | public interface EduTeacherService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/service/EduVideoService.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.service; 2 | 3 | import com.github.eduservice.entity.EduVideo; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 课程视频 服务类 9 | *

10 | * 11 | * @author HAN 12 | * @since 2021-04-09 13 | */ 14 | public interface EduVideoService extends IService { 15 | 16 | /** 17 | * 删除小节以及视频 18 | * @param id 小节id 19 | */ 20 | void removeVideo(Long id); 21 | 22 | /** 23 | * 删除小节以及视频 24 | * @param chapterId 章节id 25 | */ 26 | void removeByChapterId(Long chapterId); 27 | } 28 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/service/impl/EduChapterServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.github.eduservice.entity.EduChapter; 5 | import com.github.eduservice.entity.EduVideo; 6 | import com.github.eduservice.entity.chapter.Chapter; 7 | import com.github.eduservice.mapper.EduChapterMapper; 8 | import com.github.eduservice.service.EduChapterService; 9 | import com.github.eduservice.service.EduVideoService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | import org.springframework.transaction.annotation.Transactional; 13 | 14 | import java.util.List; 15 | import java.util.Objects; 16 | import java.util.stream.Collectors; 17 | 18 | /** 19 | *

20 | * 课程 服务实现类 21 | *

22 | * 23 | * @author HAN 24 | * @since 2021-04-09 25 | */ 26 | @Service 27 | @Transactional 28 | public class EduChapterServiceImpl extends ServiceImpl implements EduChapterService { 29 | 30 | @Autowired 31 | private EduVideoService eduVideoService; 32 | 33 | @Override 34 | public List getChapter(Long courseId) { 35 | // 获取所有章节数据 36 | List chapters = super.list(); 37 | // 获取所有小节数据 38 | List videos = eduVideoService.list(); 39 | 40 | // 递归查询 41 | return chapters.stream() 42 | .filter(item -> Objects.equals(item.getCourseId(), courseId)) // 过滤出所需课程 43 | .map(item -> new Chapter(item.getId(), item.getTitle(), null, null, null)) // 转换为所需对象 44 | .peek(item -> item.setChildren(getChildren(item, videos))) 45 | .collect(Collectors.toList()); 46 | } 47 | 48 | @Override 49 | public void deleteById(Long chapterId) { 50 | // 删除小节 51 | eduVideoService.removeByChapterId(chapterId); 52 | 53 | // 删除章节 54 | super.removeById(chapterId); 55 | } 56 | 57 | public List getChildren(Chapter root, List videos) { 58 | return videos.stream() 59 | .filter(item -> Objects.equals(item.getChapterId(), root.getId())) // 把小节中的章节id对应章节的过滤出来 60 | .map(item -> new Chapter(item.getId(), item.getTitle(), item.getVideoSourceId(), item.getIsFree(), null)) 61 | .peek(item -> item.setChildren(getChildren(item, videos))) 62 | .collect(Collectors.toList()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/service/impl/EduCommentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 5 | import com.github.eduservice.entity.EduComment; 6 | import com.github.eduservice.mapper.EduCommentMapper; 7 | import com.github.eduservice.service.EduCommentService; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.util.ObjectUtils; 10 | 11 | import java.util.List; 12 | import java.util.Objects; 13 | import java.util.stream.Collectors; 14 | 15 | /** 16 | *

17 | * 评论 服务实现类 18 | *

19 | * 20 | * @author HAN 21 | * @since 2021-05-01 22 | */ 23 | @Service 24 | public class EduCommentServiceImpl extends ServiceImpl implements EduCommentService { 25 | 26 | @Override 27 | public List getComment(Long courseId) { 28 | QueryWrapper wrapper = new QueryWrapper<>(); 29 | wrapper.eq("course_id", courseId); 30 | List comments = super.list(wrapper); 31 | return comments.stream() 32 | .filter(item -> item.getParentId() == 0) 33 | .peek(item -> item.setChildren(commentRecursiveHelper(item, comments))) 34 | .collect(Collectors.toList()); 35 | } 36 | 37 | private List commentRecursiveHelper(EduComment comment, List comments) { 38 | return comments.stream() 39 | .filter(item -> Objects.equals(item.getParentId(), comment.getId())) 40 | .peek(item -> item.setChildren(commentRecursiveHelper(item, comments))) 41 | .collect(Collectors.toList()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/service/impl/EduCourseDescriptionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.service.impl; 2 | 3 | import com.github.eduservice.entity.EduCourseDescription; 4 | import com.github.eduservice.mapper.EduCourseDescriptionMapper; 5 | import com.github.eduservice.service.EduCourseDescriptionService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 课程简介 服务实现类 12 | *

13 | * 14 | * @author HAN 15 | * @since 2021-04-09 16 | */ 17 | @Service 18 | public class EduCourseDescriptionServiceImpl extends ServiceImpl implements EduCourseDescriptionService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/service/impl/EduTeacherServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.service.impl; 2 | 3 | import com.github.eduservice.entity.EduTeacher; 4 | import com.github.eduservice.mapper.EduTeacherMapper; 5 | import com.github.eduservice.service.EduTeacherService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 讲师 服务实现类 12 | *

13 | * 14 | * @author HAN 15 | * @since 2021-04-04 16 | */ 17 | @Service 18 | public class EduTeacherServiceImpl extends ServiceImpl implements EduTeacherService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/service/impl/EduVideoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.github.eduservice.entity.EduVideo; 5 | import com.github.eduservice.feign.VodClient; 6 | import com.github.eduservice.mapper.EduVideoMapper; 7 | import com.github.eduservice.service.EduVideoService; 8 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 9 | import io.seata.spring.annotation.GlobalTransactional; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | import org.springframework.transaction.annotation.Transactional; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | *

18 | * 课程视频 服务实现类 19 | *

20 | * 21 | * @author HAN 22 | * @since 2021-04-09 23 | */ 24 | @Service 25 | @Transactional 26 | public class EduVideoServiceImpl extends ServiceImpl implements EduVideoService { 27 | 28 | @Autowired 29 | private VodClient vodClient; 30 | 31 | @Override 32 | @GlobalTransactional 33 | public void removeVideo(Long id) { 34 | QueryWrapper wrapper = new QueryWrapper<>(); 35 | wrapper.select("video_source_id").eq("id", id); 36 | EduVideo eduVideo = super.getOne(wrapper); 37 | // 删除视频 38 | vodClient.deleteVideo(eduVideo.getVideoSourceId()); 39 | // 删除小节 40 | super.removeById(id); 41 | } 42 | 43 | @Override 44 | @GlobalTransactional 45 | public void removeByChapterId(Long chapterId) { 46 | QueryWrapper wrapper = new QueryWrapper<>(); 47 | wrapper.eq("chapter_id", chapterId).select("video_source_id"); 48 | List eduVideos = super.list(wrapper); 49 | // 删除视频 50 | eduVideos.forEach(eduVideo -> vodClient.deleteVideo(eduVideo.getVideoSourceId())); 51 | // 删除小节 52 | super.remove(wrapper); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/vo/CourseFrontInfo.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.vo; 2 | 3 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 4 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | 8 | /** 9 | * @author HAN 10 | * @version 1.0 11 | * @create 04-17-16:46 12 | */ 13 | @Data 14 | public class CourseFrontInfo { 15 | @ApiModelProperty(value = "课程专业ID") 16 | @JsonSerialize(using = ToStringSerializer.class) 17 | private Long subjectId; 18 | 19 | @ApiModelProperty(value = "课程专业父级ID") 20 | @JsonSerialize(using = ToStringSerializer.class) 21 | private Long subjectParentId; 22 | 23 | @ApiModelProperty("销量排序") 24 | private String buyCountSort; 25 | 26 | @ApiModelProperty("创建时间排序") 27 | private String gmtCreateSort; 28 | 29 | @ApiModelProperty("价格排序") 30 | private String priceSort; 31 | 32 | @ApiModelProperty("课程名字模糊查询") 33 | private String courseName; 34 | } 35 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/vo/CourseInfo.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.vo; 2 | 3 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 4 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | 9 | import java.math.BigDecimal; 10 | 11 | /** 12 | * @author HAN 13 | * @version 1.0 14 | * @create 2021/4/9 15 | */ 16 | @Data 17 | @Api("接受前端返回的课程信息") 18 | public class CourseInfo { 19 | 20 | @ApiModelProperty(value = "课程ID") 21 | @JsonSerialize(using = ToStringSerializer.class) 22 | private Long id; 23 | 24 | @ApiModelProperty(value = "课程讲师ID") 25 | @JsonSerialize(using = ToStringSerializer.class) 26 | private Long teacherId; 27 | 28 | @ApiModelProperty(value = "课程专业ID") 29 | @JsonSerialize(using = ToStringSerializer.class) 30 | private Long subjectId; 31 | 32 | @ApiModelProperty(value = "课程专业父级ID") 33 | @JsonSerialize(using = ToStringSerializer.class) 34 | private Long subjectParentId; 35 | 36 | @ApiModelProperty(value = "课程标题") 37 | private String title; 38 | 39 | @ApiModelProperty(value = "课程销售价格,设置为0则可免费观看") 40 | private BigDecimal price; 41 | 42 | @ApiModelProperty(value = "总课时") 43 | private Integer lessonNum; 44 | 45 | @ApiModelProperty(value = "课程封面图片路径") 46 | private String cover; 47 | 48 | @ApiModelProperty(value = "课程简介") 49 | private String description; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/vo/CourseQuery.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.vo; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author HAN 8 | * @version 1.0 9 | * @create 2021/4/12 10 | */ 11 | @Data 12 | public class CourseQuery { 13 | 14 | @ApiModelProperty("课程名称") 15 | private String title; 16 | 17 | @ApiModelProperty("发布状态 Draft: 未发布 Normal: 已发布") 18 | private String status; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/vo/CourseWebInfo.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.vo; 2 | 3 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 4 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.*; 7 | 8 | import java.math.BigDecimal; 9 | 10 | /** 11 | * @author HAN 12 | * @version 1.0 13 | * @create 04-17-21:54 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class CourseWebInfo { 19 | @ApiModelProperty(value = "课程ID") 20 | @JsonSerialize(using = ToStringSerializer.class) 21 | private Long id; 22 | 23 | @ApiModelProperty(value = "课程标题") 24 | private String title; 25 | 26 | @ApiModelProperty(value = "课程销售价格,设置为0则可免费观看") 27 | private BigDecimal price; 28 | 29 | @ApiModelProperty(value = "总课时") 30 | private Integer lessonNum; 31 | 32 | @ApiModelProperty(value = "课程封面图片路径") 33 | private String cover; 34 | 35 | @ApiModelProperty(value = "销售数量") 36 | private Long buyCount; 37 | 38 | @ApiModelProperty(value = "浏览数量") 39 | private Long viewCount; 40 | 41 | @ApiModelProperty(value = "课程简介") 42 | private String description; 43 | 44 | @ApiModelProperty(value = "课程教师ID") 45 | @JsonSerialize(using = ToStringSerializer.class) 46 | private Long teacherId; 47 | 48 | @ApiModelProperty(value = "教师姓名") 49 | private String teacherName; 50 | 51 | @ApiModelProperty(value = "教师资历,一句话说明讲师") 52 | private String intro; 53 | 54 | @ApiModelProperty(value = "教师头像") 55 | private String avatar; 56 | 57 | @ApiModelProperty(value = "课程专业父级ID") 58 | @JsonSerialize(using = ToStringSerializer.class) 59 | private Long subjectParentId; 60 | 61 | @ApiModelProperty(value = "类别一级名称") 62 | private String subjectParentTitle; 63 | 64 | @ApiModelProperty(value = "课程专业ID") 65 | @JsonSerialize(using = ToStringSerializer.class) 66 | private Long subjectId; 67 | 68 | @ApiModelProperty(value = "类别二级名称") 69 | private String subjectTitle; 70 | } 71 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/vo/PublishInfo.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.vo; 2 | 3 | import io.swagger.annotations.Api; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | /** 8 | * @author HAN 9 | * @version 1.0 10 | * @create 2021/4/11 11 | */ 12 | @Data 13 | @Api("发布时课程信息") 14 | public class PublishInfo { 15 | 16 | @ApiModelProperty("课程id") 17 | private Long id; 18 | 19 | @ApiModelProperty("课程标题") 20 | private String title; 21 | 22 | @ApiModelProperty("课程课程封面图片路径") 23 | private String cover; 24 | 25 | @ApiModelProperty(value = "总课时") 26 | private Integer lessonNum; 27 | 28 | @ApiModelProperty("一级课程名") 29 | private String subjectFirst; 30 | 31 | @ApiModelProperty("二级课程名") 32 | private String subjectSecond; 33 | 34 | @ApiModelProperty("课程教师") 35 | private String teacherName; 36 | 37 | @ApiModelProperty("课程费用,只用作显示") 38 | private String price; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/java/com/github/eduservice/vo/TeacherQuery.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.vo; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author HAN 8 | * @version 1.0 9 | * @create 2021/4/5 10 | */ 11 | @Data 12 | public class TeacherQuery { 13 | 14 | @ApiModelProperty(value = "教师名称,模糊查询") 15 | private String name; 16 | 17 | @ApiModelProperty(value = "教师头衔,1:高级, 2:首席") 18 | private Integer level; 19 | 20 | @ApiModelProperty(value = "查询开始时间", example = "2021-01-01 10:10:10") 21 | private String begin; 22 | 23 | @ApiModelProperty(value = "查询结束时间", example = "2021-12-31 10:10:10") 24 | private String end; 25 | } 26 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8001 3 | spring: 4 | application: 5 | name: service-edu 6 | cloud: 7 | stream: 8 | bindings: 9 | buyCountCourse-in-0: # input 10 | destination: course-buy-count-exchange # 表示要使用的Exchange名称定义 11 | content-type: application/json # 消息类型 12 | binder: defaultRabbit # 要绑定的消息服务的具体设置 13 | group: course 14 | courseViewCountStat-out-0: # output 15 | destination: course-view-stat-exchange # 表示要使用的Exchange名称定义 16 | content-type: application/json # 消息类型 17 | binder: defaultRabbit # 要绑定的消息服务的具体设置 18 | rabbit: 19 | bindings: 20 | buyCountCourse-in-0: 21 | consumer: 22 | ttl: 60000 #消息60秒不消费转入死信队列 23 | autoBindDlq: true #启用死信队列,默认会生成一个DLX EXCHANGE,当消息重复消费失败后 24 | deadLetterExchange: dead-letter-exchange 25 | courseViewCountStat-out-0: 26 | producer: 27 | autoBindDlq: true #启用死信队列,默认会生成一个DLX EXCHANGE,当消息重复消费失败后 28 | deadLetterExchange: dead-letter-exchange 29 | function: 30 | definition: buyCountCourse 31 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | cloud: 5 | nacos: 6 | config: 7 | namespace: b909e98d-d1c4-4319-879a-758981c15700 8 | server-addr: nacos:8848 9 | file-extension: yaml 10 | extension-configs: 11 | - data-id: redis.yml 12 | refresh: true 13 | - data-id: mysql.yml 14 | refresh: true 15 | - data-id: mybatis-plus.yml 16 | refresh: true 17 | - data-id: nacos-sentinel.yml 18 | refresh: true 19 | - data-id: feign-sentinel.yml 20 | refresh: true 21 | - data-id: rabbitmq.yml 22 | refresh: true 23 | - data-id: seata.yml 24 | refresh: true 25 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/resources/excel/subject.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andochiwa/Online-Education-Backend/2e831abb1a88774737546295c9025c389fe2324f/service/service_edu8001/src/main/resources/excel/subject.xlsx -------------------------------------------------------------------------------- /service/service_edu8001/src/main/resources/mapper/EduChapterMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/resources/mapper/EduCommentMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/resources/mapper/EduCourseDescriptionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/resources/mapper/EduCourseMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | update edu_course 8 | set view_count = view_count + 1 9 | where id = #{courseId} 10 | 11 | 12 | update edu_course 13 | set buy_count = buy_count + 1 14 | where id = #{courseId} 15 | 16 | 17 | 32 | 33 | 57 | 58 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/resources/mapper/EduSubjectMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/resources/mapper/EduTeacherMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /service/service_edu8001/src/main/resources/mapper/EduVideoMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /service/service_edu8001/src/test/java/com/github/eduservice/excel/ExcelListener.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.excel; 2 | 3 | import com.alibaba.excel.context.AnalysisContext; 4 | import com.alibaba.excel.event.AnalysisEventListener; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * @author HAN 10 | * @version 1.0 11 | * @create 2021/4/8 12 | */ 13 | public class ExcelListener extends AnalysisEventListener { 14 | // 一行行读取excel里的内容 15 | @Override 16 | public void invoke(Student student, AnalysisContext analysisContext) { 17 | System.out.println("数据 " + student); 18 | } 19 | 20 | // 读取表头的内容 21 | @Override 22 | public void invokeHeadMap(Map headMap, AnalysisContext context) { 23 | System.out.println("表头 " + headMap); 24 | } 25 | 26 | // 读取完成后 27 | @Override 28 | public void doAfterAllAnalysed(AnalysisContext analysisContext) { 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /service/service_edu8001/src/test/java/com/github/eduservice/excel/Student.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.excel; 2 | 3 | import com.alibaba.excel.annotation.ExcelProperty; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author HAN 8 | * @version 1.0 9 | * @create 2021/4/8 10 | */ 11 | @Data 12 | public class Student { 13 | 14 | @ExcelProperty(value = "学生编号", index = 0) 15 | private Integer id; 16 | 17 | @ExcelProperty(value = "学生姓名", index = 1) 18 | private String name; 19 | } 20 | -------------------------------------------------------------------------------- /service/service_edu8001/src/test/java/com/github/eduservice/excel/TestExcelRead.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.excel; 2 | 3 | import com.alibaba.excel.EasyExcel; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | 7 | /** 8 | * @author HAN 9 | * @version 1.0 10 | * @create 2021/4/8 11 | */ 12 | @SpringBootTest 13 | public class TestExcelRead { 14 | 15 | @Test 16 | void test() { 17 | String filePath = "D:\\write.xlsx"; 18 | 19 | EasyExcel.read(filePath, Student.class, new ExcelListener()).sheet().doRead(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /service/service_edu8001/src/test/java/com/github/eduservice/excel/TestExcelWrite.java: -------------------------------------------------------------------------------- 1 | package com.github.eduservice.excel; 2 | 3 | import com.alibaba.excel.EasyExcel; 4 | import org.junit.jupiter.api.BeforeEach; 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * @author HAN 13 | * @version 1.0 14 | * @create 2021/4/8 15 | */ 16 | @SpringBootTest 17 | public class TestExcelWrite { 18 | 19 | private List list = new ArrayList<>(); 20 | 21 | @BeforeEach 22 | void initList() { 23 | for (int i = 0; i < 10; i++) { 24 | Student student = new Student(); 25 | student.setId(i); 26 | student.setName("q" + i); 27 | list.add(student); 28 | } 29 | } 30 | 31 | @Test 32 | void test() { 33 | String filePath = "D:\\write.xlsx"; 34 | 35 | EasyExcel.write(filePath, Student.class).sheet("学生列表").doWrite(this.list); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /service/service_order8006/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM adoptopenjdk/openjdk15:ubi 2 | RUN mkdir /app 3 | COPY ./service/service_order8006/target/service_order.jar /app 4 | COPY ./wait-for-it.sh /app 5 | WORKDIR /app 6 | CMD ["java", "-jar", "service_order.jar"] 7 | -------------------------------------------------------------------------------- /service/service_order8006/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | service 7 | com.github 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | service_order8006 13 | 14 | 15 | 15 16 | 15 17 | 18 | 19 | 20 | service_order 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/java/com/github/order/OrderApplicationMain8006.java: -------------------------------------------------------------------------------- 1 | package com.github.order; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.context.annotation.ComponentScan; 7 | 8 | /** 9 | * @author HAN 10 | * @version 1.0 11 | * @create 04-19-0:29 12 | */ 13 | @SpringBootApplication 14 | @ComponentScan(basePackages = "com.github") 15 | @EnableFeignClients 16 | public class OrderApplicationMain8006 { 17 | 18 | public static void main(String[] args){ 19 | SpringApplication.run(OrderApplicationMain8006.class, args); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/java/com/github/order/aspect/OrderAspect.java: -------------------------------------------------------------------------------- 1 | package com.github.order.aspect; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.aspectj.lang.JoinPoint; 5 | import org.aspectj.lang.annotation.Aspect; 6 | import org.aspectj.lang.annotation.Before; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.cloud.stream.function.StreamBridge; 9 | import org.springframework.messaging.support.MessageBuilder; 10 | import org.springframework.stereotype.Component; 11 | 12 | import java.util.concurrent.ThreadPoolExecutor; 13 | 14 | /** 15 | * @author HAN 16 | * @version 1.0 17 | * @create 04-30-2:09 18 | */ 19 | @Component 20 | @Aspect 21 | @Slf4j 22 | public class OrderAspect { 23 | 24 | @Autowired 25 | private ThreadPoolExecutor threadPoolExecutor; 26 | 27 | @Autowired 28 | private StreamBridge streamBridge; 29 | 30 | /** 31 | * 更新销售数量 32 | */ 33 | @Before("execution(* com.github.order.controller.OrderController.saveOrder(..)) ") 34 | public void payCount(JoinPoint joinPoint) { 35 | Object[] args = joinPoint.getArgs(); 36 | threadPoolExecutor.execute(() -> { 37 | streamBridge.send("buyCount-out-0", MessageBuilder.withPayload(args[0]).build()); 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/java/com/github/order/config/MybatisPlusConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.github.order.config; 2 | 3 | import com.baomidou.mybatisplus.annotation.DbType; 4 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 5 | import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; 6 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 7 | import org.mybatis.spring.annotation.MapperScan; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.transaction.annotation.EnableTransactionManagement; 11 | 12 | /** 13 | * @author HAN 14 | * @version 1.0 15 | * @create 2021/4/5 16 | */ 17 | @Configuration 18 | @EnableTransactionManagement 19 | @MapperScan("com.github.order.mapper") 20 | public class MybatisPlusConfiguration { 21 | 22 | @Bean 23 | public MybatisPlusInterceptor mybatisPlusInterceptor() { 24 | MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); 25 | mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); 26 | mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); 27 | return mybatisPlusInterceptor; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/java/com/github/order/config/ThreadPoolConfig.java: -------------------------------------------------------------------------------- 1 | package com.github.order.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import java.util.concurrent.ArrayBlockingQueue; 7 | import java.util.concurrent.Executors; 8 | import java.util.concurrent.ThreadPoolExecutor; 9 | import java.util.concurrent.TimeUnit; 10 | 11 | /** 12 | * @author HAN 13 | * @version 1.0 14 | * @create 04-30-2:08 15 | */ 16 | @Configuration 17 | public class ThreadPoolConfig { 18 | 19 | @Bean 20 | public ThreadPoolExecutor threadPoolExecutor() { 21 | return new ThreadPoolExecutor(3, 22 | 20, 23 | 30, 24 | TimeUnit.SECONDS, 25 | new ArrayBlockingQueue<>(15), 26 | Executors.defaultThreadFactory(), 27 | new ThreadPoolExecutor.CallerRunsPolicy()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/java/com/github/order/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.github.order.controller; 2 | 3 | 4 | import com.github.order.entity.Order; 5 | import com.github.order.service.OrderService; 6 | import com.github.utils.JwtUtils; 7 | import com.github.utils.ResultCommon; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import javax.servlet.http.HttpServletRequest; 14 | 15 | /** 16 | *

17 | * 订单 前端控制器 18 | *

19 | * 20 | * @author HAN 21 | * @since 2021-04-19 22 | */ 23 | @RestController 24 | @RequestMapping("/order/order") 25 | //@CrossOrigin 26 | @Api("订单信息") 27 | public class OrderController { 28 | 29 | @Autowired 30 | private OrderService orderService; 31 | 32 | /** 33 | * 生成订单 34 | * @param courseId 课程id 35 | * @param request 原生request对象 36 | */ 37 | @PostMapping("{courseId}") 38 | @ApiOperation("生成订单") 39 | public ResultCommon saveOrder(@PathVariable("courseId") long courseId, 40 | HttpServletRequest request) { 41 | 42 | // 生成订单号 43 | String orderId = orderService.saveOrder(courseId, JwtUtils.getUserIdByJwtToken(request)); 44 | 45 | return ResultCommon.success().setData("orderId", orderId); 46 | } 47 | 48 | /** 49 | * 查询订单 50 | * @param id 订单号 51 | */ 52 | @GetMapping("{orderId}") 53 | @ApiOperation("订单id查询订单") 54 | public ResultCommon getOrder(@PathVariable("orderId") String id) { 55 | Order order = orderService.getOrder(id); 56 | return ResultCommon.success().setData("items", order); 57 | } 58 | 59 | /** 60 | * 查询订单是否存在 61 | * @param courseId 课程id 62 | */ 63 | @GetMapping("course-status/{courseId}") 64 | @ApiOperation("课程和用户id查询订单是否存在") 65 | public ResultCommon isBuyCourse(@PathVariable("courseId") Long courseId, 66 | HttpServletRequest request) { 67 | int count = orderService.isBuyCourse(courseId, JwtUtils.getUserIdByJwtToken(request)); 68 | return count <= 0 ? ResultCommon.fail() : ResultCommon.success(); 69 | } 70 | 71 | } 72 | 73 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/java/com/github/order/controller/PayLogController.java: -------------------------------------------------------------------------------- 1 | package com.github.order.controller; 2 | 3 | 4 | import com.github.order.service.PayLogService; 5 | import com.github.utils.ResultCommon; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | /** 11 | *

12 | * 支付日志表 前端控制器 13 | *

14 | * 15 | * @author HAN 16 | * @since 2021-04-19 17 | */ 18 | @RestController 19 | @RequestMapping("/order/pay-log") 20 | public class PayLogController { 21 | 22 | @Autowired 23 | private PayLogService payLogService; 24 | 25 | /** 26 | * 更新订单支付状态 27 | * @param id 订单id 28 | */ 29 | @PutMapping("{orderId}") 30 | @ApiOperation("更新订单支付状态") 31 | public ResultCommon getOrderStatus(@PathVariable("orderId") String id) { 32 | payLogService.savePayLog(id); 33 | return ResultCommon.success(); 34 | } 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/java/com/github/order/entity/Order.java: -------------------------------------------------------------------------------- 1 | package com.github.order.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | import java.io.Serializable; 12 | import java.math.BigDecimal; 13 | import java.time.LocalDateTime; 14 | 15 | /** 16 | *

17 | * 订单 18 | *

19 | * 20 | * @author HAN 21 | * @since 2021-04-19 22 | */ 23 | @Data 24 | @EqualsAndHashCode(callSuper = false) 25 | @TableName("t_order") 26 | @ApiModel(value="Order对象", description="订单") 27 | public class Order implements Serializable { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | @TableId(value = "id", type = IdType.ASSIGN_ID) 32 | @JsonSerialize(using = ToStringSerializer.class) 33 | private Long id; 34 | 35 | @ApiModelProperty(value = "订单号") 36 | private String orderNo; 37 | 38 | @ApiModelProperty(value = "课程id") 39 | @JsonSerialize(using = ToStringSerializer.class) 40 | private Long courseId; 41 | 42 | @ApiModelProperty(value = "课程名称") 43 | private String courseTitle; 44 | 45 | @ApiModelProperty(value = "课程封面") 46 | private String courseCover; 47 | 48 | @ApiModelProperty(value = "讲师名称") 49 | private String teacherName; 50 | 51 | @ApiModelProperty(value = "会员id") 52 | private String memberId; 53 | 54 | @ApiModelProperty(value = "会员昵称") 55 | private String nickname; 56 | 57 | @ApiModelProperty(value = "会员邮箱") 58 | private String email; 59 | 60 | @ApiModelProperty(value = "订单金额(分)") 61 | private BigDecimal totalFee; 62 | 63 | @ApiModelProperty(value = "支付类型(1:微信 2:支付宝)") 64 | private Integer payType; 65 | 66 | @ApiModelProperty(value = "订单状态(0:未支付 1:已支付)") 67 | private Integer status; 68 | 69 | @ApiModelProperty(value = "逻辑删除 1(true)已删除, 0(false)未删除") 70 | @TableLogic 71 | private Integer isDeleted; 72 | 73 | @ApiModelProperty(value = "创建时间") 74 | @TableField(fill = FieldFill.INSERT) 75 | private LocalDateTime gmtCreate; 76 | 77 | @ApiModelProperty(value = "更新时间") 78 | @TableField(fill = FieldFill.INSERT_UPDATE) 79 | private LocalDateTime gmtModified; 80 | 81 | 82 | } 83 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/java/com/github/order/entity/PayLog.java: -------------------------------------------------------------------------------- 1 | package com.github.order.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | import java.io.Serializable; 12 | import java.math.BigDecimal; 13 | import java.time.LocalDateTime; 14 | 15 | /** 16 | *

17 | * 支付日志表 18 | *

19 | * 20 | * @author HAN 21 | * @since 2021-04-19 22 | */ 23 | @Data 24 | @EqualsAndHashCode(callSuper = false) 25 | @TableName("t_pay_log") 26 | @ApiModel(value="PayLog对象", description="支付日志表") 27 | public class PayLog implements Serializable { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | @TableId(value = "id", type = IdType.ASSIGN_ID) 32 | @JsonSerialize(using = ToStringSerializer.class) 33 | private Long id; 34 | 35 | @ApiModelProperty(value = "订单号") 36 | private String orderNo; 37 | 38 | @ApiModelProperty(value = "支付完成时间") 39 | private LocalDateTime payTime; 40 | 41 | @ApiModelProperty(value = "支付金额(分)") 42 | private BigDecimal totalFee; 43 | 44 | @ApiModelProperty(value = "交易流水号") 45 | private String transactionId; 46 | 47 | @ApiModelProperty(value = "交易状态") 48 | private String tradeState; 49 | 50 | @ApiModelProperty(value = "支付类型(1:微信 2:支付宝)") 51 | private Integer payType; 52 | 53 | @ApiModelProperty(value = "其他属性") 54 | private String attr; 55 | 56 | @ApiModelProperty(value = "逻辑删除 1(true)已删除, 0(false)未删除") 57 | @TableLogic 58 | private Integer isDeleted; 59 | 60 | @ApiModelProperty(value = "创建时间") 61 | @TableField(fill = FieldFill.INSERT) 62 | private LocalDateTime gmtCreate; 63 | 64 | @ApiModelProperty(value = "更新时间") 65 | @TableField(fill = FieldFill.INSERT_UPDATE) 66 | private LocalDateTime gmtModified; 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/java/com/github/order/feign/EduFeign.java: -------------------------------------------------------------------------------- 1 | package com.github.order.feign; 2 | 3 | import com.github.utils.ResultCommon; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | 8 | /** 9 | * @author HAN 10 | * @version 1.0 11 | * @create 04-19-2:40 12 | */ 13 | @FeignClient("service-edu") 14 | public interface EduFeign { 15 | 16 | /** 17 | * 查询课程信息 18 | * @param courseId 课程id 19 | */ 20 | @GetMapping("/eduservice/front-course/feign/{id}") 21 | ResultCommon getCourseInfoCommon(@PathVariable("id") Long courseId); 22 | } 23 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/java/com/github/order/feign/UcenterFeign.java: -------------------------------------------------------------------------------- 1 | package com.github.order.feign; 2 | 3 | import com.github.utils.ResultCommon; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | 8 | /** 9 | * @author HAN 10 | * @version 1.0 11 | * @create 04-19-2:40 12 | */ 13 | @FeignClient("service-center") 14 | public interface UcenterFeign { 15 | 16 | /** 17 | * 根据id获取用户信息 18 | * @param id 用户id 19 | */ 20 | @GetMapping("/edu-center/user-info/{id}") 21 | ResultCommon infoUserById(@PathVariable("id") String id); 22 | } 23 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/java/com/github/order/mapper/OrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.order.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.order.entity.Order; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | import org.apache.ibatis.annotations.CacheNamespace; 7 | 8 | /** 9 | *

10 | * 订单 Mapper 接口 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-04-19 15 | */ 16 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 17 | public interface OrderMapper extends BaseMapper { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/java/com/github/order/mapper/PayLogMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.order.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.order.entity.PayLog; 5 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 6 | import org.apache.ibatis.annotations.CacheNamespace; 7 | 8 | /** 9 | *

10 | * 支付日志表 Mapper 接口 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-04-19 15 | */ 16 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 17 | public interface PayLogMapper extends BaseMapper { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/java/com/github/order/service/PayLogService.java: -------------------------------------------------------------------------------- 1 | package com.github.order.service; 2 | 3 | import cn.hutool.core.util.RandomUtil; 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 6 | import com.github.order.entity.Order; 7 | import com.github.order.entity.PayLog; 8 | import com.github.order.mapper.PayLogMapper; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import java.time.LocalDateTime; 14 | 15 | /** 16 | *

17 | * 支付日志表 服务实现类 18 | *

19 | * 20 | * @author HAN 21 | * @since 2021-04-19 22 | */ 23 | @Service 24 | @Transactional 25 | public class PayLogService extends ServiceImpl { 26 | 27 | @Autowired 28 | private OrderService orderService; 29 | 30 | /** 31 | * 更新订单支付状态,并插入订单支付记录 32 | * @param id 订单id 33 | */ 34 | public void savePayLog(String id) { 35 | // 获取订单数据 36 | QueryWrapper orderQueryWrapper = new QueryWrapper<>(); 37 | orderQueryWrapper.eq("order_no", id); 38 | Order order = orderService.getOne(orderQueryWrapper); 39 | // 更新订单状态 40 | order.setStatus(1); 41 | orderService.updateById(order); 42 | 43 | // 插入记录 44 | PayLog payLog = new PayLog(); 45 | payLog.setOrderNo(id); 46 | payLog.setTotalFee(order.getTotalFee()); 47 | payLog.setTransactionId(RandomUtil.randomNumbers(11)); 48 | payLog.setPayTime(LocalDateTime.now()); 49 | super.save(payLog); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8006 3 | spring: 4 | application: 5 | name: service-order 6 | cloud: 7 | stream: 8 | bindings: 9 | buyCount-out-0: # 这个名字是一个信道的名称 10 | destination: course-buy-count-exchange # 表示要使用的Exchange名称定义 11 | content-type: application/json # 消息类型 12 | binder: defaultRabbit # 要绑定的消息服务的具体设置 13 | rabbit: 14 | bindings: 15 | buyCount-out-0: 16 | producer: 17 | ttl: 60000 #消息60秒不消费转入死信队列 18 | autoBindDlq: true #启动死信队列 19 | deadLetterExchange: dead-letter-exchange #绑定exchange 20 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | cloud: 5 | nacos: 6 | config: 7 | namespace: b909e98d-d1c4-4319-879a-758981c15700 8 | server-addr: nacos:8848 9 | file-extension: yaml 10 | extension-configs: 11 | - data-id: redis.yml 12 | refresh: true 13 | - data-id: mysql.yml 14 | refresh: true 15 | - data-id: mybatis-plus.yml 16 | refresh: true 17 | - data-id: nacos-sentinel.yml 18 | refresh: true 19 | - data-id: feign-sentinel.yml 20 | refresh: true 21 | - data-id: rabbitmq.yml 22 | refresh: true 23 | - data-id: seata.yml 24 | refresh: true 25 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/resources/mapper/OrderMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /service/service_order8006/src/main/resources/mapper/PayLogMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /service/service_oss8002/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM adoptopenjdk/openjdk15:ubi 2 | RUN mkdir /app 3 | COPY ./service/service_oss8002/target/service_oss.jar /app 4 | COPY ./wait-for-it.sh /app 5 | WORKDIR /app 6 | CMD ["java", "-jar", "service_oss.jar"] 7 | -------------------------------------------------------------------------------- /service/service_oss8002/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | service 7 | com.github 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | service_oss8002 13 | 14 | 15 | 15 16 | 15 17 | 18 | 19 | 20 | 21 | com.aliyun.oss 22 | aliyun-sdk-oss 23 | 24 | 25 | 26 | 27 | service_oss 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /service/service_oss8002/src/main/java/com/github/oss/OssApplicationMain8002.java: -------------------------------------------------------------------------------- 1 | package com.github.oss; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | /** 8 | * @author HAN 9 | * @version 1.0 10 | * @create 2021/4/8 11 | */ 12 | @SpringBootApplication 13 | @ComponentScan(basePackages = "com.github") 14 | public class OssApplicationMain8002 { 15 | 16 | public static void main(String[] args){ 17 | SpringApplication.run(OssApplicationMain8002.class, args); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /service/service_oss8002/src/main/java/com/github/oss/controller/OssController.java: -------------------------------------------------------------------------------- 1 | package com.github.oss.controller; 2 | 3 | import com.github.oss.service.OssService; 4 | import com.github.utils.ResultCommon; 5 | import io.swagger.annotations.ApiOperation; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.PostMapping; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestPart; 10 | import org.springframework.web.bind.annotation.RestController; 11 | import org.springframework.web.multipart.MultipartFile; 12 | 13 | /** 14 | * @author HAN 15 | * @version 1.0 16 | * @create 2021/4/8 17 | */ 18 | @RestController 19 | @RequestMapping("/edu-oss/file") 20 | public class OssController { 21 | 22 | @Autowired 23 | private OssService ossService; 24 | 25 | /** 26 | * 上传头像 27 | * @param file 头像对象 28 | */ 29 | @PostMapping 30 | @ApiOperation("上传图片") 31 | public ResultCommon uploadOssFile(@RequestPart("file") MultipartFile file) { 32 | 33 | // 返回上传到oss的路径 34 | String url = ossService.uploadFile(file); 35 | 36 | return ResultCommon.success().setData("url", url); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /service/service_oss8002/src/main/java/com/github/oss/mapper/OssMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.oss.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.oss.properties.ConstantProperties; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author HAN 9 | * @version 1.0 10 | * @create 04-16-21:36 11 | */ 12 | @Mapper 13 | public interface OssMapper extends BaseMapper { 14 | } 15 | -------------------------------------------------------------------------------- /service/service_oss8002/src/main/java/com/github/oss/properties/ConstantProperties.java: -------------------------------------------------------------------------------- 1 | package com.github.oss.properties; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableField; 4 | import com.baomidou.mybatisplus.annotation.TableName; 5 | import lombok.Data; 6 | 7 | /** 8 | * @author HAN 9 | * @version 1.0 10 | * @create 2021/4/8 11 | */ 12 | @Data 13 | @TableName("three_party_info") 14 | public class ConstantProperties { 15 | 16 | @TableField("temp1") 17 | private String endpoint; 18 | 19 | @TableField("id") 20 | private String keyId; 21 | 22 | @TableField("secret") 23 | private String keySecret; 24 | 25 | @TableField("temp2") 26 | private String bucketName; 27 | } 28 | -------------------------------------------------------------------------------- /service/service_oss8002/src/main/java/com/github/oss/service/OssService.java: -------------------------------------------------------------------------------- 1 | package com.github.oss.service; 2 | 3 | import cn.hutool.core.util.IdUtil; 4 | import com.aliyun.oss.OSS; 5 | import com.aliyun.oss.OSSClientBuilder; 6 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 7 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 8 | import com.github.oss.mapper.OssMapper; 9 | import com.github.oss.properties.ConstantProperties; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.web.multipart.MultipartFile; 12 | 13 | import java.io.IOException; 14 | import java.io.InputStream; 15 | import java.time.LocalDate; 16 | import java.time.format.DateTimeFormatter; 17 | 18 | /** 19 | * @author HAN 20 | * @version 1.0 21 | * @create 2021/4/8 22 | */ 23 | @Service 24 | public class OssService extends ServiceImpl { 25 | public String uploadFile(MultipartFile file) { 26 | QueryWrapper wrapper = new QueryWrapper<>(); 27 | wrapper.eq("name", "aliyun"); 28 | ConstantProperties properties = super.getOne(wrapper); 29 | 30 | String endpoint = properties.getEndpoint(); 31 | String accessKeyId = properties.getKeyId(); 32 | String accessKeySecret = properties.getKeySecret(); 33 | String bucketName = properties.getBucketName(); 34 | 35 | // 创建OSSClient实例。 36 | OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); 37 | 38 | String date = DateTimeFormatter.ofPattern("yyyy/MM/dd").format(LocalDate.now()); 39 | // 设置文件名随机值, 加上日期路径,这样就能自动创建文件夹 40 | String fileName = date + "/" + IdUtil.simpleUUID() + 41 | file.getOriginalFilename(); 42 | 43 | // 获取上传文件的输入流 44 | try (InputStream inputStream = file.getInputStream()) { 45 | ossClient.putObject(bucketName, fileName, inputStream); 46 | return "https://" + bucketName + "." + endpoint + "/" + fileName; 47 | } catch (IOException e) { 48 | e.printStackTrace(); 49 | return "https://" + bucketName + "." + endpoint + "/" + fileName; 50 | } finally { 51 | // 关闭OSSClient。 52 | ossClient.shutdown(); 53 | } 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /service/service_oss8002/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8002 3 | spring: 4 | servlet: 5 | multipart: 6 | max-file-size: 20MB 7 | max-request-size: 20MB 8 | application: 9 | name: service-oss 10 | -------------------------------------------------------------------------------- /service/service_oss8002/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | cloud: 5 | nacos: 6 | config: 7 | namespace: b909e98d-d1c4-4319-879a-758981c15700 8 | server-addr: nacos:8848 9 | file-extension: yaml 10 | extension-configs: 11 | - data-id: redis.yml 12 | refresh: true 13 | - data-id: mysql.yml 14 | refresh: true 15 | - data-id: mybatis-plus.yml 16 | refresh: true 17 | - data-id: nacos-sentinel.yml 18 | refresh: true 19 | - data-id: feign-sentinel.yml 20 | refresh: true 21 | - data-id: seata.yml 22 | refresh: true 23 | - data-id: rabbitmq.yml 24 | refresh: true 25 | -------------------------------------------------------------------------------- /service/service_statistic8007/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM adoptopenjdk/openjdk15:ubi 2 | RUN mkdir /app 3 | COPY ./service/service_statistic8007/target/service_statictis.jar /app 4 | COPY ./wait-for-it.sh /app 5 | WORKDIR /app 6 | CMD ["java", "-jar", "service_statictis.jar"] 7 | -------------------------------------------------------------------------------- /service/service_statistic8007/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | service 7 | com.github 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | service_statistic8007 13 | 14 | 15 | 15 16 | 15 17 | 18 | 19 | 20 | service_statictis 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /service/service_statistic8007/src/main/java/com/github/stat/StatisticMain8007.java: -------------------------------------------------------------------------------- 1 | package com.github.stat; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.scheduling.annotation.EnableScheduling; 8 | 9 | /** 10 | * @author HAN 11 | * @version 1.0 12 | * @create 04-20-5:04 13 | */ 14 | @SpringBootApplication 15 | @ComponentScan("com.github") 16 | @EnableFeignClients 17 | @EnableScheduling 18 | public class StatisticMain8007 { 19 | 20 | public static void main(String[] args){ 21 | SpringApplication.run(StatisticMain8007.class, args); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /service/service_statistic8007/src/main/java/com/github/stat/config/MybatisPlusConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.github.stat.config; 2 | 3 | import com.baomidou.mybatisplus.annotation.DbType; 4 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 5 | import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; 6 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 7 | import org.mybatis.spring.annotation.MapperScan; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.transaction.annotation.EnableTransactionManagement; 11 | 12 | /** 13 | * @author HAN 14 | * @version 1.0 15 | * @create 2021/4/5 16 | */ 17 | @Configuration 18 | @EnableTransactionManagement 19 | @MapperScan("com.github.stat.mapper") 20 | public class MybatisPlusConfiguration { 21 | 22 | @Bean 23 | public MybatisPlusInterceptor mybatisPlusInterceptor() { 24 | MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); 25 | mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); 26 | mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); 27 | return mybatisPlusInterceptor; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /service/service_statistic8007/src/main/java/com/github/stat/controller/StatisticsDailyController.java: -------------------------------------------------------------------------------- 1 | package com.github.stat.controller; 2 | 3 | 4 | import com.github.stat.service.StatisticsDailyService; 5 | import com.github.utils.ResultCommon; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | *

14 | * 网站统计日数据 前端控制器 15 | *

16 | * 17 | * @author HAN 18 | * @since 2021-04-20 19 | */ 20 | @RestController 21 | @RequestMapping("/stat/statistics-daily") 22 | public class StatisticsDailyController { 23 | 24 | @Autowired 25 | private StatisticsDailyService statisticsDailyService; 26 | 27 | /** 28 | * 统计某一天信息 29 | * @param date 哪一天 30 | */ 31 | @PostMapping("{date}") 32 | @ApiOperation("统计某一天信息") 33 | public ResultCommon countStat(@PathVariable("date") String date) { 34 | statisticsDailyService.countStat(date); 35 | 36 | return ResultCommon.success(); 37 | } 38 | 39 | /** 40 | * 查询图表显示数据 41 | * @param begin 开始日期 42 | * @param end 结束日期 43 | */ 44 | @GetMapping("{begin}/{end}") 45 | @ApiOperation("查询图表显示数据") 46 | public ResultCommon showData(@PathVariable("begin") String begin, 47 | @PathVariable("end") String end) { 48 | Map map = statisticsDailyService.showData(begin, end); 49 | 50 | return ResultCommon.success().setData(map); 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /service/service_statistic8007/src/main/java/com/github/stat/entity/StatisticsDaily.java: -------------------------------------------------------------------------------- 1 | package com.github.stat.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.FieldFill; 4 | import com.baomidou.mybatisplus.annotation.IdType; 5 | import com.baomidou.mybatisplus.annotation.TableField; 6 | import com.baomidou.mybatisplus.annotation.TableId; 7 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 8 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 9 | import io.swagger.annotations.ApiModel; 10 | import io.swagger.annotations.ApiModelProperty; 11 | import lombok.Data; 12 | import lombok.EqualsAndHashCode; 13 | 14 | import java.io.Serializable; 15 | import java.time.LocalDateTime; 16 | 17 | /** 18 | *

19 | * 网站统计日数据 20 | *

21 | * 22 | * @author HAN 23 | * @since 2021-04-20 24 | */ 25 | @Data 26 | @EqualsAndHashCode(callSuper = false) 27 | @ApiModel(value="StatisticsDaily对象", description="网站统计日数据") 28 | public class StatisticsDaily implements Serializable { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | @ApiModelProperty(value = "主键") 33 | @TableId(value = "id", type = IdType.ASSIGN_ID) 34 | @JsonSerialize(using = ToStringSerializer.class) 35 | private Long id; 36 | 37 | @ApiModelProperty(value = "统计日期") 38 | private String dateCalculated; 39 | 40 | @ApiModelProperty(value = "注册人数") 41 | private Integer registerNum; 42 | 43 | @ApiModelProperty(value = "登录人数") 44 | private Integer loginNum; 45 | 46 | @ApiModelProperty(value = "每日播放视频数") 47 | private Integer videoViewNum; 48 | 49 | @ApiModelProperty(value = "每日新增课程数") 50 | private Integer courseNum; 51 | 52 | @ApiModelProperty(value = "创建时间") 53 | @TableField(fill = FieldFill.INSERT) 54 | private LocalDateTime gmtCreate; 55 | 56 | @ApiModelProperty(value = "更新时间") 57 | @TableField(fill = FieldFill.INSERT_UPDATE) 58 | private LocalDateTime gmtModified; 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /service/service_statistic8007/src/main/java/com/github/stat/feign/UcenterClient.java: -------------------------------------------------------------------------------- 1 | package com.github.stat.feign; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | 7 | /** 8 | * @author HAN 9 | * @version 1.0 10 | * @create 04-20-5:44 11 | */ 12 | @FeignClient("service-center") 13 | public interface UcenterClient { 14 | 15 | @GetMapping("/edu-center/stat-register/{date}") 16 | int statRegister(@PathVariable("date") String date); 17 | } 18 | -------------------------------------------------------------------------------- /service/service_statistic8007/src/main/java/com/github/stat/mapper/StatisticsDailyMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.stat.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.servicebase.cache.MybatisRedisCacheConfig; 5 | import com.github.stat.entity.StatisticsDaily; 6 | import org.apache.ibatis.annotations.CacheNamespace; 7 | 8 | /** 9 | *

10 | * 网站统计日数据 Mapper 接口 11 | *

12 | * 13 | * @author HAN 14 | * @since 2021-04-20 15 | */ 16 | @CacheNamespace(implementation = MybatisRedisCacheConfig.class, eviction = MybatisRedisCacheConfig.class) 17 | public interface StatisticsDailyMapper extends BaseMapper { 18 | 19 | void loginCount(String date); 20 | 21 | void courseViewCount(String date); 22 | 23 | void videoViewCount(String date); 24 | 25 | void registerCount(String date); 26 | } 27 | -------------------------------------------------------------------------------- /service/service_statistic8007/src/main/java/com/github/stat/rabbitmq/CourseViewCount.java: -------------------------------------------------------------------------------- 1 | package com.github.stat.rabbitmq; 2 | 3 | import com.github.stat.service.StatisticsDailyService; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.function.Consumer; 10 | 11 | /** 12 | * @author HAN 13 | * @version 1.0 14 | * @create 04-30-20:54 15 | */ 16 | @Slf4j 17 | @Component 18 | public class CourseViewCount { 19 | 20 | @Autowired 21 | private StatisticsDailyService statisticsDailyService; 22 | 23 | /** 24 | * 统计课程数量+1 25 | */ 26 | @Bean 27 | public Consumer courseViewCountStat() { 28 | return date -> statisticsDailyService.courseViewCount(date); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /service/service_statistic8007/src/main/java/com/github/stat/rabbitmq/LoginCount.java: -------------------------------------------------------------------------------- 1 | package com.github.stat.rabbitmq; 2 | 3 | import com.github.stat.service.StatisticsDailyService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.function.Consumer; 9 | 10 | /** 11 | * @author HAN 12 | * @version 1.0 13 | * @create 04-30-17:31 14 | */ 15 | @Component 16 | public class LoginCount { 17 | 18 | @Autowired 19 | private StatisticsDailyService statisticsDailyService; 20 | 21 | /** 22 | * 统计登陆数量+1 23 | */ 24 | @Bean 25 | public Consumer statLoginCount() { 26 | return date -> statisticsDailyService.loginCount(date); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /service/service_statistic8007/src/main/java/com/github/stat/rabbitmq/RegisterCount.java: -------------------------------------------------------------------------------- 1 | package com.github.stat.rabbitmq; 2 | 3 | import com.github.stat.service.StatisticsDailyService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.function.Consumer; 9 | 10 | /** 11 | * @author HAN 12 | * @version 1.0 13 | * @create 05-04-2:10 14 | */ 15 | @Component 16 | public class RegisterCount { 17 | @Autowired 18 | private StatisticsDailyService statisticsDailyService; 19 | 20 | /** 21 | * 统计注册数量+1 22 | */ 23 | @Bean 24 | public Consumer statRegisterCount() { 25 | return date -> statisticsDailyService.registerCount(date); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /service/service_statistic8007/src/main/java/com/github/stat/rabbitmq/VideoViewCount.java: -------------------------------------------------------------------------------- 1 | package com.github.stat.rabbitmq; 2 | 3 | import com.github.stat.service.StatisticsDailyService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.function.Consumer; 9 | 10 | /** 11 | * @author HAN 12 | * @version 1.0 13 | * @create 04-30-21:44 14 | */ 15 | @Component 16 | public class VideoViewCount { 17 | 18 | @Autowired 19 | private StatisticsDailyService statisticsDailyService; 20 | 21 | /** 22 | * 统计视频观看数量+1 23 | */ 24 | @Bean 25 | public Consumer videoViewCountStat() { 26 | return date -> statisticsDailyService.videoViewCount(date); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /service/service_statistic8007/src/main/java/com/github/stat/schedule/StatCountSchedule.java: -------------------------------------------------------------------------------- 1 | package com.github.stat.schedule; 2 | 3 | import com.github.stat.service.StatisticsDailyService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.scheduling.annotation.Scheduled; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.time.LocalDate; 9 | 10 | /** 11 | * @author HAN 12 | * @version 1.0 13 | * @create 04-20-22:00 14 | */ 15 | @Component 16 | public class StatCountSchedule { 17 | 18 | @Autowired 19 | private StatisticsDailyService statisticsDailyService; 20 | 21 | @Scheduled(cron = "1 0 0 * * ?", zone = "GMT-9") 22 | public void count() { 23 | statisticsDailyService.countStat(LocalDate.now().plusDays(-1L).toString()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /service/service_statistic8007/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8007 3 | spring: 4 | application: 5 | name: service-statistic 6 | cloud: 7 | stream: 8 | bindings: 9 | statLoginCount-in-0: # input 10 | destination: login-stat-exchange # 表示要使用的Exchange名称定义 11 | content-type: application/json # 消息类型 12 | binder: defaultRabbit # 要绑定的消息服务的具体设置 13 | group: statistic 14 | courseViewCountStat-in-0: # input 15 | destination: course-view-stat-exchange # 表示要使用的Exchange名称定义 16 | content-type: application/json # 消息类型 17 | binder: defaultRabbit # 要绑定的消息服务的具体设置 18 | group: statistic 19 | videoViewCountStat-in-0: # input 20 | destination: video-view-count-exchange # 表示要使用的Exchange名称定义 21 | content-type: application/json # 消息类型 22 | binder: defaultRabbit # 要绑定的消息服务的具体设置 23 | group: statistic 24 | statRegisterCount-in-0: # input 25 | destination: register-stat-exchange # 表示要使用的Exchange名称定义 26 | content-type: application/json # 消息类型 27 | binder: defaultRabbit # 要绑定的消息服务的具体设置 28 | group: statistic 29 | rabbit: 30 | bindings: 31 | statLoginCount-in-0: 32 | consumer: 33 | autoBindDlq: true #启用死信队列,默认会生成一个DLX EXCHANGE,当消息重复消费失败后 34 | deadLetterExchange: dead-letter-exchange #绑定exchange 35 | courseViewCountStat-in-0: 36 | consumer: 37 | autoBindDlq: true #启用死信队列,默认会生成一个DLX EXCHANGE,当消息重复消费失败后 38 | deadLetterExchange: dead-letter-exchange #绑定exchange 39 | videoViewCountStat-in-0: 40 | consumer: 41 | autoBindDlq: true #启用死信队列,默认会生成一个DLX EXCHANGE,当消息重复消费失败后 42 | deadLetterExchange: dead-letter-exchange #绑定exchange 43 | statRegisterCount-in-0: 44 | consumer: 45 | autoBindDlq: true #启用死信队列,默认会生成一个DLX EXCHANGE,当消息重复消费失败后 46 | deadLetterExchange: dead-letter-exchange #绑定exchange 47 | function: 48 | definition: statLoginCount;courseViewCountStat;videoViewCountStat;statRegisterCount 49 | -------------------------------------------------------------------------------- /service/service_statistic8007/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | cloud: 5 | nacos: 6 | config: 7 | namespace: b909e98d-d1c4-4319-879a-758981c15700 8 | server-addr: nacos:8848 9 | file-extension: yaml 10 | extension-configs: 11 | - data-id: redis.yml 12 | refresh: true 13 | - data-id: mysql.yml 14 | refresh: true 15 | - data-id: mybatis-plus.yml 16 | refresh: true 17 | - data-id: nacos-sentinel.yml 18 | refresh: true 19 | - data-id: feign-sentinel.yml 20 | refresh: true 21 | - data-id: rabbitmq.yml 22 | refresh: true 23 | - data-id: seata.yml 24 | refresh: true 25 | -------------------------------------------------------------------------------- /service/service_statistic8007/src/main/resources/mapper/StatisticsDailyMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | update statistics_daily 9 | set login_num = login_num + 1 10 | where date_calculated = #{date} 11 | 12 | 13 | update statistics_daily 14 | set course_num = course_num + 1 15 | where date_calculated = #{date} 16 | 17 | 18 | update statistics_daily 19 | set video_view_num = video_view_num + 1 20 | where date_calculated = #{date} 21 | 22 | 23 | update statistics_daily 24 | set register_num = register_num + 1 25 | where date_calculated = #{date} 26 | 27 | 28 | -------------------------------------------------------------------------------- /service/service_vod8003/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM adoptopenjdk/openjdk15:ubi 2 | RUN mkdir /app 3 | COPY ./service/service_vod8003/target/service_vod.jar /app 4 | COPY ./wait-for-it.sh /app 5 | WORKDIR /app 6 | CMD ["java", "-jar", "service_vod.jar"] 7 | -------------------------------------------------------------------------------- /service/service_vod8003/lib/aliyun-java-vod-upload-1.4.13.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andochiwa/Online-Education-Backend/2e831abb1a88774737546295c9025c389fe2324f/service/service_vod8003/lib/aliyun-java-vod-upload-1.4.13.jar -------------------------------------------------------------------------------- /service/service_vod8003/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | service 7 | com.github 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | service_vod8003 13 | 14 | 15 | 15 16 | 15 17 | 18 | 19 | 20 | 21 | com.aliyun 22 | aliyun-java-sdk-core 23 | 24 | 25 | com.aliyun.oss 26 | aliyun-sdk-oss 27 | 28 | 29 | com.aliyun 30 | aliyun-java-sdk-vod 31 | 32 | 33 | com.alibaba 34 | fastjson 35 | 36 | 37 | org.json 38 | json 39 | 40 | 41 | com.aliyun 42 | aliyun-java-vod-upload 43 | 1.4.13 44 | system 45 | ${project.basedir}/lib/aliyun-java-vod-upload-1.4.13.jar 46 | 47 | 48 | 49 | 50 | service_vod 51 | 52 | 53 | lib 54 | /BOOT-INF/lib/ 55 | 56 | **/*.jar 57 | 58 | 59 | 60 | src/main/resources 61 | 62 | * 63 | 64 | false 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /service/service_vod8003/src/main/java/com/github/vod/VodApplicationMain8003.java: -------------------------------------------------------------------------------- 1 | package com.github.vod; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | /** 8 | * @author HAN 9 | * @version 1.0 10 | * @create 2021/4/12 11 | */ 12 | @SpringBootApplication 13 | @ComponentScan(basePackages = "com.github") 14 | public class VodApplicationMain8003 { 15 | 16 | public static void main(String[] args){ 17 | SpringApplication.run(VodApplicationMain8003.class, args); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /service/service_vod8003/src/main/java/com/github/vod/aspect/VodAspect.java: -------------------------------------------------------------------------------- 1 | package com.github.vod.aspect; 2 | 3 | import org.aspectj.lang.annotation.Aspect; 4 | import org.aspectj.lang.annotation.Before; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.cloud.stream.function.StreamBridge; 7 | import org.springframework.messaging.support.MessageBuilder; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.time.LocalDate; 11 | import java.util.concurrent.ThreadPoolExecutor; 12 | 13 | /** 14 | * @author HAN 15 | * @version 1.0 16 | * @create 04-30-21:23 17 | */ 18 | @Aspect 19 | @Component 20 | public class VodAspect { 21 | 22 | @Autowired 23 | private ThreadPoolExecutor threadPoolExecutor; 24 | 25 | @Autowired 26 | private StreamBridge streamBridge; 27 | 28 | @Before("execution(* com.github.vod.controller.VodController.getVideoPlayAuth(..))") 29 | public void videoViewCountStat() { 30 | threadPoolExecutor.execute(() -> { 31 | streamBridge.send("videoViewCountStat-out-0", 32 | MessageBuilder.withPayload(LocalDate.now().toString()).build()); 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /service/service_vod8003/src/main/java/com/github/vod/config/ThreadPoolConfig.java: -------------------------------------------------------------------------------- 1 | package com.github.vod.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import java.util.concurrent.ArrayBlockingQueue; 7 | import java.util.concurrent.ThreadPoolExecutor; 8 | import java.util.concurrent.TimeUnit; 9 | 10 | /** 11 | * @author HAN 12 | * @version 1.0 13 | * @create 04-30-21:26 14 | */ 15 | @Configuration 16 | public class ThreadPoolConfig { 17 | 18 | @Bean 19 | public ThreadPoolExecutor threadPoolExecutor() { 20 | return new ThreadPoolExecutor(3, 21 | 20, 22 | 30L, 23 | TimeUnit.SECONDS, 24 | new ArrayBlockingQueue<>(15)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /service/service_vod8003/src/main/java/com/github/vod/controller/VodController.java: -------------------------------------------------------------------------------- 1 | package com.github.vod.controller; 2 | 3 | import com.github.utils.ResultCommon; 4 | import com.github.vod.service.VodService; 5 | import io.swagger.annotations.ApiOperation; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.*; 8 | import org.springframework.web.multipart.MultipartFile; 9 | 10 | /** 11 | * @author HAN 12 | * @version 1.0 13 | * @create 2021/4/12 14 | */ 15 | @RestController 16 | @RequestMapping("/edu-vod/video") 17 | public class VodController { 18 | 19 | @Autowired 20 | private VodService vodService; 21 | 22 | /** 23 | * 上传视频 24 | * @param file 视频文件 25 | */ 26 | @PostMapping 27 | @ApiOperation("上传视频") 28 | public ResultCommon uploadVideo(@RequestPart("file") MultipartFile file) { 29 | // 获取视频id 30 | String videoId = vodService.uploadVideo(file); 31 | 32 | return ResultCommon.success().setData("videoId", videoId); 33 | } 34 | 35 | /** 36 | * 删除视频 37 | * @param id 视频id 38 | */ 39 | @DeleteMapping("{id}") 40 | @ApiOperation("删除视频") 41 | public ResultCommon deleteVideo(@PathVariable("id") String id) { 42 | vodService.deleteVideo(id); 43 | return ResultCommon.success(); 44 | } 45 | 46 | /** 47 | * 获取视频凭证 48 | * @param id 视频id 49 | */ 50 | @GetMapping("{id}") 51 | @ApiOperation("获取视频凭证") 52 | public ResultCommon getVideoPlayAuth(@PathVariable("id") String id) { 53 | String playAuth = vodService.getVideoPlayAuth(id); 54 | return ResultCommon.success().setData("playAuth", playAuth); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /service/service_vod8003/src/main/java/com/github/vod/mapper/VodMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.vod.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.github.vod.properties.VodProperties; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author HAN 9 | * @version 1.0 10 | * @create 04-16-21:51 11 | */ 12 | @Mapper 13 | public interface VodMapper extends BaseMapper { 14 | } 15 | -------------------------------------------------------------------------------- /service/service_vod8003/src/main/java/com/github/vod/properties/VodProperties.java: -------------------------------------------------------------------------------- 1 | package com.github.vod.properties; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableField; 4 | import com.baomidou.mybatisplus.annotation.TableName; 5 | import lombok.Data; 6 | 7 | /** 8 | * @author HAN 9 | * @version 1.0 10 | * @create 2021/4/12 11 | */ 12 | @Data 13 | @TableName("three_party_info") 14 | public class VodProperties { 15 | @TableField("id") 16 | private String keyId; 17 | 18 | @TableField("secret") 19 | private String keySecret; 20 | } 21 | -------------------------------------------------------------------------------- /service/service_vod8003/src/main/java/com/github/vod/utils/InitVodClient.java: -------------------------------------------------------------------------------- 1 | package com.github.vod.utils; 2 | 3 | import com.aliyuncs.DefaultAcsClient; 4 | import com.aliyuncs.exceptions.ClientException; 5 | import com.aliyuncs.profile.DefaultProfile; 6 | 7 | /** 8 | * @author HAN 9 | * @version 1.0 10 | * @create 2021/4/12 11 | */ 12 | public class InitVodClient { 13 | 14 | public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) throws ClientException { 15 | String regionId = "cn-shanghai"; // 点播服务接入区域 16 | DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret); 17 | return new DefaultAcsClient(profile); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /service/service_vod8003/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8003 3 | spring: 4 | application: 5 | name: service-vod 6 | servlet: 7 | multipart: 8 | max-file-size: 500MB 9 | max-request-size: 500MB 10 | cloud: 11 | stream: 12 | bindings: 13 | videoViewCountStat-out-0: # output 14 | destination: video-view-count-exchange # 表示要使用的Exchange名称定义 15 | content-type: application/json # 消息类型 16 | binder: defaultRabbit # 要绑定的消息服务的具体设置 17 | group: statistic 18 | rabbit: 19 | bindings: 20 | videoViewCountStat-out-0: 21 | producer: 22 | autoBindDlq: true #启用死信队列,默认会生成一个DLX EXCHANGE,当消息重复消费失败后 23 | deadLetterExchange: dead-letter-exchange #绑定exchange 24 | -------------------------------------------------------------------------------- /service/service_vod8003/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | cloud: 5 | nacos: 6 | config: 7 | namespace: b909e98d-d1c4-4319-879a-758981c15700 8 | server-addr: nacos:8848 9 | file-extension: yaml 10 | extension-configs: 11 | - data-id: redis.yml 12 | refresh: true 13 | - data-id: mysql.yml 14 | refresh: true 15 | - data-id: mybatis-plus.yml 16 | refresh: true 17 | - data-id: nacos-sentinel.yml 18 | refresh: true 19 | - data-id: feign-sentinel.yml 20 | refresh: true 21 | - data-id: rabbitmq.yml 22 | refresh: true 23 | - data-id: seata.yml 24 | refresh: true 25 | -------------------------------------------------------------------------------- /service/service_vod8003/src/test/java/com/github/vod/InitVodClient.java: -------------------------------------------------------------------------------- 1 | package com.github.vod; 2 | 3 | import com.aliyuncs.DefaultAcsClient; 4 | import com.aliyuncs.exceptions.ClientException; 5 | import com.aliyuncs.profile.DefaultProfile; 6 | 7 | /** 8 | * @author HAN 9 | * @version 1.0 10 | * @create 2021/4/12 11 | */ 12 | public class InitVodClient { 13 | 14 | public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) throws ClientException { 15 | String regionId = "cn-shanghai"; // 点播服务接入区域 16 | DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret); 17 | DefaultAcsClient client = new DefaultAcsClient(profile); 18 | return client; 19 | } 20 | } 21 | --------------------------------------------------------------------------------