项目初始化

main
cheney 12 months ago
parent b75a3be5f0
commit 47d8ba5321
  1. 24
      api/pom.xml
  2. 117
      api/src/main/java/com/huoran/api/NakadaiClient.java
  3. 162
      api/src/main/java/com/huoran/api/OccupationlabClient.java
  4. 136
      api/src/main/java/com/huoran/api/UserClient.java
  5. 94
      api/src/main/java/com/huoran/api/impl/NakadaiClientImpl.java
  6. 117
      api/src/main/java/com/huoran/api/impl/OccupationlabImpl.java
  7. 91
      api/src/main/java/com/huoran/api/impl/UserClientImpl.java
  8. 69
      api/src/main/java/com/huoran/config/FeignSimpleEncoderConfig.java
  9. 283
      common/pom.xml
  10. 7
      common/src/main/java/com/huoran/common/aop/annotation/LimitType.java
  11. 25
      common/src/main/java/com/huoran/common/aop/annotation/LogAnnotation.java
  12. 17
      common/src/main/java/com/huoran/common/aop/annotation/NoRepeatSubmit.java
  13. 36
      common/src/main/java/com/huoran/common/aop/annotation/RedisLimit.java
  14. 67
      common/src/main/java/com/huoran/common/aop/aspect/NoRepeatSubmitAop.java
  15. 115
      common/src/main/java/com/huoran/common/aop/aspect/RateLimiterAspect.java
  16. 109
      common/src/main/java/com/huoran/common/aop/aspect/RedisLimitAspect.java
  17. 228
      common/src/main/java/com/huoran/common/aop/aspect/RedisServiceAop.java
  18. 25
      common/src/main/java/com/huoran/common/config/FallbackHandler.java
  19. 48
      common/src/main/java/com/huoran/common/config/MyCacheConfig.java
  20. 33
      common/src/main/java/com/huoran/common/config/MybatisPlusConfig.java
  21. 125
      common/src/main/java/com/huoran/common/config/RedisAutoConfiguration.java
  22. 25
      common/src/main/java/com/huoran/common/config/RedisConfig.java
  23. 36
      common/src/main/java/com/huoran/common/config/RobotNotification.java
  24. 37
      common/src/main/java/com/huoran/common/config/SentinelConfig.java
  25. 21
      common/src/main/java/com/huoran/common/constant/AnRateLimiter.java
  26. 48
      common/src/main/java/com/huoran/common/constant/AssessmentConstant.java
  27. 33
      common/src/main/java/com/huoran/common/constant/ClassificationOfTheoreticalCoursesConstant.java
  28. 68
      common/src/main/java/com/huoran/common/constant/DelConstant.java
  29. 12
      common/src/main/java/com/huoran/common/constant/EnableStatus.java
  30. 20
      common/src/main/java/com/huoran/common/constant/ExcelConstant.java
  31. 20
      common/src/main/java/com/huoran/common/constant/LoginDistConstant.java
  32. 20
      common/src/main/java/com/huoran/common/constant/ModellConstant.java
  33. 51
      common/src/main/java/com/huoran/common/constant/OrderConstant.java
  34. 35
      common/src/main/java/com/huoran/common/constant/PlatformConstant.java
  35. 8
      common/src/main/java/com/huoran/common/constant/PointConstant.java
  36. 19
      common/src/main/java/com/huoran/common/constant/RabbitmqConstant.java
  37. 34
      common/src/main/java/com/huoran/common/constant/SMSTemplate.java
  38. 44
      common/src/main/java/com/huoran/common/constant/ServiceNameConstant.java
  39. 31
      common/src/main/java/com/huoran/common/constant/TeamCalculationMethodConstant.java
  40. 74
      common/src/main/java/com/huoran/common/entity/Architecture.java
  41. 62
      common/src/main/java/com/huoran/common/entity/BcJudgmentPoint.java
  42. 52
      common/src/main/java/com/huoran/common/entity/Class.java
  43. 146
      common/src/main/java/com/huoran/common/entity/ExperimentalReport.java
  44. 36
      common/src/main/java/com/huoran/common/entity/FilesResult.java
  45. 54
      common/src/main/java/com/huoran/common/entity/LcJudgmentPoint.java
  46. 33
      common/src/main/java/com/huoran/common/entity/LcJudgmentRuleReq.java
  47. 69
      common/src/main/java/com/huoran/common/entity/LcRuleRecord.java
  48. 63
      common/src/main/java/com/huoran/common/entity/NewClientManagement.java
  49. 46
      common/src/main/java/com/huoran/common/entity/ProjectJudgmentVo.java
  50. 161
      common/src/main/java/com/huoran/common/entity/ProjectManage.java
  51. 36
      common/src/main/java/com/huoran/common/entity/PyAttributesReq.java
  52. 27
      common/src/main/java/com/huoran/common/entity/PythonCodeResp.java
  53. 57
      common/src/main/java/com/huoran/common/entity/Role.java
  54. 92
      common/src/main/java/com/huoran/common/entity/RunCode.java
  55. 62
      common/src/main/java/com/huoran/common/entity/School.java
  56. 60
      common/src/main/java/com/huoran/common/entity/Student.java
  57. 87
      common/src/main/java/com/huoran/common/entity/UserAccount.java
  58. 104
      common/src/main/java/com/huoran/common/entity/UserInfo.java
  59. 56
      common/src/main/java/com/huoran/common/entity/UserRole.java
  60. 87
      common/src/main/java/com/huoran/common/entity/UserScore.java
  61. 58
      common/src/main/java/com/huoran/common/entity/resp/PhoneBindingrResp.java
  62. 40
      common/src/main/java/com/huoran/common/entity/resp/ProductAndOrderResp.java
  63. 19
      common/src/main/java/com/huoran/common/entity/to/JudgmentPointDataTo.java
  64. 18
      common/src/main/java/com/huoran/common/entity/to/ProjectDataTo.java
  65. 54
      common/src/main/java/com/huoran/common/exception/BusinessException.java
  66. 18
      common/src/main/java/com/huoran/common/exception/CustomException.java
  67. 56
      common/src/main/java/com/huoran/common/exception/CustomExceptionHandler.java
  68. 156
      common/src/main/java/com/huoran/common/exception/ExceptionEnum.java
  69. 24
      common/src/main/java/com/huoran/common/exception/ExceptionResult.java
  70. 69
      common/src/main/java/com/huoran/common/exception/code/BaseResponseCode.java
  71. 24
      common/src/main/java/com/huoran/common/exception/code/ResponseCodeInterface.java
  72. 28
      common/src/main/java/com/huoran/common/handler/MyMetaObjectHandler.java
  73. 97
      common/src/main/java/com/huoran/common/response/R.java
  74. 447
      common/src/main/java/com/huoran/common/utils/AliyunOssUtil.java
  75. 17
      common/src/main/java/com/huoran/common/utils/AliyunVodSDKUtil.java
  76. 143
      common/src/main/java/com/huoran/common/utils/CacheUtil.java
  77. 44
      common/src/main/java/com/huoran/common/utils/CheckCodeUtils.java
  78. 41
      common/src/main/java/com/huoran/common/utils/CheckDateUtil.java
  79. 39
      common/src/main/java/com/huoran/common/utils/ConstantPropertiesUtil.java
  80. 45
      common/src/main/java/com/huoran/common/utils/DateUtil.java
  81. 193
      common/src/main/java/com/huoran/common/utils/DateUtils.java
  82. 31
      common/src/main/java/com/huoran/common/utils/DeleteFilesUtil.java
  83. 81
      common/src/main/java/com/huoran/common/utils/EmailUtils.java
  84. 32
      common/src/main/java/com/huoran/common/utils/HttpContextUtils.java
  85. 73
      common/src/main/java/com/huoran/common/utils/IPUtils.java
  86. 57
      common/src/main/java/com/huoran/common/utils/JwtUtils.java
  87. 34
      common/src/main/java/com/huoran/common/utils/MD5.java
  88. 111
      common/src/main/java/com/huoran/common/utils/PageUtils.java
  89. 64
      common/src/main/java/com/huoran/common/utils/RandomUtil.java
  90. 56
      common/src/main/java/com/huoran/common/utils/SendSMSUtils.java
  91. 60
      common/src/main/java/com/huoran/common/utils/TokenUtils.java
  92. 18
      common/src/main/java/com/huoran/common/utils/VideoUtil.java
  93. 124
      competition/pom.xml
  94. 22
      competition/src/main/java/com/huoran/competition/CompetitionApplication.java
  95. 29
      competition/src/main/java/com/huoran/competition/config/AsyncTaskPoolConfig.java
  96. 54
      competition/src/main/java/com/huoran/competition/config/DruidConfig.java
  97. 69
      competition/src/main/java/com/huoran/competition/config/SwaggerConfig.java
  98. 51
      competition/src/main/java/com/huoran/competition/controller/CompetitionAnnexController.java
  99. 67
      competition/src/main/java/com/huoran/competition/controller/CompetitionAnnouncementAnnexController.java
  100. 114
      competition/src/main/java/com/huoran/competition/controller/CompetitionAnnouncementController.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>huoran</artifactId>
<groupId>com.huoran.parent</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.huoran.api</groupId>
<artifactId>api</artifactId>
<description>api模块</description>
<dependencies>
<dependency>
<groupId>com.huoran.common</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1,117 @@
package com.huoran.api;
import com.huoran.api.impl.NakadaiClientImpl;
import com.huoran.common.constant.ServiceNameConstant;
import com.huoran.common.entity.School;
import com.huoran.common.entity.to.JudgmentPointDataTo;
import com.huoran.common.response.R;
import com.huoran.config.FeignSimpleEncoderConfig;
import feign.Headers;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @Author cheney
* @DATE 2021/7/15 10:09
* @Version 1.0
* 远程调用中台
*/
@FeignClient(value = ServiceNameConstant.NAKADAI,
fallbackFactory = NakadaiClientImpl.class, configuration = FeignSimpleEncoderConfig.class)
@Headers("Accept: application/json")
public interface NakadaiClient {
/**
* 查询客户订单
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@GetMapping(value = "/nakadai/nakadai/order/getCustomerOrder", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
R getCustomerOrder(@RequestParam("customerId") Integer customerId);
/**
* 查询订单其他信息
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@GetMapping(value = "/nakadai/nakadai/orderOther/getOrderOther", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
R getOrderOther(@RequestParam("orderId") Integer orderId, @RequestParam("authority") Integer authority);
/**
* 删除多个文件
*
* @param keys 多个文件完整名称集合
* @return 返回多个删除的文件名
*/
// @DeleteMapping("/nakadai/oss/fileDeletion")
// R fileDeletion(@RequestParam("keys") List<String> keys);
/**
* 上传文件
*
* @param file 文件
* @return 文件路径及相关信息
*/
@PostMapping("/nakadai/nakadai/oss/fileUpload")
R fileUpload(@RequestParam("file") MultipartFile file);
/**
* 根据学校id获取客户id
*
* @param schoolId
* @return
*/
@GetMapping("/nakadai/nakadai/customer/getCustomerBySchoolId")
Integer getCustomerBySchoolId(@RequestParam("schoolId") Integer schoolId);
/**
* 根据客户id获取所有的系统id
*
* @param customerId
* @return
*/
@GetMapping("/nakadai/nakadai/curriculum/getSystemIdByCustomerId")
List<Integer> getSystemIdByCustomerId(@RequestParam("customerId") Integer customerId);
/**
* 根据系统id获取系统名称
*
* @param SystemId
* @return
*/
@GetMapping("/nakadai/nakadai/serviceConfiguration/getSystemNameBySystemId")
String getSystemNameBySystemId(@RequestParam("SystemId") Integer SystemId);
/**
* @Description : 根据学校id获取学校购买的课程id(此处返回逗号拼接格式)
* @Param schoolId
* @Author Rong---2021/11/8
*/
@GetMapping("/nakadai/nakadai/curriculum/getSchoolCourse")
String getSchoolCourse(@RequestParam("schoolId") Integer schoolId);
/**
* 查询客户订单信息
*/
@PostMapping("/nakadai/nakadai/orderOther/getCustomerOrderOther")
JudgmentPointDataTo getCustomerOrderOther(@RequestParam("schoolId") Integer schoolId, @RequestParam("systemId") Integer systemId, @RequestParam("name") String name);
@DeleteMapping("/nakadai/nakadai/oss/fileDeletion")
R fileDeletion(@RequestParam("keys")List<String> keys,@RequestParam("request") HttpServletRequest request);
@GetMapping("/nakadai/nakadai/school/getTheSchoolNameBySchoolId")
School getTheSchoolNameBySchoolId(@RequestParam("schoolId") Integer schoolId);
@GetMapping("/nakadai/nakadai/school/getTheIdBySchoolName")
School getTheIdBySchoolName(@RequestParam("schoolName") String schoolName);
@PostMapping("/nakadai/message/refreshPageNotification")
void refreshPageNotification(@RequestParam("username") String username, @RequestParam("to") String to, @RequestParam("content") String content);
}

@ -0,0 +1,162 @@
package com.huoran.api;
import com.huoran.api.impl.OccupationlabImpl;
import com.huoran.common.constant.ServiceNameConstant;
import com.huoran.common.entity.ExperimentalReport;
import com.huoran.common.entity.ProjectManage;
import com.huoran.common.entity.UserScore;
import com.huoran.common.entity.to.JudgmentPointDataTo;
import com.huoran.common.entity.to.ProjectDataTo;
import com.huoran.common.response.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @description 职站远程调用客户端
* @author: Mr.JK
* @create: 2021-09-10 15:03
**/
@FeignClient(value = ServiceNameConstant.OCCUPATIONLAB, fallbackFactory = OccupationlabImpl.class)
public interface OccupationlabClient {
/**
* 添加实验报告
*
* @param experimentalReport
* @return 添加成功返回主键id
*/
@PostMapping("/occupationlab/occupationlab/experimentalReport/addExperimentalReport")
Integer addExperimentalReport(@RequestBody ExperimentalReport experimentalReport);
/**
* 添加用户分数 单条
*
* @param userScore
* @return 添加成功返回主键id
*/
@PostMapping("/occupationlab/occupationlab/userScore/addUserScore")
Integer addUserScore(@RequestBody UserScore userScore);
/**
* 获取项目管理判分点关系表分数
*
* @param projectId 项目id
* @param JudgmentId 判分点id
* @return 分数
*/
@GetMapping("/occupationlab/occupationlab/projectJudgment/getJudgmentScore")
Integer getJudgmentScore(@RequestParam("projectId") Integer projectId, @RequestParam("JudgmentId") Integer JudgmentId);
/**
* 根据系统id项目权限获取系统内置项目
*
* @param systemId
* @param permissions
* @return
*/
@GetMapping("/occupationlab/occupationlab/projectManage/getInternalProjectBySystemId")
List<ProjectManage> getInternalProjectBySystemId(@RequestParam Integer systemId, @RequestParam Integer permissions);
@ApiOperation(value = "根据系统id获取项目(获取课程下与该学校下的所有项目)")
@GetMapping("/occupationlab/occupationlab/projectManage/getProjectBySystemId")
R getProjectBySystemId(@RequestParam String systemId, @RequestHeader String token, @RequestParam Integer permissions, @RequestParam Integer cId, @RequestParam Integer mallId);
/**
* @Description : 创建客户复制题库
* @Param schoolId
* @Author Rong---2021/11/2
*/
@PostMapping("/occupationlab/occupationlab/questions/copyQuestion")
boolean copyQuestion(@RequestParam Integer schoolId, @RequestParam Integer accountId);
/**
* @Description : 新增客户新增学生管理初始数据
* @Param req
* @Param accountId
* @Author Rong---2021/11/2
*/
@PostMapping("/occupationlab/occupationlab/architecture/saveData")
boolean saveData(@RequestParam("schoolId") Integer schoolId);
/**
* @Description : 添加课程初始数据
* @Param schoolId
* @Param accountId
* @Author Rong---2021/11/2
*/
@PostMapping("/occupationlab/occupationlab/management/edu/course/addCourseData")
boolean addCourseData(@RequestParam("schoolId") Integer schoolId, @RequestParam("accountId") Integer accountId);
/**
* 添加赛事样例数据
*
* @param schoolId
* @param accountId
* @return
*/
@PostMapping("/occupationlab/occupationlab/enterprise/match/contest/eventSampleData")
boolean eventSampleData(@RequestParam("schoolId") Integer schoolId, @RequestParam("accountId") Integer accountId);
/***
* @Description : 添加资讯内置数据
* @Param
* @Author Rong---2021/11/3
*/
@PostMapping("/occupationlab/occupationlab/information/article/addArticleData")
boolean addArticleData(@RequestParam("accountId") Integer accountId, @RequestParam("schoolId") Integer schoolId);
/**
* @Description : 创建客户复制测评规则
* @Param schoolId
* @Author Rong---2021/11/2
*/
@PostMapping("/occupationlab/occupationlab/questions/copyEvaluationRules")
boolean copyEvaluationRules(@RequestParam Integer schoolId);
/**
* @Description : 创建客户添加内置员工组织架构数据
* @Param schoolId
* @Author Rong---2021/11/11
*/
@PostMapping("/occupationlab/occupationlab/staff/saveStaffData")
boolean saveStaffData(@RequestParam Integer schoolId);
@PostMapping("/occupationlab/occupationlab/assessment/submitExam")
boolean submitExam(@RequestParam("assessmentId") Integer assessmentId,
@RequestParam("classId") Integer classId,
@RequestParam("accountId") Integer accountId,
@RequestParam("score") Integer score);
@GetMapping("/occupationlab/occupationlab/assessment/getTeacherIdByAssessmentId")
Integer getTeacherIdByAssessmentId(@RequestParam("assessmentId") Integer assessmentId);
/**
* 根据项目id查询判分点
*/
@PostMapping("/occupationlab/occupationlab/projectManage/getProjectPoints")
JudgmentPointDataTo getProjectPoints(@RequestBody ProjectDataTo projectDataTo);
@PostMapping("/occupationlab/occupationlab/theoreticalCourseClassification/builtInCourseClassification")
boolean builtInCourseClassification(@RequestParam("schoolId") Integer schoolId,@RequestParam("accountId") Integer accountId);
@GetMapping("/occupationlab/occupationlab/projectManage/getProjectBySystemIdRemoteCall")
List<ProjectManage> getProjectBySystemIdRemoteCall(
@RequestParam String systemId,
@RequestParam Integer permissions,
@RequestParam Integer cId,
@RequestParam Integer accountId);
/**
* 根据班级id查询班级详情
*/
@GetMapping("/occupationlab/occupationlab/class/queryClassDetails")
boolean queryClassDetails(@RequestParam("id") Integer id);
}

