├── Elearning-common ├── pom.xml ├── schema │ └── elearning_user.sql └── src │ └── main │ └── java │ └── org │ └── darod │ └── elearning │ └── common │ ├── cache │ ├── RedisCache.java │ └── RedisCacheManager.java │ ├── configuration │ ├── CustomSessionManager.java │ ├── FastJson2JsonRedisSerializer.java │ ├── RedisConfiguration.java │ └── RedisSessionDao.java │ ├── dto │ ├── ChapterModel.java │ ├── CommentModel.java │ ├── CommonCountModel.java │ ├── CommonPageModel.java │ ├── CourseModel.java │ ├── CoursePageModel.java │ ├── LiveRecordModel.java │ ├── LiveRoomModel.java │ ├── MessageModel.java │ ├── OrderModel.java │ ├── Shout.java │ ├── TeacherModel.java │ ├── UserLearnModel.java │ └── UserModel.java │ ├── exception │ ├── BusinessException.java │ ├── CommonError.java │ ├── EmException.java │ └── UploadException.java │ ├── response │ ├── CommonResponse.java │ └── ResponseUtils.java │ ├── service │ └── user │ │ ├── ChapterService.java │ │ ├── CommentService.java │ │ ├── CourseService.java │ │ ├── LiveService.java │ │ ├── MessageService.java │ │ ├── OrderService.java │ │ ├── PermissionService.java │ │ ├── TeacherService.java │ │ ├── UserLearnService.java │ │ └── UserService.java │ ├── utils │ ├── CopyPropertiesUtils.java │ ├── RedisUtils.java │ ├── RedisUtilsForShiro.java │ └── ShiroUtils.java │ └── validator │ ├── EnumValue.java │ ├── MyNotBlank.java │ ├── ValidationResult.java │ └── ValidatorImpl.java ├── Elearning-gateway ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── darod │ │ └── elearning │ │ └── gateway │ │ ├── GatewayApplication.java │ │ ├── advice │ │ ├── LiveAdvice.java │ │ ├── TeacherAdvice.java │ │ └── UploadAdvice.java │ │ ├── annotation │ │ └── WithoutPermission.java │ │ ├── configuration │ │ ├── CustomRealm.java │ │ ├── ShiroConfiguration.java │ │ ├── WebMvcConfig.java │ │ └── WebSocketConfiguration.java │ │ ├── controller │ │ ├── BarrageController.java │ │ ├── ChapterController.java │ │ ├── CommentController.java │ │ ├── CourseController.java │ │ ├── LiveController.java │ │ ├── MessageController.java │ │ ├── MyControllerAdvice.java │ │ ├── OrderController.java │ │ ├── TeacherController.java │ │ ├── TestController.java │ │ ├── UploadImageController.java │ │ ├── UserController.java │ │ └── UserLearnController.java │ │ ├── dao │ │ ├── ChapterDOMapper.java │ │ ├── CommentDOMapper.java │ │ ├── CourseDOMapper.java │ │ ├── ForbidDOMapper.java │ │ ├── LiveRecordDOMapper.java │ │ ├── LiveRoomDOMapper.java │ │ ├── MessageDOMapper.java │ │ ├── OrderDOMapper.java │ │ ├── RolePrivilegeDOMapper.java │ │ ├── SequenceDOMapper.java │ │ ├── TeacherDOMapper.java │ │ ├── UserDOMapper.java │ │ ├── UserLearnDOMapper.java │ │ ├── UserPasswordDOMapper.java │ │ └── UserRoleDOMapper.java │ │ ├── dataobject │ │ ├── ChapterDO.java │ │ ├── CommentDO.java │ │ ├── CourseDO.java │ │ ├── ForbidDO.java │ │ ├── LiveRecordDO.java │ │ ├── LiveRoomDO.java │ │ ├── MessageDO.java │ │ ├── OrderDO.java │ │ ├── RolePrivilegeDO.java │ │ ├── SequenceDO.java │ │ ├── TeacherDO.java │ │ ├── UserDO.java │ │ ├── UserLearnDO.java │ │ ├── UserPasswordDO.java │ │ └── UserRoleDO.java │ │ ├── interceptor │ │ ├── SessionInterceptor.java │ │ └── WebSocketHandShakeInterceptor.java │ │ ├── serviceimpl │ │ ├── ChapterServiceImpl.java │ │ ├── CommentServiceImpl.java │ │ ├── CourseServiceImpl.java │ │ ├── LiveServiceImpl.java │ │ ├── MessageServiceImpl.java │ │ ├── OrderServiceImpl.java │ │ ├── PermissionServiceImpl.java │ │ ├── TeacherServiceImpl.java │ │ ├── UserLearnServiceImpl.java │ │ └── UserServiceImpl.java │ │ ├── utils │ │ ├── RandomUtils.java │ │ ├── SwaggerConfiguration.java │ │ ├── URLUtils.java │ │ └── ValidateUtils.java │ │ └── viewobject │ │ ├── CourseLearnedVO.java │ │ └── UserVO.java │ └── resources │ ├── META-INF │ └── spring-devtools.properties │ ├── application.properties │ ├── mapping │ ├── ChapterDOMapper.xml │ ├── CommentDOMapper.xml │ ├── CourseDOMapper.xml │ ├── ForbidDOMapper.xml │ ├── LiveRecordDOMapper.xml │ ├── LiveRoomDOMapper.xml │ ├── MessageDOMapper.xml │ ├── OrderDOMapper.xml │ ├── RolePrivilegeDOMapper.xml │ ├── SequenceDOMapper.xml │ ├── TeacherDOMapper.xml │ ├── UserDOMapper.xml │ ├── UserLearnDOMapper.xml │ ├── UserPasswordDOMapper.xml │ └── UserRoleDOMapper.xml │ ├── mybatis-generator.xml │ └── static │ ├── 403.html │ ├── course_manage.html │ ├── css │ ├── bootstrap-grid.css │ ├── bootstrap-grid.css.map │ ├── bootstrap-grid.min.css │ ├── bootstrap-grid.min.css.map │ ├── bootstrap-reboot.css │ ├── bootstrap-reboot.css.map │ ├── bootstrap-reboot.min.css │ ├── bootstrap-reboot.min.css.map │ ├── bootstrap-reboot.min.min.css │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ ├── bootstrap.min.css.map │ ├── swiper.css │ ├── swiper.min.css │ ├── swiper.min.min.css │ ├── weui.min.css │ └── weuix.css │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 │ ├── js │ ├── bootstrap.bundle.js │ ├── bootstrap.bundle.js.map │ ├── bootstrap.bundle.min.js │ ├── bootstrap.bundle.min.js.map │ ├── bootstrap.bundle.min.min.js │ ├── bootstrap.js │ ├── bootstrap.js.map │ ├── bootstrap.min.js │ ├── bootstrap.min.js.map │ ├── bootstrap.min.min.js │ ├── jquery-weui.js │ ├── jquery.color-2.1.2.min.js │ ├── jquery.color-2.1.2.min.min.js │ ├── jquery.min.js │ ├── jquery.min.min.js │ ├── live.js │ ├── popper.min.js │ ├── sockjs.min.js │ ├── stomp.min.js │ ├── swiper.esm.bundle.js │ ├── swiper.esm.js │ ├── swiper.js │ ├── swiper.min.js │ ├── swiper.min.js.map │ ├── zepto.min.js │ └── zepto.weui.js │ ├── login.html │ ├── mycss │ ├── base.css │ ├── course_manage.css │ └── userinfo.css │ ├── myjs │ ├── ajaxutils.js │ ├── base.js │ ├── course_manage.js │ ├── domobject.js │ └── userinfo.js │ ├── register.html │ ├── resources │ ├── background.jpg │ ├── test_head.png │ └── test_head_2.png │ └── userinfo.html ├── Elearning-live ├── Elearning-live.iml ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── darod │ └── elearning │ └── live │ ├── configuration │ └── WebSocketConfiguration.java │ ├── controller │ └── BarrageController.java │ └── interceptor │ ├── HandshakeInterceptor.java │ └── MyChannelInterceptor.java ├── Elearning-user ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── darod │ │ └── elearning │ │ └── user │ │ ├── UserApplication.java │ │ └── serviceimpl │ │ └── UserServiceImpl.java │ └── resources │ ├── application.properties │ └── mapping │ ├── UserDOMapper.xml │ └── UserPasswordDOMapper.xml ├── LICENSE ├── README.md └── pom.xml /Elearning-common/schema/elearning_user.sql: -------------------------------------------------------------------------------- 1 | CREATE SCHEMA `elearning_user`; 2 | 3 | use elearning_user; 4 | 5 | CREATE TABLE `user_info` 6 | ( 7 | `id` int(11) NOT NULL AUTO_INCREMENT, 8 | `name` varchar(64) NOT NULL DEFAULT '', 9 | `gender` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1代表男性 2代表女性', 10 | `age` int(11) NOT NULL, 11 | `telphone` varchar(45) NOT NULL, 12 | `register_mode` varchar(45) NOT NULL COMMENT 'byphone bywechat byalipay', 13 | `third_party_id` varchar(64) NOT NULL DEFAULT '', 14 | PRIMARY KEY (`id`), 15 | UNIQUE KEY `telphone_UNIQUE` (`telphone`) 16 | ) 17 | ENGINE = InnoDB 18 | AUTO_INCREMENT = 1 19 | DEFAULT CHARSET = utf8mb4 20 | COMMENT '用户表基本信息表'; 21 | 22 | 23 | CREATE TABLE `user_password` 24 | ( 25 | `id` int(11) NOT NULL AUTO_INCREMENT, 26 | `encrypt_password` varchar(128) NOT NULL, 27 | `user_id` int(11) NOT NULL, 28 | PRIMARY KEY (`id`) 29 | ) ENGINE = InnoDB 30 | AUTO_INCREMENT = 3 31 | DEFAULT CHARSET = utf8mb4 32 | COMMENT '用户密码权限表'; 33 | 34 | CREATE TABLE `user_publisher` 35 | ( 36 | `id` int(11) NOT NULL AUTO_INCREMENT, 37 | `user_id` int(11) NOT NULL COMMENT '用户id', 38 | `id_card` varchar(18) NOT NULL COMMENT '身份证号码', 39 | `cost_percent` double NOT NULL DEFAULT '0' COMMENT '收费比例', 40 | `room_id` int(11) NOT NULL COMMENT '房间号', 41 | PRIMARY KEY (`id`) 42 | ) ENGINE = InnoDB 43 | DEFAULT CHARSET = utf8mb4 44 | COMMENT ='用户_发布者表'; 45 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/cache/RedisCache.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.cache; 2 | 3 | import org.apache.shiro.cache.Cache; 4 | import org.apache.shiro.cache.CacheException; 5 | import org.darod.elearning.common.utils.RedisUtilsForShiro; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.util.SerializationUtils; 9 | 10 | import java.util.Collection; 11 | import java.util.Set; 12 | 13 | /** 14 | * @author Darod 15 | * @version 1.0 16 | * @date 2019/7/7 0007 14:45 17 | */ 18 | @Component 19 | public class RedisCache implements Cache { 20 | @Autowired 21 | private RedisUtilsForShiro redisUtils; 22 | 23 | private final String CACHE_PREFIX = "elearning-gateway-cache:"; 24 | 25 | private String getKey(K k) { 26 | if (k instanceof String) { 27 | return (CACHE_PREFIX + k); 28 | } 29 | String temp = new String(SerializationUtils.serialize(k)); 30 | return CACHE_PREFIX + temp; 31 | } 32 | 33 | @Override 34 | public V get(K k) throws CacheException { 35 | System.out.println("从redis获取数据"); 36 | Object object = redisUtils.get(getKey(k)); 37 | if (object != null) { 38 | return (V) object; 39 | } 40 | return null; 41 | } 42 | 43 | @Override 44 | public V put(K k, V v) throws CacheException { 45 | String key = getKey(k); 46 | redisUtils.set(key, v, 600); 47 | return v; 48 | } 49 | 50 | @Override 51 | public V remove(K k) throws CacheException { 52 | String key = getKey(k); 53 | Object o = redisUtils.get(key); 54 | redisUtils.del(key); 55 | if (o != null) { 56 | return (V) o; 57 | } 58 | return null; 59 | } 60 | 61 | @Override 62 | public void clear() throws CacheException { 63 | // 64 | } 65 | 66 | @Override 67 | public int size() { 68 | return 0; 69 | } 70 | 71 | @Override 72 | public Set keys() { 73 | return null; 74 | } 75 | 76 | @Override 77 | public Collection values() { 78 | return null; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/cache/RedisCacheManager.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.cache; 2 | 3 | import org.apache.shiro.cache.Cache; 4 | import org.apache.shiro.cache.CacheException; 5 | import org.apache.shiro.cache.CacheManager; 6 | 7 | import javax.annotation.Resource; 8 | 9 | /** 10 | * @author Darod 11 | * @version 1.0 12 | * @date 2019/7/7 0007 14:44 13 | */ 14 | public class RedisCacheManager implements CacheManager { 15 | 16 | @Resource 17 | private RedisCache redisCache; 18 | 19 | @Override 20 | public Cache getCache(String s) throws CacheException { 21 | return redisCache; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/configuration/CustomSessionManager.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.configuration; 2 | 3 | import org.apache.shiro.session.Session; 4 | import org.apache.shiro.session.UnknownSessionException; 5 | import org.apache.shiro.session.mgt.SessionKey; 6 | import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; 7 | import org.apache.shiro.web.session.mgt.WebSessionKey; 8 | 9 | import javax.servlet.ServletRequest; 10 | import java.io.Serializable; 11 | 12 | /** 13 | * @author Darod 14 | * @version 1.0 15 | * @date 2019/7/7 0007 12:06 16 | */ 17 | public class CustomSessionManager extends DefaultWebSessionManager { 18 | @Override 19 | protected Session retrieveSession(SessionKey sessionKey) throws UnknownSessionException { 20 | Serializable sessionId = getSessionId(sessionKey); 21 | ServletRequest request = null; 22 | if (sessionKey instanceof WebSessionKey) { 23 | request = ((WebSessionKey) sessionKey).getServletRequest(); 24 | } 25 | if (request != null && sessionId != null) { 26 | Session session = (Session) request.getAttribute(sessionId.toString()); 27 | if(session != null)return session; 28 | } 29 | Session session = super.retrieveSession(sessionKey); 30 | if(request != null && sessionId != null){ 31 | request.setAttribute(sessionId.toString(),session); 32 | } 33 | return session; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/configuration/FastJson2JsonRedisSerializer.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.configuration; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.parser.ParserConfig; 5 | import com.alibaba.fastjson.serializer.SerializerFeature; 6 | import org.springframework.data.redis.serializer.RedisSerializer; 7 | import org.springframework.data.redis.serializer.SerializationException; 8 | 9 | import java.nio.charset.Charset; 10 | 11 | /** 12 | * @author Darod 13 | * @version 1.0 14 | * @date 2019/7/24 0024 13:46 15 | */ 16 | public class FastJson2JsonRedisSerializer implements RedisSerializer { 17 | static { 18 | ParserConfig.getGlobalInstance().setAutoTypeSupport(true); 19 | } 20 | 21 | public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); 22 | 23 | private Class clazz; 24 | 25 | public FastJson2JsonRedisSerializer(Class clazz) { 26 | super(); 27 | this.clazz = clazz; 28 | } 29 | 30 | @Override 31 | public byte[] serialize(T t) throws SerializationException { 32 | if (t == null) { 33 | return new byte[0]; 34 | } 35 | return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET); 36 | } 37 | 38 | @Override 39 | public T deserialize(byte[] bytes) throws SerializationException { 40 | if (bytes == null || bytes.length <= 0) { 41 | return null; 42 | } 43 | String str = new String(bytes, DEFAULT_CHARSET); 44 | return (T) JSON.parseObject(str, clazz); 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/configuration/RedisConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.configuration; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.data.redis.connection.RedisConnectionFactory; 6 | import org.springframework.data.redis.core.RedisTemplate; 7 | import org.springframework.data.redis.serializer.RedisSerializer; 8 | import org.springframework.data.redis.serializer.StringRedisSerializer; 9 | 10 | /** 11 | * @author Darod 12 | * @version 1.0 13 | * @date 2019/7/3 0003 21:20 14 | */ 15 | @Configuration 16 | public class RedisConfiguration { 17 | @Bean("redisTemplateForShiro") 18 | public RedisTemplate redisTemplateForShiro(RedisConnectionFactory factory) { 19 | StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); 20 | RedisTemplate template = new RedisTemplate<>(); 21 | template.setConnectionFactory(factory); 22 | template.setKeySerializer(stringRedisSerializer); 23 | template.setHashKeySerializer(stringRedisSerializer); 24 | template.afterPropertiesSet(); 25 | return template; 26 | } 27 | @Bean("redisTemplate") 28 | public RedisTemplate redisTemplate(RedisConnectionFactory factory, RedisSerializer redisSerializer) { 29 | StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); 30 | RedisTemplate template = new RedisTemplate<>(); 31 | template.setConnectionFactory(factory); 32 | template.setKeySerializer(stringRedisSerializer); 33 | template.setValueSerializer(redisSerializer); 34 | template.setHashKeySerializer(stringRedisSerializer); 35 | template.setHashValueSerializer(redisSerializer); 36 | template.afterPropertiesSet(); 37 | return template; 38 | } 39 | 40 | // @Bean 41 | // public Jackson2JsonRedisSerializer jackson2JsonRedisSerializer() { 42 | // final Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>( 43 | // Object.class); 44 | // final ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build(); 45 | //// objectMapper.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES); 46 | //// objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); 47 | //// objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); 48 | //// objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); 49 | //// objectMapper.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE); 50 | //// objectMapper.configure(MapperFeature.PROPAGATE_TRANSIENT_MARKER,false); 51 | //// objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); 52 | // jackson2JsonRedisSerializer.setObjectMapper(objectMapper); 53 | // return jackson2JsonRedisSerializer; 54 | // } 55 | @Bean 56 | public FastJson2JsonRedisSerializer fastJsonRedisSerializer(){ 57 | FastJson2JsonRedisSerializer fastJson2JsonRedisSerializer =new FastJson2JsonRedisSerializer<>(Object.class); 58 | return fastJson2JsonRedisSerializer; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/configuration/RedisSessionDao.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.configuration; 2 | 3 | import org.apache.shiro.session.Session; 4 | import org.apache.shiro.session.UnknownSessionException; 5 | import org.apache.shiro.session.mgt.eis.AbstractSessionDAO; 6 | import org.darod.elearning.common.utils.RedisUtilsForShiro; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.io.Serializable; 11 | import java.util.Collection; 12 | import java.util.HashSet; 13 | import java.util.Set; 14 | import java.util.stream.Collectors; 15 | 16 | /** 17 | * @author Darod 18 | * @version 1.0 19 | * @date 2019/7/3 0003 20:16 20 | */ 21 | @Component 22 | public class RedisSessionDao extends AbstractSessionDAO { 23 | @Autowired 24 | RedisUtilsForShiro redisUtils; 25 | 26 | private final String SHIRO_SESSION_PREFIX = "elearning-gateway-session:"; 27 | 28 | private String getKey(String key) { 29 | return SHIRO_SESSION_PREFIX + key; 30 | } 31 | 32 | private void saveSession(Session session) { 33 | if (session != null && session.getId() != null) { 34 | String key = getKey(session.getId().toString()); 35 | // byte[] value = SerializationUtils.serialize(session); 36 | redisUtils.set(key, session, 86400); 37 | } 38 | } 39 | 40 | @Override 41 | protected Serializable doCreate(Session session) { 42 | Serializable sessionId = generateSessionId(session); 43 | assignSessionId(session, sessionId); 44 | saveSession(session); 45 | return sessionId; 46 | } 47 | 48 | @Override 49 | protected Session doReadSession(Serializable sessionId) { 50 | // System.out.println("read session"); 51 | if (sessionId == null) { 52 | return null; 53 | } 54 | String key = getKey(sessionId.toString()); 55 | // return (Session)SerializationUtils.deserialize((byte[]) redisUtils.get(key)); 56 | return (Session) redisUtils.get(key); 57 | } 58 | 59 | @Override 60 | public void update(Session session) throws UnknownSessionException { 61 | saveSession(session); 62 | } 63 | 64 | @Override 65 | public void delete(Session session) { 66 | if (session == null && session.getId() == null) return; 67 | String key = getKey(session.getId().toString()); 68 | redisUtils.del(key); 69 | } 70 | 71 | @Override 72 | public Collection getActiveSessions() { 73 | Set keys = redisUtils.keys(SHIRO_SESSION_PREFIX + "*"); 74 | return keys.stream().map(key -> (Session) redisUtils.get(key)).collect(Collectors.toCollection(HashSet::new)); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/dto/ChapterModel.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.dto; 2 | 3 | import lombok.Data; 4 | import org.darod.elearning.common.validator.MyNotBlank; 5 | 6 | import javax.validation.constraints.Min; 7 | import javax.validation.constraints.NotBlank; 8 | import javax.validation.constraints.NotNull; 9 | import javax.validation.constraints.Null; 10 | import java.util.Date; 11 | 12 | /** 13 | * @author Darod 14 | * @version 1.0 15 | * @date 2019/7/16 0016 12:09 16 | */ 17 | @Data 18 | public class ChapterModel { 19 | @Null(message = "您无权设置部分字段", groups = {ChapterModelForCreate.class, ChapterModelForUpdate.class}) 20 | private Integer chapterId; 21 | @Min(value = 1, message = "章节编号不能小于1", groups = {ChapterModelForCreate.class, ChapterModelForUpdate.class}) 22 | @NotNull(message = "章节序号不能为空", groups = ChapterModelForCreate.class) 23 | private Integer chapterNo; 24 | @NotBlank(message = "章节名称不能为空", groups = ChapterModelForCreate.class) 25 | @MyNotBlank(message = "章节名称不能为空", groups = ChapterModelForUpdate.class) 26 | private String chapterName; 27 | 28 | private String chapterDescription; 29 | @Null(message = "您无权设置部分字段", groups = {ChapterModelForCreate.class, ChapterModelForUpdate.class}) 30 | private String videoUrl; 31 | @Null(message = "您无权设置部分字段", groups = {ChapterModelForCreate.class, ChapterModelForUpdate.class}) 32 | private Date publishTime; 33 | @Null(message = "您无权设置部分字段", groups = {ChapterModelForCreate.class, ChapterModelForUpdate.class}) 34 | private String totalTime; 35 | @Null(message = "您无权设置部分字段", groups = {ChapterModelForCreate.class, ChapterModelForUpdate.class}) 36 | private Integer chapterState; 37 | @Null(message = "您无权设置部分字段", groups = {ChapterModelForCreate.class, ChapterModelForUpdate.class}) 38 | private Integer courseId; 39 | 40 | public interface ChapterModelForCreate { 41 | } 42 | 43 | public interface ChapterModelForUpdate { 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/dto/CommentModel.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @author Darod 9 | * @version 1.0 10 | * @date 2019/7/16 0016 12:32 11 | */ 12 | @Data 13 | public class CommentModel { 14 | private Integer commentId; 15 | 16 | private String commentContent; 17 | 18 | private Date commentTime; 19 | 20 | private Integer userId; 21 | 22 | private Integer courseId; 23 | 24 | private Integer chapterId; 25 | 26 | private Integer commentState; 27 | 28 | public CommentModel() { 29 | } 30 | 31 | public CommentModel(Integer commentId, String commentContent, Date commentTime, Integer userId, Integer courseId, Integer chapterId, Integer commentState) { 32 | this.commentId = commentId; 33 | this.commentContent = commentContent; 34 | this.commentTime = commentTime; 35 | this.userId = userId; 36 | this.courseId = courseId; 37 | this.chapterId = chapterId; 38 | this.commentState = commentState; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/dto/CommonCountModel.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.dto; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.github.pagehelper.Page; 5 | import lombok.Data; 6 | import org.darod.elearning.common.utils.CopyPropertiesUtils; 7 | 8 | import java.util.List; 9 | import java.util.function.Function; 10 | 11 | /** 12 | * @author Darod 13 | * @version 1.0 14 | * @date 2019/7/1 0001 16:21 15 | */ 16 | @Data 17 | public class CommonCountModel> { 18 | Long total; 19 | T dataList; 20 | 21 | public CommonCountModel() { 22 | } 23 | 24 | private CommonCountModel(Long total, T dataList) { 25 | this.total = total; 26 | this.dataList = dataList; 27 | } 28 | 29 | public JSONObject toJSONObject(String listName) { 30 | JSONObject jsonObject = new JSONObject(true); 31 | jsonObject.put("total", total); 32 | jsonObject.put(listName, dataList); 33 | return jsonObject; 34 | } 35 | public static CommonCountModel> getCountModel(Long total,List dataList){ 36 | return new CommonCountModel<>(total,dataList); 37 | } 38 | 39 | public static CommonCountModel> getCountModelFromList(Page page, List list, Class clazz){ 40 | return getCountModel(page.getTotal(),CopyPropertiesUtils.mapListObject(list,clazz)); 41 | } 42 | public static CommonCountModel> getCountModelFromListWithMapper(Page page, List list, Class clazz, Function mapper){ 43 | return getCountModel(page.getTotal(),CopyPropertiesUtils.mapListObjectWithMapper(list, clazz,mapper)); 44 | } 45 | 46 | 47 | public static void main(String[] args) { 48 | CommonCountModel> commonCountModel = new CommonCountModel<>(); 49 | } 50 | } 51 | 52 | 53 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/dto/CommonPageModel.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.dto; 2 | 3 | import lombok.Data; 4 | import org.darod.elearning.common.validator.EnumValue; 5 | 6 | import javax.validation.constraints.Min; 7 | 8 | /** 9 | * @author Darod 10 | * @version 1.0 11 | * @date 2019/7/15 0015 13:53 12 | */ 13 | @Data 14 | public class CommonPageModel { 15 | @Min(value = 0, message = "页数不能为负数") 16 | private Integer page; 17 | @Min(value = 0, message = "行数不能为负数") 18 | private Integer row; 19 | 20 | //其它可选的搜索限定符 21 | private String sortBy; //按某个变量排序 22 | 23 | @EnumValue(enumClass = OrderType.class) 24 | private String order; //升序还是降序 默认降序 25 | 26 | public enum OrderType { 27 | ASC, 28 | DESC 29 | } 30 | 31 | public void checkPage() { 32 | if (page == null || row == null) { 33 | page = 0; 34 | row = 9999; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/dto/CourseModel.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.dto; 2 | 3 | import lombok.Data; 4 | import org.darod.elearning.common.validator.MyNotBlank; 5 | 6 | import javax.validation.constraints.NotBlank; 7 | import javax.validation.constraints.Null; 8 | import java.util.Date; 9 | 10 | /** 11 | * @author Darod 12 | * @version 1.0 13 | * @date 2019/7/1 0001 15:00 14 | */ 15 | @Data 16 | public class CourseModel { 17 | @Null(message = "您无权设置某些字段", groups = {CourseModelForCreate.class, CourseModelForUpdate.class}) 18 | private Integer courseId; 19 | @MyNotBlank(message = "课程名不能为空", groups = {CourseModelForUpdate.class}) 20 | @NotBlank(message = "课程名不能为空", groups = {CourseModelForCreate.class}) 21 | private String courseName; 22 | @Null(message = "您无权设置某些字段", groups = {CourseModelForCreate.class, CourseModelForUpdate.class}) 23 | private Integer teacherId; 24 | private Date publishTime; 25 | private Double price; 26 | @Null(message = "您无权设置某些字段", groups = {CourseModelForCreate.class, CourseModelForUpdate.class}) 27 | private Integer learnNum; 28 | @Null(message = "您无权设置某些字段", groups = {CourseModelForCreate.class, CourseModelForUpdate.class}) 29 | private Integer courseState; 30 | private String firstTag; 31 | private String secondTag; 32 | private String thirdTag; 33 | private String courseDescription; 34 | @Null(message = "您无权设置某些字段", groups = {CourseModelForCreate.class, CourseModelForUpdate.class}) 35 | private String courseImgUrl; 36 | 37 | public interface CourseModelForCreate { 38 | } 39 | 40 | public interface CourseModelForUpdate { 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/dto/CoursePageModel.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.dto; 2 | 3 | import lombok.Data; 4 | import org.darod.elearning.common.validator.EnumValue; 5 | 6 | import javax.validation.constraints.Min; 7 | import javax.validation.constraints.Null; 8 | 9 | /** 10 | * @author Darod 11 | * @version 1.0 12 | * @date 2019/7/9 0009 8:37 13 | */ 14 | @Data 15 | public class CoursePageModel { 16 | @Min(value = 0, message = "页数不能为负数") 17 | private Integer page; 18 | @Min(value = 0, message = "行数不能为负数") 19 | private Integer row; 20 | 21 | 22 | //其它可选的搜索限定符 23 | private String sortBy; //按某个变量排序 24 | 25 | private String order; //升序还是降序 默认降序 26 | 27 | private String labelFirst; //一级标签是XX 28 | 29 | private String labelSecond; //二级标签是XX 30 | 31 | private String labelThird; //三级标签是XX 32 | 33 | @Null(message = "您无权设置该字段") 34 | private Integer userId; //用户ID 只有在查询和用户相关课程时候用到 35 | 36 | private Integer courseId; //课程id 37 | 38 | private Integer teacherId; //教师ID 39 | 40 | private String keyWord; //课程名称关键字 41 | 42 | private String teacherName; //老师名称关键字 模糊搜索 43 | 44 | @EnumValue(enumClass = PriceRange.class) 45 | private String priceRange; //价格区间 46 | 47 | public enum PriceRange { 48 | _FREE,//免费 49 | _0T49,//0到49 50 | _50T99, //50到99 51 | _100T299, //100到299 52 | _300T499, //300到500 53 | _500 //500以上 54 | } 55 | 56 | public void checkPage() { 57 | if (page == null || row == null) { 58 | page = 0; 59 | row = 9999; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/dto/LiveRecordModel.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.dto; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * @author Darod 10 | * @version 1.0 11 | * @date 2019/7/23 0023 16:40 12 | */ 13 | @Data 14 | public class LiveRecordModel { 15 | @JSONField(serialize = false) 16 | private Integer liveRecordId; 17 | 18 | private Integer teacherId; 19 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 20 | private Date startTime; 21 | @JSONField(serialize = false) 22 | private Date finishTime; 23 | 24 | private String channelId; 25 | // @JSONField(serialize = false) 26 | private String liveSecret; 27 | 28 | private Integer watchNum; 29 | @JSONField(serialize = false) 30 | private Date beatTime; 31 | 32 | private String rtmpAddress; 33 | 34 | private String liveImage; 35 | } 36 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/dto/LiveRoomModel.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.dto; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * @author Darod 10 | * @version 1.0 11 | * @date 2019/7/22 0022 15:20 12 | */ 13 | @Data 14 | public class LiveRoomModel { 15 | private Integer userId; 16 | 17 | private Integer teacherId; 18 | 19 | private String roomName; 20 | 21 | private String roomDescription; 22 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 23 | private Date createTime; 24 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 25 | private Date lastLiveTime; 26 | 27 | private String roomImage; 28 | } 29 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/dto/MessageModel.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @author Darod 9 | * @version 1.0 10 | * @date 2019/7/16 0016 16:00 11 | */ 12 | @Data 13 | public class MessageModel { 14 | public MessageModel() { 15 | } 16 | 17 | public MessageModel(Integer messageId, Integer messageType, Date messageTime, String messageContent, Integer messageState, Integer senderId, Integer receiverId) { 18 | this.messageId = messageId; 19 | this.messageType = messageType; 20 | this.messageTime = messageTime; 21 | this.messageContent = messageContent; 22 | this.messageState = messageState; 23 | this.senderId = senderId; 24 | this.receiverId = receiverId; 25 | } 26 | 27 | private Integer messageId; 28 | 29 | private Integer messageType; 30 | 31 | private Date messageTime; 32 | 33 | private String messageContent; 34 | 35 | private Integer messageState; 36 | 37 | private Integer senderId; 38 | 39 | private Integer receiverId; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/dto/OrderModel.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.dto; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import lombok.Data; 5 | 6 | import javax.validation.constraints.Max; 7 | import javax.validation.constraints.Min; 8 | import java.util.Date; 9 | 10 | /** 11 | * @author Darod 12 | * @version 1.0 13 | * @date 2019/7/13 0013 11:33 14 | */ 15 | @Data 16 | public class OrderModel { 17 | private String orderId; 18 | 19 | private Integer userId; 20 | 21 | private Integer courseId; 22 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 23 | private Date createTime; 24 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 25 | private Date payTime; 26 | 27 | @Min(value = 0, message = "状态码错误") 28 | @Max(value = 3, message = "状态码错误") 29 | private Integer orderState; 30 | } 31 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/dto/Shout.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.dto; 2 | 3 | /** 4 | * @author Darod 5 | * @version 1.0 6 | * @date 2019/8/2 0002 22:31 7 | */ 8 | public class Shout { 9 | private String message; 10 | 11 | public Shout() { 12 | } 13 | 14 | public Shout(String message) { 15 | this.message = message; 16 | } 17 | 18 | public String getMessage() { 19 | return message; 20 | } 21 | 22 | public void setMessage(String message) { 23 | this.message = message; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/dto/TeacherModel.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.dto; 2 | 3 | import lombok.Data; 4 | import org.darod.elearning.common.validator.MyNotBlank; 5 | 6 | import javax.validation.constraints.NotBlank; 7 | import javax.validation.constraints.Null; 8 | import java.util.Date; 9 | 10 | /** 11 | * @author Darod 12 | * @version 1.0 13 | * @date 2019/7/16 0016 19:06 14 | */ 15 | @Data 16 | public class TeacherModel { 17 | @Null(message = "您无权设置部分字段", groups = {TeacherModelApply.class,TeacherModelUpdate.class}) 18 | private Integer teacherId; 19 | @Null(message = "您无权设置部分字段", groups = {TeacherModelApply.class,TeacherModelUpdate.class}) 20 | private Integer userId; 21 | private String teacherDescription; 22 | @Null(message = "您无权设置部分字段", groups = {TeacherModelApply.class,TeacherModelUpdate.class}) 23 | private Integer costPercent; 24 | @MyNotBlank(message = "教师名称不能为空", groups = {TeacherModelUpdate.class}) 25 | @NotBlank(message = "教师名称不能为空",groups = {TeacherModelApply.class}) 26 | private String teacherName; 27 | @Null(message = "您无权设置部分字段", groups = {TeacherModelApply.class,TeacherModelUpdate.class}) 28 | private Date applyTime; 29 | @Null(message = "您无权设置部分字段", groups = {TeacherModelApply.class,TeacherModelUpdate.class}) 30 | private Integer teacherState; 31 | 32 | 33 | public interface TeacherModelApply { 34 | } 35 | 36 | public interface TeacherModelUpdate { 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/dto/UserLearnModel.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.dto; 2 | 3 | 4 | import com.alibaba.fastjson.annotation.JSONField; 5 | import lombok.Data; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * @author Darod 11 | * @version 1.0 12 | * @date 2019/7/1 0001 8:30 13 | */ 14 | @Data 15 | public class UserLearnModel { 16 | private Integer userId; 17 | private String courseName; 18 | private Integer teacherId; 19 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 20 | private Date publishTime; 21 | private Double price; 22 | private Integer learnNum; 23 | private Integer courseState; 24 | private String firstTag; 25 | private String secondTag; 26 | private String thirdTag; 27 | private String courseDescription; 28 | private String courseImgUrl; 29 | private Integer courseId; 30 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 31 | private Date learnTime; 32 | private Integer lastChapter; 33 | private String chapterName; 34 | } 35 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/dto/UserModel.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.dto; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import lombok.Data; 5 | import org.hibernate.validator.constraints.URL; 6 | 7 | import javax.validation.constraints.Max; 8 | import javax.validation.constraints.Min; 9 | import javax.validation.constraints.NotBlank; 10 | import javax.validation.constraints.NotNull; 11 | import java.io.Serializable; 12 | 13 | /** 14 | * @author Darod 15 | * @version 1.0 16 | * @date 2019/6/20 0020 9:20 17 | */ 18 | @Data 19 | public class UserModel implements Serializable { 20 | private Integer userId; 21 | @NotBlank(message = "用户名不能为空") 22 | private String name; 23 | @NotNull(message = "性别不能为空") 24 | private Integer gender; 25 | @NotNull(message = "年龄不能为空") 26 | @Min(value = 0, message = "年龄必须大于0岁") 27 | @Max(value = 150, message = "年龄不能大于150岁") 28 | private Integer age; 29 | @NotBlank(message = "手机号不能为空") 30 | private String telphone; 31 | private String registerMode; 32 | private String thirdPartyId; 33 | @NotBlank(message = "密码不能为空") 34 | @JSONField(serialize = false) 35 | private String encryptPassword; 36 | private String email; 37 | @NotNull(message = "头像URL不能为空") 38 | private String headUrl; 39 | @NotNull(message = "用户状态不能为空") 40 | private Integer userState; 41 | private String userDescribtion; 42 | } 43 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.exception; 2 | 3 | /** 4 | * @author Darod 5 | * @version 1.0 6 | * @date 2019/6/20 0020 9:06 7 | */ 8 | public class BusinessException extends RuntimeException implements CommonError { 9 | private CommonError commonError; 10 | 11 | public BusinessException(CommonError commonError) { 12 | super(); 13 | this.commonError = commonError; 14 | } 15 | 16 | public BusinessException(CommonError commonError, String errMsg) { 17 | super(); 18 | this.commonError = commonError; 19 | this.commonError.setErrMsg(errMsg); 20 | } 21 | 22 | @Override 23 | public int getErrCode() { 24 | return commonError.getErrCode(); 25 | } 26 | 27 | @Override 28 | public String getErrMsg() { 29 | return commonError.getErrMsg(); 30 | } 31 | 32 | @Override 33 | public CommonError setErrMsg(String errMsg) { 34 | commonError.setErrMsg(errMsg); 35 | return commonError; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/exception/CommonError.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.exception; 2 | 3 | /** 4 | * @author Darod 5 | * @version 1.0 6 | * @date 2019/6/20 0020 9:06 7 | */ 8 | public interface CommonError { 9 | int getErrCode(); 10 | String getErrMsg(); 11 | CommonError setErrMsg(String errMsg); 12 | } 13 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/exception/EmException.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.exception; 2 | 3 | /** 4 | * @author Darod 5 | * @version 1.0 6 | * @date 2019/6/20 0020 9:09 7 | */ 8 | public enum EmException implements CommonError { 9 | 10 | PARAMETER_VALIDATION_ERROR(10000, "参数不合法"), 11 | UNKNOWN_ERROR(10001, "未知错误"), 12 | 13 | BINDING_VALIDATION_ERROR(10002, "参数绑定失败,请检查参数组合是否合理"), 14 | 15 | PERMISSION_DENIED(30000, "您没有权限"), 16 | 17 | USER_NOT_EXIST(20001, "用户不存在"), 18 | USER_LOGIN_FAIL(20002, "用户名或密码错误"), 19 | USER_NOT_LOGIN(20003, "用户还未登录"), 20 | 21 | COURSE_NOT_EXIST(40000, "课程不存在"), 22 | 23 | ORDER_NOT_EXIST(40001, "订单不存在"), 24 | 25 | COURSE_NOT_PURCHASED(40002, "课程未购买"), 26 | 27 | COURSE_HAVE_LEARNED(40003, "您已经学习该课程"), 28 | 29 | COURSE_NOT_LEARNED(40004, "您还未学习该课程"), 30 | 31 | COURSE_HAVE_PURCHASED(40005, "您已经购买过该课程,请勿重复购买"), 32 | 33 | ORDER_DELETED(40006, "订单已删除"), 34 | 35 | ORDER_EXPIRED(40007, "订单已过期,请重新下单"), 36 | 37 | CHAPTER_NOT_EXIST(40100, "章节不存在"), 38 | 39 | COMMENT_NOT_EXIST(40101, "评论不存在"), 40 | 41 | CHAPTER_VIDEO_NOT_EXIST(40102, "章节暂无视频"), 42 | 43 | TEACHER_HAVE_APPLY(40200, "您已经申请过了"), 44 | 45 | TEACHER_NOT_EXIST(40201, "教师不存在"), 46 | 47 | LIVE_HAVE_APPLY(50000, "您已开启过直播"), 48 | 49 | LIVE_ROOM_NOT_EXIST(50001, "直播间不存在"), 50 | 51 | LIVE_HAVE_STOP(50002, "直播已经停止"), 52 | 53 | ; 54 | private int errCode; 55 | private String msg; 56 | 57 | EmException(int errCode, String msg) { 58 | this.errCode = errCode; 59 | this.msg = msg; 60 | } 61 | 62 | @Override 63 | public int getErrCode() { 64 | return errCode; 65 | } 66 | 67 | @Override 68 | public String getErrMsg() { 69 | return msg; 70 | } 71 | 72 | @Override 73 | public CommonError setErrMsg(String errMsg) { 74 | this.msg = errMsg; 75 | return this; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/exception/UploadException.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.exception; 2 | 3 | /** 4 | * @author Darod 5 | * @version 1.0 6 | * @date 2019/7/19 0019 23:00 7 | */ 8 | //抛出这个异常时需要返回特定的状态码让nginx删除上传的文件 9 | public class UploadException extends BusinessException { 10 | public UploadException(CommonError commonError) { 11 | super(commonError); 12 | } 13 | public UploadException(CommonError commonError, String errMsg) { 14 | super(commonError,errMsg); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/response/CommonResponse.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.response; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import lombok.Data; 5 | 6 | /** 7 | * 通用返回类型 8 | * 9 | * @author Darod 10 | * @version 1.0 11 | * @date 2019/6/20 0020 9:04 12 | */ 13 | 14 | public class CommonResponse { 15 | @JSONField(ordinal = 1) 16 | private Integer status; 17 | @JSONField(ordinal = 2) 18 | private String message; 19 | @JSONField(ordinal = 3) 20 | private Object data; 21 | 22 | public CommonResponse(Integer status, String message, Object data) { 23 | this.status = status; 24 | this.message = message; 25 | this.data = data; 26 | } 27 | 28 | public CommonResponse(Integer status, String message) { 29 | this.status = status; 30 | this.message = message; 31 | } 32 | 33 | public Integer getStatus() { 34 | return status; 35 | } 36 | 37 | public void setStatus(Integer status) { 38 | this.status = status; 39 | } 40 | 41 | public String getMessage() { 42 | return message; 43 | } 44 | 45 | public void setMessage(String message) { 46 | this.message = message; 47 | } 48 | 49 | public Object getData() { 50 | return data; 51 | } 52 | 53 | public void setData(Object data) { 54 | this.data = data; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/response/ResponseUtils.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.response; 2 | 3 | import org.darod.elearning.common.exception.CommonError; 4 | 5 | /** 6 | * @author Darod 7 | * @version 1.0 8 | * @date 2019/6/30 0030 21:44 9 | */ 10 | public class ResponseUtils { 11 | public static final int STATUS_OK = 200; 12 | public static final int STATUS_FAILURE = 400; 13 | public static final int STATUS_UNKNOWN = 500; 14 | public static final String MESSAGE_OK = "成功"; 15 | public static final String MESSAGE_FAILURE = "失败"; 16 | public static final String MESSAGE_UNKNOWN = "未知错误"; 17 | 18 | public static CommonResponse getOKResponse() { 19 | return new CommonResponse(STATUS_OK, MESSAGE_OK, null); 20 | } 21 | 22 | public static CommonResponse getOKResponse(Object data) { 23 | return new CommonResponse(STATUS_OK, MESSAGE_OK, data); 24 | } 25 | 26 | public static CommonResponse getErrorResponse(Object erroInfo) { 27 | return new CommonResponse(STATUS_FAILURE, MESSAGE_FAILURE, erroInfo); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/service/user/ChapterService.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.service.user; 2 | 3 | import org.darod.elearning.common.dto.ChapterModel; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author Darod 9 | * @version 1.0 10 | * @date 2019/7/16 0016 12:04 11 | */ 12 | public interface ChapterService { 13 | List getAllChapterByCourseId(Integer courseId); 14 | 15 | ChapterModel getChapterInfoById(Integer courseId, Integer chapterId); 16 | 17 | List getAllChapterInfo(Integer courseId); 18 | 19 | ChapterModel addChapter(Integer courseId,ChapterModel chapterModel); 20 | 21 | ChapterModel updateChapter(Integer courseId,Integer chapterId,ChapterModel chapterModel); 22 | 23 | void deleteChapter(Integer courseId, Integer chapterId); 24 | } 25 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/service/user/CommentService.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.service.user; 2 | 3 | import org.darod.elearning.common.dto.CommentModel; 4 | import org.darod.elearning.common.dto.CommonCountModel; 5 | import org.darod.elearning.common.dto.CommonPageModel; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author Darod 11 | * @version 1.0 12 | * @date 2019/7/16 0016 12:31 13 | */ 14 | public interface CommentService { 15 | 16 | CommonCountModel> getAllCourseComment(Integer courseId, CommonPageModel commonPageModel); 17 | 18 | CommonCountModel> getAllChapterComment(Integer courseId, Integer chapterId, CommonPageModel commonPageModel); 19 | 20 | CommentModel addCourseComment(CommentModel commentModel); 21 | 22 | void deleteCourseComment(CommentModel commentModel); 23 | } 24 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/service/user/CourseService.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.service.user; 2 | 3 | import org.darod.elearning.common.dto.CommonCountModel; 4 | import org.darod.elearning.common.dto.CourseModel; 5 | import org.darod.elearning.common.dto.CoursePageModel; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author Darod 11 | * @version 1.0 12 | * @date 2019/7/1 0001 15:24 13 | */ 14 | public interface CourseService { 15 | CommonCountModel> getAllCourseInfo(int page, int row); 16 | 17 | CommonCountModel> getAllFreeCourseInfo(int page, int row); 18 | 19 | CommonCountModel> getCourseInfoLimited(CoursePageModel coursePageModel); 20 | 21 | CourseModel getCourseById(Integer courseId); 22 | 23 | // //教师视角的课程信息 目前和普通用户视角的一样 24 | // CourseModel getCourseToTeacherById(Integer userId, Integer courseId); 25 | // 26 | // //根据用户ID找到对应的教师Id,然后找到该Id的所有课程 27 | // CommonCountModel> getCourseByUserId(CoursePageModel coursePageModel); 28 | 29 | CourseModel addCourse(CourseModel courseModel); 30 | 31 | CourseModel updateCourse(CourseModel courseModel); 32 | 33 | // CourseModel updateCourseImage(CourseModel courseModel); 34 | 35 | void deleteCourse(Integer courseId); 36 | } 37 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/service/user/LiveService.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.service.user; 2 | 3 | import org.darod.elearning.common.dto.LiveRecordModel; 4 | import org.darod.elearning.common.dto.LiveRoomModel; 5 | 6 | /** 7 | * @author Darod 8 | * @version 1.0 9 | * @date 2019/7/21 0021 23:34 10 | */ 11 | public interface LiveService { 12 | 13 | LiveRecordModel addLive(Integer teacherId); 14 | 15 | void stopLive(Integer teacherId); 16 | 17 | LiveRoomModel updateLiveRoom(LiveRoomModel liveRoomModel); 18 | 19 | boolean authLive(String channelId, String liveSecret); 20 | 21 | boolean beatLive(String channelId, String liveSecret); 22 | 23 | boolean doneRecord(String channelId, String liveSecret,String url); 24 | 25 | void doneLive(String channelId, String liveSecret); 26 | 27 | void incWatchNum(String channelId); 28 | 29 | void decrWatchNum(String channelId); 30 | 31 | boolean isLiveExist(String channelId); 32 | 33 | // LiveRecordModel getCurLiveRecordModelFromCache(String channelId, String liveSecret); 34 | } 35 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/service/user/MessageService.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.service.user; 2 | 3 | import org.darod.elearning.common.dto.CommonCountModel; 4 | import org.darod.elearning.common.dto.CommonPageModel; 5 | import org.darod.elearning.common.dto.MessageModel; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author Darod 11 | * @version 1.0 12 | * @date 2019/7/16 0016 15:17 13 | */ 14 | public interface MessageService { 15 | CommonCountModel> getAllMessage(Integer userId, CommonPageModel commonPageModel); 16 | 17 | MessageModel getMessageById(Integer userId, Integer messageId); 18 | 19 | CommonCountModel> getMessagesUnread(Integer userId, CommonPageModel commonPageModel); 20 | 21 | Integer getMessagesUnreadCount(Integer userId); 22 | 23 | void deleteMessage(Integer userId, Integer messageId); 24 | 25 | void deleteAllMessage(Integer userId); 26 | 27 | void deleteAllMessageRead(Integer userId); 28 | 29 | MessageModel setMessageRead(Integer userId, Integer messageId); 30 | 31 | void setAllMessageRead(Integer userId); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/service/user/OrderService.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.service.user; 2 | 3 | import org.darod.elearning.common.dto.CommonCountModel; 4 | import org.darod.elearning.common.dto.CommonPageModel; 5 | import org.darod.elearning.common.dto.OrderModel; 6 | import org.darod.elearning.common.exception.BusinessException; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author Darod 12 | * @version 1.0 13 | * @date 2019/7/13 0013 11:32 14 | */ 15 | public interface OrderService { 16 | OrderModel createOrder(OrderModel orderModel) throws BusinessException; 17 | 18 | CommonCountModel> getAllOrderInfo(CommonPageModel commonPageModel) throws BusinessException; 19 | 20 | OrderModel getOrderInfoById(String orderId) throws BusinessException; 21 | 22 | OrderModel payOrder(OrderModel orderModel) throws BusinessException; 23 | } 24 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/service/user/PermissionService.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.service.user; 2 | 3 | import java.util.Set; 4 | 5 | /** 6 | * @author Darod 7 | * @version 1.0 8 | * @date 2019/7/20 0020 17:36 9 | */ 10 | public interface PermissionService { 11 | 12 | Set getUserRoleInfo(Integer userId); 13 | 14 | Set getUserPermissionInfo(Integer userId); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/service/user/TeacherService.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.service.user; 2 | 3 | import org.darod.elearning.common.dto.*; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author Darod 9 | * @version 1.0 10 | * @date 2019/7/16 0016 19:19 11 | */ 12 | public interface TeacherService { 13 | 14 | CommonCountModel> getCourseByUserId(CoursePageModel coursePageModel); 15 | 16 | CourseModel getCourseToTeacherById(Integer userId, Integer courseId); 17 | 18 | TeacherModel addTeacherApply(TeacherModel teacherModel); 19 | 20 | TeacherModel getTeacherInfoByTeacherId(Integer teacherId); 21 | 22 | TeacherModel getTeacherInfoByUserId(Integer userId); 23 | 24 | TeacherModel updateTeacherInfo(TeacherModel teacherModel); 25 | 26 | CourseModel addCourseTeacher(Integer userId, CourseModel courseModel); 27 | 28 | CourseModel updateCourseTeacher(Integer userId, CourseModel courseModel); 29 | 30 | CourseModel updateCourseImageTeacher(Integer userId, CourseModel courseModel); 31 | 32 | void deleteCourseTeacher(Integer userId, Integer courseId); 33 | 34 | ChapterModel getChapterInfoByIdTeacher(Integer userId, Integer courseId, Integer chapterId); 35 | 36 | List getAllChapterInfoTeacher(Integer userId, Integer courseId); 37 | 38 | ChapterModel addChapterTeacher(Integer userId, Integer courseId, ChapterModel chapterModel); 39 | 40 | ChapterModel updateChapterTeacher(Integer userId, Integer courseId, Integer chapterId, ChapterModel chapterModel); 41 | 42 | void deleteChapterTeacher(Integer userId, Integer courseId, Integer chapterId); 43 | 44 | //---------------------------直播相关-------------------------------- 45 | LiveRecordModel addLive(Integer userId); 46 | 47 | //结束直播 48 | void stopLive(Integer userId); 49 | 50 | //修改直播间信息 51 | LiveRoomModel updateLiveRoom(LiveRoomModel liveRoomModel); 52 | } 53 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/service/user/UserLearnService.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.service.user; 2 | 3 | import org.darod.elearning.common.dto.CommonCountModel; 4 | import org.darod.elearning.common.dto.CoursePageModel; 5 | import org.darod.elearning.common.dto.UserLearnModel; 6 | import org.darod.elearning.common.exception.BusinessException; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author Darod 12 | * @version 1.0 13 | * @date 2019/7/1 0001 8:29 14 | */ 15 | public interface UserLearnService { 16 | CommonCountModel> getCourseLearnedInfo(Integer userId, int page, int row); 17 | 18 | CommonCountModel> getCourseLearnedInfoLimited(CoursePageModel coursePageModel, Integer userId); 19 | 20 | UserLearnModel addUserLearnedCourse(UserLearnModel userLearnModel) throws BusinessException; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/service/user/UserService.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.service.user; 2 | 3 | import org.darod.elearning.common.dto.UserModel; 4 | import org.darod.elearning.common.exception.BusinessException; 5 | 6 | /** 7 | * @author Darod 8 | * @version 1.0 9 | * @date 2019/6/20 0020 9:19 10 | */ 11 | public interface UserService { 12 | void register(String username, String password) throws BusinessException; 13 | 14 | UserModel getUserById(Integer id); 15 | 16 | // void register(UserModel userModel) throws BusinessException; 17 | 18 | // UserModel validateLogin(String telphone, String encryptPassword) throws BusinessException; 19 | 20 | void updateUserById(UserModel userModel) throws BusinessException; 21 | 22 | void updateUserPasswordById(Integer userId, String oldPassword, String newPassword) throws BusinessException; 23 | 24 | String getChapterVideoUrl(Integer userId,Integer courseId,Integer chapterId); 25 | 26 | // void updateUserHeadImg(Integer userId, String url); 27 | 28 | String hello(); 29 | } 30 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/utils/CopyPropertiesUtils.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.utils; 2 | 3 | import org.springframework.beans.BeanUtils; 4 | import org.springframework.beans.BeanWrapper; 5 | import org.springframework.beans.BeanWrapperImpl; 6 | 7 | import java.util.HashSet; 8 | import java.util.List; 9 | import java.util.Set; 10 | import java.util.function.Consumer; 11 | import java.util.function.Function; 12 | import java.util.stream.Collectors; 13 | 14 | /** 15 | * @author Darod 16 | * @version 1.0 17 | * @date 2019/6/27 0027 15:12 18 | */ 19 | public class CopyPropertiesUtils { 20 | 21 | public static T copyProperties(Object source, Class target) { 22 | try { 23 | T t = target.newInstance(); 24 | BeanUtils.copyProperties(source, t); 25 | return t; 26 | } catch (IllegalAccessException | InstantiationException e) { 27 | throw new RuntimeException(e); 28 | } 29 | } 30 | 31 | public static List mapListObject(List source, Class target) { 32 | return source.stream().map(item -> { 33 | T t = copyProperties(item, target); 34 | return t; 35 | }).collect(Collectors.toList()); 36 | } 37 | 38 | public static List mapListObjectWithMapper(List source, Class target, Function mapper) { 39 | return source.stream().map(item -> { 40 | return mapper.apply(item); 41 | // T t = copyProperties(item, target); 42 | // return t; 43 | }).collect(Collectors.toList()); 44 | } 45 | 46 | //复制Bean属性 忽略null值 47 | public static T copyPropertiesIgnoreNull(S src, T target) { 48 | BeanUtils.copyProperties(src, target, getNullPropertyNames(src)); 49 | return target; 50 | } 51 | 52 | //获取Bean为null的属性名 53 | private static String[] getNullPropertyNames(Object source) { 54 | final BeanWrapper src = new BeanWrapperImpl(source); 55 | java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors(); 56 | 57 | Set emptyNames = new HashSet<>(); 58 | for (java.beans.PropertyDescriptor pd : pds) { 59 | Object srcValue = src.getPropertyValue(pd.getName()); 60 | if (srcValue == null) emptyNames.add(pd.getName()); 61 | } 62 | String[] result = new String[emptyNames.size()]; 63 | return emptyNames.toArray(result); 64 | } 65 | 66 | //复制插入数据库然后取出 67 | public static M copyAndInsertThenReturn(M modelObject, Class dataObjectCla, Consumer insertMethod, Function selectMethod) { 68 | D theDo = CopyPropertiesUtils.copyProperties(modelObject, dataObjectCla); 69 | insertMethod.accept(theDo); 70 | D newDo = selectMethod.apply(theDo); 71 | return CopyPropertiesUtils.copyProperties(newDo, (Class) modelObject.getClass()); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/utils/RedisUtilsForShiro.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.utils; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Qualifier; 5 | import org.springframework.data.redis.core.RedisTemplate; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.util.CollectionUtils; 8 | 9 | import java.util.Set; 10 | import java.util.concurrent.TimeUnit; 11 | 12 | /** 13 | * @author Darod 14 | * @version 1.0 15 | * @date 2019/7/3 0003 20:17 16 | */ 17 | @Component 18 | public class RedisUtilsForShiro { 19 | @Autowired 20 | @Qualifier("redisTemplateForShiro") 21 | private RedisTemplate redisTemplate; 22 | 23 | public boolean expire(String key, long time) { 24 | try { 25 | if (time > 0) { 26 | redisTemplate.expire(key, time, TimeUnit.SECONDS); 27 | } 28 | return true; 29 | } catch (Exception e) { 30 | e.printStackTrace(); 31 | return false; 32 | } 33 | } 34 | 35 | public void del(String... key) { 36 | if (key != null && key.length > 0) { 37 | if (key.length == 1) { 38 | redisTemplate.delete(key[0]); 39 | } else { 40 | redisTemplate.delete(CollectionUtils.arrayToList(key)); 41 | } 42 | } 43 | } 44 | public Object get(String key) { 45 | return key == null ? null : redisTemplate.opsForValue().get(key); 46 | } 47 | 48 | public boolean set(String key, Object value) { 49 | try { 50 | redisTemplate.opsForValue().set(key, value); 51 | return true; 52 | } catch (Exception e) { 53 | e.printStackTrace(); 54 | return false; 55 | } 56 | } 57 | 58 | public boolean set(String key, Object value, long time) { 59 | try { 60 | if (time > 0) { 61 | redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); 62 | } else { 63 | set(key, value); 64 | } 65 | return true; 66 | } catch (Exception e) { 67 | e.printStackTrace(); 68 | return false; 69 | } 70 | } 71 | 72 | public Set keys(String pattern) { 73 | if (pattern == null) { 74 | throw new RuntimeException("匹配模式不能为空"); 75 | } 76 | return redisTemplate.keys(pattern); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/utils/ShiroUtils.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.utils; 2 | 3 | import org.apache.shiro.SecurityUtils; 4 | import org.darod.elearning.common.exception.BusinessException; 5 | import org.darod.elearning.common.exception.EmException; 6 | 7 | /** 8 | * @author Darod 9 | * @version 1.0 10 | * @date 2019/7/7 0007 20:48 11 | */ 12 | public class ShiroUtils { 13 | public static Integer getCurUserId() throws BusinessException { 14 | Integer userId = (Integer) SecurityUtils.getSubject().getPrincipal(); 15 | if (userId == null) { 16 | throw new BusinessException(EmException.UNKNOWN_ERROR); 17 | } 18 | return userId; 19 | } 20 | 21 | public static void logoutUser() { 22 | SecurityUtils.getSubject().logout(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/validator/EnumValue.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.validator; 2 | 3 | import javax.validation.Constraint; 4 | import javax.validation.ConstraintValidator; 5 | import javax.validation.ConstraintValidatorContext; 6 | import javax.validation.Payload; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | import java.lang.reflect.InvocationTargetException; 12 | import java.lang.reflect.Method; 13 | 14 | /** 15 | * @author Darod 16 | * @version 1.0 17 | * @date 2019/7/9 0009 22:49 18 | */ 19 | @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE}) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Constraint(validatedBy = EnumValue.Validator.class) 22 | public @interface EnumValue { 23 | String message() default "{字段枚举值不合法}"; 24 | 25 | Class[] groups() default {}; 26 | 27 | Class[] payload() default {}; 28 | 29 | Class> enumClass(); 30 | 31 | // String enumMethod(); 32 | 33 | class Validator implements ConstraintValidator { 34 | 35 | private Class> enumClass; 36 | // private String enumMethod; 37 | 38 | @Override 39 | public void initialize(EnumValue enumValue) { 40 | // enumMethod = enumValue.enumMethod(); 41 | enumClass = enumValue.enumClass(); 42 | } 43 | 44 | @Override 45 | public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) { 46 | if (value == null) { 47 | return Boolean.TRUE; 48 | } 49 | if (enumClass == null) { 50 | return Boolean.TRUE; 51 | } 52 | 53 | Class valueClass = value.getClass(); 54 | try { 55 | Object[] objs = enumClass.getEnumConstants(); 56 | Method method = enumClass.getMethod("name"); 57 | for (Object obj : objs) { 58 | Object code = method.invoke(obj, null); 59 | if (value.equalsIgnoreCase(code.toString())) { 60 | return true; 61 | } 62 | } 63 | return false; 64 | } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { 65 | e.printStackTrace(); 66 | } 67 | 68 | 69 | // try { 70 | // Method method = enumClass.getMethod(enumMethod, valueClass); 71 | // if (!Boolean.TYPE.equals(method.getReturnType()) && !Boolean.class.equals(method.getReturnType())) { 72 | // throw new RuntimeException(Strings.formatIfArgs("%s method return is not boolean type in the %s class", enumMethod, enumClass)); 73 | // } 74 | // 75 | // if(!Modifier.isStatic(method.getModifiers())) { 76 | // throw new RuntimeException(Strings.formatIfArgs("%s method is not static method in the %s class", enumMethod, enumClass)); 77 | // } 78 | // 79 | // Boolean result = (Boolean)method.invoke(null, value); 80 | // return result == null ? false : result; 81 | // } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { 82 | // throw new RuntimeException(e); 83 | // } catch (NoSuchMethodException | SecurityException e) { 84 | // throw new RuntimeException(Strings.formatIfArgs("This %s(%s) method does not exist in the %s", enumMethod, valueClass, enumClass), e); 85 | // } 86 | return false; 87 | } 88 | 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/validator/MyNotBlank.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.validator; 2 | 3 | import javax.validation.Constraint; 4 | import javax.validation.ConstraintValidator; 5 | import javax.validation.ConstraintValidatorContext; 6 | import javax.validation.Payload; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * @author Darod 14 | * @version 1.0 15 | * @date 2019/7/17 0017 13:41 16 | */ 17 | @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE}) 18 | @Retention(RetentionPolicy.RUNTIME) 19 | @Constraint(validatedBy = MyNotBlank.Validator.class) 20 | public @interface MyNotBlank { 21 | String message() default ""; 22 | 23 | Class[] groups() default {}; 24 | 25 | Class[] payload() default {}; 26 | 27 | class Validator implements ConstraintValidator { 28 | 29 | @Override 30 | public void initialize(MyNotBlank enumValue) { 31 | } 32 | 33 | @Override 34 | public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) { 35 | if (value == null) { //字段为null时合法 36 | return true; 37 | }else { 38 | if(value.trim().equals("")){ //字段不为null时,如果为空字符串不合法 39 | return false; 40 | } 41 | } 42 | return true; 43 | } 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/validator/ValidationResult.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.validator; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | /** 9 | * @author Darod 10 | * @version 1.0 11 | * @date 2019/6/20 0020 9:14 12 | */ 13 | public class ValidationResult { 14 | //校验结果是否有错 15 | private boolean hasError = false; 16 | 17 | private Map errorMsgMap = new HashMap<>(); 18 | 19 | public boolean isHasError() { 20 | return hasError; 21 | } 22 | 23 | public void setHasError(boolean hasError) { 24 | this.hasError = hasError; 25 | } 26 | 27 | public Map getErrorMsgMap() { 28 | return errorMsgMap; 29 | } 30 | 31 | public void setErrorMsgMap(Map errorMsgMap) { 32 | this.errorMsgMap = errorMsgMap; 33 | } 34 | 35 | //通过格式化字符串获取错误结果 36 | public String getErrMsg() { 37 | return StringUtils.join(errorMsgMap.values().toArray(), ","); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Elearning-common/src/main/java/org/darod/elearning/common/validator/ValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.common.validator; 2 | 3 | 4 | import org.darod.elearning.common.exception.BusinessException; 5 | import org.darod.elearning.common.exception.EmException; 6 | 7 | import javax.annotation.Resource; 8 | import javax.validation.ConstraintViolation; 9 | import javax.validation.Validation; 10 | import javax.validation.Validator; 11 | import java.util.Set; 12 | 13 | /** 14 | * @author Darod 15 | * @version 1.0 16 | * @date 2019/6/20 0020 9:14 17 | */ 18 | @Resource 19 | public class ValidatorImpl { 20 | 21 | @Resource 22 | private Validator validator; 23 | 24 | //实现校验方法 25 | public ValidationResult validate(Object bean) { 26 | final ValidationResult validationResult = new ValidationResult(); 27 | Set> constraintViolationSet = validator.validate(bean); 28 | if (constraintViolationSet.size() > 0) { 29 | //有错误 30 | validationResult.setHasError(true); 31 | constraintViolationSet.forEach(constraintViolation -> { 32 | String errMsg = constraintViolation.getMessage(); 33 | String propertyName = constraintViolation.getPropertyPath().toString(); 34 | validationResult.getErrorMsgMap().put(propertyName, errMsg); 35 | }); 36 | } 37 | return validationResult; 38 | } 39 | 40 | public static ValidatorImpl getInstance() { 41 | ValidatorImpl validator = new ValidatorImpl(); 42 | validator.validator = Validation.buildDefaultValidatorFactory().getValidator(); 43 | return validator; 44 | } 45 | 46 | public void validateWithCheck(Object bean) throws BusinessException { 47 | ValidationResult validationResult = validate(bean); 48 | if (validationResult.isHasError()) { 49 | throw new BusinessException(EmException.PARAMETER_VALIDATION_ERROR, validationResult.getErrMsg()); 50 | } 51 | } 52 | 53 | // @Override 54 | // public void afterPropertiesSet() throws Exception { 55 | // //将hibernate validator通过工厂初始化 56 | // this.validator = Validation.buildDefaultValidatorFactory().getValidator(); 57 | // } 58 | } 59 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/GatewayApplication.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway; 2 | 3 | import com.alibaba.fastjson.serializer.SerializerFeature; 4 | import com.alibaba.fastjson.support.config.FastJsonConfig; 5 | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; 6 | import org.darod.elearning.common.validator.ValidatorImpl; 7 | import org.mybatis.spring.annotation.MapperScan; 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | import org.springframework.boot.autoconfigure.http.HttpMessageConverters; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 13 | import org.springframework.context.annotation.Import; 14 | import org.springframework.http.MediaType; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | /** 20 | * @author Darod 21 | * @version 1.0 22 | * @date 2019/6/20 0020 14:24 23 | */ 24 | @SpringBootApplication(scanBasePackages = {"org.darod.elearning"}) 25 | @MapperScan("org.darod.elearning.gateway.dao") 26 | @Import({ValidatorImpl.class}) 27 | @EnableAspectJAutoProxy 28 | public class GatewayApplication { 29 | public static void main(String[] args) { 30 | SpringApplication.run(GatewayApplication.class, args); 31 | } 32 | 33 | //启用fastjson 34 | @Bean 35 | public HttpMessageConverters fastJsonConfigure() { 36 | FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); 37 | List fastMediaTypes = new ArrayList<>(); 38 | fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8); 39 | FastJsonConfig fastJsonConfig = new FastJsonConfig(); 40 | fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat,SerializerFeature.WriteMapNullValue); 41 | //日期格式化 42 | // fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss"); //若指定全局配置 则JsonField(format=)失效 43 | converter.setFastJsonConfig(fastJsonConfig); 44 | converter.setSupportedMediaTypes(fastMediaTypes); 45 | // HttpMessageConverter array[] = new HttpMessageConverter[]{stringHttpMessageConverter(), converter}; 46 | // HttpMessageConverters httpMessageConverters = new HttpMessageConverters(false, Arrays.asList(array)); 47 | HttpMessageConverters httpMessageConverters = new HttpMessageConverters(converter); 48 | return httpMessageConverters; 49 | } 50 | 51 | // private StringHttpMessageConverter stringHttpMessageConverter() { 52 | // StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(); 53 | // stringHttpMessageConverter.setWriteAcceptCharset(false); 54 | // return stringHttpMessageConverter; 55 | // } 56 | } 57 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/advice/LiveAdvice.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.advice; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.aspectj.lang.JoinPoint; 5 | import org.aspectj.lang.annotation.AfterReturning; 6 | import org.aspectj.lang.annotation.Aspect; 7 | import org.aspectj.lang.annotation.Before; 8 | import org.aspectj.lang.annotation.Pointcut; 9 | import org.darod.elearning.common.dto.LiveRecordModel; 10 | import org.darod.elearning.common.exception.EmException; 11 | import org.darod.elearning.common.exception.UploadException; 12 | import org.darod.elearning.common.utils.RedisUtils; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.beans.factory.annotation.Value; 15 | import org.springframework.stereotype.Component; 16 | 17 | import java.util.HashMap; 18 | 19 | /** 20 | * @author Darod 21 | * @version 1.0 22 | * @date 2019/7/23 0023 14:23 23 | */ 24 | @Aspect 25 | @Component 26 | public class LiveAdvice { 27 | @Autowired 28 | RedisUtils redisUtils; 29 | @Value("${org.darod.elearning.gateway.live_key}") 30 | public String the_key; //验证密钥,只有密钥正确的请求才能增加\减少播放量 31 | @Value("${org.darod.elearning.gateway.rtmp_address}") 32 | private String rtmp_address; 33 | 34 | @Pointcut("bean(liveController)") 35 | void liveMethod() { 36 | } 37 | 38 | //验证key是否正确 39 | @Before("liveMethod() && args(map,..)") 40 | public void checkLiveKey(HashMap map) { 41 | if (map == null || StringUtils.isEmpty(map.get("key"))) { 42 | throw new UploadException(EmException.PERMISSION_DENIED, "禁止访问"); 43 | } 44 | if (!map.get("key").equals(the_key)) { 45 | throw new UploadException(EmException.PERMISSION_DENIED, "禁止访问"); 46 | } 47 | } 48 | 49 | //自动设置rtmp地址 50 | @AfterReturning(returning = "liveRecordModel", pointcut = "bean(liveServiceImpl) && execution(public org.darod.elearning.common.dto.LiveRecordModel *(..))") 51 | public void setRtmp_address(LiveRecordModel liveRecordModel) { 52 | liveRecordModel.setRtmpAddress(rtmp_address); 53 | } 54 | 55 | //更新数据库后删除缓存 56 | @AfterReturning("bean(liveServiceImpl) && args(channelId)") 57 | public void deleteLiveRecordCache(String channelId) { 58 | deleteRedisCache(channelId, null); 59 | } 60 | 61 | //更新数据库后删除缓存 62 | @AfterReturning("bean(liveServiceImpl) && args(channelId,liveSecret) && execution(public * *.*(..))") 63 | public void deleteLiveRecordCache(String channelId, String liveSecret) { 64 | deleteRedisCache(channelId, liveSecret); 65 | } 66 | 67 | private void deleteRedisCache(String channelId, String liveSecret) { 68 | if (liveSecret != null) { 69 | redisUtils.del(channelId + "?" + liveSecret); 70 | } else { 71 | redisUtils.keys(channelId + "?").forEach(redisUtils::del); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/advice/UploadAdvice.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.advice; 2 | 3 | import org.aspectj.lang.annotation.AfterThrowing; 4 | import org.aspectj.lang.annotation.Aspect; 5 | import org.aspectj.lang.annotation.Pointcut; 6 | import org.darod.elearning.common.exception.BusinessException; 7 | import org.darod.elearning.common.exception.EmException; 8 | import org.darod.elearning.common.exception.UploadException; 9 | import org.springframework.core.annotation.Order; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * @author Darod 14 | * @version 1.0 15 | * @date 2019/7/19 0019 23:09 16 | */ 17 | @Aspect 18 | @Order(1) 19 | @Component 20 | public class UploadAdvice { 21 | @Pointcut("execution(public * org.darod.elearning.gateway.controller.UploadImageController.*(..))") 22 | void uploadMethod() {} 23 | @AfterThrowing(pointcut = "uploadMethod()", throwing = "ex") 24 | public void doUploadMethodException(Throwable ex) { 25 | if(ex instanceof BusinessException){ 26 | BusinessException businessException = (BusinessException) ex; 27 | throw new UploadException(businessException); 28 | }else 29 | throw new UploadException(EmException.UNKNOWN_ERROR,"文件上传失败"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/annotation/WithoutPermission.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.annotation; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | /** 7 | * @author Darod 8 | * @version 1.0 9 | * @date 2019/7/19 0019 23:20 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | public @interface WithoutPermission { 13 | //标记不需要权限验证的方法 14 | } 15 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/configuration/CustomRealm.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.configuration; 2 | 3 | import org.apache.shiro.SecurityUtils; 4 | import org.apache.shiro.authc.*; 5 | import org.apache.shiro.authz.AuthorizationInfo; 6 | import org.apache.shiro.authz.SimpleAuthorizationInfo; 7 | import org.apache.shiro.realm.AuthorizingRealm; 8 | import org.apache.shiro.subject.PrincipalCollection; 9 | import org.apache.shiro.util.ByteSource; 10 | import org.darod.elearning.common.service.user.PermissionService; 11 | import org.darod.elearning.gateway.dao.UserDOMapper; 12 | import org.darod.elearning.gateway.dao.UserPasswordDOMapper; 13 | import org.darod.elearning.gateway.dataobject.UserDO; 14 | import org.darod.elearning.gateway.dataobject.UserPasswordDO; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | 17 | import java.util.HashSet; 18 | import java.util.Set; 19 | 20 | /** 21 | * @author Darod 22 | * @version 1.0 23 | * @date 2019/6/30 0030 17:01 24 | */ 25 | public class CustomRealm extends AuthorizingRealm { 26 | private UserDOMapper userDOMapper; 27 | private UserPasswordDOMapper userPasswordDOMapper; 28 | 29 | @Autowired 30 | PermissionService permissionService; 31 | 32 | @Autowired 33 | private void setUserMapper(UserDOMapper userDOMapper) { 34 | this.userDOMapper = userDOMapper; 35 | } 36 | 37 | @Autowired 38 | private void setUserPasswordDO(UserPasswordDOMapper userPasswordDOMapper) { 39 | this.userPasswordDOMapper = userPasswordDOMapper; 40 | } 41 | 42 | /** 43 | * 获取身份验证信息 44 | * Shiro中,最终是通过 Realm 来获取应用程序中的用户、角色及权限信息的。 45 | * 46 | * @param authenticationToken 用户身份信息 token 47 | * @return 返回封装了用户信息的 AuthenticationInfo 实例 48 | */ 49 | @Override 50 | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { 51 | UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken; 52 | // 从数据库获取对应用户名密码的用户 53 | UserDO userDO = userDOMapper.selectByUserName(token.getUsername()); 54 | if (userDO == null) 55 | return null; 56 | UserPasswordDO userPasswordDO = userPasswordDOMapper.selectByUserId(userDO.getUserId()); 57 | if (userPasswordDO == null) 58 | return null; 59 | String encryptPassword = userPasswordDO.getEncryptPassword(); 60 | 61 | if (null == encryptPassword) 62 | return null; 63 | // else if (!password.equals(new String((char[]) token.getCredentials()))) { 64 | // throw new AccountException("密码不正确"); 65 | // } 66 | SimpleAuthenticationInfo simpleAuthenticationInfo = new SimpleAuthenticationInfo(userDO.getUserId(), encryptPassword, getName()); 67 | simpleAuthenticationInfo.setCredentialsSalt(ByteSource.Util.bytes(userDO.getName())); 68 | return simpleAuthenticationInfo; 69 | } 70 | 71 | /** 72 | * 获取授权信息 73 | * 74 | * @param principalCollection 75 | * @return 76 | */ 77 | @Override 78 | protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { 79 | Integer userId = (Integer) SecurityUtils.getSubject().getPrincipal(); 80 | SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); 81 | //获得该用户角色 82 | // String role = userDOMapper.selectByPrimaryKey(userId).getUserState().toString(); 83 | // Set roleSet = new HashSet<>(); 84 | // Set permissionSet = new HashSet<>(); 85 | info.setRoles(permissionService.getUserRoleInfo(userId)); 86 | info.setStringPermissions(permissionService.getUserPermissionInfo(userId)); 87 | return info; 88 | } 89 | 90 | public static void main(String[] args) { 91 | // Md5Hash md5Hash = new Md5Hash("123456", "张三"); 92 | // System.out.println(md5Hash.toString()); 93 | String s = "mycorp-myproj-[\\w\\d-.]+.jar"; 94 | System.out.println("mycorp-myproj-core.jar".matches(s)); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/configuration/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.configuration; 2 | 3 | 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | /** 8 | * @author Darod 9 | * @version 1.0 10 | * @date 2019/6/30 0030 15:46 11 | */ 12 | //@Configuration 13 | //public class WebMvcConfig implements WebMvcConfigurer { 14 | // 15 | // 16 | //} -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/configuration/WebSocketConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.configuration; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.messaging.simp.config.MessageBrokerRegistry; 7 | import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; 8 | import org.springframework.web.socket.config.annotation.StompEndpointRegistry; 9 | import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; 10 | import org.springframework.web.socket.server.standard.ServerEndpointExporter; 11 | 12 | /** 13 | * @author Darod 14 | * @version 1.0 15 | * @date 2019/8/2 0002 12:44 16 | */ 17 | //@Configuration 18 | //@EnableWebSocketMessageBroker 19 | //public class WebSocketConfiguration implements WebSocketMessageBrokerConfigurer { 20 | // @Bean 21 | // public ServerEndpointExporter serverEndpointExporter() { 22 | // return new ServerEndpointExporter(); 23 | // } 24 | // 25 | // @Value("${org.darod.elearning.gateway.rabbitmqHost}") 26 | // private String rabbitmqHost; 27 | // @Value("${org.darod.elearning.gateway.rabbitmqUser}") 28 | // private String rabbitmqUser; 29 | // @Value("${org.darod.elearning.gateway.rabbitmqPassword}") 30 | // private String rabbitmqPassword; 31 | // 32 | // @Override 33 | // public void registerStompEndpoints(StompEndpointRegistry registry) { 34 | // registry.addEndpoint("/live_socket").setAllowedOrigins("*").withSockJS(); 35 | // } 36 | // 37 | // @Override 38 | // public void configureMessageBroker(MessageBrokerRegistry config) { 39 | // config.setApplicationDestinationPrefixes("/app") 40 | // .enableStompBrokerRelay("/topic", "/queue") 41 | // .setRelayHost(rabbitmqHost) 42 | // .setRelayPort(61613) 43 | // .setClientLogin(rabbitmqUser) 44 | // .setClientPasscode(rabbitmqPassword) 45 | // .setSystemLogin(rabbitmqUser) 46 | // .setSystemPasscode(rabbitmqPassword) 47 | // .setSystemHeartbeatSendInterval(5000) 48 | // .setSystemHeartbeatReceiveInterval(4000); 49 | //// config.enableSimpleBroker("/topic"); 50 | //// config.setApplicationDestinationPrefixes("/app"); 51 | // 52 | // } 53 | //} 54 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/controller/BarrageController.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.controller; 2 | 3 | import org.darod.elearning.common.dto.Shout; 4 | import org.springframework.messaging.handler.annotation.MessageMapping; 5 | import org.springframework.stereotype.Controller; 6 | 7 | /** 8 | * @author Darod 9 | * @version 1.0 10 | * @date 2019/8/2 0002 22:26 11 | */ 12 | //@Controller 13 | //public class BarrageController { 14 | // 15 | // @MessageMapping("/liveroom_*") 16 | // public Shout handle(Shout shout) { 17 | // return shout; 18 | // } 19 | //} 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/controller/ChapterController.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.controller; 2 | 3 | import io.swagger.annotations.Api; 4 | import org.darod.elearning.common.dto.ChapterModel; 5 | import org.darod.elearning.common.response.CommonResponse; 6 | import org.darod.elearning.common.response.ResponseUtils; 7 | import org.darod.elearning.common.service.user.ChapterService; 8 | import org.darod.elearning.common.service.user.UserService; 9 | import org.darod.elearning.gateway.serviceimpl.ChapterServiceImpl; 10 | import org.darod.elearning.common.utils.ShiroUtils; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.PathVariable; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.ResponseBody; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import javax.servlet.http.HttpServletRequest; 19 | import javax.servlet.http.HttpServletResponse; 20 | import java.util.List; 21 | 22 | /** 23 | * @author Darod 24 | * @version 1.0 25 | * @date 2019/7/16 0016 12:06 26 | */ 27 | @Controller 28 | @Api(tags = "课程章节资源接口") 29 | public class ChapterController { 30 | @Autowired 31 | private ChapterService chapterService; 32 | @Autowired 33 | private UserService userService; 34 | 35 | @RequestMapping("/course/{courseId}/chapters") 36 | @ResponseBody 37 | public CommonResponse getAllChapterByCourseId(@PathVariable("courseId") Integer courseId) { 38 | return ResponseUtils.getOKResponse(chapterService.getAllChapterByCourseId(courseId)); 39 | } 40 | 41 | //获取章节视频 42 | @RequestMapping("/course/{courseId}/chapter/{chapterId}/video") 43 | public void getChapterVideoHeader(@PathVariable("courseId") Integer courseId, 44 | @PathVariable("chapterId") Integer chapterId,HttpServletRequest request, HttpServletResponse response) { 45 | String chapterVideoUrl = userService.getChapterVideoUrl(ShiroUtils.getCurUserId(), courseId, chapterId); 46 | response.setHeader("Content-Type", "application/octet-stream"); 47 | response.setHeader("X-Accel-Redirect", "/" + chapterVideoUrl); 48 | response.setHeader("X-Accel-Charset", "utf-8"); 49 | response.setHeader("Content-Disposition", "attachment; filename=" + chapterVideoUrl); 50 | response.setHeader("Cache-Control", "no-store"); //禁止浏览器缓存 这个可以用在试看视频上 完整视频可以缓存 51 | } 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/controller/CommentController.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.controller; 2 | 3 | import io.swagger.annotations.Api; 4 | import org.apache.shiro.authz.annotation.RequiresPermissions; 5 | import org.darod.elearning.common.dto.CommentModel; 6 | import org.darod.elearning.common.dto.CommonPageModel; 7 | import org.darod.elearning.common.response.CommonResponse; 8 | import org.darod.elearning.common.response.ResponseUtils; 9 | import org.darod.elearning.gateway.serviceimpl.CommentServiceImpl; 10 | import org.darod.elearning.common.utils.ShiroUtils; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.validation.annotation.Validated; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | /** 16 | * @author Darod 17 | * @version 1.0 18 | * @date 2019/7/16 0016 12:29 19 | */ 20 | @RestController 21 | @Api(tags = "评论接口") 22 | public class CommentController { 23 | @Autowired 24 | private CommentServiceImpl commentService; 25 | 26 | @GetMapping("/course/{courseId}/comment") 27 | public CommonResponse getAllCourseComment(@PathVariable("courseId") Integer courseId, @Validated CommonPageModel commonPageModel) { 28 | commonPageModel.checkPage(); 29 | return ResponseUtils.getOKResponse(commentService.getAllCourseComment(courseId, commonPageModel).toJSONObject("comments")); 30 | } 31 | 32 | @GetMapping("/course/{courseId}/chapter/{chapterId}/comment") 33 | public CommonResponse getAllChapterComment(@PathVariable("courseId") Integer courseId, 34 | @PathVariable("chapterId") Integer chapterId, 35 | @Validated CommonPageModel commonPageModel) { 36 | commonPageModel.checkPage(); 37 | return ResponseUtils.getOKResponse(commentService.getAllChapterComment(courseId, chapterId, commonPageModel).toJSONObject("comments")); 38 | } 39 | @RequiresPermissions("comment") 40 | @PostMapping("/course/{courseId}/comment") 41 | public CommonResponse addCourseComment(@PathVariable("courseId") Integer courseId, 42 | @RequestBody CommentModel commentModel) { 43 | commentModel.setUserId(ShiroUtils.getCurUserId()); 44 | commentModel.setCourseId(courseId); 45 | return ResponseUtils.getOKResponse(commentService.addCourseComment(commentModel)); 46 | } 47 | @RequiresPermissions("comment") 48 | @PostMapping("/course/{courseId}/chapter/{chapterId}/comment") 49 | public CommonResponse addChapterComment(@PathVariable("courseId") Integer courseId, 50 | @PathVariable("chapterId") Integer chapterId, @RequestBody CommentModel commentModel) { 51 | commentModel.setUserId(ShiroUtils.getCurUserId()); 52 | commentModel.setCourseId(courseId); 53 | commentModel.setChapterId(chapterId); 54 | return ResponseUtils.getOKResponse(commentService.addCourseComment(commentModel)); 55 | } 56 | 57 | @DeleteMapping("/course/{courseId}/comment/{commentId}") 58 | public CommonResponse deleteCourseComment(@PathVariable("courseId") Integer courseId, 59 | @PathVariable("commentId") Integer commentId) { 60 | CommentModel commentModel = new CommentModel(commentId, null, null, ShiroUtils.getCurUserId(), courseId, -1, null); 61 | commentService.deleteCourseComment(commentModel); 62 | return ResponseUtils.getOKResponse(null); 63 | } 64 | 65 | @DeleteMapping("/course/{courseId}/chapter/{chapterId}/comment/{commentId}") 66 | public CommonResponse deleteChapterComment(@PathVariable("courseId") Integer courseId, 67 | @PathVariable("chapterId") Integer chapterId, 68 | @PathVariable("commentId") Integer commentId) { 69 | CommentModel commentModel = new CommentModel(commentId, null, null, ShiroUtils.getCurUserId(), courseId, chapterId, null); 70 | commentService.deleteCourseComment(commentModel); 71 | return ResponseUtils.getOKResponse(null); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/controller/CourseController.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.controller; 2 | 3 | import io.swagger.annotations.Api; 4 | import io.swagger.annotations.ApiOperation; 5 | import org.darod.elearning.common.dto.CommonCountModel; 6 | import org.darod.elearning.common.dto.CourseModel; 7 | import org.darod.elearning.common.exception.BusinessException; 8 | import org.darod.elearning.common.response.CommonResponse; 9 | import org.darod.elearning.common.response.ResponseUtils; 10 | import org.darod.elearning.common.service.user.UserLearnService; 11 | import org.darod.elearning.common.service.user.UserService; 12 | import org.darod.elearning.gateway.serviceimpl.CourseServiceImpl; 13 | import org.darod.elearning.common.dto.CoursePageModel; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.web.bind.annotation.*; 16 | 17 | import javax.validation.Valid; 18 | import java.util.List; 19 | 20 | /** 21 | * @author Darod 22 | * @version 1.0 23 | * @date 2019/7/1 0001 8:22 24 | */ 25 | @RestController 26 | @Api(tags = "课程资源接口") 27 | @RequestMapping("/course") 28 | public class CourseController { 29 | @Autowired 30 | private UserService userService; 31 | @Autowired 32 | private UserLearnService userLearnService; 33 | @Autowired 34 | private CourseServiceImpl courseService; 35 | 36 | @GetMapping("/courses") 37 | @ApiOperation(value = "获取所有课程", httpMethod = "GET") 38 | public CommonResponse getAllCourse(CoursePageModel coursePageModel){ 39 | CommonCountModel> allCourseInfo = courseService.getCourseInfoLimited(coursePageModel); 40 | return ResponseUtils.getOKResponse(allCourseInfo.toJSONObject("courses")); 41 | } 42 | 43 | @GetMapping("/courses/free") 44 | @ApiOperation(value = "获取所有免费课程", httpMethod = "GET") 45 | @Deprecated 46 | public CommonResponse getAllFreeCourse(CoursePageModel coursePageModel){ 47 | CommonCountModel> allCourseInfo = courseService.getAllCourseInfo(coursePageModel.getPage(), coursePageModel.getRow()); 48 | return ResponseUtils.getOKResponse(allCourseInfo.toJSONObject("courses")); 49 | } 50 | // @GetMapping("/courses/free") 51 | // @ApiOperation(value = "获取所有免费课程", httpMethod = "GET") 52 | // public CommonResponse getAllFreeCourse(CoursePageModel pageModel) throws BusinessException { 53 | // CommonCountModel> allCourseInfo = courseService.getAllCourseInfo(pageModel.getPage(), pageModel.getRow()); 54 | // return ResponseUtils.getOKResponse(allCourseInfo.toJSONObject("courses")); 55 | // } 56 | 57 | @ModelAttribute 58 | public CoursePageModel pageModel(@Valid CoursePageModel coursePageModel) 59 | { 60 | // if (bindingResult.hasErrors()) { 61 | // throw new BusinessException(EmException.PARAMETER_VALIDATION_ERROR, bindingResult.getFieldError().getDefaultMessage()); 62 | // } 63 | //如果没有指定分页信息,默认不分页 64 | if (coursePageModel.getPage() == null || coursePageModel.getRow() == null) { 65 | coursePageModel.setPage(0); 66 | coursePageModel.setRow(9999); 67 | } 68 | return coursePageModel; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/controller/LiveController.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.controller; 2 | 3 | import io.swagger.annotations.Api; 4 | import io.swagger.annotations.ApiOperation; 5 | import org.darod.elearning.common.service.user.LiveService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.web.bind.annotation.PostMapping; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | 11 | import javax.servlet.http.HttpServletResponse; 12 | import java.util.HashMap; 13 | 14 | /** 15 | * @author Darod 16 | * @version 1.0 17 | * @date 2019/7/21 0021 23:33 18 | */ 19 | @Controller 20 | @Api(tags = "和nginx通信的直播相关") 21 | public class LiveController { 22 | @Autowired 23 | LiveService liveService; 24 | 25 | private static final boolean debug_mode = false; 26 | 27 | @PostMapping("/live/auth") 28 | @ApiOperation(value = "验证直播权限", httpMethod = "POST") 29 | public void authLive(@RequestParam HashMap map, HttpServletResponse response) { 30 | if (debug_mode) { 31 | response.setStatus(HttpServletResponse.SC_OK); 32 | return; 33 | } 34 | if (liveService.authLive(map.get("name"), map.get("ls"))) 35 | response.setStatus(HttpServletResponse.SC_OK); 36 | else 37 | response.setStatus(HttpServletResponse.SC_FORBIDDEN); 38 | } 39 | 40 | @PostMapping("/live/beat") 41 | @ApiOperation(value = "接收直播心跳", httpMethod = "POST") 42 | public void beatLive(@RequestParam HashMap map, HttpServletResponse response) { 43 | if (map.get("ls") == null) { //play发起的update事件 不用理会 44 | response.setStatus(HttpServletResponse.SC_OK); 45 | return; 46 | } 47 | if (liveService.beatLive(map.get("name"), map.get("ls"))) 48 | response.setStatus(HttpServletResponse.SC_OK); 49 | else 50 | response.setStatus(HttpServletResponse.SC_FORBIDDEN); 51 | } 52 | 53 | @PostMapping("/live/done") 54 | @ApiOperation(value = "推流中断", httpMethod = "POST") 55 | //用户中断推流 原则上应该直接结束直播,但用户断网或者网络波动等情况可能需要保持直播状态,可以根据情况选择是否结束 56 | //数据库中如果发现用户10分钟内没有推流也会自动结束直播 57 | public void doneLive(@RequestParam HashMap map, HttpServletResponse response) { 58 | // liveService.doneLive(map.get("name"), map.get("ls")); 59 | response.setStatus(HttpServletResponse.SC_OK); 60 | } 61 | 62 | @PostMapping("/live/on_play") 63 | @ApiOperation(value = "增加观看人数", httpMethod = "POST") 64 | public void incWatchNum(@RequestParam HashMap map, HttpServletResponse response) { 65 | liveService.incWatchNum(map.get("name")); 66 | response.setStatus(HttpServletResponse.SC_OK); 67 | } 68 | 69 | @PostMapping("/live/on_play_done") 70 | @ApiOperation(value = "减少观看人数", httpMethod = "POST") 71 | public void decrWatchNum(@RequestParam HashMap map, HttpServletResponse response) { 72 | liveService.decrWatchNum(map.get("name")); 73 | response.setStatus(HttpServletResponse.SC_OK); 74 | } 75 | 76 | @PostMapping("/live/record_done") 77 | @ApiOperation(value = "封面记录完成", httpMethod = "POST") 78 | public void doneRecord(@RequestParam HashMap map, HttpServletResponse response) { 79 | liveService.doneRecord(map.get("name"), map.get("ls"),map.get("path")); 80 | response.setStatus(HttpServletResponse.SC_OK); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/controller/MessageController.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.controller; 2 | 3 | import io.swagger.annotations.Api; 4 | import org.darod.elearning.common.dto.CommonPageModel; 5 | import org.darod.elearning.common.response.CommonResponse; 6 | import org.darod.elearning.common.response.ResponseUtils; 7 | import org.darod.elearning.gateway.serviceimpl.MessageServiceImpl; 8 | import org.darod.elearning.common.utils.ShiroUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.validation.annotation.Validated; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import java.util.HashMap; 14 | import java.util.Map; 15 | 16 | /** 17 | * @author Darod 18 | * @version 1.0 19 | * @date 2019/7/16 0016 15:16 20 | */ 21 | @RestController 22 | @Api(tags = "消息接口") 23 | public class MessageController { 24 | @Autowired 25 | private MessageServiceImpl messageService; 26 | 27 | @GetMapping("/user/message") 28 | public CommonResponse getAllMessage(@Validated CommonPageModel commonPageModel) { 29 | commonPageModel.checkPage(); 30 | return ResponseUtils.getOKResponse(messageService.getAllMessage(ShiroUtils.getCurUserId(), commonPageModel).toJSONObject("messages")); 31 | } 32 | 33 | @GetMapping("/user/message/{messageId}") 34 | public CommonResponse getMessageById(@PathVariable("messageId") Integer messageId) { 35 | return ResponseUtils.getOKResponse(messageService.getMessageById(ShiroUtils.getCurUserId(), messageId)); 36 | } 37 | 38 | @GetMapping("/user/message/unread") 39 | public CommonResponse getMessagesUnread(@Validated CommonPageModel commonPageModel) { 40 | commonPageModel.checkPage(); 41 | return ResponseUtils.getOKResponse(messageService.getMessagesUnread(ShiroUtils.getCurUserId(), commonPageModel).toJSONObject("messages")); 42 | 43 | } 44 | 45 | @GetMapping("/user/message/unread_count") 46 | public CommonResponse getMessagesUnreadCount() { 47 | Map map = new HashMap<>(); 48 | map.put("total", messageService.getMessagesUnreadCount(ShiroUtils.getCurUserId())); 49 | return ResponseUtils.getOKResponse(map); 50 | } 51 | 52 | @DeleteMapping("/user/message/{messageId}") 53 | public CommonResponse deleteMessage(@PathVariable("messageId") Integer messageId) { 54 | messageService.deleteMessage(ShiroUtils.getCurUserId(), messageId); 55 | return ResponseUtils.getOKResponse(); 56 | } 57 | 58 | @DeleteMapping("/user/message/read") 59 | public CommonResponse deleteAllMessage() { 60 | messageService.deleteAllMessage(ShiroUtils.getCurUserId()); 61 | return ResponseUtils.getOKResponse(); 62 | } 63 | 64 | @PutMapping("/user/message/{messageId}") 65 | public CommonResponse setMessageRead(@PathVariable("messageId") Integer messageId) { 66 | return ResponseUtils.getOKResponse(messageService.setMessageRead(ShiroUtils.getCurUserId(), messageId)); 67 | } 68 | 69 | @PutMapping("/user/message") 70 | public CommonResponse setAllMessageRead() { 71 | messageService.setAllMessageRead(ShiroUtils.getCurUserId()); 72 | return ResponseUtils.getOKResponse(); 73 | } 74 | 75 | 76 | } 77 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/controller/MyControllerAdvice.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.controller; 2 | 3 | import org.apache.shiro.authz.UnauthorizedException; 4 | import org.darod.elearning.common.exception.BusinessException; 5 | import org.darod.elearning.common.exception.EmException; 6 | import org.darod.elearning.common.exception.UploadException; 7 | import org.darod.elearning.common.response.CommonResponse; 8 | import org.darod.elearning.common.response.ResponseUtils; 9 | import org.springframework.http.HttpStatus; 10 | import org.springframework.validation.BindException; 11 | import org.springframework.validation.ObjectError; 12 | import org.springframework.web.bind.MethodArgumentNotValidException; 13 | import org.springframework.web.bind.annotation.ControllerAdvice; 14 | import org.springframework.web.bind.annotation.ExceptionHandler; 15 | import org.springframework.web.bind.annotation.ResponseBody; 16 | import org.springframework.web.bind.annotation.ResponseStatus; 17 | 18 | import javax.servlet.http.HttpServletRequest; 19 | import java.util.HashMap; 20 | import java.util.List; 21 | import java.util.Map; 22 | import java.util.stream.Collectors; 23 | 24 | /** 25 | * @author Darod 26 | * @version 1.0 27 | * @date 2019/6/30 0030 21:16 28 | */ 29 | 30 | @ControllerAdvice 31 | public class MyControllerAdvice { 32 | 33 | @ExceptionHandler(BindException.class) 34 | @ResponseStatus(HttpStatus.OK) 35 | @ResponseBody 36 | public CommonResponse handlerValidationExcpetion(HttpServletRequest request, Exception exception) { 37 | Map map = new HashMap<>(); 38 | BindException ex = (BindException) exception; 39 | map.put("errCode", EmException.BINDING_VALIDATION_ERROR.getErrCode()); 40 | List errors = ex.getBindingResult().getAllErrors(); 41 | String errorMsg = errors.stream().map(ObjectError::getDefaultMessage).collect(Collectors.joining(",")); 42 | map.put("errMsg", errorMsg); 43 | return ResponseUtils.getErrorResponse(map); 44 | } 45 | @ExceptionHandler(MethodArgumentNotValidException.class) 46 | @ResponseStatus(HttpStatus.OK) 47 | @ResponseBody 48 | public CommonResponse handlerValidationExcpetion2(HttpServletRequest request, Exception exception) { 49 | Map map = new HashMap<>(); 50 | MethodArgumentNotValidException ex = (MethodArgumentNotValidException) exception; 51 | map.put("errCode", EmException.BINDING_VALIDATION_ERROR.getErrCode()); 52 | List errors = ex.getBindingResult().getAllErrors(); 53 | String errorMsg = errors.stream().map(ObjectError::getDefaultMessage).collect(Collectors.joining(",")); 54 | map.put("errMsg", errorMsg); 55 | return ResponseUtils.getErrorResponse(map); 56 | } 57 | 58 | @ExceptionHandler(UploadException.class) 59 | @ResponseStatus(HttpStatus.FORBIDDEN) 60 | @ResponseBody 61 | public CommonResponse handlerUploadException(HttpServletRequest request, Exception exception) { 62 | Map map = new HashMap<>(); 63 | if (exception instanceof UploadException) { 64 | BusinessException businessException = (BusinessException) exception; 65 | map.put("errCode", businessException.getErrCode()); 66 | map.put("errMsg", businessException.getErrMsg()); 67 | } 68 | return ResponseUtils.getErrorResponse(map); 69 | } 70 | 71 | @ExceptionHandler(Exception.class) 72 | @ResponseStatus(HttpStatus.OK) 73 | @ResponseBody 74 | public CommonResponse handlerException(HttpServletRequest request, Exception exception) { 75 | Map map = new HashMap<>(); 76 | if (exception instanceof BusinessException) { 77 | BusinessException businessException = (BusinessException) exception; 78 | map.put("errCode", businessException.getErrCode()); 79 | map.put("errMsg", businessException.getErrMsg()); 80 | } else if (exception instanceof UnauthorizedException) { 81 | map.put("errCode", EmException.PERMISSION_DENIED.getErrCode()); 82 | map.put("errMsg", EmException.PERMISSION_DENIED.getErrMsg()); 83 | // exception.printStackTrace(); 84 | } else { 85 | map.put("errCode", EmException.UNKNOWN_ERROR.getErrCode()); 86 | map.put("errMsg", EmException.UNKNOWN_ERROR.getErrMsg()); 87 | exception.printStackTrace(); 88 | } 89 | return ResponseUtils.getErrorResponse(map); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.controller; 2 | 3 | import io.swagger.annotations.Api; 4 | import io.swagger.annotations.ApiOperation; 5 | import org.apache.commons.lang3.StringUtils; 6 | import org.darod.elearning.common.dto.CommonPageModel; 7 | import org.darod.elearning.common.dto.OrderModel; 8 | import org.darod.elearning.common.exception.BusinessException; 9 | import org.darod.elearning.common.exception.EmException; 10 | import org.darod.elearning.common.response.CommonResponse; 11 | import org.darod.elearning.common.response.ResponseUtils; 12 | import org.darod.elearning.gateway.serviceimpl.OrderServiceImpl; 13 | import org.darod.elearning.common.utils.ShiroUtils; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.validation.annotation.Validated; 16 | import org.springframework.web.bind.annotation.*; 17 | 18 | /** 19 | * @author Darod 20 | * @version 1.0 21 | * @date 2019/7/13 0013 11:28 22 | */ 23 | @RestController 24 | @RequestMapping("/user/curuser/order") 25 | @Api(tags = "用户订单接口") 26 | public class OrderController { 27 | @Autowired 28 | private OrderServiceImpl orderService; 29 | 30 | 31 | @GetMapping("/orders") 32 | @ApiOperation(value = "获取所有", httpMethod = "GET") 33 | public CommonResponse getOrders(@RequestParam(required = false) String orderId, @Validated CommonPageModel commonPageModel) throws BusinessException { 34 | commonPageModel.checkPage(); 35 | if (!StringUtils.isEmpty(orderId)) { 36 | return ResponseUtils.getOKResponse(orderService.getOrderInfoById(orderId)); 37 | } else { 38 | return ResponseUtils.getOKResponse(orderService.getAllOrderInfo(commonPageModel).toJSONObject("orders")); 39 | } 40 | } 41 | 42 | @PostMapping("/orders") 43 | @ApiOperation(value = "创建订单", httpMethod = "POST") 44 | public CommonResponse createOrder(@RequestBody OrderModel orderModel) throws BusinessException { 45 | orderModel.setUserId(ShiroUtils.getCurUserId()); 46 | return ResponseUtils.getOKResponse(orderService.createOrder(orderModel)); 47 | } 48 | 49 | @PutMapping("/orders") 50 | @ApiOperation(value = "支付订单", httpMethod = "PUT") 51 | public CommonResponse payOrder(@RequestBody OrderModel orderModel) throws BusinessException { 52 | orderModel.setUserId(ShiroUtils.getCurUserId()); 53 | if (StringUtils.isEmpty(orderModel.getOrderId())) { 54 | throw new BusinessException(EmException.PARAMETER_VALIDATION_ERROR, "订单号不能为空"); 55 | } 56 | if (orderModel.getOrderState() != 1) { 57 | throw new BusinessException(EmException.PARAMETER_VALIDATION_ERROR, "状态码错误"); 58 | } 59 | return ResponseUtils.getOKResponse(orderService.payOrder(orderModel)); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/controller/UploadImageController.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.controller; 2 | 3 | import io.swagger.annotations.Api; 4 | import org.apache.commons.lang3.StringUtils; 5 | import org.darod.elearning.common.dto.ChapterModel; 6 | import org.darod.elearning.common.dto.CourseModel; 7 | import org.darod.elearning.common.dto.LiveRoomModel; 8 | import org.darod.elearning.common.dto.UserModel; 9 | import org.darod.elearning.common.exception.BusinessException; 10 | import org.darod.elearning.common.exception.EmException; 11 | import org.darod.elearning.common.response.CommonResponse; 12 | import org.darod.elearning.common.response.ResponseUtils; 13 | import org.darod.elearning.common.service.user.TeacherService; 14 | import org.darod.elearning.common.service.user.UserService; 15 | import org.darod.elearning.common.utils.ShiroUtils; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.stereotype.Controller; 18 | import org.springframework.web.bind.annotation.*; 19 | 20 | /** 21 | * @author Darod 22 | * @version 1.0 23 | * @date 2019/7/19 0019 18:15 24 | */ 25 | @Controller 26 | @Api(tags = "上传图片资源") 27 | public class UploadImageController { 28 | @Autowired 29 | private UserService userService; 30 | @Autowired 31 | private TeacherService teacherService; 32 | 33 | @PostMapping("/user/curuser/image") 34 | @ResponseBody 35 | public CommonResponse uploadUserHeadImg(@RequestParam(value = "userImageFile_path", required = false) String url) { 36 | UserModel userModel = new UserModel(); 37 | userModel.setUserId(ShiroUtils.getCurUserId()); 38 | userModel.setHeadUrl(getRealUrl("images", url)); 39 | userService.updateUserById(userModel); 40 | return ResponseUtils.getOKResponse(); 41 | } 42 | 43 | @PostMapping("/teachers/curTeacher/course/{courseId}/image") 44 | @ResponseBody 45 | public CommonResponse uploadCourseImg(@PathVariable("courseId") Integer courseId, 46 | @RequestParam(value = "courseImageFile_path", required = false) String url) { 47 | CourseModel courseModel = new CourseModel(); 48 | courseModel.setCourseId(courseId); 49 | courseModel.setCourseImgUrl(getRealUrl("images", url)); 50 | return ResponseUtils.getOKResponse(teacherService.updateCourseImageTeacher(ShiroUtils.getCurUserId(), courseModel)); 51 | } 52 | 53 | @PostMapping("/teachers/curTeacher/live/image") 54 | @ResponseBody 55 | public CommonResponse uploadLiveImage(@RequestParam(value = "liveImageFile_path", required = false) String url) { 56 | LiveRoomModel liveRoomModel = new LiveRoomModel(); 57 | liveRoomModel.setUserId(ShiroUtils.getCurUserId()); 58 | liveRoomModel.setRoomImage(getRealUrl("images", url)); 59 | return ResponseUtils.getOKResponse(teacherService.updateLiveRoom(liveRoomModel)); 60 | } 61 | 62 | @PostMapping("/teachers/curTeacher/course/{courseId}/chapter/{chapterId}/video") 63 | @ResponseBody 64 | public CommonResponse uploadChapterVideo(@PathVariable("courseId") Integer courseId, @PathVariable("chapterId") Integer chapterId, 65 | @RequestParam(value = "chapterVideoFile_path", required = false) String url) { 66 | ChapterModel chapterModel = new ChapterModel(); 67 | chapterModel.setVideoUrl(getRealUrl("videos", url)); 68 | return ResponseUtils.getOKResponse(teacherService.updateChapterTeacher(ShiroUtils.getCurUserId(), courseId, chapterId, chapterModel)); 69 | } 70 | 71 | 72 | private String getRealUrl(String prefix, String url) { 73 | if (StringUtils.isEmpty(url)) throw new BusinessException(EmException.PARAMETER_VALIDATION_ERROR, "URL名称或值不正确"); 74 | int i = url.lastIndexOf(prefix); 75 | if (i < 0) throw new BusinessException(EmException.PARAMETER_VALIDATION_ERROR, "URL名称或值不正确"); 76 | return url.substring(i); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/controller/UserLearnController.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.controller; 2 | 3 | import io.swagger.annotations.ApiOperation; 4 | import org.apache.logging.log4j.message.ReusableMessage; 5 | import org.darod.elearning.common.dto.CommonCountModel; 6 | import org.darod.elearning.common.dto.CoursePageModel; 7 | import org.darod.elearning.common.dto.UserLearnModel; 8 | import org.darod.elearning.common.exception.BusinessException; 9 | import org.darod.elearning.common.response.CommonResponse; 10 | import org.darod.elearning.common.response.ResponseUtils; 11 | import org.darod.elearning.common.service.user.UserLearnService; 12 | import org.darod.elearning.common.utils.ShiroUtils; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.validation.annotation.Validated; 15 | import org.springframework.web.bind.annotation.*; 16 | 17 | import javax.validation.Valid; 18 | import java.util.List; 19 | 20 | /** 21 | * @author Darod 22 | * @version 1.0 23 | * @date 2019/7/11 0011 19:41 24 | */ 25 | @RestController 26 | @RequestMapping("/user/curuser") 27 | public class UserLearnController { 28 | @Autowired 29 | private UserLearnService userLearnService; 30 | 31 | 32 | @GetMapping("/learned_course") 33 | @ApiOperation(value = "获取用户已学课程", httpMethod = "GET") 34 | public CommonResponse getUserLearnedCourse(@Validated CoursePageModel coursePageModel) throws BusinessException { 35 | //如果没有指定分页信息,默认不分页 36 | if (coursePageModel.getPage() == null || coursePageModel.getRow() == null) { 37 | coursePageModel.setPage(0); 38 | coursePageModel.setRow(9999); 39 | } 40 | Integer userId = ShiroUtils.getCurUserId(); 41 | coursePageModel.setUserId(userId); 42 | CommonCountModel> allCourseInfo = userLearnService.getCourseLearnedInfoLimited(coursePageModel, userId); 43 | return ResponseUtils.getOKResponse(allCourseInfo.toJSONObject("courses")); 44 | } 45 | 46 | @PostMapping("/learned_course") 47 | @ApiOperation(value = "学习课程", httpMethod = "POST") 48 | public CommonResponse addUserLearnedCourse(@Validated @RequestBody UserLearnModel userLearnModel) throws BusinessException { 49 | Integer curUserId = ShiroUtils.getCurUserId(); 50 | userLearnModel.setUserId(curUserId); 51 | return ResponseUtils.getOKResponse(userLearnService.addUserLearnedCourse(userLearnModel)); 52 | } 53 | 54 | 55 | // @ModelAttribute 56 | // public CoursePageModel pageModel(@Valid CoursePageModel coursePageModel) 57 | // { 58 | // //如果没有指定分页信息,默认不分页 59 | // if (coursePageModel.getPage() == null || coursePageModel.getRow() == null) { 60 | // coursePageModel.setPage(0); 61 | // coursePageModel.setRow(9999); 62 | // } 63 | // return coursePageModel; 64 | // } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/ChapterDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.darod.elearning.gateway.dataobject.ChapterDO; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import java.util.List; 7 | 8 | @Repository 9 | public interface ChapterDOMapper { 10 | /** 11 | * This method was generated by MyBatis Generator. 12 | * This method corresponds to the database table chapter_info 13 | * 14 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 15 | */ 16 | int deleteByPrimaryKey(Integer chapterId); 17 | 18 | /** 19 | * This method was generated by MyBatis Generator. 20 | * This method corresponds to the database table chapter_info 21 | * 22 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 23 | */ 24 | int insert(ChapterDO record); 25 | 26 | /** 27 | * This method was generated by MyBatis Generator. 28 | * This method corresponds to the database table chapter_info 29 | * 30 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 31 | */ 32 | int insertSelective(ChapterDO record); 33 | 34 | /** 35 | * This method was generated by MyBatis Generator. 36 | * This method corresponds to the database table chapter_info 37 | * 38 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 39 | */ 40 | ChapterDO selectByPrimaryKey(Integer chapterId); 41 | 42 | List selectAllChapterByCourseId(Integer courseId); 43 | 44 | /** 45 | * This method was generated by MyBatis Generator. 46 | * This method corresponds to the database table chapter_info 47 | * 48 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 49 | */ 50 | int updateByPrimaryKeySelective(ChapterDO record); 51 | 52 | /** 53 | * This method was generated by MyBatis Generator. 54 | * This method corresponds to the database table chapter_info 55 | * 56 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 57 | */ 58 | int updateByPrimaryKey(ChapterDO record); 59 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/CommentDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.darod.elearning.gateway.dataobject.CommentDO; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Repository 10 | public interface CommentDOMapper { 11 | /** 12 | * This method was generated by MyBatis Generator. 13 | * This method corresponds to the database table comment 14 | * 15 | * @mbg.generated Tue Jul 16 13:03:16 CST 2019 16 | */ 17 | int deleteByPrimaryKey(Integer commentId); 18 | 19 | /** 20 | * This method was generated by MyBatis Generator. 21 | * This method corresponds to the database table comment 22 | * 23 | * @mbg.generated Tue Jul 16 13:03:16 CST 2019 24 | */ 25 | int insert(CommentDO record); 26 | 27 | /** 28 | * This method was generated by MyBatis Generator. 29 | * This method corresponds to the database table comment 30 | * 31 | * @mbg.generated Tue Jul 16 13:03:16 CST 2019 32 | */ 33 | int insertSelective(CommentDO record); 34 | 35 | /** 36 | * This method was generated by MyBatis Generator. 37 | * This method corresponds to the database table comment 38 | * 39 | * @mbg.generated Tue Jul 16 13:03:16 CST 2019 40 | */ 41 | CommentDO selectByPrimaryKey(Integer commentId); 42 | 43 | List selectChapterCommentByCourseIdAndChapterId(@Param("courseId") Integer courseId, @Param("chapterId") Integer chapterId); 44 | 45 | List selectCourseCommentByCourseId(Integer courseId); 46 | 47 | /** 48 | * This method was generated by MyBatis Generator. 49 | * This method corresponds to the database table comment 50 | * 51 | * @mbg.generated Tue Jul 16 13:03:16 CST 2019 52 | */ 53 | int updateByPrimaryKeySelective(CommentDO record); 54 | 55 | /** 56 | * This method was generated by MyBatis Generator. 57 | * This method corresponds to the database table comment 58 | * 59 | * @mbg.generated Tue Jul 16 13:03:16 CST 2019 60 | */ 61 | int updateByPrimaryKey(CommentDO record); 62 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/CourseDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.darod.elearning.common.dto.CoursePageModel; 4 | import org.darod.elearning.gateway.dataobject.CourseDO; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Repository 10 | public interface CourseDOMapper { 11 | /** 12 | * This method was generated by MyBatis Generator. 13 | * This method corresponds to the database table course_info 14 | * 15 | * @mbg.generated Mon Jul 01 19:15:19 CST 2019 16 | */ 17 | int deleteByPrimaryKey(Integer courseId); 18 | 19 | /** 20 | * This method was generated by MyBatis Generator. 21 | * This method corresponds to the database table course_info 22 | * 23 | * @mbg.generated Mon Jul 01 19:15:19 CST 2019 24 | */ 25 | int insert(CourseDO record); 26 | 27 | /** 28 | * This method was generated by MyBatis Generator. 29 | * This method corresponds to the database table course_info 30 | * 31 | * @mbg.generated Mon Jul 01 19:15:19 CST 2019 32 | */ 33 | int insertSelective(CourseDO record); 34 | 35 | /** 36 | * This method was generated by MyBatis Generator. 37 | * This method corresponds to the database table course_info 38 | * 39 | * @mbg.generated Mon Jul 01 19:15:19 CST 2019 40 | */ 41 | CourseDO selectByPrimaryKey(Integer courseId); 42 | 43 | CourseDO selectByPrimaryKeyForUpdate(Integer courseId); 44 | 45 | List getAllCourseInfo(); 46 | 47 | List getAllFreeCourseInfo(); 48 | 49 | List getCourseInfoLimited(CoursePageModel coursePageModel); 50 | 51 | List getCourseByTeacherId(Integer teacherId); 52 | 53 | /** 54 | * This method was generated by MyBatis Generator. 55 | * This method corresponds to the database table course_info 56 | * 57 | * @mbg.generated Mon Jul 01 19:15:19 CST 2019 58 | */ 59 | int updateByPrimaryKeySelective(CourseDO record); 60 | 61 | /** 62 | * This method was generated by MyBatis Generator. 63 | * This method corresponds to the database table course_info 64 | * 65 | * @mbg.generated Mon Jul 01 19:15:19 CST 2019 66 | */ 67 | int updateByPrimaryKey(CourseDO record); 68 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/ForbidDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.darod.elearning.gateway.dataobject.ForbidDO; 5 | import org.darod.elearning.gateway.dataobject.UserRoleDO; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.List; 9 | 10 | @Repository 11 | public interface ForbidDOMapper { 12 | /** 13 | * This method was generated by MyBatis Generator. 14 | * This method corresponds to the database table forbid 15 | * 16 | * @mbg.generated Sat Jul 20 17:34:56 CST 2019 17 | */ 18 | int deleteByPrimaryKey(Integer forbidId); 19 | 20 | /** 21 | * This method was generated by MyBatis Generator. 22 | * This method corresponds to the database table forbid 23 | * 24 | * @mbg.generated Sat Jul 20 17:34:56 CST 2019 25 | */ 26 | int insert(ForbidDO record); 27 | 28 | /** 29 | * This method was generated by MyBatis Generator. 30 | * This method corresponds to the database table forbid 31 | * 32 | * @mbg.generated Sat Jul 20 17:34:56 CST 2019 33 | */ 34 | int insertSelective(ForbidDO record); 35 | 36 | /** 37 | * This method was generated by MyBatis Generator. 38 | * This method corresponds to the database table forbid 39 | * 40 | * @mbg.generated Sat Jul 20 17:34:56 CST 2019 41 | */ 42 | ForbidDO selectByPrimaryKey(Integer forbidId); 43 | 44 | /** 45 | * This method was generated by MyBatis Generator. 46 | * This method corresponds to the database table forbid 47 | * 48 | * @mbg.generated Sat Jul 20 17:34:56 CST 2019 49 | */ 50 | int updateByPrimaryKeySelective(ForbidDO record); 51 | 52 | /** 53 | * This method was generated by MyBatis Generator. 54 | * This method corresponds to the database table forbid 55 | * 56 | * @mbg.generated Sat Jul 20 17:34:56 CST 2019 57 | */ 58 | int updateByPrimaryKey(ForbidDO record); 59 | 60 | 61 | List getPrivilegeWithForbid(@Param("userId") Integer userId,@Param("list") List list); 62 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/LiveRecordDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.darod.elearning.gateway.dataobject.LiveRecordDO; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Repository 10 | public interface LiveRecordDOMapper { 11 | /** 12 | * This method was generated by MyBatis Generator. 13 | * This method corresponds to the database table live_record 14 | * 15 | * @mbg.generated Mon Jul 22 21:43:10 CST 2019 16 | */ 17 | int deleteByPrimaryKey(Integer liveRecordId); 18 | 19 | /** 20 | * This method was generated by MyBatis Generator. 21 | * This method corresponds to the database table live_record 22 | * 23 | * @mbg.generated Mon Jul 22 21:43:10 CST 2019 24 | */ 25 | int insert(LiveRecordDO record); 26 | 27 | /** 28 | * This method was generated by MyBatis Generator. 29 | * This method corresponds to the database table live_record 30 | * 31 | * @mbg.generated Mon Jul 22 21:43:10 CST 2019 32 | */ 33 | int insertSelective(LiveRecordDO record); 34 | 35 | /** 36 | * This method was generated by MyBatis Generator. 37 | * This method corresponds to the database table live_record 38 | * 39 | * @mbg.generated Mon Jul 22 21:43:10 CST 2019 40 | */ 41 | LiveRecordDO selectByPrimaryKey(Integer liveRecordId); 42 | 43 | /** 44 | * This method was generated by MyBatis Generator. 45 | * This method corresponds to the database table live_record 46 | * 47 | * @mbg.generated Mon Jul 22 21:43:10 CST 2019 48 | */ 49 | int updateByPrimaryKeySelective(LiveRecordDO record); 50 | 51 | /** 52 | * This method was generated by MyBatis Generator. 53 | * This method corresponds to the database table live_record 54 | * 55 | * @mbg.generated Mon Jul 22 21:43:10 CST 2019 56 | */ 57 | int updateByPrimaryKey(LiveRecordDO record); 58 | 59 | List getCurLiveRecordByTeacherId(Integer teacherId); 60 | 61 | List getCurLiveRecordByTeacherIdForUpdate(Integer teacherId); 62 | 63 | LiveRecordDO getCurLiveRecordByChannelAndSecret(@Param("channelId") String channelId, @Param("secret") String secret); 64 | 65 | LiveRecordDO getCurLiveRecordByChannelAndSecretForUpdate(@Param("channelId") String channelId, @Param("secret") String secret); 66 | 67 | LiveRecordDO getCurLiveRecordByChannel(@Param("channelId") String channelId, @Param("isUpdate") Boolean isUpdate); 68 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/LiveRoomDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.darod.elearning.gateway.dataobject.LiveRoomDO; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public interface LiveRoomDOMapper { 8 | /** 9 | * This method was generated by MyBatis Generator. 10 | * This method corresponds to the database table live_room 11 | * 12 | * @mbg.generated Tue Jul 23 21:25:10 CST 2019 13 | */ 14 | int deleteByPrimaryKey(Integer roomId); 15 | 16 | /** 17 | * This method was generated by MyBatis Generator. 18 | * This method corresponds to the database table live_room 19 | * 20 | * @mbg.generated Tue Jul 23 21:25:10 CST 2019 21 | */ 22 | int insert(LiveRoomDO record); 23 | 24 | /** 25 | * This method was generated by MyBatis Generator. 26 | * This method corresponds to the database table live_room 27 | * 28 | * @mbg.generated Tue Jul 23 21:25:10 CST 2019 29 | */ 30 | int insertSelective(LiveRoomDO record); 31 | 32 | /** 33 | * This method was generated by MyBatis Generator. 34 | * This method corresponds to the database table live_room 35 | * 36 | * @mbg.generated Tue Jul 23 21:25:10 CST 2019 37 | */ 38 | LiveRoomDO selectByPrimaryKey(Integer roomId); 39 | 40 | /** 41 | * This method was generated by MyBatis Generator. 42 | * This method corresponds to the database table live_room 43 | * 44 | * @mbg.generated Tue Jul 23 21:25:10 CST 2019 45 | */ 46 | int updateByPrimaryKeySelective(LiveRoomDO record); 47 | 48 | int updateByTeacherIdSelective(LiveRoomDO record); 49 | 50 | /** 51 | * This method was generated by MyBatis Generator. 52 | * This method corresponds to the database table live_room 53 | * 54 | * @mbg.generated Tue Jul 23 21:25:10 CST 2019 55 | */ 56 | int updateByPrimaryKey(LiveRoomDO record); 57 | 58 | LiveRoomDO selectByTeacherId(Integer teacherId); 59 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/MessageDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.darod.elearning.common.dto.CommonPageModel; 5 | import org.darod.elearning.gateway.dataobject.MessageDO; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.List; 9 | 10 | @Repository 11 | public interface MessageDOMapper { 12 | /** 13 | * This method was generated by MyBatis Generator. 14 | * This method corresponds to the database table message 15 | * 16 | * @mbg.generated Tue Jul 16 13:03:16 CST 2019 17 | */ 18 | int deleteByPrimaryKey(Integer messageId); 19 | 20 | /** 21 | * This method was generated by MyBatis Generator. 22 | * This method corresponds to the database table message 23 | * 24 | * @mbg.generated Tue Jul 16 13:03:16 CST 2019 25 | */ 26 | int insert(MessageDO record); 27 | 28 | /** 29 | * This method was generated by MyBatis Generator. 30 | * This method corresponds to the database table message 31 | * 32 | * @mbg.generated Tue Jul 16 13:03:16 CST 2019 33 | */ 34 | int insertSelective(MessageDO record); 35 | 36 | /** 37 | * This method was generated by MyBatis Generator. 38 | * This method corresponds to the database table message 39 | * 40 | * @mbg.generated Tue Jul 16 13:03:16 CST 2019 41 | */ 42 | MessageDO selectByPrimaryKey(Integer messageId); 43 | 44 | /** 45 | * This method was generated by MyBatis Generator. 46 | * This method corresponds to the database table message 47 | * 48 | * @mbg.generated Tue Jul 16 13:03:16 CST 2019 49 | */ 50 | int updateByPrimaryKeySelective(MessageDO record); 51 | 52 | /** 53 | * This method was generated by MyBatis Generator. 54 | * This method corresponds to the database table message 55 | * 56 | * @mbg.generated Tue Jul 16 13:03:16 CST 2019 57 | */ 58 | int updateByPrimaryKey(MessageDO record); 59 | 60 | 61 | List getAllMessage(@Param("userId") Integer userId, @Param("commonPageModel") CommonPageModel commonPageModel); 62 | 63 | MessageDO getMessageById(@Param("messageId") Integer messageId); 64 | 65 | List getMessagesUnread(@Param("userId") Integer userId, @Param("commonPageModel") CommonPageModel commonPageModel); 66 | 67 | Integer getMessagesUnreadCount(@Param("userId") Integer userId); 68 | 69 | void deleteMessage(@Param("messageId") Integer messageId); 70 | 71 | void deleteAllMessage(@Param("userId") Integer userId); 72 | 73 | void deleteAllMessageRead(@Param("userId") Integer userId); 74 | 75 | void setMessageRead(@Param("messageId") Integer messageId); 76 | 77 | void setAllMessageRead(@Param("userId") Integer userId); 78 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/OrderDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.darod.elearning.gateway.dataobject.OrderDO; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Repository 10 | public interface OrderDOMapper { 11 | /** 12 | * This method was generated by MyBatis Generator. 13 | * This method corresponds to the database table order_info 14 | * 15 | * @mbg.generated Mon Jul 15 12:54:50 CST 2019 16 | */ 17 | int deleteByPrimaryKey(String orderId); 18 | 19 | /** 20 | * This method was generated by MyBatis Generator. 21 | * This method corresponds to the database table order_info 22 | * 23 | * @mbg.generated Mon Jul 15 12:54:50 CST 2019 24 | */ 25 | int insert(OrderDO record); 26 | 27 | /** 28 | * This method was generated by MyBatis Generator. 29 | * This method corresponds to the database table order_info 30 | * 31 | * @mbg.generated Mon Jul 15 12:54:50 CST 2019 32 | */ 33 | int insertSelective(OrderDO record); 34 | 35 | /** 36 | * This method was generated by MyBatis Generator. 37 | * This method corresponds to the database table order_info 38 | * 39 | * @mbg.generated Mon Jul 15 12:54:50 CST 2019 40 | */ 41 | OrderDO selectByPrimaryKey(String orderId); 42 | 43 | OrderDO selectByPrimaryKeyForUpdate(String orderId); 44 | 45 | List selectByUserIdAndCourseId(@Param("userId") Integer userId, @Param("courseId") Integer courseId); 46 | 47 | List selectByUserIdAndCourseIdForUpdate(@Param("userId") Integer userId, @Param("courseId") Integer courseId); 48 | 49 | List getAllOrderInfo(); 50 | 51 | /** 52 | * This method was generated by MyBatis Generator. 53 | * This method corresponds to the database table order_info 54 | * 55 | * @mbg.generated Mon Jul 15 12:54:50 CST 2019 56 | */ 57 | int updateByPrimaryKeySelective(OrderDO record); 58 | 59 | /** 60 | * This method was generated by MyBatis Generator. 61 | * This method corresponds to the database table order_info 62 | * 63 | * @mbg.generated Mon Jul 15 12:54:50 CST 2019 64 | */ 65 | int updateByPrimaryKey(OrderDO record); 66 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/RolePrivilegeDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.darod.elearning.gateway.dataobject.RolePrivilegeDO; 4 | import org.darod.elearning.gateway.dataobject.UserRoleDO; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | @Repository 9 | public interface RolePrivilegeDOMapper { 10 | /** 11 | * This method was generated by MyBatis Generator. 12 | * This method corresponds to the database table role_privilege 13 | * 14 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 15 | */ 16 | int deleteByPrimaryKey(Integer rolePrivilegeId); 17 | 18 | /** 19 | * This method was generated by MyBatis Generator. 20 | * This method corresponds to the database table role_privilege 21 | * 22 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 23 | */ 24 | int insert(RolePrivilegeDO record); 25 | 26 | /** 27 | * This method was generated by MyBatis Generator. 28 | * This method corresponds to the database table role_privilege 29 | * 30 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 31 | */ 32 | int insertSelective(RolePrivilegeDO record); 33 | 34 | /** 35 | * This method was generated by MyBatis Generator. 36 | * This method corresponds to the database table role_privilege 37 | * 38 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 39 | */ 40 | RolePrivilegeDO selectByPrimaryKey(Integer rolePrivilegeId); 41 | 42 | /** 43 | * This method was generated by MyBatis Generator. 44 | * This method corresponds to the database table role_privilege 45 | * 46 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 47 | */ 48 | int updateByPrimaryKeySelective(RolePrivilegeDO record); 49 | 50 | /** 51 | * This method was generated by MyBatis Generator. 52 | * This method corresponds to the database table role_privilege 53 | * 54 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 55 | */ 56 | int updateByPrimaryKey(RolePrivilegeDO record); 57 | 58 | List getRolePrivilegeByRoleList(List roleList); 59 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/SequenceDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.darod.elearning.gateway.dataobject.SequenceDO; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public interface SequenceDOMapper { 8 | /** 9 | * This method was generated by MyBatis Generator. 10 | * This method corresponds to the database table sequence_info 11 | * 12 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 13 | */ 14 | int deleteByPrimaryKey(String name); 15 | 16 | /** 17 | * This method was generated by MyBatis Generator. 18 | * This method corresponds to the database table sequence_info 19 | * 20 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 21 | */ 22 | int insert(SequenceDO record); 23 | 24 | /** 25 | * This method was generated by MyBatis Generator. 26 | * This method corresponds to the database table sequence_info 27 | * 28 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 29 | */ 30 | int insertSelective(SequenceDO record); 31 | 32 | /** 33 | * This method was generated by MyBatis Generator. 34 | * This method corresponds to the database table sequence_info 35 | * 36 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 37 | */ 38 | SequenceDO selectByPrimaryKey(String name); 39 | 40 | 41 | SequenceDO getSequenceByName(String name); 42 | 43 | /** 44 | * This method was generated by MyBatis Generator. 45 | * This method corresponds to the database table sequence_info 46 | * 47 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 48 | */ 49 | int updateByPrimaryKeySelective(SequenceDO record); 50 | 51 | /** 52 | * This method was generated by MyBatis Generator. 53 | * This method corresponds to the database table sequence_info 54 | * 55 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 56 | */ 57 | int updateByPrimaryKey(SequenceDO record); 58 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/TeacherDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.darod.elearning.gateway.dataobject.TeacherDO; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public interface TeacherDOMapper { 8 | /** 9 | * This method was generated by MyBatis Generator. 10 | * This method corresponds to the database table teacher 11 | * 12 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 13 | */ 14 | int deleteByPrimaryKey(Integer teacherId); 15 | 16 | /** 17 | * This method was generated by MyBatis Generator. 18 | * This method corresponds to the database table teacher 19 | * 20 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 21 | */ 22 | int insert(TeacherDO record); 23 | 24 | /** 25 | * This method was generated by MyBatis Generator. 26 | * This method corresponds to the database table teacher 27 | * 28 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 29 | */ 30 | int insertSelective(TeacherDO record); 31 | 32 | /** 33 | * This method was generated by MyBatis Generator. 34 | * This method corresponds to the database table teacher 35 | * 36 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 37 | */ 38 | TeacherDO selectByPrimaryKey(Integer teacher_id); 39 | 40 | TeacherDO selectByUserId(Integer userId); 41 | 42 | /** 43 | * This method was generated by MyBatis Generator. 44 | * This method corresponds to the database table teacher 45 | * 46 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 47 | */ 48 | int updateByPrimaryKeySelective(TeacherDO record); 49 | 50 | /** 51 | * This method was generated by MyBatis Generator. 52 | * This method corresponds to the database table teacher 53 | * 54 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 55 | */ 56 | int updateByPrimaryKey(TeacherDO record); 57 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/UserDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.darod.elearning.gateway.dataobject.UserDO; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public interface UserDOMapper { 8 | /** 9 | * This method was generated by MyBatis Generator. 10 | * This method corresponds to the database table user 11 | * 12 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 13 | */ 14 | int deleteByPrimaryKey(Integer userId); 15 | 16 | /** 17 | * This method was generated by MyBatis Generator. 18 | * This method corresponds to the database table user 19 | * 20 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 21 | */ 22 | int insert(UserDO record); 23 | 24 | /** 25 | * This method was generated by MyBatis Generator. 26 | * This method corresponds to the database table user 27 | * 28 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 29 | */ 30 | int insertSelective(UserDO record); 31 | 32 | /** 33 | * This method was generated by MyBatis Generator. 34 | * This method corresponds to the database table user 35 | * 36 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 37 | */ 38 | UserDO selectByPrimaryKey(Integer userId); 39 | 40 | UserDO selectByUserName(String userName); 41 | 42 | /** 43 | * This method was generated by MyBatis Generator. 44 | * This method corresponds to the database table user 45 | * 46 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 47 | */ 48 | int updateByPrimaryKeySelective(UserDO record); 49 | 50 | /** 51 | * This method was generated by MyBatis Generator. 52 | * This method corresponds to the database table user 53 | * 54 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 55 | */ 56 | int updateByPrimaryKey(UserDO record); 57 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/UserLearnDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.darod.elearning.common.dto.CoursePageModel; 5 | import org.darod.elearning.gateway.dataobject.UserLearnDO; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.List; 9 | 10 | @Repository 11 | public interface UserLearnDOMapper { 12 | /** 13 | * This method was generated by MyBatis Generator. 14 | * This method corresponds to the database table user_learn 15 | * 16 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 17 | */ 18 | int deleteByPrimaryKey(Integer learnId); 19 | 20 | /** 21 | * This method was generated by MyBatis Generator. 22 | * This method corresponds to the database table user_learn 23 | * 24 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 25 | */ 26 | int insert(UserLearnDO record); 27 | 28 | /** 29 | * This method was generated by MyBatis Generator. 30 | * This method corresponds to the database table user_learn 31 | * 32 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 33 | */ 34 | int insertSelective(UserLearnDO record); 35 | 36 | /** 37 | * This method was generated by MyBatis Generator. 38 | * This method corresponds to the database table user_learn 39 | * 40 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 41 | */ 42 | UserLearnDO selectByPrimaryKey(Integer learnId); 43 | 44 | UserLearnDO selectByUserIdAndCourseId(@Param("userId") Integer userId, @Param("courseId") Integer courseId); 45 | 46 | List selectByUserId(Integer userId); 47 | 48 | UserLearnDO selectUserLearnAllByLearnId(Integer learnId); 49 | 50 | List selectUserLearnAllByUserId(Integer userId); 51 | 52 | List selectUserLearnAllByUserIdLimited(CoursePageModel coursePageModel); 53 | 54 | /** 55 | * This method was generated by MyBatis Generator. 56 | * This method corresponds to the database table user_learn 57 | * 58 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 59 | */ 60 | int updateByPrimaryKeySelective(UserLearnDO record); 61 | 62 | /** 63 | * This method was generated by MyBatis Generator. 64 | * This method corresponds to the database table user_learn 65 | * 66 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 67 | */ 68 | int updateByPrimaryKey(UserLearnDO record); 69 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/UserPasswordDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.darod.elearning.gateway.dataobject.UserPasswordDO; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public interface UserPasswordDOMapper { 8 | /** 9 | * This method was generated by MyBatis Generator. 10 | * This method corresponds to the database table user_password 11 | * 12 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 13 | */ 14 | int deleteByPrimaryKey(Integer id); 15 | 16 | /** 17 | * This method was generated by MyBatis Generator. 18 | * This method corresponds to the database table user_password 19 | * 20 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 21 | */ 22 | int insert(UserPasswordDO record); 23 | 24 | /** 25 | * This method was generated by MyBatis Generator. 26 | * This method corresponds to the database table user_password 27 | * 28 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 29 | */ 30 | int insertSelective(UserPasswordDO record); 31 | 32 | /** 33 | * This method was generated by MyBatis Generator. 34 | * This method corresponds to the database table user_password 35 | * 36 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 37 | */ 38 | UserPasswordDO selectByPrimaryKey(Integer id); 39 | 40 | UserPasswordDO selectByUserId(Integer userId); 41 | 42 | /** 43 | * This method was generated by MyBatis Generator. 44 | * This method corresponds to the database table user_password 45 | * 46 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 47 | */ 48 | int updateByPrimaryKeySelective(UserPasswordDO record); 49 | 50 | /** 51 | * This method was generated by MyBatis Generator. 52 | * This method corresponds to the database table user_password 53 | * 54 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 55 | */ 56 | int updateByPrimaryKey(UserPasswordDO record); 57 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dao/UserRoleDOMapper.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dao; 2 | 3 | import org.darod.elearning.gateway.dataobject.UserRoleDO; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import java.util.List; 7 | 8 | @Repository 9 | 10 | public interface UserRoleDOMapper { 11 | /** 12 | * This method was generated by MyBatis Generator. 13 | * This method corresponds to the database table user_role 14 | * 15 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 16 | */ 17 | int deleteByPrimaryKey(Integer userRoleId); 18 | 19 | /** 20 | * This method was generated by MyBatis Generator. 21 | * This method corresponds to the database table user_role 22 | * 23 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 24 | */ 25 | int insert(UserRoleDO record); 26 | 27 | /** 28 | * This method was generated by MyBatis Generator. 29 | * This method corresponds to the database table user_role 30 | * 31 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 32 | */ 33 | int insertSelective(UserRoleDO record); 34 | 35 | /** 36 | * This method was generated by MyBatis Generator. 37 | * This method corresponds to the database table user_role 38 | * 39 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 40 | */ 41 | UserRoleDO selectByPrimaryKey(Integer userRoleId); 42 | 43 | List getUserRoleInfoByUserId(Integer userId); 44 | 45 | /** 46 | * This method was generated by MyBatis Generator. 47 | * This method corresponds to the database table user_role 48 | * 49 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 50 | */ 51 | int updateByPrimaryKeySelective(UserRoleDO record); 52 | 53 | /** 54 | * This method was generated by MyBatis Generator. 55 | * This method corresponds to the database table user_role 56 | * 57 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 58 | */ 59 | int updateByPrimaryKey(UserRoleDO record); 60 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dataobject/RolePrivilegeDO.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dataobject; 2 | 3 | public class RolePrivilegeDO { 4 | /** 5 | * 6 | * This field was generated by MyBatis Generator. 7 | * This field corresponds to the database column role_privilege.role_privilege_id 8 | * 9 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 10 | */ 11 | private Integer rolePrivilegeId; 12 | 13 | /** 14 | * 15 | * This field was generated by MyBatis Generator. 16 | * This field corresponds to the database column role_privilege.role_name 17 | * 18 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 19 | */ 20 | private String roleName; 21 | 22 | /** 23 | * 24 | * This field was generated by MyBatis Generator. 25 | * This field corresponds to the database column role_privilege.privilege_name 26 | * 27 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 28 | */ 29 | private String privilegeName; 30 | 31 | /** 32 | * This method was generated by MyBatis Generator. 33 | * This method returns the value of the database column role_privilege.role_privilege_id 34 | * 35 | * @return the value of role_privilege.role_privilege_id 36 | * 37 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 38 | */ 39 | public Integer getRolePrivilegeId() { 40 | return rolePrivilegeId; 41 | } 42 | 43 | /** 44 | * This method was generated by MyBatis Generator. 45 | * This method sets the value of the database column role_privilege.role_privilege_id 46 | * 47 | * @param rolePrivilegeId the value for role_privilege.role_privilege_id 48 | * 49 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 50 | */ 51 | public void setRolePrivilegeId(Integer rolePrivilegeId) { 52 | this.rolePrivilegeId = rolePrivilegeId; 53 | } 54 | 55 | /** 56 | * This method was generated by MyBatis Generator. 57 | * This method returns the value of the database column role_privilege.role_name 58 | * 59 | * @return the value of role_privilege.role_name 60 | * 61 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 62 | */ 63 | public String getRoleName() { 64 | return roleName; 65 | } 66 | 67 | /** 68 | * This method was generated by MyBatis Generator. 69 | * This method sets the value of the database column role_privilege.role_name 70 | * 71 | * @param roleName the value for role_privilege.role_name 72 | * 73 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 74 | */ 75 | public void setRoleName(String roleName) { 76 | this.roleName = roleName == null ? null : roleName.trim(); 77 | } 78 | 79 | /** 80 | * This method was generated by MyBatis Generator. 81 | * This method returns the value of the database column role_privilege.privilege_name 82 | * 83 | * @return the value of role_privilege.privilege_name 84 | * 85 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 86 | */ 87 | public String getPrivilegeName() { 88 | return privilegeName; 89 | } 90 | 91 | /** 92 | * This method was generated by MyBatis Generator. 93 | * This method sets the value of the database column role_privilege.privilege_name 94 | * 95 | * @param privilegeName the value for role_privilege.privilege_name 96 | * 97 | * @mbg.generated Sat Jul 20 17:53:56 CST 2019 98 | */ 99 | public void setPrivilegeName(String privilegeName) { 100 | this.privilegeName = privilegeName == null ? null : privilegeName.trim(); 101 | } 102 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dataobject/SequenceDO.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dataobject; 2 | 3 | public class SequenceDO { 4 | /** 5 | * 6 | * This field was generated by MyBatis Generator. 7 | * This field corresponds to the database column sequence_info.name 8 | * 9 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 10 | */ 11 | private String name; 12 | 13 | /** 14 | * 15 | * This field was generated by MyBatis Generator. 16 | * This field corresponds to the database column sequence_info.current_value 17 | * 18 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 19 | */ 20 | private Integer currentValue; 21 | 22 | /** 23 | * 24 | * This field was generated by MyBatis Generator. 25 | * This field corresponds to the database column sequence_info.set 26 | * 27 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 28 | */ 29 | private Integer step; 30 | 31 | /** 32 | * This method was generated by MyBatis Generator. 33 | * This method returns the value of the database column sequence_info.name 34 | * 35 | * @return the value of sequence_info.name 36 | * 37 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 38 | */ 39 | public String getName() { 40 | return name; 41 | } 42 | 43 | /** 44 | * This method was generated by MyBatis Generator. 45 | * This method sets the value of the database column sequence_info.name 46 | * 47 | * @param name the value for sequence_info.name 48 | * 49 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 50 | */ 51 | public void setName(String name) { 52 | this.name = name == null ? null : name.trim(); 53 | } 54 | 55 | /** 56 | * This method was generated by MyBatis Generator. 57 | * This method returns the value of the database column sequence_info.current_value 58 | * 59 | * @return the value of sequence_info.current_value 60 | * 61 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 62 | */ 63 | public Integer getCurrentValue() { 64 | return currentValue; 65 | } 66 | 67 | /** 68 | * This method was generated by MyBatis Generator. 69 | * This method sets the value of the database column sequence_info.current_value 70 | * 71 | * @param currentValue the value for sequence_info.current_value 72 | * 73 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 74 | */ 75 | public void setCurrentValue(Integer currentValue) { 76 | this.currentValue = currentValue; 77 | } 78 | 79 | /** 80 | * This method was generated by MyBatis Generator. 81 | * This method returns the value of the database column sequence_info.set 82 | * 83 | * @return the value of sequence_info.set 84 | * 85 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 86 | */ 87 | public Integer getStep() { 88 | return step; 89 | } 90 | 91 | /** 92 | * This method was generated by MyBatis Generator. 93 | * This method sets the value of the database column sequence_info.set 94 | * 95 | * @param step the value for sequence_info.set 96 | * 97 | * @mbg.generated Mon Jul 08 21:02:59 CST 2019 98 | */ 99 | public void setStep(Integer step) { 100 | this.step = step; 101 | } 102 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dataobject/UserPasswordDO.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dataobject; 2 | 3 | public class UserPasswordDO { 4 | /** 5 | * 6 | * This field was generated by MyBatis Generator. 7 | * This field corresponds to the database column user_password.id 8 | * 9 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 10 | */ 11 | private Integer id; 12 | 13 | /** 14 | * 15 | * This field was generated by MyBatis Generator. 16 | * This field corresponds to the database column user_password.encrypt_password 17 | * 18 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 19 | */ 20 | private String encryptPassword; 21 | 22 | /** 23 | * 24 | * This field was generated by MyBatis Generator. 25 | * This field corresponds to the database column user_password.user_id 26 | * 27 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 28 | */ 29 | private Integer userId; 30 | 31 | /** 32 | * 33 | * This field was generated by MyBatis Generator. 34 | * This field corresponds to the database column user_password.user_status 35 | * 36 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 37 | */ 38 | private Integer userStatus; 39 | 40 | /** 41 | * This method was generated by MyBatis Generator. 42 | * This method returns the value of the database column user_password.id 43 | * 44 | * @return the value of user_password.id 45 | * 46 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 47 | */ 48 | public Integer getId() { 49 | return id; 50 | } 51 | 52 | /** 53 | * This method was generated by MyBatis Generator. 54 | * This method sets the value of the database column user_password.id 55 | * 56 | * @param id the value for user_password.id 57 | * 58 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 59 | */ 60 | public void setId(Integer id) { 61 | this.id = id; 62 | } 63 | 64 | /** 65 | * This method was generated by MyBatis Generator. 66 | * This method returns the value of the database column user_password.encrypt_password 67 | * 68 | * @return the value of user_password.encrypt_password 69 | * 70 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 71 | */ 72 | public String getEncryptPassword() { 73 | return encryptPassword; 74 | } 75 | 76 | /** 77 | * This method was generated by MyBatis Generator. 78 | * This method sets the value of the database column user_password.encrypt_password 79 | * 80 | * @param encryptPassword the value for user_password.encrypt_password 81 | * 82 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 83 | */ 84 | public void setEncryptPassword(String encryptPassword) { 85 | this.encryptPassword = encryptPassword == null ? null : encryptPassword.trim(); 86 | } 87 | 88 | /** 89 | * This method was generated by MyBatis Generator. 90 | * This method returns the value of the database column user_password.user_id 91 | * 92 | * @return the value of user_password.user_id 93 | * 94 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 95 | */ 96 | public Integer getUserId() { 97 | return userId; 98 | } 99 | 100 | /** 101 | * This method was generated by MyBatis Generator. 102 | * This method sets the value of the database column user_password.user_id 103 | * 104 | * @param userId the value for user_password.user_id 105 | * 106 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 107 | */ 108 | public void setUserId(Integer userId) { 109 | this.userId = userId; 110 | } 111 | 112 | /** 113 | * This method was generated by MyBatis Generator. 114 | * This method returns the value of the database column user_password.user_status 115 | * 116 | * @return the value of user_password.user_status 117 | * 118 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 119 | */ 120 | public Integer getUserStatus() { 121 | return userStatus; 122 | } 123 | 124 | /** 125 | * This method was generated by MyBatis Generator. 126 | * This method sets the value of the database column user_password.user_status 127 | * 128 | * @param userStatus the value for user_password.user_status 129 | * 130 | * @mbg.generated Mon Jun 24 18:28:14 CST 2019 131 | */ 132 | public void setUserStatus(Integer userStatus) { 133 | this.userStatus = userStatus; 134 | } 135 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/dataobject/UserRoleDO.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.dataobject; 2 | 3 | public class UserRoleDO { 4 | /** 5 | * 6 | * This field was generated by MyBatis Generator. 7 | * This field corresponds to the database column user_role.user_role_id 8 | * 9 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 10 | */ 11 | private Integer userRoleId; 12 | 13 | /** 14 | * 15 | * This field was generated by MyBatis Generator. 16 | * This field corresponds to the database column user_role.user_id 17 | * 18 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 19 | */ 20 | private Integer userId; 21 | 22 | /** 23 | * 24 | * This field was generated by MyBatis Generator. 25 | * This field corresponds to the database column user_role.role_name 26 | * 27 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 28 | */ 29 | private String roleName; 30 | 31 | /** 32 | * This method was generated by MyBatis Generator. 33 | * This method returns the value of the database column user_role.user_role_id 34 | * 35 | * @return the value of user_role.user_role_id 36 | * 37 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 38 | */ 39 | public Integer getUserRoleId() { 40 | return userRoleId; 41 | } 42 | 43 | /** 44 | * This method was generated by MyBatis Generator. 45 | * This method sets the value of the database column user_role.user_role_id 46 | * 47 | * @param userRoleId the value for user_role.user_role_id 48 | * 49 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 50 | */ 51 | public void setUserRoleId(Integer userRoleId) { 52 | this.userRoleId = userRoleId; 53 | } 54 | 55 | /** 56 | * This method was generated by MyBatis Generator. 57 | * This method returns the value of the database column user_role.user_id 58 | * 59 | * @return the value of user_role.user_id 60 | * 61 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 62 | */ 63 | public Integer getUserId() { 64 | return userId; 65 | } 66 | 67 | /** 68 | * This method was generated by MyBatis Generator. 69 | * This method sets the value of the database column user_role.user_id 70 | * 71 | * @param userId the value for user_role.user_id 72 | * 73 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 74 | */ 75 | public void setUserId(Integer userId) { 76 | this.userId = userId; 77 | } 78 | 79 | /** 80 | * This method was generated by MyBatis Generator. 81 | * This method returns the value of the database column user_role.role_name 82 | * 83 | * @return the value of user_role.role_name 84 | * 85 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 86 | */ 87 | public String getRoleName() { 88 | return roleName; 89 | } 90 | 91 | /** 92 | * This method was generated by MyBatis Generator. 93 | * This method sets the value of the database column user_role.role_name 94 | * 95 | * @param roleName the value for user_role.role_name 96 | * 97 | * @mbg.generated Sat Jul 20 17:29:29 CST 2019 98 | */ 99 | public void setRoleName(String roleName) { 100 | this.roleName = roleName == null ? null : roleName.trim(); 101 | } 102 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/interceptor/SessionInterceptor.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.interceptor; 2 | 3 | import org.apache.shiro.SecurityUtils; 4 | import org.apache.shiro.subject.Subject; 5 | import org.springframework.web.servlet.HandlerInterceptor; 6 | import org.springframework.web.servlet.ModelAndView; 7 | 8 | import javax.annotation.Resource; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | /** 13 | * @author Darod 14 | * @version 1.0 15 | * @date 2019/6/30 0030 15:47 16 | */ 17 | 18 | //public class SessionInterceptor implements HandlerInterceptor { 19 | // @Resource 20 | // private PermissionService permissionService; 21 | // 22 | // @Override 23 | // public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception { 24 | // System.out.println(request.getContextPath()); 25 | // Subject currentUser = SecurityUtils.getSubject(); 26 | // //判断用户是通过记住我功能自动登录,此时session失效 27 | // if (!currentUser.isAuthenticated() && currentUser.isRemembered()) { 28 | // try { 29 | // User user = permissionService.findByUserEmail(currentUser.getPrincipals().toString()); 30 | // //对密码进行加密后验证 31 | // UsernamePasswordToken token = new UsernamePasswordToken(user.getEmail(), user.getPswd(), currentUser.isRemembered()); 32 | // //把当前用户放入session 33 | // currentUser.login(token); 34 | // Session session = currentUser.getSession(); 35 | // session.setAttribute("currentUser", user); 36 | // //设置会话的过期时间--ms,默认是30分钟,设置负数表示永不过期 37 | // session.setTimeout(-1000l); 38 | // } catch (Exception e) { 39 | // //自动登录失败,跳转到登录页面 40 | // response.sendRedirect(request.getContextPath() + "/login"); 41 | // return false; 42 | // } 43 | // if (!currentUser.isAuthenticated()) { 44 | // //自动登录失败,跳转到登录页面 45 | // response.sendRedirect(request.getContextPath() + "/login"); 46 | // return false; 47 | // } 48 | // } 49 | // return true; 50 | // } 51 | // 52 | // @Override 53 | // public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { 54 | // 55 | // } 56 | // 57 | // @Override 58 | // public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception { 59 | // 60 | // } 61 | //} 62 | // 63 | // 64 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/interceptor/WebSocketHandShakeInterceptor.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.interceptor; 2 | 3 | import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; 4 | 5 | /** 6 | * @author Darod 7 | * @version 1.0 8 | * @date 2019/8/3 0003 23:55 9 | */ 10 | public class WebSocketHandShakeInterceptor extends HttpSessionHandshakeInterceptor { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/serviceimpl/ChapterServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.serviceimpl; 2 | 3 | import org.darod.elearning.common.dto.ChapterModel; 4 | import org.darod.elearning.common.exception.BusinessException; 5 | import org.darod.elearning.common.exception.EmException; 6 | import org.darod.elearning.common.service.user.ChapterService; 7 | import org.darod.elearning.common.utils.CopyPropertiesUtils; 8 | import org.darod.elearning.gateway.dao.ChapterDOMapper; 9 | import org.darod.elearning.gateway.dao.CourseDOMapper; 10 | import org.darod.elearning.gateway.dataobject.ChapterDO; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | 14 | import java.util.Date; 15 | import java.util.List; 16 | 17 | /** 18 | * @author Darod 19 | * @version 1.0 20 | * @date 2019/7/16 0016 12:04 21 | */ 22 | @Service 23 | public class ChapterServiceImpl implements ChapterService { 24 | @Autowired 25 | private ChapterDOMapper chapterDOMapper; 26 | @Autowired 27 | private CourseDOMapper courseDOMapper; 28 | 29 | @Override 30 | public List getAllChapterByCourseId(Integer courseId) { 31 | if (courseDOMapper.selectByPrimaryKey(courseId) == null) { 32 | throw new BusinessException(EmException.COURSE_NOT_EXIST); 33 | } 34 | return CopyPropertiesUtils.mapListObject(chapterDOMapper.selectAllChapterByCourseId(courseId), ChapterModel.class); 35 | } 36 | 37 | @Override 38 | public ChapterModel getChapterInfoById(Integer courseId, Integer chapterId) { 39 | ChapterDO chapterDO = chapterDOMapper.selectByPrimaryKey(chapterId); 40 | if (chapterDO == null || !chapterDO.getCourseId().equals(courseId)) { 41 | throw new BusinessException(EmException.CHAPTER_NOT_EXIST); 42 | } 43 | return CopyPropertiesUtils.copyProperties(chapterDO, ChapterModel.class); 44 | } 45 | 46 | @Override 47 | public List getAllChapterInfo(Integer courseId) { 48 | return CopyPropertiesUtils.mapListObject(chapterDOMapper.selectAllChapterByCourseId(courseId), ChapterModel.class); 49 | } 50 | 51 | @Override 52 | public ChapterModel addChapter(Integer courseId, ChapterModel chapterModel) { 53 | chapterModel.setChapterState(1); 54 | chapterModel.setPublishTime(new Date()); 55 | chapterModel.setCourseId(courseId); 56 | return CopyPropertiesUtils.copyAndInsertThenReturn(chapterModel, ChapterDO.class, chapterDOMapper::insertSelective, 57 | (x) -> chapterDOMapper.selectByPrimaryKey(x.getChapterId())); 58 | } 59 | 60 | @Override 61 | public ChapterModel updateChapter(Integer courseId, Integer chapterId, ChapterModel chapterModel) { 62 | ChapterDO chapterDO = chapterDOMapper.selectByPrimaryKey(chapterId); 63 | if (chapterDO == null || !chapterDO.getCourseId().equals(courseId)) { 64 | throw new BusinessException(EmException.CHAPTER_NOT_EXIST); 65 | } 66 | chapterModel.setCourseId(courseId); 67 | chapterModel.setChapterId(chapterId); 68 | return CopyPropertiesUtils.copyAndInsertThenReturn(chapterModel, ChapterDO.class, chapterDOMapper::updateByPrimaryKeySelective, 69 | (x) -> chapterDOMapper.selectByPrimaryKey(x.getChapterId())); 70 | } 71 | 72 | @Override 73 | public void deleteChapter(Integer courseId, Integer chapterId) { 74 | ChapterDO chapterDO = chapterDOMapper.selectByPrimaryKey(chapterId); 75 | if (chapterDO == null || !chapterDO.getCourseId().equals(courseId)) { 76 | throw new BusinessException(EmException.CHAPTER_NOT_EXIST); 77 | } 78 | chapterDOMapper.deleteByPrimaryKey(chapterId); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/serviceimpl/CommentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.serviceimpl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import org.darod.elearning.common.dto.CommentModel; 5 | import org.darod.elearning.common.dto.CommonCountModel; 6 | import org.darod.elearning.common.dto.CommonPageModel; 7 | import org.darod.elearning.common.exception.BusinessException; 8 | import org.darod.elearning.common.exception.EmException; 9 | import org.darod.elearning.common.service.user.CommentService; 10 | import org.darod.elearning.common.utils.CopyPropertiesUtils; 11 | import org.darod.elearning.gateway.dao.ChapterDOMapper; 12 | import org.darod.elearning.gateway.dao.CommentDOMapper; 13 | import org.darod.elearning.gateway.dao.CourseDOMapper; 14 | import org.darod.elearning.gateway.dao.UserLearnDOMapper; 15 | import org.darod.elearning.gateway.dataobject.CommentDO; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.stereotype.Service; 18 | 19 | import java.util.Date; 20 | import java.util.List; 21 | 22 | /** 23 | * @author Darod 24 | * @version 1.0 25 | * @date 2019/7/16 0016 12:41 26 | */ 27 | @Service 28 | public class CommentServiceImpl implements CommentService { 29 | @Autowired 30 | private CommentDOMapper commentDOMapper; 31 | @Autowired 32 | private CourseDOMapper courseDOMapper; 33 | @Autowired 34 | private ChapterDOMapper chapterDOMapper; 35 | @Autowired 36 | private UserLearnDOMapper userLearnDOMapper; 37 | 38 | @Override 39 | public CommonCountModel> getAllCourseComment(Integer courseId, CommonPageModel commonPageModel) { 40 | return CommonCountModel.getCountModelFromList(PageHelper.startPage(commonPageModel.getPage(), commonPageModel.getRow()), 41 | commentDOMapper.selectCourseCommentByCourseId(courseId), CommentModel.class); 42 | } 43 | 44 | @Override 45 | public CommonCountModel> getAllChapterComment(Integer courseId, Integer chapterId, CommonPageModel commonPageModel) { 46 | return CommonCountModel.getCountModelFromList(PageHelper.startPage(commonPageModel.getPage(), commonPageModel.getRow()), 47 | commentDOMapper.selectChapterCommentByCourseIdAndChapterId(courseId, chapterId), CommentModel.class); 48 | } 49 | 50 | @Override 51 | public CommentModel addCourseComment(CommentModel commentModel) { 52 | //没有章节号 则添加到课程评论 否则作为章节评论 53 | if (commentModel.getChapterId() == null) { 54 | commentModel.setChapterId(-1); 55 | } 56 | //看看用户学习了这门课程了吗 57 | if (userLearnDOMapper.selectByUserIdAndCourseId(commentModel.getUserId(), commentModel.getCourseId()) == null) { 58 | throw new BusinessException(EmException.COURSE_NOT_LEARNED); 59 | } 60 | //看看有没有这个章节 61 | if (commentModel.getChapterId() != -1 && chapterDOMapper.selectByPrimaryKey(commentModel.getChapterId()) == null) { 62 | throw new BusinessException(EmException.CHAPTER_NOT_EXIST); 63 | } 64 | return CopyPropertiesUtils.copyAndInsertThenReturn(commentModel,CommentDO.class,(commentDO) -> { 65 | commentDO.setCommentState(0); 66 | commentDO.setCommentId(null); 67 | commentDO.setCommentTime(new Date()); 68 | commentDOMapper.insertSelective(commentDO); 69 | },(x)->commentDOMapper.selectByPrimaryKey(x.getCommentId())); 70 | // CommentDO commentDO = CopyPropertiesUtils.copyProperties(commentModel, CommentDO.class); 71 | // commentDO.setCommentState(0); 72 | // commentDO.setCommentId(null); 73 | // commentDO.setCommentTime(new Date()); 74 | // commentDOMapper.insertSelective(commentDO); 75 | // return CopyPropertiesUtils.copyProperties(commentDOMapper.selectByPrimaryKey(commentDO.getCommentId()), CommentModel.class); 76 | } 77 | 78 | @Override 79 | public void deleteCourseComment(CommentModel commentModel) { 80 | CommentDO commentDO = commentDOMapper.selectByPrimaryKey(commentModel.getCommentId()); 81 | if (commentDO == null) throw new BusinessException(EmException.COMMENT_NOT_EXIST); 82 | if (!commentDO.getUserId().equals(commentModel.getUserId())) 83 | throw new BusinessException(EmException.PERMISSION_DENIED, "该评论不是你发布的"); 84 | if (!(commentDO.getChapterId().equals(commentModel.getChapterId()) && commentDO.getCourseId().equals(commentModel.getCourseId()))) 85 | throw new BusinessException(EmException.COMMENT_NOT_EXIST); 86 | commentDOMapper.deleteByPrimaryKey(commentModel.getCommentId()); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/serviceimpl/MessageServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.serviceimpl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import org.darod.elearning.common.dto.CommonCountModel; 5 | import org.darod.elearning.common.dto.CommonPageModel; 6 | import org.darod.elearning.common.dto.MessageModel; 7 | import org.darod.elearning.common.exception.BusinessException; 8 | import org.darod.elearning.common.exception.EmException; 9 | import org.darod.elearning.common.service.user.MessageService; 10 | import org.darod.elearning.common.utils.CopyPropertiesUtils; 11 | import org.darod.elearning.gateway.dao.MessageDOMapper; 12 | import org.darod.elearning.gateway.dataobject.MessageDO; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.stereotype.Service; 15 | 16 | import java.util.List; 17 | 18 | /** 19 | * @author Darod 20 | * @version 1.0 21 | * @date 2019/7/16 0016 15:17 22 | */ 23 | @Service 24 | public class MessageServiceImpl implements MessageService { 25 | @Autowired 26 | private MessageDOMapper messageDOMapper; 27 | 28 | @Override 29 | public CommonCountModel> getAllMessage(Integer userId, CommonPageModel commonPageModel) { 30 | return CommonCountModel.getCountModelFromList(PageHelper.startPage(commonPageModel.getPage(), commonPageModel.getRow()), 31 | messageDOMapper.getAllMessage(userId, commonPageModel), MessageModel.class); 32 | } 33 | 34 | @Override 35 | public MessageModel getMessageById(Integer userId, Integer messageId) { 36 | MessageDO messageDO = messageDOMapper.getMessageById(messageId); 37 | if (!messageDO.getReceiverId().equals(userId)) { 38 | throw new BusinessException(EmException.PERMISSION_DENIED, "您无权访问该消息"); 39 | } 40 | return CopyPropertiesUtils.copyProperties(messageDO, MessageModel.class); 41 | } 42 | 43 | @Override 44 | public CommonCountModel> getMessagesUnread(Integer userId, CommonPageModel commonPageModel) { 45 | return CommonCountModel.getCountModelFromList(PageHelper.startPage(commonPageModel.getPage(), commonPageModel.getRow()), 46 | messageDOMapper.getMessagesUnread(userId, commonPageModel), MessageModel.class); 47 | } 48 | 49 | @Override 50 | public Integer getMessagesUnreadCount(Integer userId) { 51 | return messageDOMapper.getMessagesUnreadCount(userId); 52 | } 53 | 54 | @Override 55 | public void deleteMessage(Integer userId, Integer messageId) { 56 | MessageDO messageDO = messageDOMapper.selectByPrimaryKey(messageId); 57 | if (!messageDO.getReceiverId().equals(userId)) { 58 | throw new BusinessException(EmException.PERMISSION_DENIED, "您无权删除该消息"); 59 | } 60 | messageDOMapper.deleteMessage(messageId); 61 | } 62 | 63 | @Override 64 | public void deleteAllMessage(Integer userId) { 65 | messageDOMapper.deleteAllMessage(userId); 66 | } 67 | 68 | @Override 69 | public void deleteAllMessageRead(Integer userId) { 70 | messageDOMapper.deleteAllMessageRead(userId); 71 | } 72 | 73 | @Override 74 | public MessageModel setMessageRead(Integer userId, Integer messageId) { 75 | MessageDO messageDO = messageDOMapper.selectByPrimaryKey(messageId); 76 | if (!messageDO.getReceiverId().equals(userId)) { 77 | throw new BusinessException(EmException.PERMISSION_DENIED, "您无权修改该消息"); 78 | } 79 | messageDOMapper.setMessageRead(messageId); 80 | return CopyPropertiesUtils.copyProperties(messageDOMapper.selectByPrimaryKey(messageId), MessageModel.class); 81 | } 82 | 83 | @Override 84 | public void setAllMessageRead(Integer userId) { 85 | messageDOMapper.setAllMessageRead(userId); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/serviceimpl/PermissionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.serviceimpl; 2 | 3 | import org.darod.elearning.common.service.user.PermissionService; 4 | import org.darod.elearning.gateway.dao.ForbidDOMapper; 5 | import org.darod.elearning.gateway.dao.RolePrivilegeDOMapper; 6 | import org.darod.elearning.gateway.dao.TeacherDOMapper; 7 | import org.darod.elearning.gateway.dao.UserRoleDOMapper; 8 | import org.darod.elearning.gateway.dataobject.TeacherDO; 9 | import org.darod.elearning.gateway.dataobject.UserRoleDO; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.HashSet; 14 | import java.util.List; 15 | import java.util.Set; 16 | 17 | /** 18 | * @author Darod 19 | * @version 1.0 20 | * @date 2019/7/20 0020 17:37 21 | */ 22 | @Service 23 | public class PermissionServiceImpl implements PermissionService { 24 | @Autowired 25 | private ForbidDOMapper forbidDOMapper; 26 | @Autowired 27 | private RolePrivilegeDOMapper rolePrivilegeDOMapper; 28 | @Autowired 29 | private UserRoleDOMapper userRoleDOMapper; 30 | @Autowired 31 | private TeacherDOMapper teacherDOMapper; 32 | 33 | @Override 34 | public Set getUserRoleInfo(Integer userId) { 35 | HashSet hashSet = new HashSet<>(); 36 | hashSet.add("user"); //都有用户角色 37 | //判断是否教师角色 38 | TeacherDO teacherDO = teacherDOMapper.selectByUserId(userId); 39 | if (teacherDO != null && teacherDO.getTeacherState().equals(0)) { 40 | hashSet.add("teacher"); 41 | } 42 | List userRoleInfoByUserId = userRoleDOMapper.getUserRoleInfoByUserId(userId); 43 | userRoleInfoByUserId.stream().forEach((x) -> hashSet.add(x.getRoleName())); 44 | return hashSet; 45 | } 46 | 47 | @Override 48 | public Set getUserPermissionInfo(Integer userId) { 49 | List userRoleDOS = userRoleDOMapper.getUserRoleInfoByUserId(userId); 50 | TeacherDO teacherDO = teacherDOMapper.selectByUserId(userId); 51 | if (teacherDO != null && teacherDO.getTeacherState().equals(0)) { 52 | UserRoleDO userRoleDO = new UserRoleDO(); 53 | userRoleDO.setRoleName("teacher"); 54 | userRoleDOS.add(userRoleDO); 55 | } 56 | // List rolePrivilegeByRoleList = rolePrivilegeDOMapper.getRolePrivilegeByRoleList(userRoleDOS); 57 | // rolePrivilegeByRoleList.stream().forEach((x) -> hashSet.add(x.getPrivilegeName())); 58 | //去封禁列表看看被封禁的权限 59 | List privilegeWithForbid = forbidDOMapper.getPrivilegeWithForbid(userId, userRoleDOS); 60 | return new HashSet<>(privilegeWithForbid); 61 | } 62 | 63 | 64 | } 65 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/utils/RandomUtils.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.utils; 2 | 3 | import java.util.Date; 4 | import java.util.Random; 5 | 6 | /** 7 | * @author Darod 8 | * @version 1.0 9 | * @date 2019/7/22 0022 13:15 10 | */ 11 | public class RandomUtils { 12 | public static final String SEED = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 13 | public static final int SEED_LENGTH = SEED.length(); 14 | public static final int CHANNEL_PREFIX_LEN = 6; 15 | public static final int CHANNEL_SUFFIX_LEN = 10; 16 | public static final int LIVE_SECRET_LEN = 32; 17 | 18 | public static String getRandomString(int length) { 19 | Random random = new Random(); 20 | StringBuilder sb = new StringBuilder(); 21 | for (int i = 0; i < length; i++) { 22 | sb.append(SEED.charAt(random.nextInt(SEED_LENGTH))); 23 | } 24 | return sb.toString(); 25 | } 26 | public static String getRandomChannelId(){ 27 | StringBuilder sb = new StringBuilder(); 28 | String time = String.valueOf(new Date().getTime()); 29 | sb.append(time.substring(time.length()-CHANNEL_PREFIX_LEN)); 30 | sb.append(getRandomString(CHANNEL_SUFFIX_LEN)); 31 | return sb.toString(); 32 | } 33 | public static String getRandomLiveSecret(){ 34 | return getRandomString(LIVE_SECRET_LEN); 35 | } 36 | 37 | public static void main(String[] args) { 38 | System.out.println(getRandomChannelId()); 39 | System.out.println(getRandomLiveSecret()); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/utils/SwaggerConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.utils; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.ApiInfoBuilder; 6 | import springfox.documentation.builders.PathSelectors; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.service.ApiInfo; 9 | import springfox.documentation.service.Contact; 10 | import springfox.documentation.spi.DocumentationType; 11 | import springfox.documentation.spring.web.plugins.Docket; 12 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 13 | 14 | /** 15 | * Swagger配置类 16 | * @author Darod 17 | * @version 1.0 18 | * @date 2019/6/21 0021 8:16 19 | */ 20 | @Configuration 21 | @EnableSwagger2 22 | public class SwaggerConfiguration { 23 | @Bean 24 | public Docket createRestApi() { 25 | 26 | return new Docket(DocumentationType.SWAGGER_2) 27 | .select() 28 | .apis(RequestHandlerSelectors.basePackage("org.darod.elearning.gateway.controller")) 29 | //过滤默认错误api 30 | .paths(PathSelectors.any()) 31 | .build() 32 | .apiInfo(apiInfo()); 33 | } 34 | 35 | private ApiInfo apiInfo() { 36 | return new ApiInfoBuilder() 37 | .title("Elearning接口文档") 38 | .description("Elearning网关接口文档") 39 | //版本 40 | .version("0.0.4") 41 | .contact(new Contact("Darod","","darod@qq.com")) 42 | .build(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/utils/URLUtils.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.utils; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | /** 6 | * @author Darod 7 | * @version 1.0 8 | * @date 2019/7/24 0024 18:22 9 | */ 10 | public class URLUtils { 11 | public static String getRealUrlFileName(String name, String suffix) { 12 | if (StringUtils.isEmpty(name)) return null; 13 | int i = name.lastIndexOf("/"); 14 | if (i > 0) { 15 | String fileName = name.substring(i + 1); 16 | int i2 = fileName.lastIndexOf(suffix); 17 | if (i2 < 0) 18 | return fileName; 19 | else 20 | return fileName.substring(0, i2); 21 | } 22 | return null; 23 | } 24 | 25 | public static void main(String[] args) { 26 | System.out.println(getRealUrlFileName("/roor/adsafa/qweqwe/zczfd.vsd", "zffadgafadsd")); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/utils/ValidateUtils.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.utils; 2 | 3 | import java.util.Random; 4 | import java.util.regex.Matcher; 5 | import java.util.regex.Pattern; 6 | 7 | /** 8 | * @author Darod 9 | * @version 1.0 10 | * @date 2019/7/8 0008 21:23 11 | */ 12 | public class ValidateUtils { 13 | private static final String phoneNumRegex = "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\\d{8}$"; 14 | 15 | public static boolean isPhoneNumLegal(String phone) { 16 | if (phone.length() != 11) { 17 | return false; 18 | } else { 19 | Pattern p = Pattern.compile(phoneNumRegex); 20 | Matcher m = p.matcher(phone); 21 | return m.matches(); 22 | } 23 | } 24 | 25 | public static String getRamdomOtp() { 26 | //生成OTP验证码 27 | Random random = new Random(); 28 | int randomInt = random.nextInt(99999); 29 | return String.valueOf(randomInt); 30 | } 31 | 32 | public static void main(String[] args) { 33 | System.out.println(isPhoneNumLegal("13131313131")); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/viewobject/CourseLearnedVO.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.viewobject; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * @author Darod 10 | * @version 1.0 11 | * @date 2019/7/1 0001 15:04 12 | */ 13 | @Data 14 | public class CourseLearnedVO { 15 | private Integer userId; 16 | private String courseName; 17 | private Integer teacherId; 18 | private Date publishTime; 19 | private Double price; 20 | private Integer learnNum; 21 | private Integer courseState; 22 | // private String firstTag; 23 | // private String secondTag; 24 | // private String thirdTag; 25 | // private String courseDescription; 26 | private String courseImgUrl; 27 | // private String courseId; 28 | @JSONField(format = "yyyy-MM-dd") 29 | private Date learnTime; 30 | private Integer lastChapter; 31 | private String chapterName; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/java/org/darod/elearning/gateway/viewobject/UserVO.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.gateway.viewobject; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import lombok.Data; 5 | 6 | import javax.validation.constraints.Max; 7 | import javax.validation.constraints.Min; 8 | import javax.validation.constraints.NotBlank; 9 | import javax.validation.constraints.NotNull; 10 | 11 | /** 12 | * @author Darod 13 | * @version 1.0 14 | * @date 2019/7/7 0007 22:18 15 | */ 16 | @Data 17 | public class UserVO { 18 | private Integer id; 19 | // @NotBlank(message = "用户名不能为空") 20 | private String name; 21 | // @NotNull(message = "性别不能为空") 22 | private Integer gender; 23 | // @NotNull(message = "年龄不能为空") 24 | @Min(value = 0, message = "年龄必须大于0岁") 25 | @Max(value = 150, message = "年龄不能大于150岁") 26 | private Integer age; 27 | // @NotBlank(message = "手机号不能为空") 28 | private String telphone; 29 | // private String registerMode; 30 | // private String thirdPartyId; 31 | // @NotBlank(message = "密码不能为空") 32 | private String email; 33 | // @NotNull(message = "头像URL不能为空") 34 | // @URL(message = "URL格式不正确") 35 | private String headUrl; 36 | // @NotNull(message = "用户状态不能为空") 37 | private Integer userState; 38 | } 39 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/META-INF/spring-devtools.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #restart.include.projectcommon=/shiro-[\\w-.]+.jar 5 | 6 | #restart.include.projectcommon=/mycorp-myproj-[\\w\\d-\.]+\.jar 7 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | server.port=8091 3 | spring.application.name=elearning-gateway 4 | spring.http.encoding.charset=UTF-8 5 | spring.http.encoding.force=true 6 | 7 | 8 | #设置上传文件大小 9 | spring.servlet.multipart.max-file-size=30MB 10 | spring.servlet.multipart.max-request-size=30MB 11 | 12 | #mybatis.org.darod.elearning.gateway.daocations=classpath:mapping/*.xml 13 | # 14 | #spring.datasource.name=miaosha 15 | #spring.datasource.url=jdbc:mysql://::1:3306/miaosha?useUnicode=true&allowPublicKeyRetrieval=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT&tinyInt1isBit=false 16 | #spring.datasource.username=test 17 | #spring.datasource.password=qq123456 18 | # 19 | #spring.datasource.type=com.alibaba.druid.pool.DruidDataSource 20 | #spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 21 | 22 | dubbo.registry.address=zookeeper://192.168.205.139:2181 23 | 24 | 25 | 26 | #拆分前添加的 27 | mybatis.mapper-locations=classpath:mapping/*.xml 28 | 29 | spring.datasource.name=elearning_user 30 | spring.datasource.url=jdbc:mysql://::1:3306/elearning_user?useUnicode=true&allowPublicKeyRetrieval=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT&tinyInt1isBit=false 31 | spring.datasource.username=test 32 | spring.datasource.password=qq123456 33 | 34 | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource 35 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 36 | 37 | #PageHelper 38 | pagehelper.helper-dialect=mysql 39 | pagehelper.reasonable=true 40 | pagehelper.support-methods-arguments=true 41 | pagehelper.params=count=countSql 42 | 43 | # Redis数据库索引(默认为0) 44 | spring.redis.database=0 45 | # Redis服务器地址 46 | #spring.redis.host=192.168.205.139 47 | spring.redis.host=127.0.0.1 48 | # Redis服务器连接端口 49 | spring.redis.port=6379 50 | # Redis服务器连接密码(默认为空) 51 | #spring.redis.password=qq123456 52 | # 连接池最大连接数(使用负值表示没有限制) 53 | spring.redis.jedis.pool.max-active=200 54 | # 连接池最大阻塞等待时间(使用负值表示没有限制) 55 | spring.redis.jedis.pool.max-wait=-1 56 | # 连接池中的最大空闲连接 57 | spring.redis.jedis.pool.max-idle=10 58 | # 连接池中的最小空闲连接 59 | spring.redis.jedis.pool.min-idle=0 60 | # 连接超时时间(毫秒) 61 | spring.redis.timeout=1000 62 | 63 | 64 | org.darod.elearning.gateway.live_key=D2kE8ESgzGtylKwyLcVfQRKkrMPfmKEo 65 | org.darod.elearning.gateway.rtmp_address=rtmp://192.168.205.139/live 66 | org.darod.elearning.gateway.rabbitmqHost=192.168.205.139 67 | org.darod.elearning.gateway.rabbitmqUser=admin 68 | org.darod.elearning.gateway.rabbitmqPassword=admin -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/403.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 没有权限! 9 | 10 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/css/bootstrap-reboot.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v4.2.1 (https://getbootstrap.com/) 3 | * Copyright 2011-2018 The Bootstrap Authors 4 | * Copyright 2011-2018 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */*,*::before,*::after{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0)}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus{outline:0 !important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[title],abbr[data-original-title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul,dl{margin-top:0;margin-bottom:1rem}ol ol,ul ul,ol ul,ul ol{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([tabindex]){color:inherit;text-decoration:none}a:not([href]):not([tabindex]):hover,a:not([href]):not([tabindex]):focus{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:0}pre,code,kbd,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}input,button,select,optgroup,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}button,[type="button"],[type="reset"],[type="submit"]{-webkit-appearance:button}button::-moz-focus-inner,[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner{padding:0;border-style:none}input[type="radio"],input[type="checkbox"]{box-sizing:border-box;padding:0}input[type="date"],input[type="time"],input[type="datetime-local"],input[type="month"]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type="number"]::-webkit-inner-spin-button,[type="number"]::-webkit-outer-spin-button{height:auto}[type="search"]{outline-offset:-2px;-webkit-appearance:none}[type="search"]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none !important} -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/css/bootstrap-reboot.min.min.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/981011512/Elearning/879e522baa7924fe7d768be1752da1eab2fab773/Elearning-gateway/src/main/resources/static/css/bootstrap-reboot.min.min.css -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/css/swiper.min.min.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/981011512/Elearning/879e522baa7924fe7d768be1752da1eab2fab773/Elearning-gateway/src/main/resources/static/css/swiper.min.min.css -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/981011512/Elearning/879e522baa7924fe7d768be1752da1eab2fab773/Elearning-gateway/src/main/resources/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/981011512/Elearning/879e522baa7924fe7d768be1752da1eab2fab773/Elearning-gateway/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/981011512/Elearning/879e522baa7924fe7d768be1752da1eab2fab773/Elearning-gateway/src/main/resources/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/981011512/Elearning/879e522baa7924fe7d768be1752da1eab2fab773/Elearning-gateway/src/main/resources/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/js/live.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(document).ready(function () { 4 | 5 | }); 6 | 7 | 8 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 用户登录 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 46 | 47 | 48 |
49 |
50 |

用户登录

51 |
52 |
53 |
54 |
55 |
56 |
58 |
59 |
60 |
61 |
63 |
64 |
65 |
66 | 67 |
68 |
69 | 没有账号?点击注册 70 | 71 |
72 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/mycss/base.css: -------------------------------------------------------------------------------- 1 | 2 | .navbar-nav li:hover a { 3 | color: #2270ef !important; 4 | } 5 | 6 | #head_div img { 7 | border-radius: 50%; 8 | vertical-align: middle; 9 | /*border: 2px solid;*/ 10 | } 11 | 12 | #alarm_ico { 13 | color: #b9bbbe; 14 | } 15 | 16 | /*灰色字体*/ 17 | .gray_font_color { 18 | color: #b9bbbe; 19 | } 20 | 21 | .green_font_color { 22 | color: limegreen; 23 | } 24 | 25 | .red_font_color { 26 | color: red; 27 | } 28 | .blue_font_color { 29 | color: #1c72e2; 30 | } 31 | 32 | 33 | /*自定义的按钮组件*/ 34 | .my_button { 35 | border-width: 1px; 36 | border-style: solid; 37 | border-radius: 5px; 38 | cursor: pointer; 39 | background-color: white; 40 | padding: 8px; 41 | } 42 | 43 | .my_button_primary { 44 | color: #007bff; 45 | border-bottom-color: #007bff; 46 | } 47 | 48 | .my_button_danger { 49 | color: #007bff; 50 | border-bottom-color: #007bff; 51 | } 52 | 53 | /*#alarm_ico :hover {*/ 54 | /* color: #2270ef;*/ 55 | /*}*/ 56 | 57 | #user_flex { 58 | display: none; 59 | margin-top: 0.3rem; 60 | position: absolute; 61 | z-index: 9999; 62 | width: 20rem; 63 | height: auto; 64 | box-shadow: 0 5px 10px 0 #6c757d; 65 | } 66 | 67 | #user_flex img { 68 | width: 5rem; 69 | height: 5rem; 70 | border-radius: 50%; 71 | } 72 | 73 | /*用户悬浮窗按钮*/ 74 | .user_flex_btn { 75 | width: 8rem; 76 | height: 2rem; 77 | background-color: #eceef0; 78 | display: flex; 79 | align-items: center; 80 | justify-content: center; 81 | border-radius: 5px; 82 | text-decoration: none; 83 | color: black; 84 | } 85 | 86 | .user_flex_btn:hover { 87 | background-color: #007bff; 88 | color: white; 89 | text-decoration: none; 90 | } 91 | 92 | body { 93 | min-width: 95rem; 94 | background-color: #f5f6f7; 95 | } 96 | 97 | 98 | .nav-link { 99 | font-size: 1.3rem; 100 | } 101 | 102 | #nav_bar { 103 | display: block; 104 | } 105 | 106 | #footer_div { 107 | display: flex; 108 | justify-content: center; 109 | align-items: center; 110 | width: auto; 111 | height: 8rem; 112 | background-color: #343a40; 113 | } 114 | 115 | #alarm_ico_count { 116 | width: 20px; 117 | height: 20px; 118 | position: absolute; 119 | left: 20px; 120 | top: 3px; 121 | font-size: 13px; 122 | background-color: red; 123 | color: white; 124 | border-radius: 50%; 125 | } 126 | 127 | #alarm_ico_count :hover { 128 | color: white; 129 | } 130 | 131 | .alert { 132 | display: none; 133 | position: fixed; 134 | top: 50%; 135 | left: 50%; 136 | min-width: 5rem; 137 | max-width: 20rem; 138 | transform: translate(-50%, -50%); 139 | z-index: 99999; 140 | text-align: center; 141 | padding: 5px; 142 | border-radius: 3px; 143 | } 144 | 145 | .alert-success { 146 | color: #3c763d; 147 | background-color: #dff0d8; 148 | border-color: #d6e9c6; 149 | } 150 | 151 | .alert-info { 152 | color: #31708f; 153 | background-color: #d9edf7; 154 | border-color: #bce8f1; 155 | } 156 | 157 | .alert-warning { 158 | color: #8a6d3b; 159 | background-color: #fcf8e3; 160 | border-color: #faebcc; 161 | } 162 | 163 | .alert-danger { 164 | color: #a94442; 165 | background-color: #f2dede; 166 | border-color: #ebccd1; 167 | } 168 | 169 | #search_bar { 170 | margin-left: 400px; 171 | } 172 | 173 | 174 | @media screen and (max-device-width: 960px) { 175 | #user_flex { 176 | left: 50%; 177 | transform: translateX(-50%); 178 | } 179 | 180 | #nav_bar { 181 | display: flex; 182 | } 183 | 184 | body { 185 | min-width: 0 !important; 186 | } 187 | 188 | #search_bar { 189 | margin-left: 0; 190 | width: 100%; 191 | } 192 | #search_bar form{ 193 | width: 100%; 194 | } 195 | #search_bar form input{ 196 | width: 80%; 197 | } 198 | #search_bar form button{ 199 | width: 20%; 200 | } 201 | 202 | /*#head_div {*/ 203 | /* margin-left: auto;*/ 204 | /* margin-right: auto;*/ 205 | /*}*/ 206 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/myjs/ajaxutils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 发送ajax请求 并使用重载的POST方法实现PUT DELETE方法 需要后端开启对应的拦截器 3 | * @param options:{ 4 | * type : HTTP方法类型, 5 | * data :参数的键值对, 6 | * url : 请求的URL, 7 | * success : 成功回调, 8 | * error : 失败回调, 9 | * contentType:消息体内容类型 10 | * } 11 | */ 12 | window.debug = false; 13 | 14 | function send_ajax(options) { 15 | if (options.type == "GET") { //get方法把参数放在url里 16 | options.url.replace(/{(.*?)}/g, function (result) { 17 | let dateName = result.substr(1, -1); //获取{中的属性名} 18 | if(options.data[dateName] != null) 19 | return options.data[dateName]; 20 | return ""; 21 | }); 22 | options.data = null; //GET方法没有data域 23 | } 24 | if (options.data != null) { 25 | options.data = JSON.stringify(options.data); 26 | } 27 | $.ajax({ 28 | type: options.type == null ? "POST" : options.type, 29 | datatype: "json", 30 | data: options.data, 31 | contentType: options.contentType == null ? "application/json;charset=utf-8" : options.contentType, 32 | url: options.url, 33 | success: options.success, 34 | async: options.async == null ? true : options.async, 35 | error: options.error == null ? function () { 36 | fail_toast("发生未知错误!"); 37 | } : options.error, 38 | }); 39 | } 40 | 41 | function send_ajax_quick(options) { 42 | send_ajax({ 43 | type: options.type, 44 | url: options.url, 45 | data: options.data, 46 | async: options.async == null ? true : options.async, 47 | success: function (data) { 48 | if (data.status == 200) { 49 | if (options.success == null) { 50 | success_toast(options.option + "成功!"); 51 | } else { 52 | options.success(data.data); 53 | } 54 | } else { 55 | fail_toast(options.option + "失败!原因是:" + data.message); 56 | } 57 | }, 58 | error: options.error == null ? function () { 59 | fail_toast(options.option + "失败!发生未知错误"); 60 | } : options.error, 61 | }) 62 | } 63 | 64 | function send_ajax_quick_quick(url, optionName, dataModel, modal, success, additional, type) { 65 | let data = $.bindModelReverse(dataModel); 66 | if (additional != null) { 67 | for (let i in additional) 68 | data[i] = additional[i]; 69 | } 70 | send_ajax_quick({ 71 | type: type, 72 | url: url, 73 | data: data, 74 | option: optionName, 75 | success: function (data) { 76 | success_toast(optionName + "成功!"); 77 | if (modal != null) 78 | modal.modal("hide"); 79 | if (success != null) { 80 | success(data); 81 | } 82 | } 83 | }); 84 | } 85 | 86 | function uploadFile(url, file, fileName, limitSize, options, success, error, xhr) { 87 | if (file == null) { 88 | fail_toast("未选择任何文件!") 89 | return false; 90 | } 91 | if (file.size > limitSize) { 92 | fail_toast("文件大小超过限制!") 93 | return false; 94 | } 95 | let formData = new FormData(); 96 | formData.append(fileName, file); 97 | formData.append('token', window.token); 98 | for (let option in options) { 99 | formData.append(option, options[option]); 100 | } 101 | let ajaxBody = { 102 | url: url, 103 | type: 'POST', 104 | cache: false, 105 | data: formData, 106 | processData: false, 107 | contentType: false, 108 | success: success, 109 | error: error 110 | }; 111 | if (xhr != null) { 112 | ajaxBody["xhr"] = xhr; 113 | } 114 | $.ajax(ajaxBody); 115 | return true; 116 | } -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/register.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 账号注册 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |

用户注册

17 |
18 |
个人信息
19 |
20 |
21 |
22 |
23 |
24 | 25 |
26 |
27 |
28 |
29 |
30 | 31 |
32 |
33 |
34 |
35 | 36 |
37 |
38 | 42 |
43 |
44 | 45 |
46 |
47 |
48 |
49 | 55 |
56 |
57 | 58 |
59 |
60 |
61 |
62 |
63 | 64 |
65 |
66 |
67 | 68 |
69 |
70 |
71 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/resources/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/981011512/Elearning/879e522baa7924fe7d768be1752da1eab2fab773/Elearning-gateway/src/main/resources/static/resources/background.jpg -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/resources/test_head.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/981011512/Elearning/879e522baa7924fe7d768be1752da1eab2fab773/Elearning-gateway/src/main/resources/static/resources/test_head.png -------------------------------------------------------------------------------- /Elearning-gateway/src/main/resources/static/resources/test_head_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/981011512/Elearning/879e522baa7924fe7d768be1752da1eab2fab773/Elearning-gateway/src/main/resources/static/resources/test_head_2.png -------------------------------------------------------------------------------- /Elearning-live/Elearning-live.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Elearning-live/src/main/java/org/darod/elearning/live/configuration/WebSocketConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.live.configuration; 2 | 3 | import org.darod.elearning.live.interceptor.HandshakeInterceptor; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.messaging.simp.config.MessageBrokerRegistry; 8 | import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; 9 | import org.springframework.web.socket.config.annotation.StompEndpointRegistry; 10 | import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; 11 | import org.springframework.web.socket.server.standard.ServerEndpointExporter; 12 | 13 | /** 14 | * @author Darod 15 | * @version 1.0 16 | * @date 2019/8/2 0002 12:44 17 | */ 18 | @Configuration 19 | @EnableWebSocketMessageBroker 20 | public class WebSocketConfiguration implements WebSocketMessageBrokerConfigurer { 21 | @Bean 22 | public ServerEndpointExporter serverEndpointExporter() { 23 | return new ServerEndpointExporter(); 24 | } 25 | 26 | @Value("${org.darod.elearning.gateway.rabbitmqHost}") 27 | private String rabbitmqHost; 28 | @Value("${org.darod.elearning.gateway.rabbitmqUser}") 29 | private String rabbitmqUser; 30 | @Value("${org.darod.elearning.gateway.rabbitmqPassword}") 31 | private String rabbitmqPassword; 32 | 33 | @Override 34 | public void registerStompEndpoints(StompEndpointRegistry registry) { 35 | registry.addEndpoint("/live_socket").setAllowedOrigins("*").withSockJS() 36 | .setHeartbeatTime(60) 37 | .setClientLibraryUrl("https://cdn.bootcss.com/sockjs-client/1.1.0/sockjs.js") 38 | .setInterceptors(new HandshakeInterceptor()); 39 | } 40 | 41 | @Override 42 | public void configureMessageBroker(MessageBrokerRegistry config) { 43 | // config.setApplicationDestinationPrefixes("/app") 44 | // .enableStompBrokerRelay("/topic", "/queue") 45 | // .setRelayHost(rabbitmqHost) 46 | // .setRelayPort(61613) 47 | // .setClientLogin(rabbitmqUser) 48 | // .setClientPasscode(rabbitmqPassword) 49 | // .setSystemLogin(rabbitmqUser) 50 | // .setSystemPasscode(rabbitmqPassword) 51 | // .setSystemHeartbeatSendInterval(5000) 52 | // .setSystemHeartbeatReceiveInterval(4000); 53 | config.enableSimpleBroker("/topic"); 54 | config.setApplicationDestinationPrefixes("/app"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Elearning-live/src/main/java/org/darod/elearning/live/controller/BarrageController.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.live.controller; 2 | 3 | import org.darod.elearning.common.dto.Shout; 4 | import org.springframework.messaging.handler.annotation.MessageMapping; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.CrossOrigin; 7 | 8 | /** 9 | * @author Darod 10 | * @version 1.0 11 | * @date 2019/8/2 0002 22:26 12 | */ 13 | @Controller 14 | @CrossOrigin("*") 15 | public class BarrageController { 16 | 17 | @MessageMapping("/liveroom_*") 18 | public Shout handle(Shout shout) { 19 | return shout; 20 | } 21 | } 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Elearning-live/src/main/java/org/darod/elearning/live/interceptor/HandshakeInterceptor.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.live.interceptor; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.server.ServerHttpRequest; 5 | import org.springframework.http.server.ServerHttpResponse; 6 | import org.springframework.web.socket.WebSocketHandler; 7 | import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; 8 | 9 | import java.util.Map; 10 | 11 | /** 12 | * @author Darod 13 | * @version 1.0 14 | * @date 2019/8/5 0005 23:44 15 | */ 16 | public class HandshakeInterceptor extends HttpSessionHandshakeInterceptor { 17 | 18 | @Override 19 | public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map attributes) throws Exception { 20 | System.out.println("开始握手"); 21 | return super.beforeHandshake(request, response, wsHandler, attributes); 22 | } 23 | 24 | @Override 25 | public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception ex) { 26 | System.out.println("结束握手"); 27 | super.afterHandshake(request, response, wsHandler, ex); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Elearning-live/src/main/java/org/darod/elearning/live/interceptor/MyChannelInterceptor.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.live.interceptor; 2 | 3 | import org.apache.dubbo.config.annotation.Reference; 4 | import org.darod.elearning.common.service.user.LiveService; 5 | import org.springframework.messaging.Message; 6 | import org.springframework.messaging.MessageChannel; 7 | import org.springframework.messaging.simp.stomp.StompCommand; 8 | import org.springframework.messaging.simp.stomp.StompHeaderAccessor; 9 | import org.springframework.messaging.support.ChannelInterceptor; 10 | 11 | /** 12 | * @author Darod 13 | * @version 1.0 14 | * @date 2019/8/7 0007 23:44 15 | */ 16 | public class MyChannelInterceptor implements ChannelInterceptor { 17 | 18 | @Reference 19 | LiveService liveService; 20 | 21 | @Override 22 | public void afterSendCompletion(Message message, MessageChannel channel, boolean sent, Exception ex) { 23 | StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message); 24 | StompCommand command = accessor.getCommand(); 25 | if (StompCommand.SUBSCRIBE.equals(command)) { 26 | liveService.incWatchNum(getChannelIdFromDestination(accessor.getDestination())); //连接建立成功 增加观看人数 27 | } 28 | if (StompCommand.DISCONNECT.equals(command)) { 29 | liveService.decrWatchNum(getChannelIdFromDestination(accessor.getDestination())); //断开后减少观看人数 30 | } 31 | } 32 | 33 | 34 | @Override 35 | public Message preSend(Message message, MessageChannel channel) { 36 | StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message); 37 | StompCommand command = accessor.getCommand(); 38 | if (StompCommand.SUBSCRIBE.equals(command)) { 39 | String channelId = getChannelIdFromDestination(accessor.getDestination()); 40 | if (liveService.isLiveExist(channelId)) { 41 | return message; 42 | } else { 43 | return null; 44 | } 45 | } else { 46 | return message; 47 | } 48 | } 49 | 50 | private String getChannelIdFromDestination(String des) { 51 | if (des == null) return ""; 52 | return des.substring(des.lastIndexOf("/") + 1); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Elearning-user/src/main/java/org/darod/elearning/user/UserApplication.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.user; 2 | 3 | import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.ConfigurableApplicationContext; 7 | 8 | /** 9 | * @author Darod 10 | * @version 1.0 11 | * @date 2019/6/20 0020 20:07 12 | */ 13 | //@EnableDubbo 14 | @SpringBootApplication 15 | public class UserApplication { 16 | public static void main(String[] args) { 17 | ConfigurableApplicationContext context = SpringApplication.run(UserApplication.class, args); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Elearning-user/src/main/java/org/darod/elearning/user/serviceimpl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.darod.elearning.user.serviceimpl; 2 | 3 | import org.apache.dubbo.config.annotation.Service; 4 | import org.darod.elearning.common.dto.UserModel; 5 | import org.darod.elearning.common.exception.BusinessException; 6 | import org.darod.elearning.common.service.user.UserService; 7 | 8 | /** 9 | * @author Darod 10 | * @version 1.0 11 | * @date 2019/6/20 0020 15:20 12 | */ 13 | //@Service 14 | //public class UserServiceImpl implements UserService { 15 | // 16 | // 17 | // @Override 18 | // public UserModel getUserById(int id) { 19 | // return null; 20 | // } 21 | // 22 | // @Override 23 | // public void register(UserModel userModel) throws BusinessException { 24 | // 25 | // } 26 | // 27 | // @Override 28 | // public UserModel validateLogin(String telphone, String encryptPassword) throws BusinessException { 29 | // return null; 30 | // } 31 | // 32 | // @Override 33 | // public String hello() { 34 | // return "hello"; 35 | // } 36 | //} 37 | -------------------------------------------------------------------------------- /Elearning-user/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8092 2 | 3 | spring.application.name=elearning-user 4 | 5 | mybatis.mapper-locations=classpath:mapping/*.xml 6 | 7 | spring.datasource.name=elearning_user 8 | spring.datasource.url=jdbc:mysql://::1:3306/elearning_user?useUnicode=true&allowPublicKeyRetrieval=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT&tinyInt1isBit=false 9 | spring.datasource.username=test 10 | spring.datasource.password=qq123456 11 | 12 | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource 13 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 14 | 15 | #dubbo 16 | dubbo.application.name=${spring.application.name} 17 | dubbo.registry.address=zookeeper://192.168.205.139:2181 18 | dubbo.protocol.name=dubbo 19 | dubbo.protocol.port=20880 20 | dubbo.scan.base-packages=org.darod.elearning.user.org.darod.elearning.gateway.serviceimpl 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2019-08-08:v0.1.1 2 | 增加弹幕系统 3 | 2019-07-24:v0.1.0 4 | 加入直播模块 5 | 2019-07-20:v0.0.9 6 | 2019-07-16:v0.0.8 7 | 2019-07-01:v0.0.6 8 | 引入shiro进行登录和权限管理 9 | 完善个人信息页面 10 | 2019-06-28:v0.0.5 11 | 完成用户个人信息页面、课程管理页面 12 | 2019-06-20:v0.0.4 13 | 基本架构搭建 14 | 2019-06-19:v0.0.1 15 | 项目启动 16 | --------------------------------------------------------------------------------