From b144856549c7db55a804bbe4c6225cd0ced3afcb Mon Sep 17 00:00:00 2001 From: DengMin <16679070171@qq.com> Date: Tue, 22 Mar 2022 17:20:21 +0800 Subject: [PATCH] 单设备登录 --- pom.xml | 20 ++++++++++---------- src/main/java/com/subsidy/common/Code.java | 45 --------------------------------------------- src/main/java/com/subsidy/common/configure/RedisConfig.java | 237 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------- src/main/java/com/subsidy/common/constant/Code.java | 2 +- src/main/java/com/subsidy/common/interceptor/AuthenticationInterceptor.java | 39 +++++++++++++++++++++++++++------------ src/main/java/com/subsidy/common/interceptor/LoginRequired.java | 2 +- src/main/java/com/subsidy/controller/AdministerController.java | 50 ++++++++++++++++++++++++++++++++------------------ src/main/java/com/subsidy/controller/AnsweringQuestionController.java | 6 ++++++ src/main/java/com/subsidy/controller/CategoryController.java | 8 ++++---- src/main/java/com/subsidy/controller/ClassDictController.java | 20 ++++++++++---------- src/main/java/com/subsidy/controller/ClassHourDictController.java | 5 +++-- src/main/java/com/subsidy/controller/ClassNoticeController.java | 8 +++++++- src/main/java/com/subsidy/controller/ClassTypeDictController.java | 5 +++++ src/main/java/com/subsidy/controller/CompanyDictController.java | 8 ++++---- src/main/java/com/subsidy/controller/CourseContentController.java | 8 ++++---- src/main/java/com/subsidy/controller/CourseDictController.java | 10 ++++++---- src/main/java/com/subsidy/controller/DepartmentDictController.java | 10 ++++++---- src/main/java/com/subsidy/controller/ExerciseDictController.java | 8 +++++--- src/main/java/com/subsidy/controller/ExerciseDoneHistoryController.java | 2 ++ src/main/java/com/subsidy/controller/ExerciseDoneResultController.java | 2 ++ src/main/java/com/subsidy/controller/FieldDictController.java | 5 +++++ src/main/java/com/subsidy/controller/FileDictController.java | 8 ++++---- src/main/java/com/subsidy/controller/JobDictController.java | 5 +++++ src/main/java/com/subsidy/controller/MemberController.java | 22 +++++++++++++++------- src/main/java/com/subsidy/controller/OprAdmDictController.java | 2 ++ src/main/java/com/subsidy/controller/OprMemDictController.java | 2 ++ src/main/java/com/subsidy/controller/PaperDictController.java | 8 ++++---- src/main/java/com/subsidy/controller/RankDictController.java | 5 +++++ src/main/java/com/subsidy/controller/RotationImgDictController.java | 5 +++++ src/main/java/com/subsidy/controller/SignInRecordController.java | 5 ++++- src/main/java/com/subsidy/controller/VodDictController.java | 8 ++++---- src/main/java/com/subsidy/controller/VodPlayHistoryController.java | 7 +++++++ src/main/java/com/subsidy/service/impl/MemberServiceImpl.java | 18 ++++++++++++++---- src/main/java/com/subsidy/util/RedisUtil.java | 1253 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/main/java/com/subsidy/vo/administer/UserRoleVO.java | 2 ++ src/main/java/com/subsidy/vo/member/MemberVO.java | 2 ++ src/main/resources/application-prod.properties | 6 +++--- src/main/resources/code.properties | 1 + 38 files changed, 961 insertions(+), 898 deletions(-) delete mode 100644 src/main/java/com/subsidy/common/Code.java diff --git a/pom.xml b/pom.xml index 09d7345..95e2f29 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 5.2.0 5.4.1 3.10.3 - + 3.3.0 @@ -192,21 +192,21 @@ 1.0.7 - - - - + + org.springframework.boot + spring-boot-starter-data-redis + org.springframework.boot spring-boot-starter-quartz - - - - - + + redis.clients + jedis + ${jedis.version} + diff --git a/src/main/java/com/subsidy/common/Code.java b/src/main/java/com/subsidy/common/Code.java deleted file mode 100644 index 91afe9e..0000000 --- a/src/main/java/com/subsidy/common/Code.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.subsidy.common; - -public enum Code { - - USERNAMENOTFOUND(10001, "用户不存在"), - BADCREDENTIALS(10002,"账户或者密码错误"), - ACCOUNTEXPIRED(10003,"账户过期"), - LOCKEDEXCEPTION(10004, "账户已锁定"), - DISABLEDEXCEPTION(10005,"账户已禁用"), - ACCESSDENIED(10006,"无权限访问"), - AUTHENTICATION(10007,"身份验证异常"), - NOHANDLERFOUND(10008,"找不到相应的视图处理器"), - PARAM_INVALID(10009, "参数不合法"), - TOKEN_EXCEPTION(10010, "Token不合法"), - TOKEN_EXPIRED(10011, "Token已过期"), - OSS_ERROR(10012, "OSS文件上传异常"), - Network_ERROR(90000, "网络请求失败"), - SERVER_INTERNAL_ERROR(99999, "服务器内部错误"), - ; - - private Integer code; - - private String message; - - Code(Integer code, String message) { - this.code = code; - this.message = message; - } - - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/src/main/java/com/subsidy/common/configure/RedisConfig.java b/src/main/java/com/subsidy/common/configure/RedisConfig.java index 3a4abf8..63cf2de 100644 --- a/src/main/java/com/subsidy/common/configure/RedisConfig.java +++ b/src/main/java/com/subsidy/common/configure/RedisConfig.java @@ -1,115 +1,122 @@ -//package com.subsidy.common.configure; -// -//import com.fasterxml.jackson.annotation.JsonAutoDetect; -//import com.fasterxml.jackson.annotation.PropertyAccessor; -//import com.fasterxml.jackson.databind.ObjectMapper; -//import org.springframework.cache.annotation.CachingConfigurerSupport; -//import org.springframework.cache.annotation.EnableCaching; -//import org.springframework.context.annotation.Bean; -//import org.springframework.context.annotation.Configuration; -// -//@EnableCaching -// -///** -// *

-// * Redis -// *

-// * -// * @author DengMin -// * @since 2020/12/14 -// */ -//@Configuration -//public class RedisConfig extends CachingConfigurerSupport { -// -// /** -// * retemplate相关配置 -// * @param factory -// * @return -// */ -// @Bean -// public RedisTemplate redisTemplate(RedisConnectionFactory factory) { -// -// RedisTemplate template = new RedisTemplate<>(); -// // 配置连接工厂 -// template.setConnectionFactory(factory); -// -// //使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式) -// Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class); -// -// ObjectMapper om = new ObjectMapper(); -// // 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public -// om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); -// // 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常 -// om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); -// jacksonSeial.setObjectMapper(om); -// -// // 值采用json序列化 -// template.setValueSerializer(jacksonSeial); -// //使用StringRedisSerializer来序列化和反序列化redis的key值 -// template.setKeySerializer(new StringRedisSerializer()); -// -// // 设置hash key 和value序列化模式 -// template.setHashKeySerializer(new StringRedisSerializer()); -// template.setHashValueSerializer(jacksonSeial); -// template.afterPropertiesSet(); -// -// return template; -// } -// -// /** -// * 对hash类型的数据操作 -// * -// * @param redisTemplate -// * @return -// */ -// @Bean -// public HashOperations hashOperations(RedisTemplate redisTemplate) { -// return redisTemplate.opsForHash(); -// } -// -// /** -// * 对redis字符串类型数据操作 -// * -// * @param redisTemplate -// * @return -// */ -// @Bean -// public ValueOperations valueOperations(RedisTemplate redisTemplate) { -// return redisTemplate.opsForValue(); -// } -// -// /** -// * 对链表类型的数据操作 -// * -// * @param redisTemplate -// * @return -// */ -// @Bean -// public ListOperations listOperations(RedisTemplate redisTemplate) { -// return redisTemplate.opsForList(); -// } -// -// /** -// * 对无序集合类型的数据操作 -// * -// * @param redisTemplate -// * @return -// */ -// @Bean -// public SetOperations setOperations(RedisTemplate redisTemplate) { -// return redisTemplate.opsForSet(); -// } -// -// /** -// * 对有序集合类型的数据操作 -// * -// * @param redisTemplate -// * @return -// */ -// @Bean -// public ZSetOperations zSetOperations(RedisTemplate redisTemplate) { -// return redisTemplate.opsForZSet(); -// } -// -// -//} \ No newline at end of file +package com.subsidy.common.configure; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.cache.annotation.CachingConfigurerSupport; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.HashOperations; +import org.springframework.data.redis.core.ListOperations; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.SetOperations; +import org.springframework.data.redis.core.ValueOperations; +import org.springframework.data.redis.core.ZSetOperations; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +@EnableCaching + +/** + *

+ * Redis + *

+ * + * @author DengMin + * @since 2020/12/14 + */ +@Configuration +public class RedisConfig extends CachingConfigurerSupport { + + /** + * retemplate相关配置 + * @param factory + * @return + */ + @Bean + public RedisTemplate redisTemplate(RedisConnectionFactory factory) { + + RedisTemplate template = new RedisTemplate<>(); + // 配置连接工厂 + template.setConnectionFactory(factory); + + //使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式) + Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class); + + ObjectMapper om = new ObjectMapper(); + // 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + // 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常 + om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); + jacksonSeial.setObjectMapper(om); + + // 值采用json序列化 + template.setValueSerializer(jacksonSeial); + //使用StringRedisSerializer来序列化和反序列化redis的key值 + template.setKeySerializer(new StringRedisSerializer()); + + // 设置hash key 和value序列化模式 + template.setHashKeySerializer(new StringRedisSerializer()); + template.setHashValueSerializer(jacksonSeial); + template.afterPropertiesSet(); + + return template; + } + + /** + * 对hash类型的数据操作 + * + * @param redisTemplate + * @return + */ + @Bean + public HashOperations hashOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForHash(); + } + + /** + * 对redis字符串类型数据操作 + * + * @param redisTemplate + * @return + */ + @Bean + public ValueOperations valueOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForValue(); + } + + /** + * 对链表类型的数据操作 + * + * @param redisTemplate + * @return + */ + @Bean + public ListOperations listOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForList(); + } + + /** + * 对无序集合类型的数据操作 + * + * @param redisTemplate + * @return + */ + @Bean + public SetOperations setOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForSet(); + } + + /** + * 对有序集合类型的数据操作 + * + * @param redisTemplate + * @return + */ + @Bean + public ZSetOperations zSetOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForZSet(); + } +} \ No newline at end of file diff --git a/src/main/java/com/subsidy/common/constant/Code.java b/src/main/java/com/subsidy/common/constant/Code.java index d4a02f9..fbe57a0 100644 --- a/src/main/java/com/subsidy/common/constant/Code.java +++ b/src/main/java/com/subsidy/common/constant/Code.java @@ -15,7 +15,7 @@ public enum Code { NOHANDLERFOUND(1008,"找不到相应的视图处理器"), PARAM_INVALID(1009, "参数不合法"), TOKEN_EXCEPTION(1010, "无效的令牌"), - TOKEN_EXPIRED(1011, "令牌已过期"), + TOKEN_EXPIRED(1011, "当前账户已在其他设备登录"), TOKEN_VERIFICATION_FAILED(1013, "令牌验证失败"), OSS_ERROR(1012, "OSS文件上传异常"), Network_ERROR(9000, "网络请求失败"), diff --git a/src/main/java/com/subsidy/common/interceptor/AuthenticationInterceptor.java b/src/main/java/com/subsidy/common/interceptor/AuthenticationInterceptor.java index 94f2eeb..d18921b 100644 --- a/src/main/java/com/subsidy/common/interceptor/AuthenticationInterceptor.java +++ b/src/main/java/com/subsidy/common/interceptor/AuthenticationInterceptor.java @@ -2,11 +2,16 @@ package com.subsidy.common.interceptor; import com.auth0.jwt.interfaces.Claim; import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.subsidy.common.ResponseData; +import com.subsidy.common.ResponseVO; +import com.subsidy.common.constant.Code; import com.subsidy.common.exception.HttpException; import com.subsidy.mapper.AdministerMapper; import com.subsidy.model.AdministerDO; +import com.subsidy.util.ConstantUtils; import com.subsidy.util.JwtUtil; import com.subsidy.util.Localstorage; +import com.subsidy.util.RedisUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.method.HandlerMethod; @@ -14,7 +19,10 @@ import org.springframework.web.servlet.HandlerInterceptor; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; import java.lang.reflect.Method; +import java.nio.charset.StandardCharsets; import java.util.Map; /** @@ -31,6 +39,9 @@ public class AuthenticationInterceptor implements HandlerInterceptor { @Autowired private AdministerMapper administerMapper; + @Autowired + private RedisUtil redisUtil; + @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { // 不需要进行拦截 @@ -55,27 +66,31 @@ public class AuthenticationInterceptor implements HandlerInterceptor { Map claimMap = JwtUtil.getClaims(token); if (claimMap != null) { - String[] role = methodAnnotation.value(); + //String[] role = methodAnnotation.value(); String type = claimMap.get("type").asString(); - if (role.length > 0) { - if ("administer".equals(type)) { - AdministerDO administerDO = administerMapper.selectById(claimMap.get("id").asLong()); - if (administerDO != null) { - Localstorage.setUser(administerDO); + if (ConstantUtils.ADMINISTER_TERMINATE.equals(type)) { + AdministerDO administerDO = administerMapper.selectById(claimMap.get("id").asLong()); + if (administerDO != null) { + Localstorage.setUser(administerDO); + return true; + } + } else if(ConstantUtils.MOBILE_TERMINATE.equals(type)) { + /** + * 学生端设置单设备登录 + */ + String tk = (String) redisUtil.get(ConstantUtils.MOBILE_TERMINATE+"_"+claimMap.get("id").asLong()); + if(StringUtils.isNotBlank(tk)) { + if(tk.equals(token)) { return true; } + throw new HttpException(1011); } else { throw new HttpException(1010); } } else { - AdministerDO administerDO = administerMapper.selectById(claimMap.get("id").asLong()); - if (administerDO != null) { - Localstorage.setUser(administerDO); - return true; - } + throw new HttpException(1010); } } - //return true; } throw new HttpException(1010); } diff --git a/src/main/java/com/subsidy/common/interceptor/LoginRequired.java b/src/main/java/com/subsidy/common/interceptor/LoginRequired.java index 19e2615..7ff944a 100644 --- a/src/main/java/com/subsidy/common/interceptor/LoginRequired.java +++ b/src/main/java/com/subsidy/common/interceptor/LoginRequired.java @@ -16,5 +16,5 @@ import java.lang.annotation.*; @Inherited public @interface LoginRequired { - String[] value(); + //String[] value(); } \ No newline at end of file diff --git a/src/main/java/com/subsidy/controller/AdministerController.java b/src/main/java/com/subsidy/controller/AdministerController.java index 91f9dfe..4b43003 100644 --- a/src/main/java/com/subsidy/controller/AdministerController.java +++ b/src/main/java/com/subsidy/controller/AdministerController.java @@ -56,53 +56,56 @@ public class AdministerController { @PostMapping("/getPermissions") @ApiOperation("权限查询") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO getPermissions() { return ResponseData.generateCreatedResponse(0, administerService.getPermissions()); } @PostMapping("/administers") @ApiOperation("查询所有运营者 { userName pageNum pageSize }") - //@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO operators(@RequestBody OperatorsDTO operatorsDTO){ return ResponseData.generateCreatedResponse(0,administerService.operators(operatorsDTO)); } @PostMapping("addAdminister") @ApiOperation("添加运营者 id userName 名称 accountName 账号 ") + @LoginRequired public ResponseVO addAdminister(@RequestBody AdministerDO administerDO){ return ResponseData.generateCreatedResponse(0,administerService.addAdminister(administerDO)); } @PostMapping("deleteAdminister") @ApiOperation("添加运营者 id ") + @LoginRequired public ResponseVO deleteAdminister(@RequestBody AdministerDO administerDO){ return ResponseData.generateCreatedResponse(0,administerService.deleteAdminister(administerDO)); } @PostMapping("updateAdminister") @ApiOperation("编辑运营者 id userName 名称 accountName 账号 password") + @LoginRequired public ResponseVO updateAdminister(@RequestBody AdministerDO administerDO){ return ResponseData.generateCreatedResponse(0,administerService.updateAdminister(administerDO)); } @PostMapping("classSummary") @ApiOperation("班级详情--数据概览 id 班级id ") -// @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO classSummary(@RequestBody ClassDetailDTO classDetailDTO){ return ResponseData.generateCreatedResponse(0,administerService.classSummary(classDetailDTO)); } @PostMapping("classDetail") @ApiOperation("班级管理--班级成员 id 班级id userName") - //@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO classDetail(@RequestBody ClassDetailDTO classDetailDTO){ return ResponseData.generateCreatedResponse(0,administerService.classDetail(classDetailDTO)); } @PostMapping("exportClassDetail") @ApiOperation("班级管理--班级成员--导出 id 班级id userName") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public void exportClassDetail(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{ classDetailDTO.setFlag(true); administerService.exportClassDetail(classDetailDTO); @@ -110,14 +113,14 @@ public class AdministerController { @PostMapping("signDetail") @ApiOperation("班级管理--注册签到 id 班级id userName") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO signDetail(@RequestBody ClassDetailDTO classDetailDTO){ return ResponseData.generateCreatedResponse(0,administerService.signDetail(classDetailDTO)); } @PostMapping("exportSignDetail") @ApiOperation("班级管理--注册签到 id 班级id userName") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public void exportSignDetail(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{ classDetailDTO.setFlag(true); administerService.exportSignDetail(classDetailDTO); @@ -125,14 +128,14 @@ public class AdministerController { @PostMapping("exerciseTest") @ApiOperation("班级管理--测评成绩 id 班级id userName paperId") - //@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO exerciseTest(@RequestBody ClassDetailDTO classDetailDTO){ return ResponseData.generateCreatedResponse(0,administerService.exerciseTest(classDetailDTO)); } @PostMapping("exportExerciseTest") @ApiOperation("班级管理--测评成绩 id 班级id userName paperId") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public void exportExerciseTest(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{ classDetailDTO.setFlag(true); administerService.exportExerciseTest(classDetailDTO); @@ -140,26 +143,28 @@ public class AdministerController { @PostMapping("getMemberPapers") @ApiOperation("获取某个成员某个卷子的做题历史 memberId paperId") + @LoginRequired public ResponseVO getMemberPapers(@RequestBody ExerciseDoneResultDO exerciseDoneResultDO){ return ResponseData.generateCreatedResponse(0,administerService.getMemberPapers(exerciseDoneResultDO)); } @PostMapping("getPaperDetail") @ApiOperation("获取某个卷子做题详情 doneId getMemberPapers接口返回id memberId成员id") + @LoginRequired public ResponseVO getPaperDetail(@RequestBody ExerciseDoneHistoryDO exerciseDoneHistoryDO){ return ResponseData.generateCreatedResponse(0,administerService.getPaperDetail(exerciseDoneHistoryDO)); } @PostMapping("answerRecord") @ApiOperation("班级管理--答疑 id 班级id userName") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO answerRecord(@RequestBody ClassDetailDTO classDetailDTO){ return ResponseData.generateCreatedResponse(0,administerService.answerRecord(classDetailDTO)); } @PostMapping("exportAnswerRecord") @ApiOperation("班级管理--答疑 id 班级id userName") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public void exportAnswerRecord(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{ classDetailDTO.setFlag(true); administerService.exportAnswerRecord(classDetailDTO); @@ -167,62 +172,71 @@ public class AdministerController { @PostMapping("classVodInfo") @ApiOperation("学习记录---课件进度提醒 {courseId 课程id classId 班级id vodName视频名称}") + @LoginRequired public ResponseVO classVodInfo(@RequestBody ClassVodInfoDTO classVodInfoDTO){ return ResponseData.generateCreatedResponse(0,administerService.classVodInfo(classVodInfoDTO)); } @PostMapping("classDailyInfo") @ApiOperation("学习记录---每日学习时长 {courseId 课程id classId 班级id userName startDate endDate}") + @LoginRequired public ResponseVO classDailyInfo(@RequestBody ClassDailyInfoDTO classDailyInfoDTO){ return ResponseData.generateCreatedResponse(0,administerService.classDailyInfo(classDailyInfoDTO)); } @PostMapping("exportClassDailyInfo") @ApiParam("每日学习日志") + @LoginRequired public void exportVodInfo(@RequestBody ClassDailyInfoDTO classDailyInfoDTO){ administerService.exportClassDailyInfo(classDailyInfoDTO); } @PostMapping("classVodDailyInfo") @ApiOperation("学习记录---每日学习时长(视频维度)") + @LoginRequired public ResponseVO classVodDailyInfo(@RequestBody ClassVodDailyInfoDTO classVodDailyInfoDTO ){ return ResponseData.generateCreatedResponse(0,administerService.classVodDailyInfo(classVodDailyInfoDTO)); } @PostMapping("exportClassVodDailyInfo") @ApiOperation("学习记录---每日学习时长(视频维度) pageSize pageNum userName classId") + @LoginRequired public void exportClassVodDailyInfo(@RequestBody ClassVodDailyInfoDTO classVodDailyInfoDTO ){ administerService.exportClassVodDailyInfo(classVodDailyInfoDTO); } + @PostMapping("memberStudy") + @ApiOperation("学员学习日志 pageSize pageNum classId memberId") + @LoginRequired + public ResponseVO memberStudy(@RequestBody MemberStudyLogDTO memberStudyLogDTO){ + return ResponseData.generateCreatedResponse(0,administerService.memberStudy(memberStudyLogDTO)); + } + @PostMapping("exportZip") @ApiOperation("下载压缩包 id 班级id") @CrossOrigin - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public void exportZip(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{ administerService.export(classDetailDTO); } - @PostMapping("memberStudy") - @ApiOperation("学员学习日志 pageSize pageNum classId memberId") - public ResponseVO memberStudy(@RequestBody MemberStudyLogDTO memberStudyLogDTO){ - return ResponseData.generateCreatedResponse(0,administerService.memberStudy(memberStudyLogDTO)); - } - @PostMapping("memberStudyLog") @ApiOperation("学员学习日志 classId memberId") + @LoginRequired public void memberStudyLog(@RequestBody MemberStudyLogDTO memberStudyLogDTO) throws Exception{ administerService.memberStudyLog(memberStudyLogDTO); } @PostMapping("importMember") @ApiOperation("导入学生 {companyId 公司id file}") + @LoginRequired public ResponseVO importMember(Long companyId,@RequestParam("file") MultipartFile file)throws Exception{ return ResponseData.generateCreatedResponse(0,administerService.importMember(companyId,file)); } @PostMapping("manageMember") @ApiOperation("用户管理 {pageSize pageNum userName:名字}") + @LoginRequired public ResponseVO manageMember(@RequestBody ManageMemberDTO manageMemberDTO){ return ResponseData.generateCreatedResponse(0,administerService.manageMember(manageMemberDTO)); } diff --git a/src/main/java/com/subsidy/controller/AnsweringQuestionController.java b/src/main/java/com/subsidy/controller/AnsweringQuestionController.java index 06ce356..65b8ca9 100644 --- a/src/main/java/com/subsidy/controller/AnsweringQuestionController.java +++ b/src/main/java/com/subsidy/controller/AnsweringQuestionController.java @@ -3,6 +3,7 @@ package com.subsidy.controller; import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; +import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.dto.course.GetCourseQuestionDTO; import com.subsidy.model.AnsweringQuestionDO; import com.subsidy.service.AnsweringQuestionService; @@ -32,30 +33,35 @@ public class AnsweringQuestionController { @PostMapping("getCourseQuestion") @ApiOperation(" 获取某个课程的答疑 {classId pageSize pageNum memberId}") + @LoginRequired public ResponseVO getCourseQuestion(@RequestBody GetCourseQuestionDTO getCourseQuestionDTO){ return ResponseData.generateCreatedResponse(0,answeringQuestionService.getCourseQuestion(getCourseQuestionDTO)); } @PostMapping("addQuestion") @ApiOperation("新增答疑 {classId askId title}") + @LoginRequired public ResponseVO addQuestion(@RequestBody AnsweringQuestionDO answeringQuestionDO){ return ResponseData.generateCreatedResponse(0,answeringQuestionService.addQuestion(answeringQuestionDO)); } @PostMapping("deleteQuestion") @ApiOperation(" 删除答疑 {id}") + @LoginRequired public ResponseVO deleteQuestion(@RequestBody AnsweringQuestionDO answeringQuestionDO){ return ResponseData.generateCreatedResponse(0,answeringQuestionService.deleteQuestion(answeringQuestionDO)); } @PostMapping("updateQuestion") @ApiOperation("编辑答疑 {id answerId answer}") + @LoginRequired public ResponseVO updateQuestion(@RequestBody AnsweringQuestionDO answeringQuestionDO){ return ResponseData.generateCreatedResponse(0, answeringQuestionService.updateQuestion(answeringQuestionDO)); } @PostMapping("getNoAnswers") @ApiOperation("获取某个课程没有回答的答疑个数 classId 课程id") + @LoginRequired public ResponseVO getNoAnswers(@RequestBody AnsweringQuestionDO answeringQuestionDO){ return ResponseData.generateCreatedResponse(0,answeringQuestionService.getNoAnswers(answeringQuestionDO)); } diff --git a/src/main/java/com/subsidy/controller/CategoryController.java b/src/main/java/com/subsidy/controller/CategoryController.java index 80ccfac..87ee8b9 100644 --- a/src/main/java/com/subsidy/controller/CategoryController.java +++ b/src/main/java/com/subsidy/controller/CategoryController.java @@ -34,7 +34,7 @@ public class CategoryController { @PostMapping("getCategories") @ApiOperation("查询类目 name 类目名称 companyId pageSize pageNum") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO getCategories(@RequestBody GetCategoriesDTO getCategoriesDTO){ return ResponseData.generateCreatedResponse(0,categoryService.getCategories(getCategoriesDTO)); } @@ -47,21 +47,21 @@ public class CategoryController { @PostMapping("addCategory") @ApiOperation("新增类目 name companyId") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO addCategory(@RequestBody CategoryDO categoryDO){ return ResponseData.generateCreatedResponse(0,categoryService.addCategory(categoryDO)); } @PostMapping("deleteCategory") @ApiOperation("删除类目 id") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO deleteCategory(@RequestBody CategoryDO categoryDO){ return ResponseData.generateCreatedResponse(0,categoryService.deleteCategory(categoryDO)); } @PostMapping("updateCategory") @ApiOperation("修改类目 id name companyId") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO updateCategory(@RequestBody CategoryDO categoryDO){ return ResponseData.generateCreatedResponse(0,categoryService.updateCategory(categoryDO)); } diff --git a/src/main/java/com/subsidy/controller/ClassDictController.java b/src/main/java/com/subsidy/controller/ClassDictController.java index e0e2ae7..835f21b 100644 --- a/src/main/java/com/subsidy/controller/ClassDictController.java +++ b/src/main/java/com/subsidy/controller/ClassDictController.java @@ -38,71 +38,71 @@ public class ClassDictController { @PostMapping("getAllClasses") @ApiOperation("获取某公司下的所有班级 companyId 所选企业id className 班级名称 openStatus 开放状态 startDate 开始时间 endDate 结束时间") - // @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO getAllClasses(@RequestBody ClassDictDO classDictDO)throws Exception{ return ResponseData.generateCreatedResponse(0,classDictService.getAllClasses(classDictDO)); } @PostMapping("deleteClasses") @ApiOperation(" 删除班级 id") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO deleteClasses(@RequestBody ClassDictDO classDictDO){ return ResponseData.generateCreatedResponse(0,classDictService.deleteClasses(classDictDO)); } @PostMapping("addClass") @ApiOperation("添加班级 userId:登录人id companyId courseId classTypeId className startDate endDate testRule 是否视频看完再做测试 isOrder 是否按照顺序播放 isFastPlay 是否快进 memberIds [] 班级学员 classNoticeDOS[noticeType noticeTime]") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO addClass(@RequestBody AddClassDTO addClassDTO){ return ResponseData.generateCreatedResponse(0,classDictService.addClass(addClassDTO)); } @PostMapping("updateClass") @ApiOperation("修改班级 id companyId className classTypeId startDate endDate") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO updateClass(@RequestBody ClassDictDO classDictDO){ return ResponseData.generateCreatedResponse(0,classDictService.updateClass(classDictDO)); } @PostMapping("classDetail") @ApiOperation("获取一个班级详情 id") - //@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO classDetail(@RequestBody ClassDictDO classDictDO){ return ResponseData.generateCreatedResponse(0,classDictService.classDetail(classDictDO)); } @PostMapping("removeMember") @ApiOperation("移除班级 classId 班级id memberId人员id") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO removeMember(@RequestBody ClassMemberMappingDO classMemberMappingDO){ return ResponseData.generateCreatedResponse(0,classDictService.removeMember(classMemberMappingDO)); } @PostMapping("getSpareMembers") @ApiOperation("获取不在某班级的某企业里所有成员 companyId 企业id classId 班级id") + @LoginRequired public ResponseVO getSpareMembers(@RequestBody GetSpareMembersDTO getSpareMembersDTO){ return ResponseData.generateCreatedResponse(0,classDictService.getSpareMembers(getSpareMembersDTO)); } @PostMapping("addMemberToClass") @ApiOperation("将多个成员加入到某个班级里 classId memberIds []") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO addMemberToClass(@RequestBody AddMemberToClassDTO addMemberToClassDTO){ return ResponseData.generateCreatedResponse(0,classDictService.addMemberToClass(addMemberToClassDTO)); } @PostMapping("batchSms") @ApiOperation(" 批量发送班级短信通知 {id 班级id }") + @LoginRequired public ResponseVO batchSms(@RequestBody ClassDictDO classDictDO){ return ResponseData.generateCreatedResponse(0,classDictService.batchSms(classDictDO)); } @PostMapping("getClassBaseInfo") @ApiOperation("班级详情--获取课程基本信息 id") + @LoginRequired public ResponseVO getClassBaseInfo(@RequestBody GetClassBaseInfoDTO getClassBaseInfoDTO){ return ResponseData.generateCreatedResponse(0,classDictService.getClassBaseInfo(getClassBaseInfoDTO)); } - - - } diff --git a/src/main/java/com/subsidy/controller/ClassHourDictController.java b/src/main/java/com/subsidy/controller/ClassHourDictController.java index 75ba8ad..f12cc73 100644 --- a/src/main/java/com/subsidy/controller/ClassHourDictController.java +++ b/src/main/java/com/subsidy/controller/ClassHourDictController.java @@ -35,20 +35,21 @@ public class ClassHourDictController { @PostMapping("getSetting") @ApiOperation("查看当天设置的最大学习时长 companyId") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO getSetting(@RequestBody ClassHourDictDO classHourDictDO){ return ResponseData.generateCreatedResponse(0,classHourDictService.getSetting(classHourDictDO)); } @PostMapping("updateSetting") @ApiOperation("修改当天设置时长 companyId 主键 logo classHour status interrupt interruptStatus repeatTime repeatStatus rotationImgDictDOS[companyId rotationImg]") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO updateSetting(@RequestBody GetSettingVO getSettingVO){ return ResponseData.generateCreatedResponse(0,classHourDictService.updateSetting(getSettingVO)); } @PostMapping("pollingGet") @ApiOperation("轮询查询当前这个人当天有没有超过最长时长 memberId playLength") + @LoginRequired public ResponseVO pollingGet(@RequestBody VodPlayHistoryDO vodPlayHistoryDO){ return ResponseData.generateCreatedResponse(0,classHourDictService.pollingGet(vodPlayHistoryDO)); } diff --git a/src/main/java/com/subsidy/controller/ClassNoticeController.java b/src/main/java/com/subsidy/controller/ClassNoticeController.java index 1e7540f..ae46912 100644 --- a/src/main/java/com/subsidy/controller/ClassNoticeController.java +++ b/src/main/java/com/subsidy/controller/ClassNoticeController.java @@ -3,6 +3,7 @@ package com.subsidy.controller; import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; +import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.dto.classNotice.SendNotificationDTO; import com.subsidy.model.ClassNoticeDO; import com.subsidy.service.ClassNoticeService; @@ -32,31 +33,36 @@ public class ClassNoticeController { private ClassNoticeService classNoticeService; @PostMapping("addNotice") - @ApiOperation("新增一个通知 classId noticeType isAuto noticeTime") + @ApiOperation("新增一个通知 classId noticeType isAuto noticeTime") + @LoginRequired public ResponseVO addNotice(@RequestBody ClassNoticeDO classNoticeDO){ return ResponseData.generateCreatedResponse(0,classNoticeService.addNotice(classNoticeDO)); } @PostMapping("updateNotice") @ApiOperation("修改一个通知 id noticeType isAuto noticeTime") + @LoginRequired public ResponseVO updateNotice(@RequestBody ClassNoticeDO classNoticeDO){ return ResponseData.generateCreatedResponse(0,classNoticeService.updateNotice(classNoticeDO)); } @PostMapping("deleteNotice") @ApiOperation("删除一个通知 id") + @LoginRequired public ResponseVO deleteNotice(@RequestBody ClassNoticeDO classNoticeDO){ return ResponseData.generateCreatedResponse(0,classNoticeService.deleteNotice(classNoticeDO)); } @PostMapping("queryClassNotices") @ApiOperation("查看某个课程的通知提醒 classId 课程id status 状态(待发送/已发送)") + @LoginRequired public ResponseVO queryClassNotices(@RequestBody ClassNoticeDO classNoticeDO){ return ResponseData.generateCreatedResponse(0,classNoticeService.queryClassNotices(classNoticeDO)); } @PostMapping("sendClassNotices") @ApiOperation("发送通知:classId/课程Id sendType/发送类型(全部成员/未签到成员/未完课成员)") + @LoginRequired public ResponseVO sendClassNotices(@RequestBody SendNotificationDTO sendNotificationDTO) { classNoticeService.sendNotification(sendNotificationDTO); return ResponseData.generateCreatedResponse(0); diff --git a/src/main/java/com/subsidy/controller/ClassTypeDictController.java b/src/main/java/com/subsidy/controller/ClassTypeDictController.java index adaff58..7d24892 100644 --- a/src/main/java/com/subsidy/controller/ClassTypeDictController.java +++ b/src/main/java/com/subsidy/controller/ClassTypeDictController.java @@ -3,6 +3,7 @@ package com.subsidy.controller; import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; +import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.dto.classDict.ClassTypeDTO; import com.subsidy.model.ClassTypeDictDO; import com.subsidy.service.ClassTypeDictService; @@ -33,24 +34,28 @@ public class ClassTypeDictController { @PostMapping("addClassType") @ApiOperation("添加课程类型 companyId 运营者公司id不传 classType") + @LoginRequired public ResponseVO addClassType(@RequestBody ClassTypeDictDO classTypeDictDO){ return ResponseData.generateCreatedResponse(0,classTypeDictService.addClassType(classTypeDictDO)); } @PostMapping("updateClassType") @ApiOperation("修改课程类型 id companyId classType") + @LoginRequired public ResponseVO updateClassType(@RequestBody ClassTypeDictDO classTypeDictDO){ return ResponseData.generateCreatedResponse(0,classTypeDictService.updateClassType(classTypeDictDO)); } @PostMapping("deleteClassType") @ApiOperation("删除课程类型 id") + @LoginRequired public ResponseVO deleteClassType(@RequestBody ClassTypeDictDO classTypeDictDO){ return ResponseData.generateCreatedResponse(0,classTypeDictService.deleteClassType(classTypeDictDO)); } @PostMapping("queryClassTypes") @ApiOperation("查询某个公司的班级类型 userId 登录人id companyId") + @LoginRequired public ResponseVO queryClassTypes(@RequestBody ClassTypeDTO classTypeDTO){ return ResponseData.generateCreatedResponse(0,classTypeDictService.queryClassTypes(classTypeDTO)); } diff --git a/src/main/java/com/subsidy/controller/CompanyDictController.java b/src/main/java/com/subsidy/controller/CompanyDictController.java index b20a1d3..5e400ac 100644 --- a/src/main/java/com/subsidy/controller/CompanyDictController.java +++ b/src/main/java/com/subsidy/controller/CompanyDictController.java @@ -35,28 +35,28 @@ public class CompanyDictController { @PostMapping("/administers") @ApiOperation("查询所有企业 {id companyName fieldId 行业id pageNum pageSize }") -// @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO operators(@RequestBody OperatorsDTO operatorsDTO){ return ResponseData.generateCreatedResponse(0,companyDictService.operators(operatorsDTO)); } @PostMapping("addCompany") @ApiOperation("添加企业 {accountName:账号 companyName:企业名称 address 企业所在地 shortName 简称 banner:标语 field[]:领域 role 1:超级管理员 2:普通成员}") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO addOperator(@RequestBody AddCompanyDTO addCompanyDTO){ return ResponseData.generateCreatedResponse(0,companyDictService.addOperator(addCompanyDTO)); } @PostMapping("deleteCompany") @ApiOperation("删除企业 id") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO deleteAdminister(@RequestBody CompanyDictDO companyDictDO){ return ResponseData.generateCreatedResponse(0,companyDictService.deleteAdminister(companyDictDO)); } @PostMapping("updateCompany") @ApiOperation("修改企业 id accountName:账号 logo companyName:企业名称 address 企业所在地 shortName 简称 banner:标语 field[]:领域 role 1:超级管理员 2:普通成员") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO updateAdminister(@RequestBody AddCompanyDTO addCompanyDTO){ return ResponseData.generateCreatedResponse(0,companyDictService.updateAdminister(addCompanyDTO)); } diff --git a/src/main/java/com/subsidy/controller/CourseContentController.java b/src/main/java/com/subsidy/controller/CourseContentController.java index 2016b71..d98275e 100644 --- a/src/main/java/com/subsidy/controller/CourseContentController.java +++ b/src/main/java/com/subsidy/controller/CourseContentController.java @@ -33,28 +33,28 @@ public class CourseContentController { @PostMapping("getContents") @ApiOperation("获取课程目录 {courseId}") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO getContents(@RequestBody CourseContentDO courseContentDO){ return ResponseData.generateCreatedResponse(0,courseContentService.getContents(courseContentDO)); } @PostMapping("deleteContent") @ApiOperation("删除一个目录 {id} ") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO deleteContent(@RequestBody CourseContentDO courseContentDO){ return ResponseData.generateCreatedResponse(0,courseContentService.deleteContent(courseContentDO)); } @PostMapping("addContent") @ApiOperation("添加一个目录 {courseId content}") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO addContent(@RequestBody CourseContentDO courseContentDO){ return ResponseData.generateCreatedResponse(0,courseContentService.addContent(courseContentDO)); } @PostMapping("updateContent") @ApiOperation("更新一个目录 {id courseId content}") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO updateContent(@RequestBody CourseContentDO courseContentDO){ return ResponseData.generateCreatedResponse(0,courseContentService.updateContent(courseContentDO)); } diff --git a/src/main/java/com/subsidy/controller/CourseDictController.java b/src/main/java/com/subsidy/controller/CourseDictController.java index f2d7671..7c1751d 100644 --- a/src/main/java/com/subsidy/controller/CourseDictController.java +++ b/src/main/java/com/subsidy/controller/CourseDictController.java @@ -36,40 +36,42 @@ public class CourseDictController { @PostMapping("addCourse") @ApiOperation("添加课程 companyId courseName courseType coverPage openStatus remark fieldDictDOS[] categoryDOS[] jobDictDOS[] rankDictDOS[]") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO addCourse(@RequestBody AddCourseDTO addCourseDTO){ return ResponseData.generateCreatedResponse(0,courseDictService.addCourse(addCourseDTO)); } @PostMapping("deleteCourse") @ApiOperation("删除课程 id") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO deleteCourse(@RequestBody CourseDictDO courseDictDO){ return ResponseData.generateCreatedResponse(0,courseDictService.deleteCourse(courseDictDO)); } @PostMapping("queryCourses") @ApiOperation("平台运营者--查询课程 pageSize pageNum courseName fieldId categoryId jobId rankId courseType openStatus") - //@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO queryCourses(@RequestBody QueryCoursesDTO queryCoursesDTO){ return ResponseData.generateCreatedResponse(0,courseDictService.queryCourses(queryCoursesDTO)); } @PostMapping("updateCourses") @ApiOperation("编辑课程 id courseName courseType coverPage openStatus fieldDictDOS[] categoryDOS[] jobDictDOS[] rankDictDOS[]") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO updateCourses(@RequestBody UpdateCoursesDTO updateCoursesDTO){ return ResponseData.generateCreatedResponse(0,courseDictService.updateCourses(updateCoursesDTO)); } @PostMapping("queryCompanyCourse") @ApiOperation("企业内容管理-- { companyId 所选企业id pageSize pageNum courseName categoryId jobId rankId openStatus}") + @LoginRequired public ResponseVO queryCompanyCourse(@RequestBody QueryCoursesDTO queryCoursesDTO){ return ResponseData.generateCreatedResponse(0,courseDictService.queryCompanyCourse(queryCoursesDTO)); } @PostMapping("updateOpenStatus") @ApiOperation("修改课程开放状态 id openStatus") + @LoginRequired public ResponseVO updateOpenStatus(@RequestBody CourseDictDO courseDictDO){ return ResponseData.generateCreatedResponse(0,courseDictService.updateOpenStatus(courseDictDO)); } diff --git a/src/main/java/com/subsidy/controller/DepartmentDictController.java b/src/main/java/com/subsidy/controller/DepartmentDictController.java index 69957dd..bb68374 100644 --- a/src/main/java/com/subsidy/controller/DepartmentDictController.java +++ b/src/main/java/com/subsidy/controller/DepartmentDictController.java @@ -35,40 +35,42 @@ public class DepartmentDictController { @PostMapping("getDepartments") @ApiOperation("获取所有部门 companyId 企业id") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO getDepartments(@RequestBody DepartmentDictDO departmentDictDO){ return ResponseData.generateCreatedResponse(0,departmentDictService.getDepartments(departmentDictDO)); } @PostMapping("addDepartment") @ApiOperation("添加部门 companyId departmentName leaderName parentId 父节点") - //@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO addDepartment(@RequestBody DepartmentDictDO departmentDictDO){ return ResponseData.generateCreatedResponse(0,departmentDictService.addDepartment(departmentDictDO)); } @PostMapping("deleteDepartment") @ApiOperation("删除部门 id") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO deleteDepartment(@RequestBody DepartmentDictDO departmentDictDO){ return ResponseData.generateCreatedResponse(0,departmentDictService.deleteDepartment(departmentDictDO)); } @PostMapping("updateDepartment") @ApiOperation("编辑部门 id companyId departmentName leaderName parentId") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO updateDepartment(@RequestBody DepartmentDictDO departmentDictDO){ return ResponseData.generateCreatedResponse(0,departmentDictService.updateDepartment(departmentDictDO)); } @PostMapping("getDepartmentMembers") @ApiOperation("获取部门成员 companyId 公司id departmentId 部门id userName startDate endDate") + @LoginRequired public ResponseVO getDepartmentMembers(@RequestBody GetDepartmentMembersDTO getDepartmentMembersDTO){ return ResponseData.generateCreatedResponse(0,departmentDictService.getDepartmentMembers(getDepartmentMembersDTO)); } @PostMapping("getMembers") @ApiOperation("获取成员(树) companyId 公司id startDate endDate ") + @LoginRequired public ResponseVO getMembers(@RequestBody GetDepartmentMembersDTO getDepartmentMembersDTO){ return ResponseData.generateCreatedResponse(0,departmentDictService.getMembers(getDepartmentMembersDTO)); } diff --git a/src/main/java/com/subsidy/controller/ExerciseDictController.java b/src/main/java/com/subsidy/controller/ExerciseDictController.java index cabfbf1..94e3cd3 100644 --- a/src/main/java/com/subsidy/controller/ExerciseDictController.java +++ b/src/main/java/com/subsidy/controller/ExerciseDictController.java @@ -37,33 +37,35 @@ public class ExerciseDictController { @PostMapping("addExercise") @ApiOperation("添加题目 {paperId 试卷id courseId 课程id exerciseType 题目类型 difficulty 难度 title题目 items 选项 rightAnswer 正确答案 }") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO addExercise(@RequestBody ExerciseDictDO exerciseDictDO){ return ResponseData.generateCreatedResponse(0,exerciseDictService.addExercise(exerciseDictDO)); } @PostMapping("deleteExercise") @ApiOperation("删除题目 id") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO deleteExercise(@RequestBody ExerciseDictDO exerciseDictDO){ return ResponseData.generateCreatedResponse(0,exerciseDictService.deleteExercise(exerciseDictDO)); } @PostMapping("updateExercise") @ApiOperation("修改题目 id exerciseType 题目类型 difficulty 难度 title题目 items 选项 rightAnswer 正确答案") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO updateExercise(@RequestBody ExerciseDictDO exerciseDictDO){ return ResponseData.generateCreatedResponse(0,exerciseDictService.updateExercise(exerciseDictDO)); } @PostMapping("submit") @ApiOperation("提交答案 {paperId 卷子id memberId 成员id classId课程 courseId 课程id memberExerciseVOS [ id selectAnswer ] length:做题时长} ") + @LoginRequired public ResponseVO submit(@RequestBody SubmitDTO submitDTO){ return ResponseData.generateCreatedResponse(0,exerciseDictService.submit(submitDTO)); } @PostMapping("getPaperExercise") @ApiOperation("获取某个卷子的所有题目 pageSize pageNum paperId 卷子id exerciseType 类型 difficulty难度 title题目名称") + @LoginRequired public ResponseVO getPaperExercise(@RequestBody GetPaperExerciseDTO getPaperExerciseDTO){ return ResponseData.generateCreatedResponse(0,exerciseDictService.getPaperExercise(getPaperExerciseDTO)); } diff --git a/src/main/java/com/subsidy/controller/ExerciseDoneHistoryController.java b/src/main/java/com/subsidy/controller/ExerciseDoneHistoryController.java index cfa65a1..c3a6c0a 100644 --- a/src/main/java/com/subsidy/controller/ExerciseDoneHistoryController.java +++ b/src/main/java/com/subsidy/controller/ExerciseDoneHistoryController.java @@ -3,6 +3,7 @@ package com.subsidy.controller; import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; +import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.model.ExerciseDoneResultDO; import com.subsidy.service.ExerciseDoneHistoryService; import io.swagger.annotations.Api; @@ -31,6 +32,7 @@ public class ExerciseDoneHistoryController { @PostMapping("getDoneHistoryDetail") @ApiOperation("获取某一个试卷每个题目的做题详情 id 提交后返回的id memberId 成员id ") + @LoginRequired public ResponseVO getDoneHistoryDetail(@RequestBody ExerciseDoneResultDO exerciseDoneResultDO){ return ResponseData.generateCreatedResponse(0,exerciseDoneHistoryService.getDoneHistoryDetail(exerciseDoneResultDO)); } diff --git a/src/main/java/com/subsidy/controller/ExerciseDoneResultController.java b/src/main/java/com/subsidy/controller/ExerciseDoneResultController.java index 3c7ef42..1982383 100644 --- a/src/main/java/com/subsidy/controller/ExerciseDoneResultController.java +++ b/src/main/java/com/subsidy/controller/ExerciseDoneResultController.java @@ -3,6 +3,7 @@ package com.subsidy.controller; import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; +import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.model.ExerciseDoneResultDO; import com.subsidy.service.ExerciseDoneResultService; import io.swagger.annotations.Api; @@ -29,6 +30,7 @@ public class ExerciseDoneResultController { @PostMapping("getDoneDetail") @ApiOperation("提交后获取做题结果 id 提交后返回的id") + @LoginRequired public ResponseVO getDoneDetail(@RequestBody ExerciseDoneResultDO exerciseDoneResultDO){ return ResponseData.generateCreatedResponse(0,exerciseDoneResultService.getDoneDetail(exerciseDoneResultDO)); } diff --git a/src/main/java/com/subsidy/controller/FieldDictController.java b/src/main/java/com/subsidy/controller/FieldDictController.java index 889199a..3983e1e 100644 --- a/src/main/java/com/subsidy/controller/FieldDictController.java +++ b/src/main/java/com/subsidy/controller/FieldDictController.java @@ -3,6 +3,7 @@ package com.subsidy.controller; import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; +import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.dto.field.QueryFieldsDTO; import com.subsidy.model.FieldDictDO; import com.subsidy.service.FieldDictService; @@ -33,24 +34,28 @@ public class FieldDictController { @PostMapping("addField") @ApiOperation("添加行业 fieldName 行业名称") + @LoginRequired public ResponseVO addField(@RequestBody FieldDictDO fieldDictDO){ return ResponseData.generateCreatedResponse(0,fieldDictService.addField(fieldDictDO)); } @PostMapping("updateField") @ApiOperation("修改行业 id fieldName 行业名称") + @LoginRequired public ResponseVO updateField(@RequestBody FieldDictDO fieldDictDO){ return ResponseData.generateCreatedResponse(0,fieldDictService.updateField(fieldDictDO)); } @PostMapping("deleteField") @ApiOperation("删除行业 id") + @LoginRequired public ResponseVO deleteField(@RequestBody FieldDictDO fieldDictDO){ return ResponseData.generateCreatedResponse(0,fieldDictService.deleteField(fieldDictDO)); } @PostMapping("queryFields") @ApiOperation("查询行业 pageSize pageNum fieldName") + @LoginRequired public ResponseVO queryFields(@RequestBody QueryFieldsDTO queryFieldsDTO){ return ResponseData.generateCreatedResponse(0,fieldDictService.queryFields(queryFieldsDTO)); } diff --git a/src/main/java/com/subsidy/controller/FileDictController.java b/src/main/java/com/subsidy/controller/FileDictController.java index a479597..fb48868 100644 --- a/src/main/java/com/subsidy/controller/FileDictController.java +++ b/src/main/java/com/subsidy/controller/FileDictController.java @@ -33,28 +33,28 @@ public class FileDictController { @PostMapping("getContendFiles") @ApiOperation("获取目录下的视频 {contentId fileName}") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO getContendFiles(@RequestBody FileDictDO fileDictDO){ return ResponseData.generateCreatedResponse(0,fileDictService.getContendFiles(fileDictDO)); } @PostMapping("deleteFile") @ApiOperation("** 删除视频 id ") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO deleteFile(@RequestBody FileDictDO fileDictDO){ return ResponseData.generateCreatedResponse(0,fileDictService.deleteFile(fileDictDO)); } @PostMapping("addFile") @ApiOperation("** 新增视频 contentId fileName fileSize fileType fileUrl") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO addFile(@RequestBody FileDictDO fileDictDO){ return ResponseData.generateCreatedResponse(0,fileDictService.addFile(fileDictDO)); } @PostMapping("updateFile") @ApiOperation("** 新增视频 id contentId fileName fileSize fileType fileUrl") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO updateFile(@RequestBody FileDictDO fileDictDO){ return ResponseData.generateCreatedResponse(0,fileDictService.updateFile(fileDictDO)); } diff --git a/src/main/java/com/subsidy/controller/JobDictController.java b/src/main/java/com/subsidy/controller/JobDictController.java index 267b53d..561d6f3 100644 --- a/src/main/java/com/subsidy/controller/JobDictController.java +++ b/src/main/java/com/subsidy/controller/JobDictController.java @@ -3,6 +3,7 @@ package com.subsidy.controller; import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; +import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.model.JobDictDO; import com.subsidy.service.JobDictService; import io.swagger.annotations.ApiOperation; @@ -33,24 +34,28 @@ public class JobDictController { @PostMapping("queryJobs") @ApiOperation("查询某公司的岗位 companyId") + @LoginRequired public ResponseVO queryJobs(@RequestBody JobDictDO jobDictDO){ return ResponseData.generateCreatedResponse(0,jobDictService.queryJobs(jobDictDO)); } @PostMapping("deleteJob") @ApiOperation("删除某个岗位 id") + @LoginRequired public ResponseVO deleteJob(@RequestBody JobDictDO jobDictDO){ return ResponseData.generateCreatedResponse(0,jobDictService.deleteJob(jobDictDO)); } @PostMapping("addJob") @ApiOperation("添加岗位 companyId jobName") + @LoginRequired public ResponseVO addJob(@RequestBody JobDictDO jobDictDO){ return ResponseData.generateCreatedResponse(0,jobDictService.addJob(jobDictDO)); } @PostMapping("updateJob") @ApiOperation("更新岗位 id jobName") + @LoginRequired public ResponseVO updateJob(@RequestBody JobDictDO jobDictDO){ return ResponseData.generateCreatedResponse(0,jobDictService.updateJob(jobDictDO)); } diff --git a/src/main/java/com/subsidy/controller/MemberController.java b/src/main/java/com/subsidy/controller/MemberController.java index 79033d8..ca7bab2 100644 --- a/src/main/java/com/subsidy/controller/MemberController.java +++ b/src/main/java/com/subsidy/controller/MemberController.java @@ -1,6 +1,5 @@ package com.subsidy.controller; - import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; import com.subsidy.common.interceptor.LoginRequired; @@ -15,7 +14,6 @@ import com.subsidy.dto.member.StudyHistoryDTO; import com.subsidy.model.ExerciseDoneResultDO; import com.subsidy.model.MemberDO; import com.subsidy.service.MemberService; -import com.subsidy.util.ConstantUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -42,28 +40,28 @@ public class MemberController { @PostMapping("getAll") @ApiOperation("查询某部门成员 pageNum pageSize departmentId userName status startDate endDate") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO getAll(@RequestBody GetAllDTO getAllDTO){ return ResponseData.generateCreatedResponse(0,memberService.getAll(getAllDTO)); } @PostMapping("deleteMember") @ApiOperation("删除成员 id ") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO deleteMember(@RequestBody MemberDO memberDO){ return ResponseData.generateCreatedResponse(0,memberService.deleteMember(memberDO)); } @PostMapping("addMember") @ApiOperation("新增成员 companyId userName accountName accountNameEn telephone gender image idCard departmentIds jobIds workNo inductionDate email") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO addMember(@RequestBody AddMemberDTO addMemberDTO){ return ResponseData.generateCreatedResponse(0,memberService.addMember(addMemberDTO)); } @PostMapping("updateMember") @ApiOperation("编辑成员 {id companyId userName accountName accountNameEn telephone gender image idCard status departmentIds jobIds}") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO updateMember(@RequestBody AddMemberDTO addMemberDTO){ return ResponseData.generateCreatedResponse(0,memberService.updateMember(addMemberDTO)); } @@ -82,6 +80,7 @@ public class MemberController { @PostMapping("updatePassword") @ApiOperation("修改密码 {id password}") + @LoginRequired public ResponseVO updatePassword(@RequestBody MemberDO memberDO){ return ResponseData.generateCreatedResponse(0,memberService.updatePassword(memberDO)); } @@ -94,62 +93,71 @@ public class MemberController { @PostMapping("myCourses") @ApiOperation("手机端:我的学习--课程 memberId 学员id status 状态 0:全部 1:进行中 2:待开始 3:已完成 ") + @LoginRequired public ResponseVO myCourses(@RequestBody MyCoursesDTO myCoursesDTO){ return ResponseData.generateCreatedResponse(0,memberService.myCourses(myCoursesDTO)); } @PostMapping("contentVod") @ApiOperation("手机端:目录+视频 classId 班级id courseId 课程 memberId 学员id") + @LoginRequired public ResponseVO contentVod(@RequestBody ContentMemberDTO contentVodDTO){ return ResponseData.generateCreatedResponse(0,memberService.contentVod(contentVodDTO)); } @PostMapping("contentFiles") @ApiOperation("手机端:目录+课件 courseId 课程 memberId 学员id") + @LoginRequired public ResponseVO contentFiles(@RequestBody ContentMemberDTO contentMemberDTO){ return ResponseData.generateCreatedResponse(0,memberService.contentFiles(contentMemberDTO)); } @PostMapping("studyHistory") @ApiOperation("学习记录 memberId 成员id pageSize pageNum") + @LoginRequired public ResponseVO studyHistory(@RequestBody StudyHistoryDTO studyHistoryDTO){ return ResponseData.generateCreatedResponse(0,memberService.studyHistory(studyHistoryDTO)); } @PostMapping("getCourseTest") @ApiOperation("获取课程下的测试情况 {memberId 成员id 班级id classId courseId 课程id }") + @LoginRequired public ResponseVO getCourseTest(@RequestBody ContentMemberDTO contentMemberDTO){ return ResponseData.generateCreatedResponse(0,memberService.getCourseTest(contentMemberDTO)); } @PostMapping("getTestDoneDetail") @ApiOperation("获取某个测评学生的完成情况 paperId memberId") + @LoginRequired public ResponseVO getPaperDoneDetail(@RequestBody ExerciseDoneResultDO exerciseDoneResultDO){ return ResponseData.generateCreatedResponse(0,memberService.getPaperDoneDetail(exerciseDoneResultDO)); } @PostMapping("getStudyInfo") @ApiOperation("获取学生完成课程情况 id 学员id") + @LoginRequired public ResponseVO getStudyInfo(@RequestBody MemberDO memberDO){ return ResponseData.generateCreatedResponse(0,memberService.getStudyInfo(memberDO)); } @PostMapping("checkTimes") @ApiOperation("检测是否超过次数 memberId paperId classId") + @LoginRequired public ResponseVO checkTimes(@RequestBody ExerciseDoneResultDO exerciseDoneResultDO){ return ResponseData.generateCreatedResponse(0,memberService.checkTimes(exerciseDoneResultDO)); } @PostMapping("importRedis") @ApiOperation("导入学生账号到redis") + @LoginRequired public void importRedis(){ memberService.importRedis(); } @PostMapping("changeDepartments") @ApiOperation("修改部门 desDepId[] 目的部门 memberIds[] 成员id") + @LoginRequired public ResponseVO changeDepartments(@RequestBody ChangeDepartmentsDTO changeDepartmentsDTO){ return ResponseData.generateCreatedResponse(0,memberService.changeDepartments(changeDepartmentsDTO)); } - } diff --git a/src/main/java/com/subsidy/controller/OprAdmDictController.java b/src/main/java/com/subsidy/controller/OprAdmDictController.java index 7dc33eb..2b38b26 100644 --- a/src/main/java/com/subsidy/controller/OprAdmDictController.java +++ b/src/main/java/com/subsidy/controller/OprAdmDictController.java @@ -3,6 +3,7 @@ package com.subsidy.controller; import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; +import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.dto.opr.GetHistoryDTO; import com.subsidy.service.OprAdmDictService; import io.swagger.annotations.Api; @@ -31,6 +32,7 @@ public class OprAdmDictController { @PostMapping("getHistory") @ApiOperation("获取后台用户审计 {pageSize pageNum userName startDate endDate}") + @LoginRequired public ResponseVO getHistory(@RequestBody GetHistoryDTO getHistoryDTO){ return ResponseData.generateCreatedResponse(0,oprAdmDictService.getHistory(getHistoryDTO)); } diff --git a/src/main/java/com/subsidy/controller/OprMemDictController.java b/src/main/java/com/subsidy/controller/OprMemDictController.java index e942f74..a522a88 100644 --- a/src/main/java/com/subsidy/controller/OprMemDictController.java +++ b/src/main/java/com/subsidy/controller/OprMemDictController.java @@ -3,6 +3,7 @@ package com.subsidy.controller; import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; +import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.dto.opr.GetHistoryDTO; import com.subsidy.service.OprMemDictService; import io.swagger.annotations.Api; @@ -31,6 +32,7 @@ public class OprMemDictController { @PostMapping("getHistory") @ApiOperation("获取学员审计 {pageSize pageNum userName startDate endDate}") + @LoginRequired public ResponseVO getHistory(@RequestBody GetHistoryDTO getHistoryDTO){ return ResponseData.generateCreatedResponse(0,oprMemDictService.getHistory(getHistoryDTO)); } diff --git a/src/main/java/com/subsidy/controller/PaperDictController.java b/src/main/java/com/subsidy/controller/PaperDictController.java index 76e906f..d831ca5 100644 --- a/src/main/java/com/subsidy/controller/PaperDictController.java +++ b/src/main/java/com/subsidy/controller/PaperDictController.java @@ -33,28 +33,28 @@ public class PaperDictController { @PostMapping("queryPapers") @ApiOperation("查看课程下的测试 {courseId paperName}") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO queryPapers(@RequestBody PaperDictDO paperDictDO) { return ResponseData.generateCreatedResponse(0, paperDictService.queryPapers(paperDictDO)); } @PostMapping("deletePaper") @ApiOperation("删除卷子 {id}") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO deletePaper(@RequestBody PaperDictDO paperDictDO) { return ResponseData.generateCreatedResponse(0, paperDictService.deletePaper(paperDictDO)); } @PostMapping("update") @ApiOperation("启用/禁用 {id paperStatus}") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO updateStatus(@RequestBody PaperDictDO paperDictDO) { return ResponseData.generateCreatedResponse(0, paperDictService.updateStatus(paperDictDO)); } @PostMapping("addPaper") @ApiOperation("添加卷子 {courseId paperName}") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO addPaper(@RequestBody PaperDictDO paperDictDO) { return ResponseData.generateCreatedResponse(0, paperDictService.addPaper(paperDictDO)); } diff --git a/src/main/java/com/subsidy/controller/RankDictController.java b/src/main/java/com/subsidy/controller/RankDictController.java index d0aa079..91e0f9f 100644 --- a/src/main/java/com/subsidy/controller/RankDictController.java +++ b/src/main/java/com/subsidy/controller/RankDictController.java @@ -3,6 +3,7 @@ package com.subsidy.controller; import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; +import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.mapper.RankDictMapper; import com.subsidy.model.RankDictDO; import com.subsidy.service.RankDictService; @@ -34,24 +35,28 @@ public class RankDictController { @PostMapping("addRank") @ApiOperation("添加职级 companyId rank") + @LoginRequired public ResponseVO addRank(@RequestBody RankDictDO rankDictDO){ return ResponseData.generateCreatedResponse(0,rankDictService.addRank(rankDictDO)); } @PostMapping("deleteRank") @ApiOperation("删除职级 id") + @LoginRequired public ResponseVO deleteById(@RequestBody RankDictDO rankDictDO){ return ResponseData.generateCreatedResponse(0,rankDictService.deleteRank(rankDictDO)); } @PostMapping("updateRank") @ApiOperation("添加职级 id rank") + @LoginRequired public ResponseVO updateRank(@RequestBody RankDictDO rankDictDO){ return ResponseData.generateCreatedResponse(0,rankDictService.updateRank(rankDictDO)); } @PostMapping("queryRanks") @ApiOperation("查看职级 companyId") + @LoginRequired public ResponseVO queryRanks(@RequestBody RankDictDO rankDictDO){ return ResponseData.generateCreatedResponse(0,rankDictService.queryRanks(rankDictDO)); } diff --git a/src/main/java/com/subsidy/controller/RotationImgDictController.java b/src/main/java/com/subsidy/controller/RotationImgDictController.java index e3ed440..9b844ed 100644 --- a/src/main/java/com/subsidy/controller/RotationImgDictController.java +++ b/src/main/java/com/subsidy/controller/RotationImgDictController.java @@ -3,6 +3,7 @@ package com.subsidy.controller; import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; +import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.model.RotationImgDictDO; import com.subsidy.service.RotationImgDictService; import io.swagger.annotations.ApiOperation; @@ -32,24 +33,28 @@ public class RotationImgDictController { @PostMapping("addRotation") @ApiOperation("添加轮播图 {companyId 公司id rotationImg 轮播图地址}") + @LoginRequired public ResponseVO addRotation(@RequestBody RotationImgDictDO rotationImgDictDO){ return ResponseData.generateCreatedResponse(0,rotationImgDictService.addRotation(rotationImgDictDO)); } @PostMapping("deleteRotation") @ApiOperation("删除轮播图 {id}") + @LoginRequired public ResponseVO deleteRotation(@RequestBody RotationImgDictDO rotationImgDictDO){ return ResponseData.generateCreatedResponse(0,rotationImgDictService.deleteRotation(rotationImgDictDO)); } @PostMapping("updateRotation") @ApiOperation("编辑轮播图 id") + @LoginRequired public ResponseVO updateRotation(@RequestBody RotationImgDictDO rotationImgDictDO){ return ResponseData.generateCreatedResponse(0,rotationImgDictService.updateRotation(rotationImgDictDO)); } @PostMapping("getAllRotations") @ApiOperation("获取某企业的轮播图 companyId") + @LoginRequired public ResponseVO getAllRotations(@RequestBody RotationImgDictDO rotationImgDictDO){ return ResponseData.generateCreatedResponse(0,rotationImgDictService.getAllRotations(rotationImgDictDO)); } diff --git a/src/main/java/com/subsidy/controller/SignInRecordController.java b/src/main/java/com/subsidy/controller/SignInRecordController.java index f20654a..4523e3e 100644 --- a/src/main/java/com/subsidy/controller/SignInRecordController.java +++ b/src/main/java/com/subsidy/controller/SignInRecordController.java @@ -35,25 +35,28 @@ public class SignInRecordController { @PostMapping("getMemberSignInfo") @ApiOperation("获取某个成员的签到记录 id 成员id pageSize pageNum") + @LoginRequired public ResponseVO getMemberSignInfo(@RequestBody GetMemberSignInfoDTO getMemberSignInfoDTO) { return ResponseData.generateCreatedResponse(0, signInRecordService.getMemberSignInfo(getMemberSignInfoDTO)); } @PostMapping("signIn") @ApiOperation("签到 memberId") + @LoginRequired public ResponseVO signIn(@RequestBody SignInRecordDO signInRecordDO) { return ResponseData.generateCreatedResponse(0, signInRecordService.signIn(signInRecordDO)); } @PostMapping("dataView") @ApiOperation("数据概览 id 校区id className pageSize pageNum") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO dataView(@RequestBody DataViewDTO classSignInfoDTO) { return ResponseData.generateCreatedResponse(0, signInRecordService.dataView(classSignInfoDTO)); } @PostMapping("signInStatus") @ApiOperation("判断学生当天有没有打卡 {memberId 学生id}") + @LoginRequired public ResponseVO signInStatus(@RequestBody SignInRecordDO signInRecordDO) { return ResponseData.generateCreatedResponse(0, signInRecordService.signInStatus(signInRecordDO)); } diff --git a/src/main/java/com/subsidy/controller/VodDictController.java b/src/main/java/com/subsidy/controller/VodDictController.java index abd6949..4caff49 100644 --- a/src/main/java/com/subsidy/controller/VodDictController.java +++ b/src/main/java/com/subsidy/controller/VodDictController.java @@ -41,28 +41,28 @@ public class VodDictController { @PostMapping("getContendVods") @ApiOperation("获取目录下的视频 {contentId vodName}") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO getContendVods(@RequestBody GetContendVodsDTO getContendVodsDTO) { return ResponseData.generateCreatedResponse(0, vodDictService.getContendVods(getContendVodsDTO)); } @PostMapping("deleteVod") @ApiOperation("删除视频 id ") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO deleteVod(@RequestBody VodDictDO vodDictDO) { return ResponseData.generateCreatedResponse(0, vodDictService.deleteVod(vodDictDO)); } @PostMapping("addVod") @ApiOperation("新增视频 contentId vodName vodLength vodType vodSize vodUrl vodCode") - //@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO addVod(@RequestBody VodDictDO vodDictDO) { return ResponseData.generateCreatedResponse(0, vodDictService.addVod(vodDictDO)); } @PostMapping("updateVod") @ApiOperation("新增视频 id contentId vodName vodLength vodType vodSize vodUrl vodCode") - @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) + @LoginRequired public ResponseVO updateVod(@RequestBody VodDictDO vodDictDO) { return ResponseData.generateCreatedResponse(0, vodDictService.updateVod(vodDictDO)); } diff --git a/src/main/java/com/subsidy/controller/VodPlayHistoryController.java b/src/main/java/com/subsidy/controller/VodPlayHistoryController.java index 4441072..aa54099 100644 --- a/src/main/java/com/subsidy/controller/VodPlayHistoryController.java +++ b/src/main/java/com/subsidy/controller/VodPlayHistoryController.java @@ -4,6 +4,7 @@ package com.subsidy.controller; import com.alibaba.fastjson.JSON; import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; +import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.dto.vod.RemainSecondsDTO; import com.subsidy.dto.vod.SignDatePlaysDTO; import com.subsidy.model.VodPlayHistoryDO; @@ -34,12 +35,14 @@ public class VodPlayHistoryController { @PostMapping("insertHistory") @ApiOperation("记录学生看视频位置 ajax请求 classId班级id vodId 视频id memberId 成员id playLength 播放时长 playRecord 位点") + @LoginRequired public ResponseVO insertHistory(@RequestBody VodPlayHistoryDO vodPlayHistoryDO){ return ResponseData.generateCreatedResponse(0,vodPlayHistoryService.insertHistory(vodPlayHistoryDO)); } @RequestMapping("insertHistoryNew") @ApiOperation("记录学生看视频位置 classId班级id vodId 视频id memberId 成员id playLength 播放时长 playRecord 位点") + @LoginRequired public ResponseVO insertHistoryNew(@RequestBody String param){ VodPlayHistoryDO vodPlayHistoryDO = JSON.parseObject(param,VodPlayHistoryDO.class); return ResponseData.generateCreatedResponse(0,vodPlayHistoryService.insertHistoryNew(vodPlayHistoryDO)); @@ -47,24 +50,28 @@ public class VodPlayHistoryController { @PostMapping("dataFix") @ApiOperation("每个视频都看一次") + @LoginRequired public void dadaFix(@RequestBody SignDatePlaysDTO dataFixDTO){ vodPlayHistoryService.dataFix(dataFixDTO); } @PostMapping("signDatePlays") @ApiOperation("每天接着看几个视频 接dataFix的") + @LoginRequired public void signDatePlays(@RequestBody SignDatePlaysDTO signDatePlaysDTO ){ vodPlayHistoryService.signDatePlays(signDatePlaysDTO); } @PostMapping("remainSeconds") @ApiOperation("每个视频先看一下,然后剩余时长分配到每天里") + @LoginRequired public void remainSeconds(@RequestBody RemainSecondsDTO remainSecondsDTO){ vodPlayHistoryService.remainSeconds(remainSecondsDTO); } @PostMapping("playLengthFix") @ApiOperation("按照时长去跑脚本 {classId}") + @LoginRequired public void playLengthFix(@RequestBody RemainSecondsDTO remainSecondsDTO){ vodPlayHistoryService.playLengthFix(remainSecondsDTO); } diff --git a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java index 465fc8c..3bb1bbf 100644 --- a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java @@ -53,6 +53,8 @@ import com.subsidy.model.VodDictDO; import com.subsidy.service.MemberService; import com.subsidy.util.ConstantUtils; //import com.subsidy.util.RedisUtil; +import com.subsidy.util.JwtUtil; +import com.subsidy.util.RedisUtil; import com.subsidy.vo.administer.UserRoleVO; import com.subsidy.vo.member.ContentFilesVO; import com.subsidy.vo.member.ContentVodNewVO; @@ -114,8 +116,8 @@ public class MemberServiceImpl extends ServiceImpl imple @Autowired private MemberDepartmentMappingMapper memberDepartmentMappingMapper; - //@Autowired - //private RedisUtil redisUtil; + @Autowired + private RedisUtil redisUtil; @Autowired private CourseFieldMappingMapper courseFieldMappingMapper; @@ -384,6 +386,10 @@ public class MemberServiceImpl extends ServiceImpl imple .lambda() .eq(RotationImgDictDO::getCompanyId, companyDictDO.getId())); userRoleVO.setRotationImgDictDOS(rotationImgDictDOS); + + String token = JwtUtil.generateToken(memberDO.getId() ,ConstantUtils.MOBILE_TERMINATE); + redisUtil.set(ConstantUtils.MOBILE_TERMINATE+"_"+memberDO.getId(), token); + userRoleVO.setToken(token); return userRoleVO; } @@ -407,8 +413,6 @@ public class MemberServiceImpl extends ServiceImpl imple } CompanyDictDO companyDictDO = companyDictMapper.selectById(memberDO.getCompanyId()); - - if (memberDO.getPassword().equals(passwordLoginDTO.getPassword()) && 1 == memberDO.getFirstLogin() && !"冻结".equals(memberDO.getStatus())) { MemberVO memberVO = new MemberVO(); BeanUtils.copyProperties(memberDO, memberVO); @@ -434,6 +438,10 @@ public class MemberServiceImpl extends ServiceImpl imple memberVO.setRotationImgDictDOS(rotationImgDictDOS); //redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + passwordLoginDTO.getCompanyId() + ":" + passwordLoginDTO.getAccountName(), memberDO); //redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + ":" + System.currentTimeMillis(), 1); + + String token = JwtUtil.generateToken(memberDO.getId() ,ConstantUtils.MOBILE_TERMINATE); + redisUtil.set(ConstantUtils.MOBILE_TERMINATE+"_"+memberDO.getId(), token); + memberVO.setToken(token); return memberVO; } else { if (!memberDO.getPassword().equals(passwordLoginDTO.getPassword())) { @@ -451,6 +459,7 @@ public class MemberServiceImpl extends ServiceImpl imple //redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + ":" + System.currentTimeMillis(), oprMemDictDO); throw new HttpException(10016); } + if (0 == memberDO.getFirstLogin()) { OprMemDictDO oprMemDictDO = new OprMemDictDO(); oprMemDictDO.setUserId(memberDO.getId()); @@ -466,6 +475,7 @@ public class MemberServiceImpl extends ServiceImpl imple //redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + ":" + System.currentTimeMillis(), 0); throw new HttpException(10015); } + if ("冻结".equals(memberDO.getStatus())) { throw new HttpException(10014); } diff --git a/src/main/java/com/subsidy/util/RedisUtil.java b/src/main/java/com/subsidy/util/RedisUtil.java index 118f178..0b7e9dc 100644 --- a/src/main/java/com/subsidy/util/RedisUtil.java +++ b/src/main/java/com/subsidy/util/RedisUtil.java @@ -1,633 +1,620 @@ -//package com.subsidy.util; -// -//import com.google.common.collect.Sets; -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.data.redis.connection.jedis.JedisConnection; -//import org.springframework.data.redis.core.BoundListOperations; -//import org.springframework.data.redis.core.Cursor; -//import org.springframework.data.redis.core.RedisCallback; -//import org.springframework.data.redis.core.RedisTemplate; -//import org.springframework.data.redis.core.ScanOptions; -//import org.springframework.data.redis.serializer.RedisSerializer; -//import org.springframework.stereotype.Component; -//import org.springframework.util.CollectionUtils; -//import org.springframework.web.bind.annotation.RequestMapping; -//import org.springframework.web.bind.annotation.RestController; -//import redis.clients.jedis.ScanParams; -//import redis.clients.jedis.commands.JedisCommands; -//import redis.clients.jedis.commands.MultiKeyCommands; -// -//import javax.annotation.Resource; -//import java.io.Serializable; -//import java.util.HashSet; -//import java.util.List; -//import java.util.Map; -//import java.util.Set; -//import java.util.concurrent.TimeUnit; -// -///** -// *

-// * redisTemplate封装 -// *

-// * -// * @author DengMin -// * @since 2020/12/17 -// */ -// -//@Component -//public class RedisUtil { -// -// -// @Autowired -// private RedisTemplate redisTemplate; -// -// public RedisUtil(RedisTemplate redisTemplate) { -// this.redisTemplate = redisTemplate; -// } -// -// /** -// * 指定缓存失效时间 -// * @param key 键 -// * @param time 时间(秒) -// * @return -// */ -// public boolean expire(String key,long time){ -// try { -// if(time>0){ -// redisTemplate.expire(key, time, TimeUnit.SECONDS); -// } -// return true; -// } catch (Exception e) { -// e.printStackTrace(); -// return false; -// } -// } -// -// /** -// * 根据key 获取过期时间 -// * @param key 键 不能为null -// * @return 时间(秒) 返回0代表为永久有效 -// */ -// public long getExpire(String key){ -// return redisTemplate.getExpire(key,TimeUnit.SECONDS); -// } -// -// /** -// * 判断key是否存在 -// * @param key 键 -// * @return true 存在 false不存在 -// */ -// public boolean hasKey(String key){ -// try { -// return redisTemplate.hasKey(key); -// } catch (Exception e) { -// e.printStackTrace(); -// return false; -// } -// } -// -// /** -// * 删除缓存 -// * @param key 可以传一个值 或多个 -// */ -// @SuppressWarnings("unchecked") -// public void del(String ... key){ -// if(key!=null&&key.length>0){ -// if(key.length==1){ -// redisTemplate.delete(key[0]); -// }else{ -// redisTemplate.delete(CollectionUtils.arrayToList(key)); -// } -// } -// } -// -// /** -// * 删除缓存 -// * @param key 集合数据 -// */ -// public void del(Set key) { -// if (key != null && key.size() > 0) { -// redisTemplate.delete(key); -// } -// } -// -// //============================String============================= -// /** -// * 普通缓存获取 -// * @param key 键 -// * @return 值 -// */ -// public Object get(String key){ -// return key==null?null:redisTemplate.opsForValue().get(key); -// } -// -// /** -// * 普通缓存放入 -// * @param key 键 -// * @param value 值 -// * @return true成功 false失败 -// */ -// public boolean set(String key,Object value) { -// try { -// redisTemplate.opsForValue().set(key, value); -// return true; -// } catch (Exception e) { -// e.printStackTrace(); -// return false; -// } -// } -// -// /** -// * 普通缓存放入并设置时间 -// * @param key 键 -// * @param value 值 -// * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 -// * @return true成功 false 失败 -// */ -// public boolean set(String key,Object value,long time){ -// try { -// if(time>0){ -// redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); -// }else{ -// set(key, value); -// } -// return true; -// } catch (Exception e) { -// e.printStackTrace(); -// return false; -// } -// } -// -// /** -// * 递增 -// * @param key 键 -// * @param delta 要增加几(大于0) -// * @return -// */ -// public long incr(String key, long delta){ -// if(delta<0){ -// throw new RuntimeException("递增因子必须大于0"); -// } -// return redisTemplate.opsForValue().increment(key, delta); -// } -// -// /** -// * 递减 -// * @param key 键 -// * @param delta 要减少几(小于0) -// * @return -// */ -// public long decr(String key, long delta){ -// if(delta<0){ -// throw new RuntimeException("递减因子必须大于0"); -// } -// return redisTemplate.opsForValue().increment(key, -delta); -// } -// -// //================================Map================================= -// /** -// * HashGet -// * @param key 键 不能为null -// * @param item 项 不能为null -// * @return 值 -// */ -// public Object hget(String key,String item){ -// return redisTemplate.opsForHash().get(key, item); -// } -// -// /** -// * 获取hashKey对应的所有键值 -// * @param key 键 -// * @return 对应的多个键值 -// */ -// public Map hmget(String key){ -// return redisTemplate.opsForHash().entries(key); -// } -// -// /** -// * HashSet -// * @param key 键 -// * @param map 对应多个键值 -// * @return true 成功 false 失败 -// */ -// public boolean hmset(String key, Map map){ -// try { -// redisTemplate.opsForHash().putAll(key, map); -// return true; -// } catch (Exception e) { -// e.printStackTrace(); -// return false; -// } -// } -// -// /** -// * HashSet 并设置时间 -// * @param key 键 -// * @param map 对应多个键值 -// * @param time 时间(秒) -// * @return true成功 false失败 -// */ -// public boolean hmset(String key, Map map, long time){ -// try { -// redisTemplate.opsForHash().putAll(key, map); -// if(time>0){ -// expire(key, time); -// } -// return true; -// } catch (Exception e) { -// e.printStackTrace(); -// return false; -// } -// } -// -// /** -// * 向一张hash表中放入数据,如果不存在将创建 -// * @param key 键 -// * @param item 项 -// * @param value 值 -// * @return true 成功 false失败 -// */ -// public boolean hset(String key,String item,Object value) { -// try { -// redisTemplate.opsForHash().put(key, item, value); -// return true; -// } catch (Exception e) { -// e.printStackTrace(); -// return false; -// } -// } -// -// /** -// * 向一张hash表中放入数据,如果不存在将创建 -// * @param key 键 -// * @param item 项 -// * @param value 值 -// * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 -// * @return true 成功 false失败 -// */ -// public boolean hset(String key,String item,Object value,long time) { -// try { -// redisTemplate.opsForHash().put(key, item, value); -// if(time>0){ -// expire(key, time); -// } -// return true; -// } catch (Exception e) { -// e.printStackTrace(); -// return false; -// } -// } -// -// /** -// * 删除hash表中的值 -// * @param key 键 不能为null -// * @param item 项 可以使多个 不能为null -// */ -// public void hdel(String key, Object... item){ -// redisTemplate.opsForHash().delete(key,item); -// } -// -// /** -// * 判断hash表中是否有该项的值 -// * @param key 键 不能为null -// * @param item 项 不能为null -// * @return true 存在 false不存在 -// */ -// public boolean hHasKey(String key, String item){ -// return redisTemplate.opsForHash().hasKey(key, item); -// } -// -// /** -// * hash递增 如果不存在,就会创建一个 并把新增后的值返回 -// * @param key 键 -// * @param item 项 -// * @param by 要增加几(大于0) -// * @return -// */ -// public double hincr(String key, String item,double by){ -// return redisTemplate.opsForHash().increment(key, item, by); -// } -// -// /** -// * hash递减 -// * @param key 键 -// * @param item 项 -// * @param by 要减少记(小于0) -// * @return -// */ -// public double hdecr(String key, String item,double by){ -// return redisTemplate.opsForHash().increment(key, item,-by); -// } -// -// //============================set============================= -// /** -// * 根据key获取Set中的所有值 -// * @param key 键 -// * @return -// */ -// public Set sGet(String key){ -// try { -// return redisTemplate.opsForSet().members(key); -// } catch (Exception e) { -// e.printStackTrace(); -// return null; -// } -// } -// -// /** -// * 根据value从一个set中查询,是否存在 -// * @param key 键 -// * @param value 值 -// * @return true 存在 false不存在 -// */ -// public boolean sHasKey(String key,Object value){ -// try { -// return redisTemplate.opsForSet().isMember(key, value); -// } catch (Exception e) { -// e.printStackTrace(); -// return false; -// } -// } -// -// /** -// * 将数据放入set缓存 -// * @param key 键 -// * @param values 值 可以是多个 -// * @return 成功个数 -// */ -// public long sSet(String key, Object...values) { -// try { -// return redisTemplate.opsForSet().add(key, values); -// } catch (Exception e) { -// e.printStackTrace(); -// return 0; -// } -// } -// -// /** -// * 将set数据放入缓存 -// * @param key 键 -// * @param time 时间(秒) -// * @param values 值 可以是多个 -// * @return 成功个数 -// */ -// public long sSetAndTime(String key,long time,Object...values) { -// try { -// Long count = redisTemplate.opsForSet().add(key, values); -// if(time>0) { -// expire(key, time); -// } -// return count; -// } catch (Exception e) { -// e.printStackTrace(); -// return 0; -// } -// } -// -// /** -// * 获取set缓存的长度 -// * @param key 键 -// * @return -// */ -// public long sGetSetSize(String key){ -// try { -// return redisTemplate.opsForSet().size(key); -// } catch (Exception e) { -// e.printStackTrace(); -// return 0; -// } -// } -// -// /** -// * 移除值为value的 -// * @param key 键 -// * @param values 值 可以是多个 -// * @return 移除的个数 -// */ -// public long setRemove(String key, Object ...values) { -// try { -// Long count = redisTemplate.opsForSet().remove(key, values); -// return count; -// } catch (Exception e) { -// e.printStackTrace(); -// return 0; -// } -// } -// //===============================list================================= -// -// /** -// * 获取list缓存的内容 -// * @param key 键 -// * @param start 开始 -// * @param end 结束 0 到 -1代表所有值 -// * @return -// */ -// public List lGet(String key, long start, long end){ -// try { -// return redisTemplate.opsForList().range(key, start, end); -// } catch (Exception e) { -// e.printStackTrace(); -// return null; -// } -// } -// -// /** -// * 获取list缓存的长度 -// * @param key 键 -// * @return -// */ -// public long lGetListSize(String key){ -// try { -// return redisTemplate.opsForList().size(key); -// } catch (Exception e) { -// e.printStackTrace(); -// return 0; -// } -// } -// -// /** -// * 通过索引 获取list中的值 -// * @param key 键 -// * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 -// * @return -// */ -// public Object lGetIndex(String key,long index){ -// try { -// return redisTemplate.opsForList().index(key, index); -// } catch (Exception e) { -// e.printStackTrace(); -// return null; -// } -// } -// -// /** -// * 将list放入缓存 -// * @param key 键 -// * @param value 值 -// * @return -// */ -// public boolean lSet(String key, Object value) { -// try { -// redisTemplate.opsForList().rightPush(key, value); -// return true; -// } catch (Exception e) { -// e.printStackTrace(); -// return false; -// } -// } -// -// /** -// * 将list放入缓存 -// * @param key 键 -// * @param value 值 -// * @param time 时间(秒) -// * @return -// */ -// public boolean lSet(String key, Object value, long time) { -// try { -// redisTemplate.opsForList().rightPush(key, value); -// if (time > 0) { -// expire(key, time); -// } -// return true; -// } catch (Exception e) { -// e.printStackTrace(); -// return false; -// } -// } -// -// /** -// * 将list放入缓存 -// * @param key 键 -// * @param value 值 -// * @return -// */ -// public boolean lSet(String key, List value) { -// try { -// redisTemplate.opsForList().rightPushAll(key, value); -// return true; -// } catch (Exception e) { -// e.printStackTrace(); -// return false; -// } -// } -// -// /** -// * 将list放入缓存 -// * @param key 键 -// * @param value 值 -// * @param time 时间(秒) -// * @return -// */ -// public boolean lSet(String key, List value, long time) { -// try { -// redisTemplate.opsForList().rightPushAll(key, value); -// if (time > 0) { -// expire(key, time); -// } -// return true; -// } catch (Exception e) { -// e.printStackTrace(); -// return false; -// } -// } -// -// /** -// * 根据索引修改list中的某条数据 -// * @param key 键 -// * @param index 索引 -// * @param value 值 -// * @return -// */ -// public boolean lUpdateIndex(String key, long index,Object value) { -// try { -// redisTemplate.opsForList().set(key, index, value); -// return true; -// } catch (Exception e) { -// e.printStackTrace(); -// return false; -// } -// } -// -// /** -// * 移除N个值为value -// * @param key 键 -// * @param count 移除多少个 -// * @param value 值 -// * @return 移除的个数 -// */ -// public long lRemove(String key,long count,Object value) { -// try { -// Long remove = redisTemplate.opsForList().remove(key, count, value); -// return remove; -// } catch (Exception e) { -// e.printStackTrace(); -// return 0; -// } -// } -// -// ///** -// // * 模糊查询获取key值 -// // * @param pattern -// // * @return -// // */ -// public Set keys(String pattern){ -// return redisTemplate.keys(pattern); -// } -// -// /** -// * 模糊查询 -// * @param pattern -// * @return -// */ -// public Set scan(String pattern) { -// return redisTemplate.execute((RedisCallback>) redisConnection -> { -// Set keys = new HashSet<>(); -// Cursor cursor = redisConnection.scan(new ScanOptions.ScanOptionsBuilder().match(pattern).count(Integer.MAX_VALUE).build()); -// while (cursor.hasNext()) { -// keys.add(new String(cursor.next())); -// } -// return keys; -// }); -// } -// -// /** -// * 使用Redis的消息队列 -// * @param channel -// * @param message 消息内容 -// */ -// public void convertAndSend(String channel, Object message){ -// redisTemplate.convertAndSend(channel,message); -// } -// -// -// //=========BoundListOperations 用法 start============ -// -// -// /** -// * 根据起始结束序号遍历Redis中的list -// * @param listKey -// * @param start 起始序号 -// * @param end 结束序号 -// * @return -// */ -// public List rangeList(String listKey, long start, long end) { -// //绑定操作 -// BoundListOperations boundValueOperations = redisTemplate.boundListOps(listKey); -// //查询数据 -// return boundValueOperations.range(start, end); -// } -// /** -// * 弹出右边的值 --- 并且移除这个值 -// * @param listKey -// */ -// public Object rifhtPop(String listKey){ -// //绑定操作 -// BoundListOperations boundValueOperations = redisTemplate.boundListOps(listKey); -// return boundValueOperations.rightPop(); -// } -// -// //=========BoundListOperations 用法 End============ -// -//} \ No newline at end of file +package com.subsidy.util; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.BoundListOperations; +import org.springframework.data.redis.core.Cursor; +import org.springframework.data.redis.core.RedisCallback; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ScanOptions; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +/** + *

+ * redisTemplate封装 + *

+ * + * @author DengMin + * @since 2020/12/17 + */ + +@Component +public class RedisUtil { + + @Autowired + private RedisTemplate redisTemplate; + + public RedisUtil(RedisTemplate redisTemplate) { + this.redisTemplate = redisTemplate; + } + + /** + * 指定缓存失效时间 + * @param key 键 + * @param time 时间(秒) + * @return + */ + public boolean expire(String key,long time){ + try { + if(time>0){ + redisTemplate.expire(key, time, TimeUnit.SECONDS); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 根据key 获取过期时间 + * @param key 键 不能为null + * @return 时间(秒) 返回0代表为永久有效 + */ + public long getExpire(String key){ + return redisTemplate.getExpire(key,TimeUnit.SECONDS); + } + + /** + * 判断key是否存在 + * @param key 键 + * @return true 存在 false不存在 + */ + public boolean hasKey(String key){ + try { + return redisTemplate.hasKey(key); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 删除缓存 + * @param key 可以传一个值 或多个 + */ + @SuppressWarnings("unchecked") + public void del(String ... key){ + if(key!=null&&key.length>0){ + if(key.length==1){ + redisTemplate.delete(key[0]); + }else{ + redisTemplate.delete(CollectionUtils.arrayToList(key)); + } + } + } + + /** + * 删除缓存 + * @param key 集合数据 + */ + public void del(Set key) { + if (key != null && key.size() > 0) { + redisTemplate.delete(key); + } + } + + //============================String============================= + /** + * 普通缓存获取 + * @param key 键 + * @return 值 + */ + public Object get(String key){ + return key==null?null:redisTemplate.opsForValue().get(key); + } + + /** + * 普通缓存放入 + * @param key 键 + * @param value 值 + * @return true成功 false失败 + */ + public boolean set(String key,Object value) { + try { + redisTemplate.opsForValue().set(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 普通缓存放入并设置时间 + * @param key 键 + * @param value 值 + * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 + * @return true成功 false 失败 + */ + public boolean set(String key,Object value,long time){ + try { + if(time>0){ + redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); + }else{ + set(key, value); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 递增 + * @param key 键 + * @param delta 要增加几(大于0) + * @return + */ + public long incr(String key, long delta){ + if(delta<0){ + throw new RuntimeException("递增因子必须大于0"); + } + return redisTemplate.opsForValue().increment(key, delta); + } + + /** + * 递减 + * @param key 键 + * @param delta 要减少几(小于0) + * @return + */ + public long decr(String key, long delta){ + if(delta<0){ + throw new RuntimeException("递减因子必须大于0"); + } + return redisTemplate.opsForValue().increment(key, -delta); + } + + //================================Map================================= + /** + * HashGet + * @param key 键 不能为null + * @param item 项 不能为null + * @return 值 + */ + public Object hget(String key,String item){ + return redisTemplate.opsForHash().get(key, item); + } + + /** + * 获取hashKey对应的所有键值 + * @param key 键 + * @return 对应的多个键值 + */ + public Map hmget(String key){ + return redisTemplate.opsForHash().entries(key); + } + + /** + * HashSet + * @param key 键 + * @param map 对应多个键值 + * @return true 成功 false 失败 + */ + public boolean hmset(String key, Map map){ + try { + redisTemplate.opsForHash().putAll(key, map); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * HashSet 并设置时间 + * @param key 键 + * @param map 对应多个键值 + * @param time 时间(秒) + * @return true成功 false失败 + */ + public boolean hmset(String key, Map map, long time){ + try { + redisTemplate.opsForHash().putAll(key, map); + if(time>0){ + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 向一张hash表中放入数据,如果不存在将创建 + * @param key 键 + * @param item 项 + * @param value 值 + * @return true 成功 false失败 + */ + public boolean hset(String key,String item,Object value) { + try { + redisTemplate.opsForHash().put(key, item, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 向一张hash表中放入数据,如果不存在将创建 + * @param key 键 + * @param item 项 + * @param value 值 + * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 + * @return true 成功 false失败 + */ + public boolean hset(String key,String item,Object value,long time) { + try { + redisTemplate.opsForHash().put(key, item, value); + if(time>0){ + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 删除hash表中的值 + * @param key 键 不能为null + * @param item 项 可以使多个 不能为null + */ + public void hdel(String key, Object... item){ + redisTemplate.opsForHash().delete(key,item); + } + + /** + * 判断hash表中是否有该项的值 + * @param key 键 不能为null + * @param item 项 不能为null + * @return true 存在 false不存在 + */ + public boolean hHasKey(String key, String item){ + return redisTemplate.opsForHash().hasKey(key, item); + } + + /** + * hash递增 如果不存在,就会创建一个 并把新增后的值返回 + * @param key 键 + * @param item 项 + * @param by 要增加几(大于0) + * @return + */ + public double hincr(String key, String item,double by){ + return redisTemplate.opsForHash().increment(key, item, by); + } + + /** + * hash递减 + * @param key 键 + * @param item 项 + * @param by 要减少记(小于0) + * @return + */ + public double hdecr(String key, String item,double by){ + return redisTemplate.opsForHash().increment(key, item,-by); + } + + //============================set============================= + /** + * 根据key获取Set中的所有值 + * @param key 键 + * @return + */ + public Set sGet(String key){ + try { + return redisTemplate.opsForSet().members(key); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 根据value从一个set中查询,是否存在 + * @param key 键 + * @param value 值 + * @return true 存在 false不存在 + */ + public boolean sHasKey(String key,Object value){ + try { + return redisTemplate.opsForSet().isMember(key, value); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将数据放入set缓存 + * @param key 键 + * @param values 值 可以是多个 + * @return 成功个数 + */ + public long sSet(String key, Object...values) { + try { + return redisTemplate.opsForSet().add(key, values); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 将set数据放入缓存 + * @param key 键 + * @param time 时间(秒) + * @param values 值 可以是多个 + * @return 成功个数 + */ + public long sSetAndTime(String key,long time,Object...values) { + try { + Long count = redisTemplate.opsForSet().add(key, values); + if(time>0) { + expire(key, time); + } + return count; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 获取set缓存的长度 + * @param key 键 + * @return + */ + public long sGetSetSize(String key){ + try { + return redisTemplate.opsForSet().size(key); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 移除值为value的 + * @param key 键 + * @param values 值 可以是多个 + * @return 移除的个数 + */ + public long setRemove(String key, Object ...values) { + try { + Long count = redisTemplate.opsForSet().remove(key, values); + return count; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + //===============================list================================= + + /** + * 获取list缓存的内容 + * @param key 键 + * @param start 开始 + * @param end 结束 0 到 -1代表所有值 + * @return + */ + public List lGet(String key, long start, long end){ + try { + return redisTemplate.opsForList().range(key, start, end); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 获取list缓存的长度 + * @param key 键 + * @return + */ + public long lGetListSize(String key){ + try { + return redisTemplate.opsForList().size(key); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 通过索引 获取list中的值 + * @param key 键 + * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 + * @return + */ + public Object lGetIndex(String key,long index){ + try { + return redisTemplate.opsForList().index(key, index); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @return + */ + public boolean lSet(String key, Object value) { + try { + redisTemplate.opsForList().rightPush(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @param time 时间(秒) + * @return + */ + public boolean lSet(String key, Object value, long time) { + try { + redisTemplate.opsForList().rightPush(key, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @return + */ + public boolean lSet(String key, List value) { + try { + redisTemplate.opsForList().rightPushAll(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @param time 时间(秒) + * @return + */ + public boolean lSet(String key, List value, long time) { + try { + redisTemplate.opsForList().rightPushAll(key, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 根据索引修改list中的某条数据 + * @param key 键 + * @param index 索引 + * @param value 值 + * @return + */ + public boolean lUpdateIndex(String key, long index,Object value) { + try { + redisTemplate.opsForList().set(key, index, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 移除N个值为value + * @param key 键 + * @param count 移除多少个 + * @param value 值 + * @return 移除的个数 + */ + public long lRemove(String key,long count,Object value) { + try { + Long remove = redisTemplate.opsForList().remove(key, count, value); + return remove; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + ///** + // * 模糊查询获取key值 + // * @param pattern + // * @return + // */ + public Set keys(String pattern){ + return redisTemplate.keys(pattern); + } + + /** + * 模糊查询 + * @param pattern + * @return + */ + public Set scan(String pattern) { + return redisTemplate.execute((RedisCallback>) redisConnection -> { + Set keys = new HashSet<>(); + Cursor cursor = redisConnection.scan(new ScanOptions.ScanOptionsBuilder().match(pattern).count(Integer.MAX_VALUE).build()); + while (cursor.hasNext()) { + keys.add(new String(cursor.next())); + } + return keys; + }); + } + + /** + * 使用Redis的消息队列 + * @param channel + * @param message 消息内容 + */ + public void convertAndSend(String channel, Object message){ + redisTemplate.convertAndSend(channel,message); + } + + + //=========BoundListOperations 用法 start============ + + + /** + * 根据起始结束序号遍历Redis中的list + * @param listKey + * @param start 起始序号 + * @param end 结束序号 + * @return + */ + public List rangeList(String listKey, long start, long end) { + //绑定操作 + BoundListOperations boundValueOperations = redisTemplate.boundListOps(listKey); + //查询数据 + return boundValueOperations.range(start, end); + } + /** + * 弹出右边的值 --- 并且移除这个值 + * @param listKey + */ + public Object rifhtPop(String listKey){ + //绑定操作 + BoundListOperations boundValueOperations = redisTemplate.boundListOps(listKey); + return boundValueOperations.rightPop(); + } + + //=========BoundListOperations 用法 End============ + +} \ No newline at end of file diff --git a/src/main/java/com/subsidy/vo/administer/UserRoleVO.java b/src/main/java/com/subsidy/vo/administer/UserRoleVO.java index b21bc08..cd47047 100644 --- a/src/main/java/com/subsidy/vo/administer/UserRoleVO.java +++ b/src/main/java/com/subsidy/vo/administer/UserRoleVO.java @@ -30,4 +30,6 @@ public class UserRoleVO { private List rotationImgDictDOS; + private String token; + } diff --git a/src/main/java/com/subsidy/vo/member/MemberVO.java b/src/main/java/com/subsidy/vo/member/MemberVO.java index a193b84..968bf17 100644 --- a/src/main/java/com/subsidy/vo/member/MemberVO.java +++ b/src/main/java/com/subsidy/vo/member/MemberVO.java @@ -27,4 +27,6 @@ public class MemberVO { private String logo; private List rotationImgDictDOS; + + private String token; } diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index cf81c7a..eb13e2d 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -38,9 +38,9 @@ spring.servlet.multipart.max-request-size=4098KB #spring.redis.lettuce.pool.max-active=32 #spring.redis.lettuce.pool.min-idle=8 -spring.redis.host=r-uf6pdbuxqgy0ztfmn1pd.redis.rds.aliyuncs.com -spring.redis.password=r-uf6pdbuxqgy0ztfmn1:Ykhl@208 -spring.redis.port=6379 +spring.redis.host=sh-crs-hq5xbrsq.sql.tencentcdb.com +spring.redis.password=Ykhl@302 +spring.redis.port=20260 spring.redis.lettuce.pool.max-idle=16 spring.redis.lettuce.pool.max-active=32 spring.redis.lettuce.pool.min-idle=8 \ No newline at end of file diff --git a/src/main/resources/code.properties b/src/main/resources/code.properties index 078b9ab..7a58a2c 100644 --- a/src/main/resources/code.properties +++ b/src/main/resources/code.properties @@ -1,6 +1,7 @@ meishu.code-message[0]=成功 meishu.code-message[1010]=无效的令牌 +meishu.code-message[1011]=当前账户已在其他设备登录 meishu.code-message[10003]=验证码错误 meishu.code-message[10004]=账号或密码错误 -- libgit2 0.25.0