@ -0,0 +1,136 @@
package com.huoran.api;
import com.huoran.api.impl.UserClientImpl;
import com.huoran.common.constant.ServiceNameConstant;
import com.huoran.common.entity.Role;
import com.huoran.common.entity.UserRole;
import com.huoran.common.response.R;
import feign.Headers;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* <p>
* 远程调用用户服务
* </p>
*
* @author lr
* @since 2021-08-24
*/
@FeignClient(value = ServiceNameConstant.USERS, fallbackFactory = UserClientImpl.class)
@Headers("Accept: application/json")
public interface UserClient {
/**
* 根据账号id获取当前账号id所在学校id
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@GetMapping(value = "/users/users/userAccount/getSchoolIdByAccountId", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
Integer getSchoolIdByAccountId(@RequestParam("accountId") String accountId);
/**
* 删除职站用户
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@PostMapping(value = "/users/users/occupationlab/user/delStudent", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
void delStudent(@RequestParam("accountIds") List<Integer> accountIds);
/**
* 删除用户账户信息表
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@PostMapping(value = "/users/users/occupationlab/user/delAccountAndUser", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
void delAccountAndUser(@RequestParam("accountId") Integer accountId);
/**
* 账号赋予角色
*
* @param accountId
* @param roleIds
* @return
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@PostMapping(value = "/users/users/user-role/rolePermissionService", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
R rolePermissionService(@RequestParam("accountId") Integer accountId, @RequestParam("roleIds") List<Integer> roleIds,@RequestParam(value = "teamId",required = false) Integer teamId);
/**
* @Description :删除某用户下的某个角色
* @Param roleId
* @Param accountId
* @Author Rong---2021/10/15
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@PostMapping(value = "/users/users/role/delRoleByAccountId", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
R delRoleByAccountId(@RequestParam("roleId") Integer roleId, @RequestParam("accountId") Integer accountId);
/**
* 为客户添加超管角色等相关操作
*
* @param schoolId
* @param accountId
* @return
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@PostMapping("/users/users/role/addCustomerAdmin")
boolean addCustomerAdmin(@RequestParam("schoolId") Integer schoolId, @RequestParam("accountId") String accountId);
/**
* @Description : 判断该角色是否存在
* @Param roleName
* @Param request
* @Author Rong---2021/10/18
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@PostMapping(value = "/users/users/role/checkRoleIsExist", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
Role checkRoleIsExist(@RequestParam("roleName") String roleName, @RequestParam("schoolId") Integer schoolId,@RequestParam("platformId")Integer platformId);
/**
* @Description : 校验手机号是否存在
* @Param phone
* @Author Rong---2021/10/18
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@GetMapping(value = "/users/users/userInfo/checkPhoneOrEmailExist", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
boolean checkPhoneOrEmailExist(@RequestParam("phone") String phone, @RequestParam("email") String email, @RequestParam("type") Integer type);
@Headers({"Content-Type: application/json", "Accept: application/json"})
@PostMapping(value = "/users/users/role/checkIsSuperTube", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
boolean checkIsSuperTube(@RequestParam("accountId") String accountId);
/**
* 根据平台获取该用户在该平台的角色
*
* @param accountId
* @param platformId
* @return
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@PostMapping(value = "/users/users/role/getUserAllRole", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
String getUserAllRole(@RequestParam("accountId") String accountId, @RequestParam("platformId") Integer platformId);
/**
* @Description : 根据账号id查询账户名称
* @Param accountId
* @Author Rong---2021/12/30
*/
@GetMapping(value = "/users/users/userInfo/getUserName")
String getUserName(@RequestParam("accountId") Integer accountId);
@GetMapping(value = "/users/users/user/accountIsDisabled")
boolean accountIsDisabled(@RequestParam("token") String token);
@PostMapping(value = "/users/users/role/getAccountIdsBySchoolId")
List<Integer> getAccountIdsBySchoolId( @RequestParam("schoolId") Integer schoolId, @RequestParam("platformId") Integer platformId);
}

@ -0,0 +1,94 @@
package com.huoran.api.impl;
import com.huoran.api.NakadaiClient;
import com.huoran.common.entity.School;
import com.huoran.common.entity.to.JudgmentPointDataTo;
import com.huoran.common.response.R;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @version 1.1 2021年8月26日15:03:52 JK修改 服务降级处理
* @Author chen
* @DATE 2021/7/15 11:16
* @Version 1.0
*/
@Component
public class NakadaiClientImpl implements FallbackFactory<NakadaiClient> {
@Override
public NakadaiClient create(Throwable throwable) {
return new NakadaiClient() {
@Override
public R getCustomerOrder(Integer customerId) {
return R.error("调用服务失败:" + throwable.getMessage());
}
@Override
public R getOrderOther(Integer orderId, Integer authority) {
return R.error("调用服务失败:" + throwable.getMessage());
}
/*@Override
public R fileDeletion(List<String> keys) {
return R.error("调用服务失败:" + throwable.getMessage());
}
*/
@Override
public R fileUpload(MultipartFile file) {
return R.error("调用服务失败:" + throwable.getMessage());
}
@Override
public Integer getCustomerBySchoolId(Integer schoolId) {
return -1;
}
@Override
public List<Integer> getSystemIdByCustomerId(Integer customerId) {
return null;
}
@Override
public String getSystemNameBySystemId(Integer SystemId) {
return null;
}
@Override
public String getSchoolCourse(Integer schoolId) {
return null;
}
@Override
public JudgmentPointDataTo getCustomerOrderOther(Integer schoolId, Integer systemId,String name) {
return null;
}
@Override
public R fileDeletion(List<String> keys, HttpServletRequest request) {
return null;
}
@Override
public School getTheSchoolNameBySchoolId(Integer schoolId) {
return null;
}
@Override
public School getTheIdBySchoolName(String schoolName) {
return null;
}
@Override
public void refreshPageNotification(String username, String to, String content) {
}
};
}
}

@ -0,0 +1,117 @@
package com.huoran.api.impl;
import com.huoran.api.OccupationlabClient;
import com.huoran.common.entity.ExperimentalReport;
import com.huoran.common.entity.ProjectManage;
import com.huoran.common.entity.UserScore;
import com.huoran.common.entity.to.JudgmentPointDataTo;
import com.huoran.common.entity.to.ProjectDataTo;
import com.huoran.common.response.R;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @description 服务降级
* @author: Mr.JK
* @create: 2021-09-10 15:09
**/
@Component
public class OccupationlabImpl implements FallbackFactory<OccupationlabClient> {
@Override
public OccupationlabClient create(Throwable cause) {
return new OccupationlabClient() {
@Override
public Integer addExperimentalReport(ExperimentalReport experimentalReport) {
return null;
}
@Override
public Integer addUserScore(UserScore userScore) {
return null;
}
@Override
public Integer getJudgmentScore(Integer projectId, Integer JudgmentId) {
return 0;
}
@Override
public List<ProjectManage> getInternalProjectBySystemId(Integer systemId, Integer permissions) {
return null;
}
@Override
public boolean copyQuestion(Integer schoolId, Integer accountId) {
return false;
}
@Override
public boolean saveData(Integer schoolId) {
return false;
}
@Override
public boolean addCourseData(Integer schoolId, Integer accountId) {
return false;
}
@Override
public boolean eventSampleData(Integer schoolId, Integer accountId) {
return false;
}
@Override
public boolean addArticleData(Integer accountId, Integer schoolId) {
return false;
}
@Override
public boolean copyEvaluationRules(Integer schoolId) {
return false;
}
@Override
public boolean saveStaffData(Integer schoolId) {
return false;
}
@Override
public boolean submitExam(Integer assessmentId, Integer classId, Integer accountId, Integer score) {
return false;
}
@Override
public Integer getTeacherIdByAssessmentId(Integer assessmentId) {
return null;
}
@Override
public JudgmentPointDataTo getProjectPoints(ProjectDataTo projectDataTo) {
return null;
}
@Override
public boolean builtInCourseClassification(Integer schoolId, Integer accountId) {
return false;
}
@Override
public List<ProjectManage> getProjectBySystemIdRemoteCall(String systemId, Integer permissions, Integer cId, Integer accountId) {
return null;
}
@Override
public boolean queryClassDetails(Integer id) {
return false;
}
@Override
public R getProjectBySystemId(String systemId, String token, Integer permissions, Integer cId,Integer mallId) {
return null;
}
};
}
}

@ -0,0 +1,91 @@
package com.huoran.api.impl;
import com.huoran.api.UserClient;
import com.huoran.common.entity.Role;
import com.huoran.common.response.R;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
/**
* @Author chen
* @DATE 2021/7/15 11:16
* @Version 1.0
*/
@Component
public class UserClientImpl implements FallbackFactory<UserClient> {
@Override
public UserClient create(Throwable cause) {
return new UserClient() {
@Override
public Integer getSchoolIdByAccountId(String accountId) {
return -1;
}
@Override
public void delStudent(List<Integer> accountIds) {
}
@Override
public void delAccountAndUser(Integer accountId) {
}
@Override
public boolean addCustomerAdmin(Integer schoolId, String accountId) {
return false;
}
@Override
public R rolePermissionService(Integer accountId, List<Integer> roleIds,Integer teamId) {
return null;
}
@Override
public R delRoleByAccountId(Integer roleId, Integer accountId) {
return null;
}
@Override
public Role checkRoleIsExist(String roleName, Integer schoolId,Integer platformId) {
return null;
}
@Override
public boolean checkPhoneOrEmailExist(String phone, String email, Integer type) {
return false;
}
@Override
public boolean checkIsSuperTube(String accountId) {
return false;
}
@Override
public String getUserAllRole(String accountId, Integer platformId) {
return null;
}
@Override
public String getUserName(Integer accountId) {
return null;
}
@PostMapping("/users/users/role/getAccountIdsBySchoolId")
@Override
public List<Integer> getAccountIdsBySchoolId(Integer schoolId, Integer platformId) {
return null;
}
@Override
public boolean accountIsDisabled(String token) {
return false;
}
};
}
}

@ -0,0 +1,69 @@
package com.huoran.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import com.alibaba.fastjson.support.springfox.SwaggerJsonSerializer;
import feign.Logger;
import feign.codec.Decoder;
import feign.codec.Encoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.SpringDecoder;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import java.util.ArrayList;
import java.util.List;
/**
* @Author chen
* @DATE 2021/7/15 16:52
* @Version 1.0
*/
@Configuration
public class FeignSimpleEncoderConfig {
@Bean
Logger.Level feignLoggerLevel() {
//这里记录所有,根据实际情况选择合适的日志level
return Logger.Level.FULL;
}
@Bean
public Encoder feignEncoder() {
return new SpringEncoder(feignHttpMessageConverter());
}
@Bean
public Decoder feignDecoder() {
return new SpringDecoder(feignHttpMessageConverter());
}
/**
* 设置解码器为fastjson
*
* @return
*/
private ObjectFactory<HttpMessageConverters> feignHttpMessageConverter() {
final HttpMessageConverters httpMessageConverters = new HttpMessageConverters(this.getFastJsonConverter());
return () -> httpMessageConverters;
}
private FastJsonHttpMessageConverter getFastJsonConverter() {
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
List<MediaType> supportedMediaTypes = new ArrayList<>();
MediaType mediaTypeJson = MediaType.valueOf(MediaType.APPLICATION_JSON_UTF8_VALUE);
supportedMediaTypes.add(mediaTypeJson);
converter.setSupportedMediaTypes(supportedMediaTypes);
FastJsonConfig config = new FastJsonConfig();
config.getSerializeConfig().put(JSON.class, new SwaggerJsonSerializer());
config.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect);
converter.setFastJsonConfig(config);
return converter;
}
}

@ -0,0 +1,283 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>huoran</artifactId>
<groupId>com.huoran.parent</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.huoran.common</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>common</name>
<description>或然项目子工程-公共微服务</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<gson.version>2.8.2</gson.version>
<hutool-all.version>5.7.0</hutool-all.version>
<jwt.version>0.7.0</jwt.version>
<mysql-connector-java.version>8.0.16</mysql-connector-java.version>
</properties>
<dependencyManagement>
<dependencies>
<!--Spring Cloud-alibaba-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.1.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.0</version>
</dependency>
<!-- form数据验证依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!--druid依赖-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.20</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-zipkin</artifactId>-->
<!-- </dependency>-->
<!--&lt;!&ndash; sentinel分布式系统的流量控制&ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>-->
<!-- </dependency>-->
<!-- redisson分布式锁,分布式作用功能框架 -->
<!-- <dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<!--视频上传依赖-->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-sdk-vod-upload</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-vod</artifactId>
</dependency>
<!-- JWT-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jwt.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<!--服务调用-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-cloud-netflix-archaius</artifactId>
<groupId>org.springframework.cloud</groupId>
</exclusion>
</exclusions>
</dependency>
<!--服务发现-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<exclusions>
<exclusion>
<artifactId>fastjson</artifactId>
<groupId>com.alibaba</groupId>
</exclusion>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
</exclusions>
</dependency>
<!--服务配置-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!--导入mysql的驱动-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- springboot整合redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- elasticsearch -->
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>-->
<!-- mybatis-plus-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus -->
<!-- <dependency>-->
<!-- <groupId>com.baomidou</groupId>-->
<!-- <artifactId>mybatis-plus</artifactId>-->
<!-- <version>3.5.3.1</version>-->
<!-- </dependency>-->
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!--swagger start-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<!--移除swagger-models 1.5.20 依赖,存在Swagger2异常:Illegal DefaultValue null for parameter type integer问题-->
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</dependency>
<!--swagger end-->
<!-- json工具包 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
</dependency>
<!-- 发送邮箱 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool-all.version}</version>
</dependency>
<!-- velocity 模板引擎, Mybatis Plus 代码生成器需要 -->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>${velocity.version}</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1,7 @@
package com.huoran.common.aop.annotation;
public enum LimitType {
IP,
CUSTOMER;
}

@ -0,0 +1,25 @@
package com.huoran.common.aop.annotation;
import java.lang.annotation.*;
/**
* LogAnnotation
*
* @author cheney
* @version V1.0
* @date 2022年7月28日
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface LogAnnotation {
/**
* 模块
*/
String title() default "";
/**
* 功能
*/
String action() default "";
}

@ -0,0 +1,17 @@
package com.huoran.common.aop.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @Description 不重复提交注解
*/
@Target(ElementType.METHOD) // 作用到方法上
@Retention(RetentionPolicy.RUNTIME) // 运行时有效
public @interface NoRepeatSubmit {
String name() default "name:";
}

@ -0,0 +1,36 @@
package com.huoran.common.aop.annotation;
import java.lang.annotation.*;
@Target({ElementType.METHOD,ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface RedisLimit {
//count 代表请求总数量
//period 代表限制时间
//即 period 时间内,只允许有 count 个请求总数量访问,超过的将被限制不能访问
// 资源名称
String name() default "";
// 资源key
String key() default "";
// 前缀
String prefix() default "";
// 时间
int period();
// 最多访问次数
int count();
// 类型
LimitType limitType() default LimitType.CUSTOMER;
// 提示信息
String msg() default "系统繁忙,请稍后再试";
}

@ -0,0 +1,67 @@
package com.huoran.common.aop.aspect;
import com.huoran.common.aop.annotation.NoRepeatSubmit;
import com.huoran.common.exception.CustomException;
import com.huoran.common.response.R;
import com.huoran.common.utils.JwtUtils;
import lombok.Synchronized;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.TimeUnit;
import static com.huoran.common.exception.ExceptionEnum.LOGIN_INVALID;
/**
* @Description aop解析注解
*/
@Aspect
@Component
public class NoRepeatSubmitAop {
private Log logger = LogFactory.getLog(getClass());
@Autowired
private RedisServiceAop redisService;
@Synchronized
@Around("execution(* com.huoran.*.controller.*.*(..)) && @annotation(noRepeatSubmit)")
public Object around(ProceedingJoinPoint pjp, NoRepeatSubmit noRepeatSubmit) throws Throwable {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
String token = request.getHeader("token");
//如果header中不存在token,则从参数中获取token
if (StringUtils.isEmpty(token)) {
throw new CustomException(LOGIN_INVALID);
}
// 校验并解析token,如果token过期或者篡改,则会返回null
boolean isVerify = JwtUtils.checkToken(token);
if (!isVerify) {
throw new CustomException(LOGIN_INVALID);
}
String key = token + "-" + request.getServletPath();
if ( !redisService.haskey(key) ) {// 如果缓存中有这个url视为重复提交
Object o = pjp.proceed();
redisService.setCacheObject(key, 0, 1, TimeUnit.SECONDS);
return o;
} else {
redisService.setCacheObject(key, 0, 1, TimeUnit.SECONDS);//点了同样的URL继续限制,直到2次点击中间间隔超过了限制
return R.error("请勿重复提交或者操作过于频繁!");
}
}
}

@ -0,0 +1,115 @@
package com.huoran.common.aop.aspect;
import com.google.common.collect.Maps;import com.google.common.util.concurrent.RateLimiter;import lombok.extern.slf4j.Slf4j;import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;import org.aspectj.lang.annotation.Pointcut;import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
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.util.Map;
import java.util.Objects;
import com.huoran.common.constant.AnRateLimiter;
@Slf4j
@Aspect
@Component
public class RateLimiterAspect {
/**
* 使用url做为key,存放令牌桶 防止每次重新创建令牌桶
*/
private Map limitMap = Maps.newConcurrentMap();
@Pointcut("@annotation(com.huoran.common.constant.AnRateLimiter)")
public void anRateLimiter() {
}
@Around("anRateLimiter()")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
// 获取request,response
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
// 或者url(存在map集合的key)
String url = request.getRequestURI();
// 获取自定义注解
AnRateLimiter rateLimiter = getAnRateLimiter(joinPoint);
if (rateLimiter != null) {
RateLimiter limiter = null;
// 判断map集合中是否有创建有创建好的令牌桶
if (!limitMap.containsKey(url)) {
// 创建令牌桶
limiter = RateLimiter.create(rateLimiter.permitsPerSecond());
limitMap.put(url, limiter);
log.info("<<================= 请求{},创建令牌桶,容量{} 成功!!!", url, rateLimiter.permitsPerSecond());
}
limiter = (RateLimiter) limitMap.get(url);
// 获取令牌
boolean acquire = limiter.tryAcquire(rateLimiter.timeout(), rateLimiter.timeunit());
if (!acquire) {
responseResult(response, 500, rateLimiter.msg());
return null;
}
}
return joinPoint.proceed();
}
/**
* 获取注解对象
*
* @param joinPoint 对象
* @return ten LogAnnotation
*/
private AnRateLimiter getAnRateLimiter(final JoinPoint joinPoint) {
Method[] methods = joinPoint.getTarget().getClass().getDeclaredMethods();
String name = joinPoint.getSignature().getName();
if (!StringUtils.isEmpty(name)) {
for (Method method : methods) {
AnRateLimiter annotation = method.getAnnotation(AnRateLimiter.class);
if (!Objects.isNull(annotation) && name.equals(method.getName())) {
return annotation;
}
}
}
return null;
}
/**
* 自定义响应结果
*
* @param response 响应
* @param code 响应码
* @param message 响应信息
*/
private void responseResult(HttpServletResponse response, Integer code, String message) {
response.resetBuffer();
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
PrintWriter writer = null;
try {
writer = response.getWriter();
writer.println("{\"code\":" + code + " ,\"message\" :\"" + message + "\"}");
response.flushBuffer();
} catch (IOException e) {
log.error(" 输入响应出错 e = {}", e.getMessage(), e);
} finally {
if (writer != null) {
writer.flush();
writer.close();
}
}
}
}

@ -0,0 +1,109 @@
package com.huoran.common.aop.aspect;
import com.google.common.collect.ImmutableList;
import com.huoran.common.aop.annotation.LimitType;
import com.huoran.common.aop.annotation.RedisLimit;
import com.huoran.common.exception.CustomException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.Objects;
import static com.huoran.common.exception.ExceptionEnum.REDIS_LIMIT;
@Slf4j
@Aspect
@Configuration
public class RedisLimitAspect {
@Resource
private final RedisTemplate<String, Object> redisTemplate;
public RedisLimitAspect(RedisTemplate<String, Object> redisTemplate) {
this.redisTemplate = redisTemplate;
}
@Around("@annotation(com.huoran.common.aop.annotation.RedisLimit)")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
MethodSignature methodSignature = (MethodSignature)pjp.getSignature();
Method method = methodSignature.getMethod();
RedisLimit annotation = method.getAnnotation(RedisLimit.class);
LimitType limitType = annotation.limitType();
String name = annotation.name();
String key;
int period = annotation.period();
int count = annotation.count();
switch (limitType){
case IP:
key = getIpAddress();
break;
case CUSTOMER:
key = annotation.key();
break;
default:
key = StringUtils.upperCase(method.getName());
}
ImmutableList<String> keys = ImmutableList.of(StringUtils.join(annotation.prefix(), key));
String luaScript = buildLuaScript();
DefaultRedisScript<Number> redisScript = new DefaultRedisScript<>(luaScript, Number.class);
Number number = redisTemplate.execute(redisScript, keys, count, period);
log.info("Access try count is {} for name = {} and key = {}", number, name, key);
if(number != null && number.intValue() == 1){
return pjp.proceed();
}
throw new CustomException(REDIS_LIMIT);
}
public String buildLuaScript(){
return "redis.replicate_commands(); local listLen,time" +
"\nlistLen = redis.call('LLEN', KEYS[1])" +
// 不超过最大值,则直接写入时间
"\nif listLen and tonumber(listLen) < tonumber(ARGV[1]) then" +
"\nlocal a = redis.call('TIME');" +
"\nredis.call('LPUSH', KEYS[1], a[1]*1000000+a[2])" +
"\nelse" +
// 取出现存的最早的那个时间,和当前时间比较,看是小于时间间隔
"\ntime = redis.call('LINDEX', KEYS[1], -1)" +
"\nlocal a = redis.call('TIME');" +
"\nif a[1]*1000000+a[2] - time < tonumber(ARGV[2])*1000000 then" +
// 访问频率超过了限制,返回0表示失败
"\nreturn 0;" +
"\nelse" +
"\nredis.call('LPUSH', KEYS[1], a[1]*1000000+a[2])" +
"\nredis.call('LTRIM', KEYS[1], 0, tonumber(ARGV[1])-1)" +
"\nend" +
"\nend" +
"\nreturn 1;";
}
public String getIpAddress(){
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
String ip = request.getHeader("x-forwarded-for");
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)){
ip = request.getHeader("Proxy-Client-IP");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)){
ip = request.getHeader("WL-Client-IP");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)){
ip = request.getRemoteAddr();
}
return ip;
}
}

@ -0,0 +1,228 @@
package com.huoran.common.aop.aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.*;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* @Description RedisService
*/
@Component
@SuppressWarnings(value = {"unchecked", "rawtypes"})
public class RedisServiceAop {
@Autowired
public RedisTemplate redisTemplate;
/**
* 缓存基本的对象IntegerString实体类等
*
* @param key 缓存的键值
* @param value 缓存的值
* @return 缓存的对象
*/
public <T> ValueOperations<String, T> setCacheObject(String key, T value) {
ValueOperations<String, T> operation = redisTemplate.opsForValue();
operation.set(key, value);
return operation;
}
/**
* 缓存基本的对象IntegerString实体类等
*
* @param key 缓存的键值
* @param value 缓存的值
* @param timeout 时间
* @param timeUnit 时间颗粒度
* @return 缓存的对象
*/
public <T> ValueOperations<String, T> setCacheObject(String key, T value, Integer timeout, TimeUnit timeUnit) {
ValueOperations<String, T> operation = redisTemplate.opsForValue();
operation.set(key, value, timeout, timeUnit);
return operation;
}
/**
* 获得缓存的基本对象
*
* @param key 缓存键值
* @return 缓存键值对应的数据
*/
public <T> T getCacheObject(String key) {
ValueOperations<String, T> operation = redisTemplate.opsForValue();
return operation.get(key);
}
/**
* 删除单个对象
*
* @param key
*/
public void deleteObject(String key) {
redisTemplate.delete(key);
}
/**
* 删除集合对象
*
* @param collection
*/
public void deleteObject(Collection collection) {
redisTemplate.delete(collection);
}
/**
* 缓存List数据
*
* @param key 缓存的键值
* @param dataList 待缓存的List数据
* @return 缓存的对象
*/
public <T> ListOperations<String, T> setCacheList(String key, List<T> dataList) {
ListOperations listOperation = redisTemplate.opsForList();
if (null != dataList) {
int size = dataList.size();
for (int i = 0; i < size; i++) {
listOperation.leftPush(key, dataList.get(i));
}
}
return listOperation;
}
/**
* 获得缓存的list对象
*
* @param key 缓存的键值
* @return 缓存键值对应的数据
*/
public <T> List<T> getCacheList(String key) {
List<T> dataList = new ArrayList<T>();
ListOperations<String, T> listOperation = redisTemplate.opsForList();
Long size = listOperation.size(key);
for (int i = 0; i < size; i++) {
dataList.add(listOperation.index(key, i));
}
return dataList;
}
/**
* 缓存Set
*
* @param key 缓存键值
* @param dataSet 缓存的数据
* @return 缓存数据的对象
*/
public <T> BoundSetOperations<String, T> setCacheSet(String key, Set<T> dataSet) {
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
Iterator<T> it = dataSet.iterator();
while (it.hasNext()) {
setOperation.add(it.next());
}
return setOperation;
}
/**
* 获得缓存的set
*
* @param key
* @return
*/
public <T> Set<T> getCacheSet(String key) {
Set<T> dataSet = new HashSet<T>();
BoundSetOperations<String, T> operation = redisTemplate.boundSetOps(key);
dataSet = operation.members();
return dataSet;
}
/**
* 缓存Map
*
* @param key
* @param dataMap
* @return
*/
public <T> HashOperations<String, String, T> setCacheMap(String key, Map<String, T> dataMap) {
HashOperations hashOperations = redisTemplate.opsForHash();
if (null != dataMap) {
for (Map.Entry<String, T> entry : dataMap.entrySet()) {
hashOperations.put(key, entry.getKey(), entry.getValue());
}
}
return hashOperations;
}
/**
* 获得缓存的Map
*
* @param key
* @return
*/
public <T> Map<String, T> getCacheMap(String key) {
Map<String, T> map = redisTemplate.opsForHash().entries(key);
return map;
}
/**
* 获得缓存的基本对象列表
*
* @param pattern 字符串前缀
* @return 对象列表
*/
public Collection<String> keys(String pattern) {
return redisTemplate.keys(pattern);
}
/**
*
* @param key
* @return
*/
public boolean haskey(String key){
return redisTemplate.hasKey(key);
}
public Long getExpire(String key){
return redisTemplate.getExpire(key);
}
public <T> ValueOperations<String, T> setBillObject(String key, List<Map<String, Object>> value) {
ValueOperations<String, T> operation = redisTemplate.opsForValue();
operation.set(key, (T) value);
return operation;
}
/**
* 缓存list<Map<String, Object>>
*
* @param key 缓存的键值
* @param value 缓存的值
* @param timeout 时间
* @param timeUnit 时间颗粒度
* @return 缓存的对象
*/
public <T> ValueOperations<String, T> setBillObject(String key, List<Map<String, Object>> value, Integer timeout, TimeUnit timeUnit) {
ValueOperations<String, T> operation = redisTemplate.opsForValue();
operation.set(key,(T)value, timeout, timeUnit);
return operation;
}
/**
* 缓存Map
*
* @param key
* @param dataMap
* @return
*/
public <T> HashOperations<String, String, T> setCKdBillMap(String key, Map<String, T> dataMap) {
HashOperations hashOperations = redisTemplate.opsForHash();
if (null != dataMap) {
for (Map.Entry<String, T> entry : dataMap.entrySet()) {
hashOperations.put(key, entry.getKey(), entry.getValue());
}
}
return hashOperations;
}
}

@ -0,0 +1,25 @@
package com.huoran.common.config;
import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.nio.charset.StandardCharsets;
@Component
public class FallbackHandler implements ErrorWebExceptionHandler {
@Override
public Mono<Void> handle(ServerWebExchange exchange, Throwable ex) {
String message = "服务正在维护,请稍后再试!";
byte[] bytes = String.format("{\"code\":-1,\"message\":\"%s\",\"data\":null}",
message).getBytes(StandardCharsets.UTF_8);
DataBuffer buffer = exchange.getResponse().bufferFactory().wrap(bytes);
exchange.getResponse().getHeaders().setContentType(MediaType.APPLICATION_JSON);
return exchange.getResponse().writeWith(Flux.just(buffer));
}
}

@ -0,0 +1,48 @@
package com.huoran.common.config;
import org.springframework.boot.autoconfigure.cache.CacheProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* @Author chen
* @DATE 2021/12/28 10:42
* @Version 1.0
*/
@EnableConfigurationProperties(CacheProperties.class)
@Configuration
@EnableCaching
public class MyCacheConfig {
@Bean
RedisCacheConfiguration redisCacheConfiguration(CacheProperties cacheProperties){
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
//修改缓存key、value的序列化机制,返回json数据格式
config.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()));
config.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer()));
//读取redis配置文件
CacheProperties.Redis redisProperties = cacheProperties.getRedis();
if (redisProperties.getTimeToLive() != null) {
config = config.entryTtl(redisProperties.getTimeToLive());
}
if (redisProperties.getKeyPrefix() != null) {
config = config.prefixKeysWith(redisProperties.getKeyPrefix());
}
if (!redisProperties.isCacheNullValues()) {
config = config.disableCachingNullValues();
}
if (!redisProperties.isUseKeyPrefix()) {
config = config.disableKeyPrefix();
}
return config;
}
}

@ -0,0 +1,33 @@
package com.huoran.common.config;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @description
* @author: Mr.JK
* @create: 2021-06-25 16:31
**/
@Configuration
public class MybatisPlusConfig {
/**
* 分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor page = new PaginationInterceptor();
page.setDialectType("mysql");
return page;
}
/**
* 逻辑删除插件
*/
@Bean
public ISqlInjector sqlInjector() {
return new LogicSqlInjector();
}
}

@ -0,0 +1,125 @@
package com.huoran.common.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
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.RedisOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import java.net.UnknownHostException;
@Configuration
@ConditionalOnClass(RedisOperations.class)
@EnableConfigurationProperties(RedisProperties.class)
//@Import({ LettuceConnectionConfiguration.class, JedisConnectionConfiguration.class })
public class RedisAutoConfiguration {
// @Bean
// @ConditionalOnMissingBean(name = "redisTemplate")
// public RedisTemplate<Object, Object> redisTemplate(
// RedisConnectionFactory redisConnectionFactory) throws UnknownHostException {
// RedisTemplate<Object, Object> template = new RedisTemplate<>();
// template.setConnectionFactory(redisConnectionFactory);
// return template;
// }
@Bean
@ConditionalOnMissingBean
public StringRedisTemplate stringRedisTemplate(
RedisConnectionFactory redisConnectionFactory) throws UnknownHostException {
StringRedisTemplate template = new StringRedisTemplate();
template.setConnectionFactory(redisConnectionFactory);
return template;
}
/**
// * 缓存对象 bean 配置
// *
// * @param redisConnectionFactory
// * @return
// */
@Bean(name = "redisTemplate")
@ConditionalOnMissingBean(name = "redisTemplate")
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory);
// key 的序列化规则 默认单节点模式
RedisSerializer<String> redisKeySerializer = new StringRedisSerializer();
template.setKeySerializer(redisKeySerializer);
template.setHashKeySerializer(redisKeySerializer);
// value 的序列化规则
// 使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
/// om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
// 解决 jackson2 无法反序列化 LocalDateTime 的问题
om.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
om.registerModule(new JavaTimeModule());
jackson2JsonRedisSerializer.setObjectMapper(om);
template.setValueSerializer(jackson2JsonRedisSerializer);
template.setHashValueSerializer(jackson2JsonRedisSerializer);
template.afterPropertiesSet();
return template;
}
/**
* 缓存管理器配置
*
* <P>缓存注解配置</P>
*
* @param factory
* @return
*/
// @Bean
// public CacheManager cacheManager(RedisConnectionFactory factory) {
// // key 的序列化规则
// RedisSerializer<String> redisKeySerializer = new StringRedisSerializer();
//
// // vulue 序列化规则
// Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
// //解决查询缓存转换异常的问题
// ObjectMapper om = new ObjectMapper();
// om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
// jackson2JsonRedisSerializer.setObjectMapper(om);
// // 解决 jackson2 无法反序列化 LocalDateTime 的问题
// om.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
// om.registerModule(new JavaTimeModule());
//
//
// // 配置序列化(解决乱码的问题)
// RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
// // 设置缓存的默认过期时间,也是使用Duration设置
// .entryTtl(Duration.ofMinutes(0))
//// .prefixKeysWith(prefixCacheNameWith)
// // .computePrefixWith(name -> ":")
//// .prefixCacheNameWith(prefixCacheNameWith)
// .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisKeySerializer))
// .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer));
//// log.info("redis 分布式缓存管理器注册成功, 可以使用缓存注解进行缓存数据");
// return RedisCacheManager
// .builder(factory)
// .cacheDefaults(config)
// .build();
// }
}

@ -0,0 +1,25 @@
package com.huoran.common.config;
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.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
public class RedisConfig {
@Bean
public RedisTemplate<String, ?> getRedisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, ?> template = new RedisTemplate<>();
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
template.setEnableTransactionSupport(true);
template.setConnectionFactory(factory);
return template;
}
}

@ -0,0 +1,36 @@
package com.huoran.common.config;
import okhttp3.*;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
@Configuration
public class RobotNotification {
static String WECHAT_GROUP = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=8d6b7307-2534-4d51-8708-740bc98fc1d7";
/**
* @content要发送的消息
* WECHAT_GROUP机器人的webhook
*/
public static String callWeChatBot(String content) {
OkHttpClient client = new OkHttpClient()
.newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(content,mediaType);
Request request = new Request.Builder()
.url(WECHAT_GROUP)
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = null;
try {
response = client.newCall(request).execute();
} catch (IOException e) {
e.printStackTrace();
}
return response.message();
}
}

@ -0,0 +1,37 @@
/*
package com.huoran.common.config;
import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlBlockHandler;
import com.alibaba.csp.sentinel.adapter.servlet.callback.WebCallbackManager;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.fastjson.JSON;
import com.huoran.common.response.R;
import org.springframework.context.annotation.Configuration;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
*/
/**
* @Author chen
* @DATE 2022/7/11 11:45
* @Version 1.0
*//*
@Configuration
public class SentinelConfig {
public SentinelConfig(){
WebCallbackManager.setUrlBlockHandler(new UrlBlockHandler() {
@Override
public void blocked(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, BlockException e) throws IOException {
R error = R.error("流量请求过大!");
httpServletResponse.setCharacterEncoding("UTF-8");
httpServletResponse.setContentType("application/json");
httpServletResponse.getWriter().write(JSON.toJSONString(error));
}
});
}
}
*/

@ -0,0 +1,21 @@
package com.huoran.common.constant;
import java.lang.annotation.*;
import java.util.concurrent.TimeUnit;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@Documented
public @interface AnRateLimiter {
//以固定数值往令牌桶添加令牌
double permitsPerSecond();
//获取令牌最大等待时间
long timeout();
// 单位(例:分钟/秒/毫秒) 默认:毫秒
TimeUnit timeunit() default TimeUnit.MILLISECONDS;
// 无法获取令牌返回提示信息 默认值可以自行修改
String msg() default "系统繁忙,请稍后再试.";
}

@ -0,0 +1,48 @@
package com.huoran.common.constant;
/**
* @Author chen
* @DATE 2021/7/1 17:06
* @Version 1.0
* @Description 考核常量类
*/
public interface AssessmentConstant {
//考试状态(0、未考 1、在考 2、已考
/**
* 未考
*/
Integer EXAMINATION_STATE_NOT_START = 0;
/**
* 在考
*/
Integer EXAMINATION_STATE_START = 1;
/**
* 已考-已结束
*/
Integer EXAMINATION_STATE_STOP = 2;
/**
* 指定范围
*/
Integer IS_SPECIFY = 1;
/**
* 未指定范围
*/
Integer NOT_IS_SPECIFY = 0;
/**
* 是否启用邀请码 :未启用
*/
Integer NOT_IS_ENABLE_CODE= 0;
/**
* 是否启用邀请码 :启用
*/
Integer IS_ENABLE_CODE = 1;
}

@ -0,0 +1,33 @@
package com.huoran.common.constant;
/**
* @ProjectName: huorantech
* @Package: com.huoran.data_platform.constant
* @ClassName: DelConstant
* @Description: 理论课程
* @Author: Maureen.Rong
* @CreateDate: 2021/6/30 16:09
* @UpdateDate: 2021/6/30 16:09
* @Version: 1.0
*/
public class ClassificationOfTheoreticalCoursesConstant {
//学校分类
public static final Integer SCHOOL_CLASSIFICATION = 1;
//中台分类
public static final Integer NAKADAI_CLASSIFICATION = 0;
/**
* 理论课程范围 (0:本校内 1:全平台 2.指定区域院校)
*/
//本校
public static final Integer OUR_SCHOOL = 0;
//全平台
public static final Integer ALL_PLATFORMS = 1;
//指定范围
public static final Integer SPECIFIED_RANGE = 2;
}

@ -0,0 +1,68 @@
package com.huoran.common.constant;
/**
* @ProjectName: huorantech
* @Package: com.huoran.data_platform.constant
* @ClassName: DelConstant
* @Description: 逻辑删除
* @Author: Maureen.Rong
* @CreateDate: 2021/6/30 16:09
* @UpdateDate: 2021/6/30 16:09
* @Version: 1.0
*/
public class DelConstant {
/**
* 已删除
*/
public static final Integer IS_DEL = 1;
/**
* 未删除
*/
public static final Integer NOT_DEL = 0;
/**
* 已启用
*/
public static final Integer IS_ENABLE = 1;
/**
* 未启用
*/
public static final Integer NO_ENABLE = 0;
/**
* 开启
*/
public static final Integer IS_OPEN = 0;
/**
* 未开启
*/
public static final Integer NO_OPEN = 1;
/**
* 发布状态:1发布
*/
public static final Integer POST_STATUS = 1;
/**
* 发布状态0未发布
*/
public static final Integer NOT_RELEASE = 0;
/**
* 数据平台:普通用户角色
*/
public static final Integer ROLE_USER = 0;
/**
* 发布类型(0默认发布 1批量手动导入)
*/
public static final Integer PUBLICATION_TYPE_DEFAULT = 0;
public static final Integer PUBLICATION_TYPE_MANUALOPERATION = 1;
}

@ -0,0 +1,12 @@
package com.huoran.common.constant;
/**
* @Author chen
* @DATE 2020/10/10 10:30
* @Version 1.0
* 课程启用状态常亮类
*/
public interface EnableStatus {
String ENABLE = "1";//启用
String NOT_ACTIVATED = "0";//未启用
}

@ -0,0 +1,20 @@
package com.huoran.common.constant;
/**
* @description excel导出常量类
* @author: Mr.JK
* @create: 2021-06-10 09:54
**/
public class ExcelConstant {
/**
* 每个sheet存储的记录数 100W
*/
public static final Integer PER_SHEET_ROW_COUNT = 1000000;
/**
* 每次向EXCEL写入的记录数(查询每页数据大小) 20W
*/
public static final Integer PER_WRITE_ROW_COUNT = 200000;
}

@ -0,0 +1,20 @@
package com.huoran.common.constant;
/**
* @Author chen
* @DATE 2021/7/19 9:58
* @Version 1.0
* 区分手机号账号登录,1为账号登录,2为手机号或邮箱登录
*/
public interface LoginDistConstant {
/**
* 账号登录
*/
Integer ACCOUNT_LOGIN = 1;
/**
* 手机号或邮箱登录
*/
Integer PHONE_EMAIL_LOGIN = 2;
}

@ -0,0 +1,20 @@
package com.huoran.common.constant;
public class ModellConstant {
//创建来源 系统 or 院校
/**
* 系统
*/
public static final Integer SOURCE_SYSTEM = 0;
/**
* 院校来源
*/
public static final Integer SOURCE_INSTITUTION = 1;
public static final Integer PUBLICATION_STATUS_PUBLISHED = 1;
}

@ -0,0 +1,51 @@
package com.huoran.common.constant;
/**
* @Author chen
* @DATE 2021/7/1 17:06
* @Version 1.0
* @Description 订单常量类
*/
public interface OrderConstant {
/**
* 未发货
*/
Integer NOT_SHIPPED = 0;
/**
* 已发货,已完成
*/
Integer SHIPPED = 1;
/**
* 启用
*/
Integer Enable = 1;
/**
* 不启用
*/
Integer Not_enabled = 0;
/**
* 数据平台权限
*/
Integer DATA_AUTHORITY = 0;
/**
* 课程权限
*/
Integer COURSE_AUTHORITY = 1;
/**
* 订单初签
*/
Integer FIRST_SIGN = 1;
/**
* 订单续签
*/
Integer RENEW = 2;
}

@ -0,0 +1,35 @@
package com.huoran.common.constant;
/**
* @ProjectName: huorantech
* @Package: com.huoran.data_platform.constant
* @ClassName: DelConstant
* @Description: 数据平台平台来源
* @Author: Maureen.Rong
* @CreateDate: 2021/6/30 16:09
* @UpdateDate: 2021/6/30 16:09
* @Version: 1.0
*/
public class PlatformConstant {
//职站
public static final Integer POST_STATION = 1;
//数据平台id
public static final Integer DATA_PLATFORM = 2;
//中台
public static final Integer NAKADAI = 3;
//合伙人平台
public static final Integer ACCESSORY = 4;
//教师端
public static final Integer TEACHER_SIDE = 0;
//学生端
public static final Integer STUDENT_SIDE = 1;
//无端
public static final Integer UNPROVOKED = 2;
}

@ -0,0 +1,8 @@
package com.huoran.common.constant;
public interface PointConstant {
int PROGRAMMING = 0;//0编程类
int PROCESS = 1;//1流程类
}

@ -0,0 +1,19 @@
package com.huoran.common.constant;
public interface RabbitmqConstant {
/**
* 评论交换机常量
*/
String COMMENT_EXCHANGE = "comment.exchange";
/**
* 评论队列常量
*/
String COMMENT_QUEUE = "commentQueue";
/**
* 评论路由键
*/
String COMMENT_ROUTING_KEY = "commentKey";
}

@ -0,0 +1,34 @@
package com.huoran.common.constant;
/**
* @Author chen
* @DATE 2021/7/7 14:14
* @Version 1.0
*/
public interface SMSTemplate {
// 短信签名
String SMS_SIGNATURE = "或然科技";
// 找回密码验证码
String RETRIEVE_PASSWORD_CODE = "SMS_219310031";
// 身份验证验证码
String AUTHENTICATION_CODE = "SMS_221515019";
// 登录确认验证码
String LOGIN_VERIFICATION_CODE = "SMS_204155296";
// 登录异常验证码
String LOGIN_EXCEPTION_CODE = "SMS_204155295";
// 用户注册验证码
String USER_REGISTRATION_CODE = "SMS_204155294";
// 修改密码验证码
String MODIFY_PASSWORD_CODE = "SMS_204155293";
// 信息变更验证码
String INFORMATION_CHANGE_CODE = "SMS_204155292";
}

@ -0,0 +1,44 @@
package com.huoran.common.constant;
/**
* @description 服务名称常量类
* @author: Mr.JK
* @create: 2021-08-26 14:30
**/
public class ServiceNameConstant {
/**
* 数据平台serviceId
*/
public static final String DATA_PLATFORM = "data";
/**
* 判分点serviceId
*/
public static final String JUDGMENT_POINT = "judgment";
/**
* 中台serviceId
*/
public static final String NAKADAI = "nakadai";
/**
* 职站serviceId
*/
public static final String OCCUPATIONLAB = "occupationlab";
/**
* 用户管理serviceId
*/
public static final String USERS = "users";
/**
* python子系统serviceId
*/
public static final String PYTHON = "python";
/**
* 银行子系统serviceId
*/
public static final String BANK = "bank";
}

@ -0,0 +1,31 @@
package com.huoran.common.constant;
/**
* @Author chen
* @DATE 2021/7/1 17:06
* @Version 1.0
* @Description 考核常量类
*/
public interface TeamCalculationMethodConstant {
//团队成绩计算方式(0:最高分,1:平均分,2:求和)
/**
* 取最高分
*/
Integer HIGHEST_SCORE_IN_A_TEAM_EVENT = 0;
/**
* 取平均分
*/
Integer AVERAGE_SCORE_OF_TEAM_COMPETITION = 1;
/**
* 取最高分
*/
Integer SUM_OF_TEAM_COMPETITION = 2;
//赛事类型(0为个人赛,1为团队赛)默认为0
Integer TYPE_OF_EVENT_INDIVIDUAL_COMPETITION = 0;
Integer TYPE_OF_EVENT_TEAM_EVENT = 1;
}

@ -0,0 +1,74 @@
package com.huoran.common.entity;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* <p>
* 学生组织架构
* </p>
*
* @author lr
* @since 2021-08-24
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("ol_architecture")
@ApiModel(value = "Architecture对象", description = "学生组织架构")
public class Architecture implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "自增id 新增无需传值")
private Integer id;
@ApiModelProperty(value = "组织名称")
private String organizationName;
@ApiModelProperty(value = "父id 一级为0", example = "0", name = "parentId")
private Integer parentId;
@ApiModelProperty(value = "学校id", example = "1", name = "schoolId")
private Integer schoolId;
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
@ApiModelProperty(value = "逻辑删除")
@TableLogic
private Integer isDel;
@ApiModelProperty(value = "层级")
private Integer level;
@ApiModelProperty(value = "子级")
@TableField(exist = false)
private List<Architecture> children;
@ApiModelProperty(value = "层级拼接")
@TableField(exist = false)
private String splicingLevel;
/*@ApiModelProperty(value = "班級")
@TableField(exist = false)
private List<Architecture> classList;*/
}

@ -0,0 +1,62 @@
package com.huoran.common.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* @description 编程类判分点实体
* @author: Mr.JK
* @create: 2021-09-01 16:12
**/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class BcJudgmentPoint implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "编程类判分点主键")
private Integer bcId;
@ApiModelProperty(value = "编程类判分点名称")
private String name;
@ApiModelProperty(value = "实验要求")
private String experimentalRequirements;
@ApiModelProperty(value = "实验代码")
private String experimentCode;
@ApiModelProperty(value = "实验要求显示类型")
private String experimentalRequirementsType;
@ApiModelProperty(value = "实验代码显示类型")
private String experimentCodeType;
@ApiModelProperty(value = "项目id")
private String projectId;
@ApiModelProperty(value = "系统id")
private Integer systemId;
@ApiModelProperty(value = "账号id")
private Integer accountId;
@ApiModelProperty(value = "是否开启(0开启 1未开启 默认为0)")
private Integer isOpen;
@ApiModelProperty(value = "是否删除(0未删除 1已删除 默认为0)")
private Integer isDel;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "更新时间")
private Date updateTime;
}

@ -0,0 +1,52 @@
package com.huoran.common.entity;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 班级表
* </p>
*
* @author lr
* @since 2021-08-18
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("ol_class")
@ApiModel(value = "Class对象", description = "班级表")
public class Class implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "班级名称")
private String className;
@ApiModelProperty(value = "学生架构id(ol_architecture表)")
private Integer architectureId;
@TableLogic
@ApiModelProperty(value = "是否删除(0、未删除 1、已删除)")
private Integer isDel;
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "备注")
private String remark;
}

@ -0,0 +1,146 @@
package com.huoran.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* @description
* @author: Mr.JK
* @create: 2021-09-13 17:13
**/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("ol_experimental_report")
@ApiModel(value = "ExperimentalReport对象", description = "存储各子系统的实验报告")
public class ExperimentalReport implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "实验报告主键")
@TableId(value = "report_id", type = IdType.AUTO)
private Integer reportId;
@ApiModelProperty(value = "项目管理id")
private Integer projectId;
@ApiModelProperty(value = "班级id")
private Integer classId;
@ApiModelProperty(value = "课程id(curriculum表主键)")
private Integer curriculumId;
@ApiModelProperty(value = "考核id(当进入的实验为练习时本列为空)")
private Integer assessmentId;
@ApiModelProperty(value = "老师名称")
@TableField(exist = false)
private String teacherName;
@ApiModelProperty(value = "学号")
@TableField(exist = false)
private String workNumber;
@ApiModelProperty(value = "用户名称 (学生姓名)")
@TableField(exist = false)
private String userName;
@ApiModelProperty(value = "学生账号id")
private Integer accountId;
@ApiModelProperty(value = "实验原理")
private String principle;
@ApiModelProperty(value = "实验内容")
private String content;
@ApiModelProperty(value = "实验步骤")
private String step;
@ApiModelProperty(value = "实验数据")
private String data;
@ApiModelProperty(value = "实验分析")
private String analysis;
@ApiModelProperty(value = "实验结论")
private String conclusion;
@ApiModelProperty(value = "实验总结")
private String summarize;
@ApiModelProperty(value = "实验器材")
private String equipment;
@ApiModelProperty(value = "实验目的")
private String purpose;
@ApiModelProperty(value = "对本实验过程方法及手段的改进建议")
private String improvement;
@ApiModelProperty(value = "绑定教师评语id")
private Integer commentId;
@ApiModelProperty(value = "教师评语")
private String comment;
@ApiModelProperty(value = "绑定老师id")
private Integer teacherId;
@ApiModelProperty(value = "学时")
private String period;
@ApiModelProperty(value = "实验室名称")
private String laboratory;
@ApiModelProperty(value = "是否启用教师签名(0不启用,1启用,默认0)")
private Integer isSignature;
@ApiModelProperty(value = "绑定教师签名id")
private Integer signatureId;
@ApiModelProperty(value = "指导老师:(考核的自动读取发布考核的老师名称,可修改)")
private String instructor;
@ApiModelProperty(value = "实验项目名称:(自动读取,可修改)")
private String projectName;
@ApiModelProperty(value = "学生班级:(自动读取学生班级,可修改)")
private String className;
@ApiModelProperty(value = "得分")
private Integer score;
@ApiModelProperty(value = "进入时间")
private Date startTime;
@ApiModelProperty(value = "结束时间")
private Date endTime;
@ApiModelProperty(value = "提交时间")
private Date submitTime;
@ApiModelProperty(value = "耗时")
private Integer timeSum;
@ApiModelProperty(value = "是否删除(0未删除1已删除 默认0)")
private Integer isDel;
@ApiModelProperty(value = "学校id")
private Integer schoolId;
@ApiModelProperty(value = "商品id")
private Integer mallId;
}

@ -0,0 +1,36 @@
package com.huoran.common.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.io.Serializable;
/**
* @Author chen
* @DATE 2021/7/13 9:52
* @Version 1.0
*/
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class FilesResult implements Serializable {
private static final long serialVersionUID = 1L;
// 阿里云存储文件名
private String ossFileName;
// 文件在储存空间的路径
private String fileUrl;
// 文件类型
private String fileType;
// 视频资源Id
private String fileId;
//文件大小
private String fileSize;
//原传文件名
private String originalFileName;
}

@ -0,0 +1,54 @@
package com.huoran.common.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* @description 流程类判分点实体
* @author: Mr.JK
* @create: 2021-09-01 16:30
**/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class LcJudgmentPoint implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "流程类判分点主键")
private Integer lcId;
@ApiModelProperty(value = "流程类判分点名称")
private String name;
@ApiModelProperty(value = "实验要求")
private String experimentalRequirements;
@ApiModelProperty(value = "项目id")
private String projectId;
@ApiModelProperty(value = "系统id")
private Integer systemId;
@ApiModelProperty(value = "账号id")
private Integer accountId;
@ApiModelProperty(value = "是否开启(0开启 1未开启 默认0)")
private Integer isOpen;
@ApiModelProperty(value = "是否删除(0未删除 1已删除 默认0)")
private Integer isDel;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "更新时间")
private Date updateTime;
}

@ -0,0 +1,33 @@
package com.huoran.common.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @description 前端判分规则实体
* @author: Mr.JK
* @create: 2021-08-18 17:26
**/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class LcJudgmentRuleReq {
@ApiModelProperty(value = "操作id串")
private String operationIds;
@ApiModelProperty(value = "题目类型(1选择 2判断 3填空 4问答 5指标结果)")
private String type;
@ApiModelProperty(value = "空格一",notes = "选择题、判断题填subject_id,填空题、问答题、指标结果填需要字段")
private String emptyOne;
@ApiModelProperty(value = "空格二",notes = "选择题、判断题填item_id,填空题、问答题、指标结果填需要字段")
private String emptyTwo;
@ApiModelProperty(value = "答案id(缓存使用)")
private String answerId;
}

@ -0,0 +1,69 @@
package com.huoran.common.entity;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 流程类判分规则用户答案记录表
* </p>
*
* @author Mr.JK
* @since 2021-09-18
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="LcRuleRecord对象", description="流程类判分规则用户答案记录表")
public class LcRuleRecord implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "规则id")
private Integer ruleId;
@ApiModelProperty(value = "题目类型(1选择 2判断 3填空 4问答 5指标结果)")
@TableField(exist = false)
private String type;
@ApiModelProperty(value = "考核点名称")
@TableField(exist = false)
private String name;
@ApiModelProperty(value = "规则答案")
private String ruleAnswer;
@ApiModelProperty(value = "用户答案")
private String userAnswer;
@ApiModelProperty(value = "标识")
private String flag;
@ApiModelProperty(value = "是否删除")
@TableLogic(value = "0",delval = "1")
private Integer isDel;
@ApiModelProperty(value = "开始时间")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
@TableField(exist = false)
private String operationIds;
}

@ -0,0 +1,63 @@
package com.huoran.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* <p>
* 企业端客户管理
* </p>
*
* @author Ning
* @since 2020-10-27
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("ol_client_management")
@ApiModel(value = "ClientManagement对象", description = "企业端客户管理")
public class NewClientManagement implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "客户名称")
private String clientName;
@ApiModelProperty(value = "省份id")
private Integer provinceId;
@ApiModelProperty(value = "城市id")
private Integer cityId;
@ApiModelProperty(value = "省份名称")
private String provinceName;
@ApiModelProperty(value = "城市名称")
private String cityName;
@ApiModelProperty(value = "联系人姓名")
private String contactPersonName;
@ApiModelProperty(value = "手机号")
private String phone;
@ApiModelProperty(value = "客户类型")
private Integer type;
@ApiModelProperty(value = "是否禁用")
@TableField("is_disable")
private Integer isDisable;
}

@ -0,0 +1,46 @@
package com.huoran.common.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @description 项目管理判分点中间表增强实体
* @author: Mr.JK
* @create: 2021-09-01 16:00
**/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class ProjectJudgmentVo {
@ApiModelProperty(value = "主键id")
private Integer id;
@ApiModelProperty(value = "分数")
@NotNull(message = "分数不能为空!")
private Integer score;
@ApiModelProperty(value = "项目id")
@NotNull(message = "项目id不能为空!")
private String projectId;
@ApiModelProperty(value = "判分点id(编程与流程)系统id为11时,是流程类")
@NotNull(message = "判分点id不能为空!")
private Integer judgmentId;
@ApiModelProperty(value = "实验要求")
private String experimentalRequirements;
@ApiModelProperty(value = "判分点名称")
private String name;
@ApiModelProperty(value = "实验要求显示类型")
private String experimentalRequirementsType;
@ApiModelProperty(value = "实验代码显示类型")
private String experimentCodeType;
}

@ -0,0 +1,161 @@
package com.huoran.common.entity;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 项目管理表
* </p>
*
* @author Mr.JK
* @since 2021-08-26
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("ol_project_manage")
@ApiModel(value = "ProjectManage对象", description = "项目管理表")
public class ProjectManage implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(value = "project_id", type = IdType.AUTO)
private Integer projectId;
@ApiModelProperty(value = "项目名称")
@NotBlank(message = "项目名称不能为空!")
private String projectName;
@ApiModelProperty(value = "项目权限(0、练习 1、考核 2、竞赛)")
@NotNull(message = "项目权限不能为空!")
private Integer permissions;
@ApiModelProperty(value = "系统id")
@NotNull(message = "系统id不能为空!")
private Integer systemId;
@ApiModelProperty(value = "系统名称")
@TableField(exist = false)
private String systemName;
@ApiModelProperty(value = "账号id")
private Integer accountId;
@ApiModelProperty(value = "学校id")
private Integer schoolId;
@ApiModelProperty(value = "创建人角色(0、系统 1、院校)")
@NotNull(message = "创建人角色不能为空!")
private Integer founder;
@ApiModelProperty(value = "创建人")
@TableField(exist = false)
private String creator;
@ApiModelProperty(value = "状态(0、草稿箱 1、已发布)")
@NotNull(message = "状态不能为空!")
private Integer state;
@ApiModelProperty(value = "系统类型(0编程类 1流程类)")
@TableField(exist = false)
private Integer type;
@ApiModelProperty(value = "实验目标")
private String experimentTarget;
@ApiModelProperty(value = "实验描述")
private String experimentDescription;
@ApiModelProperty(value = "实验提示")
private String experimentHint;
@ApiModelProperty(value = "实验目标显示类型")
private String experimentTargetType;
@ApiModelProperty(value = "实验描述显示类型")
private String experimentDescriptionType;
@ApiModelProperty(value = "实验提示显示类型")
private String experimentHintType;
@ApiModelProperty(value = "实验提示是否开启(0开启 1不开启 默认0)")
private Integer hintOpen;
@ApiModelProperty(value = "学校实验提示是否开启(0开启 1不开启)")
@TableField(exist = false)
private Integer hintOpenBySchool;
@ApiModelProperty(value = "是否开启(0开启 1未开启 默认0)")
private Integer isOpen;
@ApiModelProperty(value = "中台是否开启(0开启 1未开启 默认0)")
private Integer ztOpen;
@ApiModelProperty(value = "是否删除(0、未删除 1、已删除 默认0)")
@TableLogic(value = "0", delval = "1")
private Integer isDel;
@ApiModelProperty(value = "中台是否删除(0未删除 1已删除 默认0)")
private Integer ztDel;
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
@ApiModelProperty(value = "是否为管理员发布 0否 1是")
@TableField(exist = false)
private Integer isAdminRelease;
@ApiModelProperty(value = "学校名称")
@TableField(exist = false)
private String schoolName;
@ApiModelProperty(value = "职站是否禁用启用(0启用 1已禁用)")
@TableField(exist = false)
private Integer ccupationlabOpen;
@ApiModelProperty(value = "创建人")
@TableField(exist = false)
private String createUser;
@ApiModelProperty(value = "项目发布人角色")
@TableField(exist = false)
private String roleName;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "是否学习(0未学习 1已学习)")
@TableField(exist = false)
private Integer whetherToStudyOrNot;
@ApiModelProperty(value = "学习进展id")
@TableField(exist = false)
private Integer learningProgressId;
@ApiModelProperty(value = "商品id")
private Integer mallId;
}

@ -0,0 +1,36 @@
package com.huoran.common.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
/**
* @Description : python子系统提交答案参数
* @Author Rong---2021/12/15
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class PyAttributesReq {
@ApiModelProperty("编程类判分点id")
private Integer bcId;
@ApiModelProperty("运行结果id")
private Integer codeId;
@ApiModelProperty("是否提交(0未提交,1为已提交)")
private Integer isSubmit;
@ApiModelProperty("当前规则用户输入的答案")
private String answer;
@ApiModelProperty(value = "返回结果(1为正确 0为错误)")
private Integer retResult;
}

@ -0,0 +1,27 @@
package com.huoran.common.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "PythonCodeResp", description = "执行返回结果")
public class PythonCodeResp {
@ApiModelProperty(value = "图片url")
private String photoUrl;
@ApiModelProperty(value = "执行结果")
private String runResult;
@ApiModelProperty(value = "返回结果(1为正确 0为错误)")
private Integer retResult;
@ApiModelProperty(value = "结果")
private Integer codeId;
}

@ -0,0 +1,57 @@
package com.huoran.common.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 角色表
* </p>
*
* @author chen
* @since 2021-09-29
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("acl_role")
@ApiModel(value="Role对象", description="角色表")
public class Role implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "角色id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "学校id")
private Integer schoolId;
@ApiModelProperty(value = "角色名称")
private String roleName;
@ApiModelProperty(value = "角色编码")
private String roleCode;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
private Date createTime;
@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
private Date updateTime;
}

@ -0,0 +1,92 @@
package com.huoran.common.entity;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* python储存实验运行记录
* </p>
*
* @author lr
* @since 2021-09-06
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("python_run_code")
@ApiModel(value = "RunCode对象", description = "python储存实验运行记录")
public class RunCode implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "实验代码主键Id", hidden = true)
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "实验代码", required = true, example = "IMPORT random WORDS = [ \"Python\", \"jumble\", \"easy\", \"difficult\", \"answer\", \"continue\", \"phone\", \"position\", \"pose\", \"game\" ] print ( \"\"\"" +
"欢迎参加猜单词游戏" +
"\"\"\" )" +
"WHILE" +
"TRUE : # 从序列中随机挑出一个单词" +
"word = random.choice ( WORDS ) # 判断玩家是否猜对的变量" +
"correct = word # 保存乱序后的单词" +
"jumble = \"\"" +
"WHILE" +
"word : # 根据 word 长度产生word的随机位置" +
"position = random.randrange ( len ( word ) ) # 将position位置的字母组合乱序后单词" +
"jumble += word [ position ] # 通过切片将position位置的字母从原有单词中删除" +
"word = word [: position ] + word [ ( position + 1 ) :] print ( \"打乱顺序后的单词:\", jumble ) guess = 'q'" +
"IF" +
"guess != 'q' :" +
"WHILE" +
"guess != correct " +
"AND guess != \"\" : print ( \"对不起,不正确!\" ) guess = EXIT ( \"validing:继续猜:\" )" +
"IF" +
"guess == correct : print ( \"恭喜,猜对了!\" ) elif guess == 'q' : print ( '再见!' ) break")
private String code;
@ApiModelProperty(value = "绑定的项目id", example = "1", required = true)
private Integer projectId;
@ApiModelProperty(value = "判分点主键Id", example = "1")
private Integer judgmentPointsId;
@ApiModelProperty(value = "提交状态:默认0未提交,1为已提交", example = "0", hidden = true)
private Integer isSubmit;
@ApiModelProperty(value = "运行结果", example = "欢迎参加猜单词游戏 打乱顺序后的单词: aersnw 再见!")
private String runResult;
@ApiModelProperty(value = "运行有没有出现错误(0、运行正确 1、运行错误)", hidden = true)
private Integer isError;
@ApiModelProperty(value = "绑定账号id", hidden = true)
private Integer accountId;
@ApiModelProperty(value = "逻辑删除—>默认0未删除,1为已删除", hidden = true)
@TableLogic(value = "0", delval = "1")
private Integer isDel;
@ApiModelProperty(value = "运行时间", hidden = true)
@TableField(fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "修改时间", hidden = true)
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
@ApiModelProperty(value = "实验报告id(ol_experimental_report)", hidden = true)
private Integer reportId;
@ApiModelProperty(value = "运行的图片")
private String runPhotoUrl;
}

@ -0,0 +1,62 @@
package com.huoran.common.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 学校表
* </p>
*
* @author lr
* @since 2021-08-10
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("ol_school")
@ApiModel(value="School对象", description="学校表")
public class School implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "学校主键id")
@TableId(value = "schoolId", type = IdType.AUTO)
private Integer schoolId;
@ApiModelProperty(value = "学校名称")
@TableField("schoolName")
private String schoolName;
@ApiModelProperty(value = "绑定省份Id")
@TableField("provinceId")
private Integer provinceId;
@ApiModelProperty(value = "绑定城市Id")
@TableField("cityId")
private Integer cityId;
@ApiModelProperty(value = "层次(1、本科 2、大专 3、高职 4、中专 5、其他)")
private Integer level;
@ApiModelProperty(value = "是否删除(0、未删除 1、已删除)")
private String isdel;
@ApiModelProperty(value = "省份名称")
@TableField("provinceName")
private String provinceName;
@ApiModelProperty(value = "城市名称")
@TableField("cityName")
private String cityName;
}

@ -0,0 +1,60 @@
package com.huoran.common.entity;
import com.baomidou.mybatisplus.annotation.*;
import java.util.Date;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 学生表
* </p>
*
* @author lr
* @since 2021-08-24
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("ol_student")
@ApiModel(value = "Student对象", description = "学生表")
public class Student implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "账号id")
private Integer accountId;
@ApiModelProperty(value = "班级id(可多个班级逗号隔开,未加入班级的默认为0)")
private String classId;
@ApiModelProperty(value = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "学校id(用于区分一个学生可以存在不同的学校)")
private Integer schoolId;
@ApiModelProperty(value = "更新时间")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
private Integer isDel;
}

@ -0,0 +1,87 @@
package com.huoran.common.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @描述各个平台账号表
* @作者: Rong
* @日期: 2021-08-25
*/
@Data
@ApiModel(value = "各个平台账号表")
@TableName("hr_user_account")
public class UserAccount implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "主键id(平台用户id)")
private Integer id;
@ApiModelProperty(value = "用户表id")
private Integer userId;
@ApiModelProperty(value = "客户表id")
private Integer customerId;
@ApiModelProperty(value = "账号")
private String account;
@ApiModelProperty(value = "密码")
private String password;
@ApiModelProperty(value = "工号")
private String workNumber;
@ApiModelProperty(value = "绑定的角色id(0为数据平台普通用户)")
private String roleId;
@ApiModelProperty(value = "绑定院校id")
private Integer schoolId;
@ApiModelProperty(value = "所属平台id")
private String platformId;
@ApiModelProperty(value = "平台(系统)绑定时间")
private Date platformBindTime;
@ApiModelProperty(value = "平台端区分:0->教师端 1->学生端 2->无端")
private Integer type;
@ApiModelProperty(value = "电话", example = "17788771965")
private String phone;
@ApiModelProperty(value = "是否删除(0、未删除 1、已删除)")
private Integer isDel;
@ApiModelProperty(value = "是否禁用(0->禁用,1->启用)")
private Boolean isEnable;
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
@ApiModelProperty(value = "班级id")
@TableField(exist = false)
private String classId;
@ApiModelProperty(value = "班级id")
@TableField(exist = false)
private String userName;
@ApiModelProperty(value = "绑定时间")
private String phoneBindingTime;
}

@ -0,0 +1,104 @@
package com.huoran.common.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @描述用户信息表
* @作者: Rong
* @日期: 2021-08-25
*/
@Data
@ApiModel(value = "用户信息表")
@TableName("hr_user_info")
public class UserInfo implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "用户id")
private Integer userId;
@ApiModelProperty(value = "用户姓名")
private String userName;
@ApiModelProperty(value = "唯一标识账号")
private String uniqueIdentification;
@ApiModelProperty(value = "证件类型(1、身份证)")
private Integer documentType;
@ApiModelProperty(value = "证件号码")
private String idNumber;
@ApiModelProperty(value = "绑定省份id")
private Integer provinceId;
@ApiModelProperty(value = "绑定城市id")
private Integer cityId;
@ApiModelProperty(value = "国家归属地")
private String countries;
@ApiModelProperty(value = "出生日期")
private Date dateBirth;
@ApiModelProperty(value = "教育程度")
private Integer educationDegree;
@ApiModelProperty(value = "绑定学校id")
private Integer schoolId;
@ApiModelProperty(value = "邮箱")
private String email;
@ApiModelProperty(value = "微信号")
private String wechatId;
@ApiModelProperty(value = "登陆次数")
private Integer loginNumber;
@ApiModelProperty(value = "性别(1、男 2、女)")
private Integer sex;
@ApiModelProperty(value = "用户头像路径")
private String userAvatars;
@ApiModelProperty(value = "是否删除(0->未删除;1->已删除)")
private Integer isDel;
@ApiModelProperty(value = "最后登陆时间")
private String lastLoginTime;
@ApiModelProperty(value = "绑定多个角色id")
private String roleId;
@ApiModelProperty(value = "组织关系:1->有组织关系;2->无组织关系;")
private Integer organizationalRelation;
@ApiModelProperty(value = "是否禁用(0->禁用,1->启用)")
private Boolean isEnable;
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
@ApiModelProperty(value = "账户表-电话")
@TableField(exist = false)
private String phone;
}

@ -0,0 +1,56 @@
package com.huoran.common.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 用户角色表
* </p>
*
* @author chen
* @since 2021-09-29
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("acl_user_role")
@ApiModel(value="UserRole对象", description="用户角色表")
public class UserRole implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "角色id")
private Integer roleId;
@ApiModelProperty(value = "账号id")
private Integer accountId;
@ApiModelProperty(value = "逻辑删除 1(true)已删除, 0(false)未删除")
@TableLogic
private Boolean isDel;
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
private Date createTime;
@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
private Date updateTime;
}

@ -0,0 +1,87 @@
package com.huoran.common.entity;
/**
* @description
* @author: Mr.JK
* @create: 2021-09-14 15:01
**/
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 用户分数表
* </p>
*
* @author Mr.JK
* @since 2021-09-14
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "UserScore对象", description = "用户分数表")
@TableName("ol_user_score")
public class UserScore implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "分数")
private Integer score;
@ApiModelProperty(value = "实验报告主键")
private Integer reportId;
@ApiModelProperty(value = "账号id")
private Integer accountId;
@ApiModelProperty(value = "系统id")
private Integer systemId;
@ApiModelProperty(value = "判分点id(系统11为流程类)")
private Integer judgmentId;
@ApiModelProperty(value = "用户答案")
private String answer;
@ApiModelProperty(value = "是否正确")
private Integer isCorrect;
@ApiModelProperty(value = "是否删除")
@TableLogic
private Integer isDel;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "更新时间")
private Date updateTime;
@ApiModelProperty(value = "赛事id")
private Integer competitionId;
@ApiModelProperty(value = "赛事阶段id")
private Integer stageId;
@ApiModelProperty(value = "耗时(用于区分线下赛事的耗时)")
private Integer timeSum;
@ApiModelProperty(value = "提交时间(用于区分线下赛事的提交时间)")
private Date submitTime;
@ApiModelProperty(value = "团队id")
private Integer teamId;
}

@ -0,0 +1,58 @@
package com.huoran.common.entity.resp;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @描述
* @作者: Rong
* @日期: 2022/4/19 17:06
*/
@Data
public class PhoneBindingrResp {
@ApiModelProperty(value = "用户id")
private Integer userId;
@ApiModelProperty(value = "账号id")
private Integer accountId;
@ApiModelProperty(value = "类型")
private Integer type;
@ApiModelProperty(value = "用户姓名")
private String userName;
@ApiModelProperty(value = "唯一标识账号")
private String uniqueIdentificationAccount;
@ApiModelProperty(value = "电话")
private String phone;
@ApiModelProperty(value = "账号")
private String account;
@ApiModelProperty(value = "工号")
private String workNumber;
@ApiModelProperty(value = "登陆次数")
private Integer logInNumber;
@ApiModelProperty(value = "平台名称")
private String platformName;
@ApiModelProperty(value = "是否禁用(0->禁用,1->启用)")
private Integer isEnable;
@ApiModelProperty(value = "最后登陆时间")
private String lastLoginTime;
@ApiModelProperty(value = "角色")
private String roleName;
@ApiModelProperty(value = "绑定组织名称")
private String schoolName;
@ApiModelProperty(value = "绑定时间")
private String phoneBindingTime;
}

@ -0,0 +1,40 @@
package com.huoran.common.entity.resp;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @description
* @author: Mr.JK
* @create: 2021-07-07 16:04
**/
@Data
public class ProductAndOrderResp {
@ApiModelProperty(value = "开始时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
@ApiModelProperty(value = "期限")
private Integer deadline;
@ApiModelProperty(value = "账号数量")
private Integer accountNum;
@ApiModelProperty(value = "学校名称")
private String schoolName;
@ApiModelProperty(value = "订单id")
private Integer orderId;
@ApiModelProperty(value = "数据产品id")
private Integer dataProductId;
@ApiModelProperty(value = "产品名称")
private String productName;
@ApiModelProperty(value = "产品里购买的表id")
private String tableId;
}

@ -0,0 +1,19 @@
package com.huoran.common.entity.to;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
/**
* @Author chen
* @DATE 2022/2/16 15:33
* @Version 1.0
*/
@Data
public class JudgmentPointDataTo implements Serializable {
private static final long serialVersionUID = 1L;
private ArrayList<Integer> judgmentIds;
}

@ -0,0 +1,18 @@
package com.huoran.common.entity.to;
import lombok.Data;
import java.util.HashSet;
/**
* @Author chen
* @DATE 2022/2/16 15:39
* @Version 1.0
*/
@Data
public class ProjectDataTo {
private HashSet<Integer> set;
private String name;
private Integer systemId;
}

@ -0,0 +1,54 @@
package com.huoran.common.exception;
import com.huoran.common.exception.code.BaseResponseCode;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
/**
* BusinessException
*
* @author cheney
* @version V1.0
* @date 2022年7月28日
*/
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class BusinessException extends RuntimeException {
private BaseResponseCode baseResponseCode;
private int code = 200; //返回码(400)
private String msg; //返回码对应的消息
public BusinessException(Exception e) {
super(e);
}
public BusinessException(Exception e, String msg) {
super(e);
this.msg = msg;
}
public BusinessException(String msg) {
super();
this.msg = msg;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}

@ -0,0 +1,18 @@
package com.huoran.common.exception;
import com.huoran.common.response.R;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
/**
* @description 自定义项目异常类
* @author: Mr.JK
* @create: 2021-06-07 10:26
**/
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class CustomException extends RuntimeException{
private ExceptionEnum ExceptionEnum;
}

@ -0,0 +1,56 @@
package com.huoran.common.exception;
import com.google.common.collect.Maps;
import com.huoran.common.response.R;
import io.jsonwebtoken.ExpiredJwtException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicReference;
/**
* @description 自定义异常控制器 用于自定义异常抛出后@ControllerAdvice 默认拦截全部Controller
* 如果发生异常将异常信息返回(异常状态码,异常消息,异常发生时间)
* @author: Mr.JK
* @create: 2021-06-07 10:49
**/
@Slf4j
@RestControllerAdvice
public class CustomExceptionHandler {
/**
* 拦截token异常- ExpiredJwtException
*/
@ExceptionHandler(ExpiredJwtException.class)
public R handleException(ExpiredJwtException e){
log.error("token已过期");
return R.error(e.getMessage());
}
@ExceptionHandler(CustomException.class)
public R handleException(CustomException e){
ExceptionEnum em = e.getExceptionEnum();
return R.error(em.getCode(),em.getMsg());
}
/**
* 处理参数格式校验异常
*/
@ExceptionHandler(value = MethodArgumentNotValidException.class)
public R handleValidException(MethodArgumentNotValidException e){
log.error("参数格式校验异常");
BindingResult bindingResult = e.getBindingResult();
HashMap<String, String> errorMap = Maps.newHashMap();
AtomicReference<String> errorMsg = new AtomicReference<>("");
bindingResult.getFieldErrors().forEach(fieldError -> {
errorMsg.set(fieldError.getDefaultMessage());
errorMap.put(fieldError.getField(),fieldError.getDefaultMessage());
});
return R.error(ExceptionEnum.VALID_EXCEPTION.getCode(), errorMsg).put("data",errorMap);
}
}

@ -0,0 +1,156 @@
package com.huoran.common.exception;
import lombok.*;
/**
* @description 异常枚举类
* @author: Mr.JK
* @create: 2021-06-07 10:30
* 异常代码枚举
* 异常代码列表
* 10 中台主项目
* 001 参数格式校验
* 002 密码无改变
* 003 账号已存在
* 004 验证码已过期
* 005 验证码错误
* 006 密码错误
* 007 账号禁用
* 008 账号不存在
* 009 客户已存在
* 010 客户无订单
* 20 数据平台
* 001
* 30 用户管理
* 001 手机号未绑定
**/
@Getter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public enum ExceptionEnum {
UNKNOWN_EXCEPTION(10000, "未知异常,请联系管理员解决!"),
VALID_EXCEPTION(10001, "参数格式校验异常!"),
NO_CHANGE_EXCEPTION(10002, "密码无改变,更新失败!"),
EXIST_ACCOUNT(10003, "账号已存在,请重新设置!"),
CODE_EXPIRED(10004, "验证码已过期"),
CODE_ERROR(10005, "验证码错误"),
WRONG_PASSWORD(10006, "密码错误"),
ACCOUNT_DISABLED(10007, "账号已禁用"),
ACCOUNT_NOT_EXIST(10008, "账号不存在"),
NOT_AUTHORITY(10008, "无该平台登录权限!"),
PHONE_NOT_EXIST(10008, "手机号不存在"),
MAIL_NOT_EXIST(10008, "邮箱不存在"),
NOT_ALLOWED(10008, "超管只支持账号进行登录!"),
EXIST_CUSTOMER(10009, "客户已存在!"),
NO_ORDER(10010, "该账号下没有订单,请下订单后进行登录!"),
NO_SHIPPED(10011, "订单还未发货,请发货后进行登录!"),
NO_ENABLE(10012, "订单还未启用,请启用后进行登录!"),
MATURITY(10013, "订单到期,请联系管理员续费后进行登录!"),
USER_NOT_EXIST(10014, "用户不存在"),
ACCOUNT_AVALIABLE(10015, "可使用账号数量不足,无法启用账号!"),
SERVICE_CALL_FAILED(10016, "服务调用失败,请稍后再试!"),
TOO_MANY_REQUEST(10017, "请求流量过大,请稍后再试!"),
SERVICE_FAIL(10018, "服务调用失败,请稍后再试!"),
REPEAT_ORDERS(10019, "该时间段与现有订单有效期重叠,请勿重复下单!"),
STUDENT_ID_NOT_EXIST(10020, "学号不存在"),
JOB_ID_NOT_EXIST(10021, "工号不存在"),
DATA_PLATFORM_ACCOUNT_AVALIABLE_FAIL(10022, "当前用户所在的院校在数据平台的可用账号数量不足,是否继续!"),
INVITATION_CODE_EXPIRED(10023, "邀请码已失效"),
USER_ALREADY_EXISTS_GROUP(10024, "用户已存在该团队"),
CANT_JOIN_TEAM(10025, "无法加入自己的团队"),
CANNOT_ADDED_REPEATEDLY(10026, "该用户已经是团队管理员,无法重复添加!"),
DEFAULT_ROLE_NOTEXIST(10027, "默认角色不存在"),
TEAM_NOT_EXIST(10028, "团队不存在"),
PARTNER_REMOVAL(10029, "移除只能移除团队内成员,管理员无法移除!"),
SUPERVISING_ROLE(10030, "该用户存在超管角色,请转移后进行删除!"),
VERIFICATION_CODE_HAS_BEEN_SENT(10031, "验证码已发,请勿重复操作!"),
LOGIN_INVALID(401, "登录已失效,请重新登录"),
ASSOCIATED_PRODUCT(10031, "已关联产品,请在商城管理下架对应产品后再删除!"),
COURSE_PRODUCTS_HAVE_BEEN_REMOVED(10032, "保存失败,关联课程产品已删除,请更换关联产品!"),
COURSE_PRODUCTS_HAVE_BEEN_REMOVED_FROM_SALE(10033, "保存失败,关联课程产品已下架,请更换关联产品!"),
DATA_PRODUCTS_HAVE_BEEN_REMOVED(10032, "保存失败,关联数据产品已删除,请更换关联产品!"),
DATA_PRODUCTS_HAVE_BEEN_REMOVED_FROM_SALE(10033, "保存失败,关联数据产品已下架,请更换关联产品!"),
CLASSIFICATION_HAS_NO_MODEL_DATA(10034,"当前选择的分类下的没有满足条件的模型数据可供导入!"),
REDIS_LIMIT(10035,"当前人数较多,请稍后再试!"),
//数据平台
DATA_NOT_FOUND(20001, "数据不存在!"),
INVALID_PARAM(20002, "参数错误!"),
TABLE_NO_FOUND(20003, "该表不存在!"),
TABLE_DOWNLOAD_FAIL(20004, "表下载量更新失败!"),
SELECT_TOTAL_IS_ZERO(20005, "查询总数为零!"),
QUERY_TABLE_DATA_FAIL(20006, "查询表数据失败!"),
TABLE_CLICK_FAIL(20007, "表点击量更新失败!"),
SYMBOL_OF_ILLEGAL(20008, "符号非法!"),
//用户管理
NO_BIND_PHONE(30001, "未绑定手机号,请绑定后再登录!"),
//职站
QUESTION_NUM_INVALID(40001, "测评题目数量设置超出范围!"),
QUESTION_EXISTS(40002, "此题已存在!"),
QUESTION_TYPE_INVALID(40003, "题型错误!"),
EXCEL_INVALID(40004, "excel表内容错误!"),
EXCEL_FILE_INVALID(40005, "上传excel文件错误!"),
EXCEL_FILE_NULL(40006, "导入失败,导入数据为空!"),
EXCEL_FILE_FORMAT_ERROR(40007, "请根据模板使用说明录入正确的题库信息!"),
ASSESSMENT_ENABLE_CODE_NULL(40008, "请输入正确的邀请码!"),
ADD_COLUMNS_FAILED(40009, "栏目最多可添加10个!"),
INSERT_PROJECT_MANAGE_FAIL(40010, "新增项目管理失败!"),
UPDATE_PROJECT_MANAGE_FAIL(40010, "更新项目管理失败!"),
SAVE_ASSESSMENT_FAIL(40011, "新增考核失败!"),
UPDATE_ASSESSMENT_FAIL(40012, "修改考核失败!"),
ENTER_EXAM_FAIL(40013, "进入考试失败!"),
DELETE_JUDGMENT_FAIL(40014, "删除判分点失败"),
EMPTY_SCHOOL(40015,"请选择所属学校"),
EMPTY_ACCOUNT(40015,"账号不能为空"),
EMPTY_WORK_NUMBER(40015,"学号/工号不能为空"),
EMPTY_PARAMETER(40016,"登录参数不完整!"),
TEAM_LIMIT1(40017,"报名失败,超过团队人数限制!"),
TEAM_LIMIT2(40018,"报名失败,超过赛事团队数上限!"),
TEAM_LIMIT3(40019,"报名失败,超过赛事人数上限!"),
CODE(40019,"报名失败,报名邀请码错误!"),
HAVE_BEEN_REGISTERED(40020,"你已经报过名啦!"),
UNABLE_TO_REGISTER(40021,"你所在院校不符合参赛要求,无法报名!"),
ENTER_CORRECT_EMAIL(40022,"请输入正确邮箱!"),
THE_REMOTE_FILE_TYPE_IS_UNRECOGNIZED(40023,"远程文件类型无法识别!"),
REFRESH_THE_LIST(40024,"当前项目状态已被更改,即将刷新列表!"),
DELETE_REFRESH_LIST(40025,"当前项目已被删除,请刷新列表!"),
ACTIVITY_REGISTRATION_FAILURE(40026,"报名失败,超过项目人数上限!"),
//判分点
DELETE_JUDGMENT_POINT_FAIL(50001, "删除判分点失败!"),
DELETE_JUDGMENT_POINT_RULE_FAIL(50002, "删除判分点规则失败!"),
ADD_JUDGMENT_POINT_FAIL(50003, "添加判分点失败!"),
ADD_JUDGMENT_POINT_RULE_FAIL(50004, "添加判分点规则失败!"),
SUBJECT_TYPE_IS_NULL(50005, "题目类型为空!"),
UPDATE_JUDGMENT_POINT_FAIL(50006, "判分点更新失败!"),
UPDATE_JUDGMENT_POINT_RULE_FAIL(50007, "判分点规则更新失败!"),
//python
RUN_TIMEOUT(60001, "当前代码运行超时,请重新再试!!"),
//银行
ADD_EXPERIMENTAL_REPORT_FAIL(70001, "添加实验报告失败!"),
REPEAT_SUBMISSION(70004, "重复提交考核!"),
ADD_USER_SCORE_FAIL(70002, "添加用户分数失败!"),
SELECT_JUDGMENT_SCORE_FAIL(70003, "查询判分点分数失败!"),
FALSE_CODE(70005, "非法代码,请检查是否调用系统命令!"),
;
private int code;
private String msg;
}

@ -0,0 +1,24 @@
package com.huoran.common.exception;
import lombok.Data;
/**
* @description 处理异常结果
* @author: Mr.JK
* @create: 2021-06-07 10:56
**/
@Data
public class ExceptionResult {
private int status;
private String message;
private Long timestamp;
public ExceptionResult(ExceptionEnum em){
this.status = em.getCode();
this.message = em.getMsg();
this.timestamp = System.currentTimeMillis();
}
}

@ -0,0 +1,69 @@
package com.huoran.common.exception.code;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* 错误码
*
* @author cheney
* @version V1.0
* @date 2022年7月28日
*/
@Getter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public enum BaseResponseCode implements ResponseCodeInterface {
/**
* 错误码
*/
USERNAME_EXISTS(10008, "用户名已存在!"),
KEY_OR_TOMEUNIT(10009, "key or TomeUnit 不能为空!"),
DICTIONARY_DATA_FAILED(10010, "获取字典数据失败"),
UPLOAD_EMPTY(10011, "上传内容为空"),
UPLOAD_FAILED(10012, "上传失败"),
VERIFICATION_CODE_ERROR(10007, "验证码错误!"),
VERIFICATION_CODE_EXPIRED(10006, "验证码已过期!"),
CANNOT_SAME(10005, "新密码不能与旧密码相同!"),
EXCEL_FILE_INVALID(10004, "上传excel文件错误!"),
VALID_EXCEPTION(10003, "参数格式校验异常!"),
OPERATION_ERROR(10002, "操作失败"),
SYSTEM_BUSY(500, "系统繁忙,请稍候再试"),
SUCCESS(200, "success"),
EXCEL_FILE_FORMAT_ERROR(40007, "请根据模板使用说明录入正确的用户信息!"),
TOKEN_ERROR(401, "登录凭证已过期,请重新登录"),
DATA_ERROR(401003, "传入数据异常"),
NOT_ACCOUNT(401004, "该用户不存在,请先注册"),
USER_LOCK(401005, "该用户已被锁定,请联系运营人员"),
PASSWORD_ERROR(401006, "用户名或密码错误"),
METHOD_ARGUMENT_NOT_VALID_EXCEPTION(400, "请求参数有误"),
UNAUTHORIZED_ERROR(401008, "权鉴校验不通过"),
ROLE_PERMISSION_RELATION(401009, "该菜单权限存在子集关联,不允许删除"),
OLD_PASSWORD_ERROR(401010, "旧密码不正确"),
NOT_PERMISSION_DELETED_DEPT(401011, "该组织机构下还关联着用户,不允许删除"),
DELETE_SUB_DEPARTMENTS_FIRST(401018, "请先删除子级部门!"),
OPERATION_MENU_PERMISSION_CATALOG_ERROR(401012, "操作后的菜单类型是目录,所属菜单必须为默认顶级菜单或者目录"),
OPERATION_MENU_PERMISSION_MENU_ERROR(401013, "操作后的菜单类型是菜单,所属菜单必须为目录类型"),
OPERATION_MENU_PERMISSION_BTN_ERROR(401013, "操作后的菜单类型是按钮,所属菜单必须为菜单类型"),
OPERATION_MENU_PERMISSION_URL_NOT_NULL(401015, "菜单权限的url不能为空"),
OPERATION_MENU_PERMISSION_URL_PERMS_NULL(401016, "菜单权限的标识符不能为空"),
ROLE_ERROR(401017, "账号角色被删,请联系管理员添加角色后再试"),
EXCEL_FILE_NULL(40006, "导入失败,导入数据为空!"),
DATA_DOES_NOT_EXIST(500, "当前数据不存在"),
;
/**
* 错误码
*/
private int code;
/**
* 错误消息
*/
private String msg;
}

@ -0,0 +1,24 @@
package com.huoran.common.exception.code;
/**
* ResponseCodeInterface
*
* @author cheney
* @version V1.0
* @date 2022年7月28日
*/
public interface ResponseCodeInterface {
/**
* 获取code
*
* @return code
*/
int getCode();
/**
* 获取信息
*
* @return msg
*/
String getMsg();
}

@ -0,0 +1,28 @@
package com.huoran.common.handler;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
* @Author cheney
* @DATE 2021/5/10 11:13
* @Version 1.0
* 元数据处理自动更新更新时间及填充创建时间
*/
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
this.setFieldValByName("createTime", new Date(), metaObject);
this.setFieldValByName("updateTime", new Date(), metaObject);
}
@Override
public void updateFill(MetaObject metaObject) {
this.setFieldValByName("updateTime", new Date(), metaObject);
}
}

@ -0,0 +1,97 @@
package com.huoran.common.response;
import com.huoran.common.exception.ExceptionEnum;
import org.apache.http.HttpStatus;
import org.springframework.lang.Nullable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author chen
* @DATE 2020/9/30 11:18
* @Version 1.0
*/
public class R<T> extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
public R() {
put("status", 200);
put("message", "success");
}
public static R error() {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
}
public static R error(String msg) {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
}
public static R error(int code, String msg) {
R r = new R();
r.put("status", code);
r.put("message", msg);
return r;
}
@Deprecated
public static <T> R<T> error(int code, @Nullable T msg) {
R r = new R();
r.put("status", code);
r.put("message", msg);
return r;
}
public static R ok(String msg) {
R r = new R();
r.put("message", msg);
return r;
}
public static R ok(Map<String, Object> map) {
R r = new R();
r.putAll(map);
return r;
}
public static R ok(List list) {
R r = new R();
r.put("list",list);
return r;
}
public static R ok() {
return new R();
}
@Deprecated
public static <T> R ok(@Nullable T msg) {
R r = new R();
r.put("message", msg);
return r;
}
public static R error(ExceptionEnum exceptionEnum) {
R r = new R();
r.put("status",exceptionEnum.getCode());
r.put("message",exceptionEnum.getMsg());
return r;
}
@Override
public R put(String key, Object value) {
super.put(key, value);
return this;
}
public static R toR(int rows){
return rows > 0 ? R.ok() : R.error();
}
public static R toR(boolean result){
return result ? R.ok() : R.error();
}
}

@ -0,0 +1,447 @@
package com.huoran.common.utils;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.IdUtil;
import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.*;
import com.aliyun.vod.upload.impl.UploadVideoImpl;
import com.aliyun.vod.upload.req.UploadStreamRequest;
import com.aliyun.vod.upload.resp.UploadStreamResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.vod.model.v20170321.DeleteVideoRequest;
import com.aliyuncs.vod.model.v20170321.DeleteVideoResponse;
import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthRequest;
import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse;
import com.huoran.common.entity.FilesResult;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.List;
public class AliyunOssUtil {
/**
* 视频上传
* @param file 视频文件
* @return 返回文件信息
* @throws IOException IO异常
*/
/*public static FilesResult vodUpload(MultipartFile file) throws IOException {
FilesResult filesResult = new FilesResult();
//获取文件流
InputStream inputStream = file.getInputStream();
String originalFilename = file.getOriginalFilename();
assert originalFilename != null;
String title = originalFilename.substring(0, originalFilename.lastIndexOf("."));
// 获取文件尾缀
String fileType = originalFilename.substring(originalFilename.lastIndexOf(".")+1);
// 文件类型
filesResult.setFileType(fileType);
//上传流请求
UploadStreamRequest request = new UploadStreamRequest(ConstantPropertiesUtil.ACCESS_KEY_ID,
ConstantPropertiesUtil.ACCESS_KEY_SECRET, title, originalFilename, inputStream);
*//* 是否使用默认水印(可选),指定模板组ID时,根据模板组配置确定是否使用默认水印*//*
//request.setShowWaterMark(true);
*//* 设置上传完成后的回调URL(可选),建议通过点播控制台配置消息监听事件,参见文档 https://help.aliyun.com/document_detail/57029.html *//*
//request.setCallback("http://callback.sample.com");
*//* 自定义消息回调设置,参数说明参考文档 https://help.aliyun.com/document_detail/86952.html#UserData *//*
//request.setUserData(""{\"Extend\":{\"test\":\"www\",\"localId\":\"xxxx\"},\"MessageCallback\":{\"CallbackURL\":\"http://test.test.com\"}}"");
*//* 视频分类ID(可选) *//*
//request.setCateId(0);
*//* 视频标签,多个用逗号分隔(可选) *//*
//request.setTags("标签1,标签2");
*//* 视频描述(可选) *//*
//request.setDescription("视频描述");
*//* 封面图片(可选) *//*
//request.setCoverURL("http://cover.sample.com/sample.jpg");
*//* 模板组ID(可选) *//*
//request.setTemplateGroupId("8c4792cbc8694e7084fd5330e56a33d");
*//* 工作流ID(可选) *//*
//request.setWorkflowId("d4430d07361f0*be1339577859b0177b");
*//* 存储区域(可选) *//*
//request.setStorageLocation("in-201703232118266-5sejdln9o.oss-cn-shanghai.aliyuncs.com");
*//* 开启默认上传进度回调 *//*
// request.setPrintProgress(true);
*//* 设置自定义上传进度回调 (必须继承 VoDProgressListener) *//*
// request.setProgressListener(new PutObjectProgressListener());
*//* 设置应用ID*//*
//request.setAppId("app-1000000");
*//* 点播服务接入点 *//*
//request.setApiRegionId("cn-shanghai");
*//* ECS部署区域*//*
// request.setEcsRegionId("cn-shanghai");
UploadVideoImpl uploader = new UploadVideoImpl();
UploadStreamResponse response = uploader.uploadStream(request);
//如果设置回调URL无效,不影响视频上传,可以返回VideoId同时会返回错误码。
// 其他情况上传失败时,VideoId为空,此时需要根据返回错误码分析具体错误原因
String videoId = response.getVideoId();
if (!response.isSuccess()) {
String errorMessage = "阿里云视频上传错误:" + "code:" + response.getCode() + ", message:" + response.getMessage();
if(StringUtils.isEmpty(videoId)){
throw new CustomException(ExceptionEnum.UNKNOWN_EXCEPTION);
}
}
filesResult.setFileId(videoId);
return filesResult;
}*/
/**
* 根据视频id删除视频
*
* @param videoId 视频id
*/
public static void removeVideo(String videoId) throws com.aliyuncs.exceptions.ClientException {
DefaultAcsClient client = AliyunVodSDKUtil.initVodClient(
ConstantPropertiesUtil.ACCESS_KEY_ID,
ConstantPropertiesUtil.ACCESS_KEY_SECRET);
DeleteVideoRequest request = new DeleteVideoRequest();
request.setVideoIds(videoId);
DeleteVideoResponse response = client.getAcsResponse(request);
System.out.print("RequestId = " + response.getRequestId() + "\n");
}
/**
* 根据视频id批量删除视频
*
* @param videoIdList 视频id
*/
public static void removeMoreVideo(List<String> videoIdList) throws com.aliyuncs.exceptions.ClientException {
DefaultAcsClient client = AliyunVodSDKUtil.initVodClient(
ConstantPropertiesUtil.ACCESS_KEY_ID,
ConstantPropertiesUtil.ACCESS_KEY_SECRET);
DeleteVideoRequest request = new DeleteVideoRequest();
//使用工具类将集合转化成指定的字符串
String videos = StringUtils.join(videoIdList, ",");
request.setVideoIds(videos);
DeleteVideoResponse response = client.getAcsResponse(request);
System.out.print("RequestId = " + response.getRequestId() + "\n");
}
/**
* 根据视频id获取播放凭证
*
* @param videoId 视频id
* @return 返回凭证
*/
public static String getPlayAuth(String videoId) throws com.aliyuncs.exceptions.ClientException {
DefaultAcsClient client = AliyunVodSDKUtil.initVodClient(ConstantPropertiesUtil.ACCESS_KEY_ID, ConstantPropertiesUtil.ACCESS_KEY_SECRET);
GetVideoPlayAuthRequest request = new GetVideoPlayAuthRequest();
request.setVideoId(videoId);
GetVideoPlayAuthResponse response = client.getAcsResponse(request);
//得到播放凭证并返回
return response.getPlayAuth();
}
/**
* 创建存储空间
*
* @param ossClient oss客户端
*/
public static void createBucket(OSS ossClient) {
// 判断存储空间是否存在,不存在,则创建
if (!ossClient.doesBucketExist(ConstantPropertiesUtil.BUCKET_NAME)) {
// 创建CreateBucketRequest对象,设置仓库名称
CreateBucketRequest bucketRequest = new CreateBucketRequest(ConstantPropertiesUtil.BUCKET_NAME);
// 设置存储空间的权限为公共读,默认是私有。
bucketRequest.setCannedACL(CannedAccessControlList.PublicRead);
// 此处以设置存储空间的存储类型为标准存储为例。
// createBucketRequest.setStorageClass(StorageClass.Standard);
// 默认情况下,数据容灾类型为本地冗余存储,即DataRedundancyType.LRS。如果需要设置数据容灾类型为同城冗余存储,请替换为DataRedundancyType.ZRS。
// createBucketRequest.setDataRedundancyType(DataRedundancyType.ZRS)
// 创建存储空间。
ossClient.createBucket(bucketRequest);
}
}
public static String getFormatSize(double size) {
double kiloByte = size / 1024;
if (kiloByte < 1) {
return size + "Byte(s)";
}
double megaByte = kiloByte / 1024;
if (megaByte < 1) {
BigDecimal result1 = new BigDecimal(Double.toString(kiloByte));
return result1.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "KB";
}
double gigaByte = megaByte / 1024;
if (gigaByte < 1) {
BigDecimal result2 = new BigDecimal(Double.toString(megaByte));
return result2.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "MB";
}
double teraBytes = gigaByte / 1024;
if (teraBytes < 1) {
BigDecimal result3 = new BigDecimal(Double.toString(gigaByte));
return result3.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "GB";
}
BigDecimal result4 = new BigDecimal(teraBytes);
return result4.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "TB";
}
public static void main(String[] args) {
System.out.println(getFormatSize(68160));
}
/**
* 上传文件
*
* @param file 文件
* @return 返回文件上传结果
* @throws OSSException oss异常
* @throws ClientException 客户端异常
* @throws IOException io异常
*/
public static FilesResult uploadFile(MultipartFile file) throws OSSException, ClientException, IOException {
//获取访问key
String endPoint = ConstantPropertiesUtil.END_POINT;
String accessKeyId = ConstantPropertiesUtil.ACCESS_KEY_ID;
String accessKeySecret = ConstantPropertiesUtil.ACCESS_KEY_SECRET;
//创建ossClient
OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, accessKeySecret);
FilesResult result = new FilesResult();
// 创建存储空间
createBucket(ossClient);
//获取上传文件流
InputStream inputStream = file.getInputStream();
//获取当前日期构建日期路径:avatar/2019/02/26/文件名
String currentDate = new DateTime().toString("yyyyMMdd");
//获取上传的文件名称
String fileName = file.getOriginalFilename();
result.setOriginalFileName(fileName);//原文件名
// 获取文件尾缀
assert fileName != null;
String ext = fileName.substring(fileName.lastIndexOf("."));
// 获取文件类型,大小
String fileType = getFileType(ext);
long fileSize = file.getSize();
//获取随机值
String snowflakeId = IdUtil.getSnowflake(6, 4).nextIdStr();
//文件名:雪花算法.文件扩展名
String newName = snowflakeId + ext;
String sort = ext.substring(ext.lastIndexOf(".") + 1);
result.setFileType(sort);
result.setFileSize(String.valueOf(fileSize));
//组合新的文件名
String fileUrl = currentDate + "/" + sort + "/" + newName;
result.setOssFileName(fileUrl);
// 设置上传时存储类型与访问权限
ObjectMetadata metadata = new ObjectMetadata();
// 指定该Object被下载时的网页的缓存行为
metadata.setCacheControl("no-cache");
// 指定该Object下设置Header
metadata.setHeader("Pragma", "no-cache");
// 指定该Object被下载时的内容编码格式
metadata.setContentEncoding("utf-8");
// 文件的MIME,定义文件的类型及网页编码,决定浏览器将以什么形式、什么编码读取文件。如果用户没有指定则根据Key或文件名的扩展名生成,
// 如果没有扩展名则填默认值application/octet-stream
metadata.setContentType(fileType);
// 指定该Object被下载时的名称(指示MINME用户代理如何显示附加的文件,打开或下载,及文件名称)
metadata.setContentDisposition("filename/filesize=" + file.getName() + "/" + fileSize + "Byte.");
//上传文件 (上传文件流的形式)
ossClient.putObject(ConstantPropertiesUtil.BUCKET_NAME, fileUrl, inputStream, metadata);
// 关闭OSSClient。
ossClient.shutdown();
// 拼接文件url地址,返回控制层
String tempEndpoint = ConstantPropertiesUtil.END_POINT;
String endpoint = tempEndpoint.substring(tempEndpoint.lastIndexOf("/") + 1, tempEndpoint.length());
String url = "https://" + ConstantPropertiesUtil.BUCKET_NAME + "." + endpoint + "/" + fileUrl;
result.setFileUrl(url);
// 关闭OSSClient。
ossClient.shutdown();
return result;
}
/**
* 文件下载
*
* @param response 响应对象
* @param ossClient oss客户端
* @param objectName 文件名
*/
public static void downloadFiles(HttpServletResponse response, OSS ossClient,
String objectName) throws IOException {
// ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
OSSObject ossObject = ossClient.getObject(ConstantPropertiesUtil.BUCKET_NAME, objectName);
InputStream input = null;
OutputStream outputStream = null;
try {
// 获取文件名
String fileName = objectName.substring(objectName.lastIndexOf("/") + 1);
//获取输入流
input = ossObject.getObjectContent();
// 获取OutputStream输出流
outputStream = response.getOutputStream();
byte[] buffer = new byte[input.available()];
response.setHeader("content-Type", "application/octet-stream");
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
response.flushBuffer();
for (int length = 0; (length = input.read(buffer)) > 0; ) {
outputStream.write(buffer, 0, length);
}
} catch (IOException e) {
e.printStackTrace();
throw e;
} finally {
if (null != outputStream) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != input) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
// 关闭OSSClient。
ossClient.shutdown();
}
}
/**
* *** 谨慎操作 ***
* 删除存储空间
*
* @param bucketName 存储空间名称
*/
public static void deleteBucket(String bucketName) {
String endPoint = ConstantPropertiesUtil.END_POINT;
String accessKeyId = ConstantPropertiesUtil.ACCESS_KEY_ID;
String accessKeySecret = ConstantPropertiesUtil.ACCESS_KEY_SECRET;
// 创建OSSClient实例。
OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, accessKeySecret);
// 删除存储空间。
ossClient.deleteBucket(bucketName);
// 关闭OSSClient。
ossClient.shutdown();
}
/**
* 创建文件夹
*
* @param ossClient oss连接
* @param bucketName 存储空间
* @param folder 文件夹名 "qj_nanjing/"
* @return 返回创建的文件夹名
*/
public static String createFolder(OSS ossClient, String bucketName, String folder) {
// 判断文件夹是否存在,不存在则创建
if (!ossClient.doesObjectExist(bucketName, folder)) {
// 创建文件夹
ossClient.putObject(bucketName, folder, new ByteArrayInputStream(new byte[0]));
// 得到文件夹名
OSSObject object = ossClient.getObject(bucketName, folder);
return object.getKey();
}
return folder;
}
/**
* 批量删除文件key等同于ObjectName表示删除OSS文件时需要指定包含文件后缀在内的完整路径例如abc/efg/123.jpg
*
* @param keys 文件完整路径
*/
public static List<String> deleteFiles(List<String> keys) {
String endPoint = ConstantPropertiesUtil.END_POINT;
String accessKeyId = ConstantPropertiesUtil.ACCESS_KEY_ID;
String accessKeySecret = ConstantPropertiesUtil.ACCESS_KEY_SECRET;
String bucketName = ConstantPropertiesUtil.BUCKET_NAME;
// 创建OSSClient实例。
OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, accessKeySecret);
DeleteObjectsResult deleteObjectsResult = ossClient.deleteObjects(new DeleteObjectsRequest(bucketName).withKeys(keys));
List<String> deletedObjects = deleteObjectsResult.getDeletedObjects();
// 关闭OSSClient。
ossClient.shutdown();
//返回删除成功文件列表
return deletedObjects;
}
/**
* 获取文件类型
*
* @param fileExtension 文件后缀
* @return 返回类型
*/
public static String getFileType(String fileExtension) {
if (".bmp".equalsIgnoreCase(fileExtension)) {
return "image/bmp";
}
if (".gif".equalsIgnoreCase(fileExtension)) {
return "image/gif";
}
if (".jpeg".equalsIgnoreCase(fileExtension) || ".jpg".equalsIgnoreCase(fileExtension)
|| ".png".equalsIgnoreCase(fileExtension)) {
return "image/jpg";
}
if (".html".equalsIgnoreCase(fileExtension)) {
return "text/html";
}
if (".txt".equalsIgnoreCase(fileExtension)) {
return "text/plain";
}
if (".vsd".equalsIgnoreCase(fileExtension)) {
return "application/vnd.visio";
}
if (".ppt".equalsIgnoreCase(fileExtension) || ".pptx".equalsIgnoreCase(fileExtension)) {
return "application/vnd.ms-powerpoint";
}
if (".doc".equalsIgnoreCase(fileExtension) || ".docx".equalsIgnoreCase(fileExtension)) {
return "application/msword";
}
if (".xml".equalsIgnoreCase(fileExtension)) {
return "text/xml";
}
if (".mp4".equalsIgnoreCase(fileExtension) || ".avi".equalsIgnoreCase(fileExtension)) {
return "video/mp4";
}
if (".mpg".equalsIgnoreCase(fileExtension) || ".mpeg".equalsIgnoreCase(fileExtension)) {
return "video/mpeg";
}
if ("pdf".equalsIgnoreCase(fileExtension)) {
return "application/pdf";
}
return "application/octet-stream";
}
}

@ -0,0 +1,17 @@
package com.huoran.common.utils;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.profile.DefaultProfile;
/**
* @Author chen
* @DATE 2020/10/12 9:10
* @Version 1.0
*/
public class AliyunVodSDKUtil {
public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) {
String regionId = "cn-shanghai"; // 点播服务接入区域
DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
return new DefaultAcsClient(profile);
}
}

@ -0,0 +1,143 @@
package com.huoran.common.utils;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* @description 缓存工具类用于缓存复杂对象
* @author: Mr.JK
* @create: 2021-09-09 14:46
**/
public class CacheUtil {
//键值对集合
private final static Map<String, Entity> map = new HashMap<>();
//定时器线程池,用于清除过期缓存
private final static ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
/**
* 添加缓存
*一天时间缓存
* @param key
* @param data
*/
public synchronized static void put(String key, Object data) {
CacheUtil.put(key, data, 86400000);
}
/**
* 添加缓存
*
* @param key
* @param data
* @param expire 过期时间单位毫秒 0表示无限长
*/
public synchronized static void put(String key, Object data, long expire) {
//清除原键值对
CacheUtil.remove(key);
//设置过期时间
if (expire > 0) {
Future future = executor.schedule(new Runnable() {
@Override
public void run() {
//过期后清除该键值对
synchronized (CacheUtil.class) {
map.remove(key);
}
}
}, expire, TimeUnit.MILLISECONDS);
map.put(key, new Entity(data, future));
} else {
//不设置过期时间
map.put(key, new Entity(data, null));
}
}
/**
* 读取缓存
*
* @param key
* @return
*/
public synchronized static Object get(String key) {
Entity entity = map.get(key);
return entity == null ? null : entity.getValue();
}
/**
* 读取缓存
*
* @param key
* * @param clazz 值类型
* @return
*/
public synchronized static <T> T get(String key, Class<T> clazz) {
return clazz.cast(CacheUtil.get(key));
}
/**
* 清除缓存
*
* @param key
* @return
*/
public synchronized static Object remove(String key) {
//清除原缓存数据
Entity entity = map.remove(key);
if (entity == null) {
return null;
}
//清除原键值对定时器
Future future = entity.getFuture();
if (future != null) {
future.cancel(true);
}
return entity.getValue();
}
/**
* 查询当前缓存的键值对数量
*
* @return
*/
public synchronized static int size() {
return map.size();
}
/**
* 缓存实体类
*/
private static class Entity {
//键值对的value
private Object value;
//定时器Future
private Future future;
public Entity(Object value, Future future) {
this.value = value;
this.future = future;
}
/**
* 获取值
*
* @return
*/
public Object getValue() {
return value;
}
/**
* 获取Future对象
*
* @return
*/
public Future getFuture() {
return future;
}
}
}

@ -0,0 +1,44 @@
package com.huoran.common.utils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;
/**
* @description 验证码工具类
* @author: Mr.JK
* @create: 2021-06-22 15:56
**/
public class CheckCodeUtils {
/**
* 获取六位随机数验证码
* @return
*/
public String sendCode(){
Random random = new Random();
String code="";
for (int i=0;i<6;i++)
{
code+=random.nextInt(10);
}
return code;
}
/**
* 生成时间
*/
public String letTimes(int letTime){
Calendar instance = Calendar.getInstance();
instance.add(Calendar.MINUTE,+letTime);
Date time = instance.getTime();
SimpleDateFormat myFmt=new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
String format1 = myFmt.format(time);
return format1;
}
}

@ -0,0 +1,41 @@
package com.huoran.common.utils;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @ProjectName: huorantech
* @Package: com.huoran.common.utils
* @ClassName: CheckDateUtil
* @Description: 校验用户输入的时间
* @Author: Maureen.Rong
* @CreateDate: 2021/8/19 11:12
* @UpdateDate: 2021/8/19 11:12
* @Version: 1.0
*/
public class CheckDateUtil {
/**
* 如果为true表示
* 校验用户输入的时间
*
* @param startTime
* @return
*/
public static boolean checStartkTime(String startTime) {
try {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//用户输入的时间
Date dateTime1 = dateFormat.parse(startTime);
//当前时间
String DateStr2 = DateUtils.nowTime();
Date dateTime2 = dateFormat.parse(DateStr2);
int i = dateTime1.compareTo(dateTime2);
boolean ret = false;
ret = i > 0;
return ret;
} catch (Exception e) {
return false;
}
}
}

@ -0,0 +1,39 @@
package com.huoran.common.utils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* 常量类读取配置文件application.properties中的配置
*/
@Component
@PropertySource("classpath:application.properties")
public class ConstantPropertiesUtil implements InitializingBean {
@Value("${aliyun.oss.file.endpoint}")
private String endpoint;
@Value("${aliyun.oss.file.keyid}")
private String keyId;
@Value("${aliyun.oss.file.keysecret}")
private String keySecret;
@Value("${aliyun.oss.file.bucketname}")
private String bucketName;
public static String END_POINT;
public static String ACCESS_KEY_ID;
public static String ACCESS_KEY_SECRET;
public static String BUCKET_NAME;
@Override
public void afterPropertiesSet() throws Exception {
END_POINT = endpoint;
ACCESS_KEY_ID = keyId;
ACCESS_KEY_SECRET = keySecret;
BUCKET_NAME = bucketName;
}
}

@ -0,0 +1,45 @@
package com.huoran.common.utils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* @Author chen
* @DATE 2020/10/20 10:46
* @Version 1.0
*/
public class DateUtil {
public static String lastDate(Integer month){
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar c = Calendar.getInstance();
if (month==1){
c.add(Calendar.MONTH,-1);
Date time = c.getTime();
return format.format(time);
}
if (month==3){
c.add(Calendar.MONTH,-3);
Date time = c.getTime();
return format.format(time);
}
if (month==6){
c.add(Calendar.MONTH,-6);
Date time = c.getTime();
return format.format(time);
}
return "";
}
public static String currentDate(){
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return format.format(new Date());
}
public static void main(String[] args) {
System.out.println(currentDate());
}
}

@ -0,0 +1,193 @@
package com.huoran.common.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
public class DateUtils {
public static String handleTime(Date date) {
Instant instant = date.toInstant();
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime();
return localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); // 当前日期和时间
}
public static String formatTime(LocalDateTime time) {
String timeStr1 = time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
return timeStr1;
}
/**
* 时间类型转换
*
* @param time
* @return
*/
public static String dateForByStr(String time) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date date = sdf.parse(time);
//获取String类型的时间
String createdate = sdf.format(date);
return createdate;
} catch (ParseException e) {
e.printStackTrace();
return null;
}
}
/**
* 获取当前时间
*
* @return
*/
/*public static String getNowTime(Integer userId) {
String getDate = template.opsForValue().get("date:userId_" + userId);
SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String datetime = tempDate.format(new java.utils.Date());
//也可以用这个
String datetimes = tempDate.format(new Date(System.currentTimeMillis()));
return getDate;
}*/
public static String getNowTime() {
SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String datetime = tempDate.format(new Date());
//也可以用这个
String datetimes = tempDate.format(new Date(System.currentTimeMillis()));
return datetime;
}
public static String nowTime() {
SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String datetime = tempDate.format(new Date());
//也可以用这个
String datetimes = tempDate.format(new Date(System.currentTimeMillis()));
return datetime;
}
/**
* 获取当前时间往后推几个月
*
* @param startDate
* @param number
* @return
*/
public static String getAfterDate(Date startDate, int number) {
Calendar c = Calendar.getInstance();//获得一个日历的实例
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
c.setTime(startDate);
c.add(Calendar.MONTH, number);
return sdf.format(c.getTime());
}
//获取两个日期之间的天数
public static int getDatePoor(Date endDate, Date nowDate) {
Calendar cal = Calendar.getInstance();
cal.setTime(endDate);
long time1 = cal.getTimeInMillis();
cal.setTime(nowDate);
long time2 = cal.getTimeInMillis();
long between_days = (time2 - time1) / (1000 * 3600 * 24);
int parseInt = Integer.parseInt(String.valueOf(between_days));
parseInt = parseInt + 1;
return parseInt;
}
public static void main(String[] args) throws ParseException {
String d1 = "2022-06-09 00:00";
String d2 = "2022-06-10 23:00";
System.out.println(getTheNumberOfDaysBetweenTwoDates(d2, d1));
}
public static int getTheNumberOfDaysBetweenTwoDates(String endDate, String nowDate) throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = simpleDateFormat.parse(nowDate);
Date date2 = simpleDateFormat.parse(endDate);
int l = (int) (date2.getTime() - date1.getTime()) / (1000 * 24 * 60 * 60);
// System.out.println("两个时间相差" + l + "天");
return l;
}
/**
* Date 转换为 String
*
* @param date
* @return
*/
public static String getDateByString(Date date) {
String pattern2 = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf2 = new SimpleDateFormat(pattern2);
System.out.println(sdf2.format(date));
return sdf2.format(date);
}
public static Date getDateByDay(int day) {
Calendar calendar = Calendar.getInstance();
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
calendar.add(Calendar.DAY_OF_YEAR, day);
return calendar.getTime();
}
/*public static long dateDiff(String startTime, String endTime) {
//按照dao传入的格式生成一个simpledateformate对象
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm");
long nd = 1000 * 24 * 60 * 60;//一天的毫秒数
long nh = 1000 * 60 * 60;//一小时的毫秒数
long nm = 1000 * 60;//一分钟的毫秒数
long ns = 1000;//一秒钟的毫秒数
long diff;
try {
//获得两个时间的毫秒时间差异
diff = sd.parse(endTime).getTime() - sd.parse(startTime).getTime();
long day = diff / nd;//计算差多少天
long hour = diff % nd / nh;//计算差多少小时
long min = diff % nd % nh / nm;//计算差多少分钟
long sec = diff % nd % nh % nm / ns;//计算差多少秒//输出结果
System.out.println("时间相差:" + day + "天" + hour + "小时" + min + "分钟" + sec + "秒。");
long countHour = 0;//统计分钟
countHour = (day * 24 * 60) + (hour * 60) + min;//天数*24小时
return countHour;
} catch (Exception e) {
System.out.println(e.getMessage());
return 0;
}
}*/
public static long dateDiffByLong(String startTime) throws ParseException {
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long start = sd.parse(startTime).getTime();
long end = System.currentTimeMillis();
long min = (end - start) / (1000 * 60);
System.out.println(min);
if (min == 0) {
return 1;
}
return min;
}
/*public static void main(String[] args) throws ParseException {
dateDiffByLong("2021-05-28 09:52:05");
}*/
}

@ -0,0 +1,31 @@
package com.huoran.common.utils;
import java.io.File;
/**
* @描述
* @作者: Rong
* @日期: 2021/12/17 14:54
*/
public class DeleteFilesUtil {
/**
* 删除生成的文件
*
* @param path
*/
public static void deleteFile(String path) {
File file = new File(path);
// 判断目录或文件是否存在
if (file.exists()) { // 不存在返回 false
// 判断是否为文件
if (file.isFile()) {
// 路径为文件且不为空则进行删除
if (file.isFile() && file.exists()) {
file.delete();
}
}
}
}
}

@ -0,0 +1,81 @@
package com.huoran.common.utils;
import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.HtmlEmail;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Properties;
/**
* @description
* @author: Mr.JK
* @create: 2021-06-22 16:08
**/
public class EmailUtils {
//服务器地址
private static final String SERVER_ADDRESS = "smtp.mxhichina.com";
//邮箱地址
private static final String EMAILADDRESS = "postmaster@huorantech.cn";
//发生邮箱密码
private static final String EMAILPASSWORD = "HR111aaa";
//发送人姓名
private static final String EMAILUSERNAME = "DataForward";
//授权码
//private static final String AUTHORIZATION_CODE = "smtp.mxhichina.com";
//邮件标题
private static final String EMAILHEAD = "数据前瞻平台";
//邮件信息(后接验证码)头部信息
private static final String EMAILMASSAGEHEAD = "尊敬的用户,欢迎使用数据前瞻平台,您本次的验证码是: ";
//邮件信息(后接验证码)尾部信息
private static final String EMAILMASSAGETAIL = ",有效时间为5分钟";
//邮箱验证码
public static boolean sendEmail(String emailaddress,String code){
try {
HtmlEmail email = new HtmlEmail();
email.setHostName(SERVER_ADDRESS);
email.setSSLOnConnect(true); //使用ssl加密true
email.setSslSmtpPort("465"); //使用465端口
email.setCharset("UTF-8");
email.addTo(emailaddress);
email.setFrom(EMAILADDRESS, EMAILUSERNAME);
// -- 使用阿里企业邮箱无授权码
// email.setAuthentication(EMAILADDRESS, AUTHORIZATION_CODE);
email.setAuthenticator(new DefaultAuthenticator(EMAILADDRESS,EMAILPASSWORD));
email.setSubject(EMAILHEAD);
email.setMsg( EMAILMASSAGEHEAD + code + EMAILMASSAGETAIL);
email.send();
return true;
}
catch(Exception e){
e.printStackTrace();
return false;
}
}
/**
* 描述是否是邮箱.
*
* @param str 指定的字符串
* @return 是否是邮箱:是为true否则false
*/
public static Boolean isEmail(String str) {
Boolean isEmail = false;
String expr = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})$";
if (str.matches(expr)) {
isEmail = true;
}
return isEmail;
}
}

@ -0,0 +1,32 @@
package com.huoran.common.utils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
/**
* HttpContextUtils
*
* @author cheney
* @version V1.0
* @date 2022年7月28日
*/
public class HttpContextUtils {
public static HttpServletRequest getHttpServletRequest() {
return ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
}
public static boolean isAjaxRequest(HttpServletRequest request) {
String accept = request.getHeader("accept");
String xRequestedWith = request.getHeader("X-Requested-With");
// 如果是异步请求或是手机端,则直接返回信息
return ((accept != null && accept.contains("application/json")
|| (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest"))
));
}
}

@ -0,0 +1,73 @@
package com.huoran.common.utils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* IPUtils
*
* @author cheney
* @version V1.0
* @date 2022年7月28日
*/
public class IPUtils {
private static Logger logger = LoggerFactory.getLogger(IPUtils.class);
/**
* 获取IP地址
* <p>
* 使用Nginx等反向代理软件 则不能通过request.getRemoteAddr()获取IP地址
* 如果使用了多级反向代理的话X-Forwarded-For的值并不止一个而是一串IP地址X-Forwarded-For中第一个非unknown的有效IP字符串则为真实IP地址
*/
public static String getIpAddr(HttpServletRequest request) {
String ip = null;
try {
ip = request.getHeader("x-forwarded-for");
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (StringUtils.isEmpty(ip) || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
} catch (Exception e) {
logger.error("IPUtils ERROR ", e);
}
// 使用代理,则获取第一个IP地址
if (!StringUtils.isEmpty(ip) && ip.length() > 15) {
if (ip.indexOf(",") > 0) {
ip = ip.substring(0, ip.indexOf(","));
}
}
return ip;
}
/**
* 获取客户端主机名称
*/
public static String getHostName() {
try {
return InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
logger.error(e.getMessage(), e);
}
return "未知";
}
}

@ -0,0 +1,57 @@
package com.huoran.common.utils;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.springframework.util.StringUtils;
import java.util.Date;
/**
* @author cheney
*/
public class JwtUtils {
public static final long EXPIRE = 1000 * 60 * 600 * 24;//失效时间
public static final String APP_SECRET = "HuoRan2021chenHS25666";//hs256对称加密算法
public static String getJwtToken(String id){
String JwtToken = Jwts.builder()
.setHeaderParam("typ", "JWT")
.setHeaderParam("alg", "HS256")
.setSubject("user")
.setIssuedAt(new Date())
.setExpiration(new Date(System.currentTimeMillis() + EXPIRE))
.claim("accountId", id)
.signWith(SignatureAlgorithm.HS256, APP_SECRET)
.compact();
return JwtToken;
}
public static void main(String[] args) {
String jwtToken = getJwtToken("108");
System.out.println(jwtToken);
// boolean jwtToken = checkToken("\n" +
// "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiaWF0IjoxNjk4OTkwNzc3LCJleHAiOjE2OTk4NTQ3NzcsImFjY291bnRJZCI6IjMxIn0.PkzSpCHaRNtFd2k0ik4zfqg0KhoYR1e-r51lbb1S0nc");
// System.out.println(jwtToken);
}
/**
* 判断token是否存在与有效
*/
public static boolean checkToken(String jwtToken) {
if(StringUtils.isEmpty(jwtToken)) {
return false;
}
try {
Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
}

@ -0,0 +1,34 @@
package com.huoran.common.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public final class MD5 {
public static void main(String[] args) {
System.out.println(encrypt("admin"));
}
public static String encrypt(String strSrc) {
try {
char hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'a', 'b', 'c', 'd', 'e', 'f' };
byte[] bytes = strSrc.getBytes();
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(bytes);
bytes = md.digest();
int j = bytes.length;
char[] chars = new char[j * 2];
int k = 0;
for (int i = 0; i < bytes.length; i++) {
byte b = bytes[i];
chars[k++] = hexChars[b >>> 4 & 0xf];
chars[k++] = hexChars[b & 0xf];
}
return new String(chars);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
throw new RuntimeException("MD5加密出错!!+" + e);
}
}
}

@ -0,0 +1,111 @@
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/
package com.huoran.common.utils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.io.Serializable;
import java.util.List;
/**
* 分页工具类
*
* @author Mark sunlightcs@gmail.com
*/
public class PageUtils implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 总记录数
*/
private int totalCount;
/**
* 每页记录数
*/
private int pageSize;
/**
* 总页数
*/
private int totalPage;
/**
* 当前页数
*/
private int currPage;
/**
* 列表数据
*/
private List<?> list;
/**
* 分页
* @param list 列表数据
* @param totalCount 总记录数
* @param pageSize 每页记录数
* @param currPage 当前页数
*/
public PageUtils(List<?> list, int totalCount, int pageSize, int currPage) {
this.list = list;
this.totalCount = totalCount;
this.pageSize = pageSize;
this.currPage = currPage;
this.totalPage = (int) Math.ceil((double) totalCount / pageSize);
}
/**
* 分页
*/
public PageUtils(IPage<?> page) {
this.list = page.getRecords();
this.totalCount = (int) page.getTotal();
this.pageSize = (int) page.getSize();
this.currPage = (int) page.getCurrent();
this.totalPage = (int) page.getPages();
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getCurrPage() {
return currPage;
}
public void setCurrPage(int currPage) {
this.currPage = currPage;
}
public List<?> getList() {
return list;
}
public void setList(List<?> list) {
this.list = list;
}
}

@ -0,0 +1,64 @@
package com.huoran.common.utils;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
/**
* 获取随机数
*
* @author cheney
*
*/
public class RandomUtil {
private static final Random random = new Random();
private static final DecimalFormat fourdf = new DecimalFormat("0000");
private static final DecimalFormat sixdf = new DecimalFormat("000000");
public static String getFourBitRandom() {
return fourdf.format(random.nextInt(10000));
}
public static String getSixBitRandom() {
return sixdf.format(random.nextInt(1000000));
}
/**
* 给定数组抽取n个数据
* @param list
* @param n
* @return
*/
public static ArrayList getRandom(List list, int n) {
Random random = new Random();
HashMap<Object, Object> hashMap = new HashMap<Object, Object>();
// 生成随机数字并存入HashMap
for (int i = 0; i < list.size(); i++) {
int number = random.nextInt(100) + 1;
hashMap.put(number, i);
}
// 从HashMap导入数组
Object[] robjs = hashMap.values().toArray();
ArrayList r = new ArrayList();
// 遍历数组并打印数据
for (int i = 0; i < n; i++) {
r.add(list.get((int) robjs[i]));
System.out.print(list.get((int) robjs[i]) + "\t");
}
System.out.print("\n");
return r;
}
}

@ -0,0 +1,56 @@
package com.huoran.common.utils;
import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import com.huoran.common.constant.SMSTemplate;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.util.Map;
/**
* @description
* @author: Mr.JK
* @create: 2021-06-22 15:58
**/
@Slf4j
public class SendSMSUtils {
public static boolean send(String PhoneNumbers, String templateCode, Map<String,Object> param) {
if(StringUtils.isEmpty(PhoneNumbers)) {
return false;
}
DefaultProfile profile =
DefaultProfile.getProfile("default", "LTAI4FzqQHnk4rozqLZ8jCNj", "mveW7B1OyFoKUkHm8WsxmrjHmkJWHq");
IAcsClient client = new DefaultAcsClient(profile);
CommonRequest request = new CommonRequest();
request.setMethod(MethodType.GET);
request.setDomain("dysmsapi.aliyuncs.com");
request.setVersion("2017-05-25");
request.setAction("SendSms");
request.putQueryParameter("PhoneNumbers", PhoneNumbers);
request.putQueryParameter("SignName", SMSTemplate.SMS_SIGNATURE);
request.putQueryParameter("TemplateCode", templateCode);
request.putQueryParameter("TemplateParam", JSONObject.toJSONString(param));
try {
CommonResponse response = client.getCommonResponse(request);
System.out.println(response.getData());
return response.getHttpResponse().isSuccess();
} catch (ClientException e) {
e.printStackTrace();
}
return false;
}
}

@ -0,0 +1,60 @@
package com.huoran.common.utils;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwts;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
import static com.huoran.common.utils.JwtUtils.APP_SECRET;
/**
* @Author chen
* @DATE 2021/7/8 11:21
* @Version 1.0
*/
public class TokenUtils {
/**
* 判断token是否存在与有效
*/
public static boolean checkToken(HttpServletRequest request) {
try {
String jwtToken = request.getHeader("token");
if(StringUtils.isEmpty(jwtToken)) {
return false;
}
Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
/**
* 根据token获取账号id
*/
public static String getIdByJwtToken(HttpServletRequest request) {
String jwtToken = request.getHeader("token");
if(StringUtils.isEmpty(jwtToken)) {
return "";
}
Jws<Claims> claimsJws = Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
Claims claims = claimsJws.getBody();
return (String)claims.get("accountId");
}
/**
* 根据token获取账号id
*/
public static String getIdByJwtToken(String token) {
if(StringUtils.isEmpty(token)) {
return "";
}
Jws<Claims> claimsJws = Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(token);
Claims claims = claimsJws.getBody();
return (String)claims.get("accountId");
}
}

@ -0,0 +1,18 @@
package com.huoran.common.utils;
import java.util.regex.Pattern;
/**
* @Author chen
* @DATE 2020/10/12 9:47
* @Version 1.0
* 正则验证是否为视频文件工具类
*/
public class VideoUtil {
public static boolean isVideo(String suffix){
String reg = "(mp4|flv|avi|rm|rmvb|wmv|qlv)";
Pattern p = Pattern.compile(reg);
return p.matcher(suffix).find();
}
}

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>huoran</artifactId>
<groupId>com.huoran.parent</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>competition</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- <dependency>-->
<!-- <groupId>com.lxgnb</groupId>-->
<!-- <artifactId>xxl-job-boot-starter</artifactId>-->
<!-- <version>2.3.0-jobinfo-executor-2</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.huoran.common</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.huoran.api</groupId>
<artifactId>api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<exclusions>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
<exclusion>
<artifactId>poi-ooxml-schemas</artifactId>
<groupId>org.apache.poi</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
</dependency>
</dependencies>
<build>
<finalName>competition-1.0.0</finalName>
<resources>
<resource>
<!-- 描述存放资源的目录,该路径相对POM路径-->
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--添加配置跳过测试-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<!--<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.7.0.1746</version>
</plugin>-->
</plugins>
</build>
</project>

@ -0,0 +1,22 @@
package com.huoran.competition;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableDiscoveryClient
@EnableScheduling//定时任务
@EnableFeignClients(basePackages = "com.huoran.api")
@MapperScan(basePackages = "com.huoran.competition.mapper")
@ComponentScan(basePackages = {"com.huoran"})
public class CompetitionApplication {
public static void main(String[] args) {
SpringApplication.run(CompetitionApplication.class, args);
}
}

@ -0,0 +1,29 @@
package com.huoran.competition.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.ThreadPoolExecutor;
@Configuration
@EnableAsync
public class AsyncTaskPoolConfig implements AsyncConfigurer {
@Bean(name = "competitionExecutor")
public ThreadPoolTaskExecutor taskExecutor(){
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(300);
taskExecutor.setMaxPoolSize(500);
taskExecutor.setQueueCapacity(800);
taskExecutor.setKeepAliveSeconds(60);
taskExecutor.setThreadNamePrefix("competition-async-");
taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
taskExecutor.setAwaitTerminationSeconds(60);
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
taskExecutor.initialize();
return taskExecutor;
}
}

@ -0,0 +1,54 @@
package com.huoran.competition.config;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;
//@Configuration
public class DruidConfig {
/*
将自定义的 Druid数据源添加到容器中不再让 Spring Boot 自动创建
绑定全局配置文件中的 druid 数据源属性到 com.alibaba.druid.pool.DruidDataSource从而让它们生效
@ConfigurationProperties(prefix = "spring.datasource")作用就是将 全局配置文件中
前缀为 spring.datasource的属性值注入到 com.alibaba.druid.pool.DruidDataSource 的同名参数中
*/
@ConfigurationProperties(prefix = "spring.datasource")
@Bean
public DataSource druidDataSource() {
return new DruidDataSource();
}
//配置 Druid 监控管理后台的Servlet;
//内置 Servlet 容器时没有web.xml文件,所以使用 Spring Boot 的注册 Servlet 方式
@Bean
public ServletRegistrationBean statViewServlet() {
ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
// 这些参数可以在 com.alibaba.druid.support.http.StatViewServlet
// 的父类 com.alibaba.druid.support.http.ResourceServlet 中找到
Map<String, String> initParams = new HashMap<>();
initParams.put("loginUsername", "admin"); //后台管理界面的登录账号
initParams.put("loginPassword", "123456"); //后台管理界面的登录密码
//后台允许谁可以访问
//initParams.put("allow", "localhost"):表示只有本机可以访问
//initParams.put("allow", ""):为空或者为null时,表示允许所有访问
initParams.put("allow", "");
//deny:Druid 后台拒绝谁访问
//initParams.put("kuangshen", "192.168.1.20");表示禁止此ip访问
//设置初始化参数
bean.setInitParameters(initParams);
return bean;
}
}

@ -0,0 +1,69 @@
package com.huoran.competition.config;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger.web.DocExpansion;
import springfox.documentation.swagger.web.OperationsSorter;
import springfox.documentation.swagger.web.UiConfiguration;
import springfox.documentation.swagger.web.UiConfigurationBuilder;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.List;
/**
* @author Mr.JK
*/
@Configuration
@EnableSwagger2
@Profile({"dev","test"})
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
// 构造token给测试的时候填写
ParameterBuilder tokenPar = new ParameterBuilder();
List<Parameter> pars = new ArrayList<Parameter>();
tokenPar.name("token").description("用户令牌(不需用户鉴权的不需要传)").modelRef(new ModelRef("string")).parameterType("header")
.required(false).build();
pars.add(tokenPar.build());
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.huoran.competition.controller"))
.apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(PathSelectors.any())
.build().globalOperationParameters(pars);
}
@Bean
UiConfiguration uiConfig() {
return UiConfigurationBuilder.builder().docExpansion(DocExpansion.LIST).operationsSorter(OperationsSorter.ALPHA).build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("赛事微服务接口文档")
.description("cheney")
.contact("developer@mail.com")
.version("1.0")
.build();
}
}

@ -0,0 +1,51 @@
package com.huoran.competition.controller;
import com.huoran.common.aop.annotation.NoRepeatSubmit;
import com.huoran.common.response.R;
import com.huoran.competition.entity.CompetitionAnnex;
import com.huoran.competition.service.CompetitionAnnexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* <p>
* 赛事附件表 前端控制器
* </p>
*
* @author cheney
* @since 2022-11-16
*/
@Api(tags = "赛事附件管理")
@RestController
@RequestMapping("/competition/annex")
public class CompetitionAnnexController {
@Autowired
private CompetitionAnnexService competitionAnnexService;
@NoRepeatSubmit
@PostMapping("/update")
@ApiOperation(value = "编辑赛事附件",response = CompetitionAnnex.class)
public R update(@RequestBody CompetitionAnnex competitionAnnex) {
boolean update = competitionAnnexService.updateById(competitionAnnex);
return update ? R.ok() : R.error();
}
@NoRepeatSubmit
@PostMapping("/save")
@ApiOperation(value = "新增赛事附件",response = CompetitionAnnex.class)
public R save(@RequestBody CompetitionAnnex competitionAnnex) {
boolean save = competitionAnnexService.save(competitionAnnex);
return save ? R.ok() : R.error();
}
@NoRepeatSubmit
@PostMapping("/delete")
@ApiOperation(value = "删除赛事附件",response = CompetitionAnnex.class)
public R delete(@RequestParam("id") @ApiParam(name = "id", value = "附件id", required = true) Integer id) {
boolean del = competitionAnnexService.removeById(id);
return del ? R.ok() : R.error();
}
}

@ -0,0 +1,67 @@
package com.huoran.competition.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.huoran.common.aop.annotation.NoRepeatSubmit;
import com.huoran.common.constant.DelConstant;
import com.huoran.common.response.R;
import com.huoran.competition.entity.CompetitionAnnouncementAnnex;
import com.huoran.competition.service.CompetitionAnnouncementAnnexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>
* 赛事公告附件表 前端控制器
* </p>
*
* @author cheney
* @since 2022-11-16
*/
@Api(tags = "赛事公告附件管理")
@RestController
@RequestMapping("/competition/announcementAnnex")
public class CompetitionAnnouncementAnnexController {
@Autowired
public CompetitionAnnouncementAnnexService service;
@PostMapping("/viewAttachments")
@ApiOperation(value = "查看公告下的附件",response = CompetitionAnnouncementAnnex.class)
public R findById(@RequestParam("announcementId") @ApiParam(value = "announcementId") Integer announcementId) {
QueryWrapper<CompetitionAnnouncementAnnex> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("announcement_id",announcementId);
queryWrapper.eq("is_del", DelConstant.NOT_DEL);
List<CompetitionAnnouncementAnnex> annexList = service.list(queryWrapper);
return R.ok().put("list",annexList);
}
@NoRepeatSubmit
@PostMapping("/save")
@ApiOperation(value = "新增",response = CompetitionAnnouncementAnnex.class)
public R save(@RequestBody CompetitionAnnouncementAnnex competitionAnnouncementAnnex) {
boolean save = service.save(competitionAnnouncementAnnex);
return save ? R.ok() : R.error();
}
@NoRepeatSubmit
@PostMapping("/update")
@ApiOperation(value = "修改",response = CompetitionAnnouncementAnnex.class)
public R update(@RequestBody CompetitionAnnouncementAnnex competitionAnnouncementAnnex) {
boolean update = service.updateById(competitionAnnouncementAnnex);
return update ? R.ok() : R.error();
}
@NoRepeatSubmit
@PostMapping("/delete")
@ApiOperation(value = "根据主键删除",response = CompetitionAnnouncementAnnex.class)
public R delete(@RequestParam("id") @ApiParam(value = "id")Integer id) {
boolean delete = service.removeById(id);
return delete ? R.ok() : R.error();
}
}

@ -0,0 +1,114 @@
package com.huoran.competition.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.huoran.common.aop.annotation.NoRepeatSubmit;
import com.huoran.common.constant.DelConstant;
import com.huoran.common.response.R;
import com.huoran.common.utils.TokenUtils;
import com.huoran.competition.entity.CompetitionAnnouncement;
import com.huoran.competition.entity.CompetitionAnnouncementAnnex;
import com.huoran.competition.service.CompetitionAnnouncementAnnexService;
import com.huoran.competition.service.CompetitionAnnouncementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* <p>
* 赛事公告表 前端控制器
* </p>
*
* @author cheney
* @since 2022-11-16
*/
@Api(tags = "赛事公告管理")
@RestController
@RequestMapping("/competition/announcement")
public class CompetitionAnnouncementController {
@Autowired
public CompetitionAnnouncementService service;//公告
@Autowired
public CompetitionAnnouncementAnnexService annexService;//大赛公告附件
@PostMapping("/queryAnnouncementDetails")
@ApiOperation(value = "查询公告详情",response = CompetitionAnnouncement.class)
public R findById(
@RequestParam("id") @ApiParam(value = "公告主键") Integer id) {
CompetitionAnnouncement competitionAnnouncement = service.getById(id);
QueryWrapper<CompetitionAnnouncementAnnex> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("announcement_id",id);
queryWrapper.eq("is_del", DelConstant.NOT_DEL);
List<CompetitionAnnouncementAnnex> annexList = annexService.list(queryWrapper);
if (annexList.size()>0){
competitionAnnouncement.setAnnouncementAnnexList(annexList);
}
return R.ok().put("data", competitionAnnouncement);
}
@NoRepeatSubmit
@PostMapping("/addAnnouncement")
@ApiOperation(value = "新增公告",response = CompetitionAnnouncement.class)
public R save(@RequestBody CompetitionAnnouncement competitionAnnouncement, HttpServletRequest request) {
String accountId = TokenUtils.getIdByJwtToken(request);
competitionAnnouncement.setAccountId(Integer.valueOf(accountId));
boolean save = service.save(competitionAnnouncement);
if (competitionAnnouncement.getAnnouncementAnnexList().size() > 0) {
competitionAnnouncement.getAnnouncementAnnexList().forEach(competitionAnnex -> {
competitionAnnex.setAnnouncementId(competitionAnnouncement.getId());
boolean saveCompetitionAnnex = annexService.save(competitionAnnex);//保存比赛附件
});
}
return save ? R.ok() : R.error();
}
@NoRepeatSubmit
@PostMapping("/amendmentAnnouncement")
@ApiOperation(value = "修改公告",response = CompetitionAnnouncement.class)
public R update(@RequestBody CompetitionAnnouncement competitionAnnouncement) {
boolean update = service.updateById(competitionAnnouncement);
return update ? R.ok() : R.error();
}
@NoRepeatSubmit
@ApiOperation(value = "是否禁用公告")
@PutMapping("/disableAnnouncement")
public R disableAnnouncement(@ApiParam(name = "id", value = "公告主键", required = true) @RequestParam Integer id,
@ApiParam(name = "isDisable", value = "是否开启(0开启 1未开启 默认0)", required = true)@RequestParam Integer isDisable) {
if (isDisable==1 || isDisable==0) {
CompetitionAnnouncement CompetitionAnnouncement = new CompetitionAnnouncement();
CompetitionAnnouncement.setId(id);
CompetitionAnnouncement.setIsOpen(isDisable);
boolean update = service.updateById(CompetitionAnnouncement);
return update ? R.ok() : R.error();
} else {
return R.error("启用状态错误");
}
}
@NoRepeatSubmit
@PostMapping("/deleteAnnouncement")
@ApiOperation(value = "删除公告",response = CompetitionAnnouncement.class)
public R delete(@RequestParam("id") @ApiParam(value = "公告主键") Integer id) {
boolean del = service.removeById(id);
return del ? R.ok() : R.error();
}
@PostMapping("/queryAnnouncementByCompetitionId")
@ApiOperation(value = "根据赛事id查询公告列表(分页)",response = CompetitionAnnouncement.class)
public R queryAnnouncementByCompetitionId(
@RequestParam("competitionId") @ApiParam(value = "赛事id") String competitionId,
@ApiParam(value = "当前页数", required = true) @RequestParam("pageNum") Integer pageNum,
@ApiParam(value = "当前页需要显示的数量", required = true) @RequestParam("pageSize") Integer pageSize) {
return service.queryAnnouncementByCompetitionId(competitionId, pageNum, pageSize);
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save