exam-system/pom.xml
@@ -25,6 +25,13 @@ <artifactId>ruoyi-file</artifactId> </dependency> <!-- 七牛云短信--> <dependency> <groupId>com.qiniu</groupId> <artifactId>qiniu-java-sdk</artifactId> <version>[7.2.0, 7.2.99]</version> </dependency> </dependencies> </project> exam-system/src/main/java/com/gkhy/exam/institutionalaccess/controller/ThBatchManagerController.java
@@ -31,4 +31,10 @@ public AjaxResult getStudent(@PathVariable String batchUuid) { return AjaxResult.success(thBatchManagerService.getStudent(batchUuid)); } //发送短信提醒 @GetMapping("/sendMessage/{idcard}") public AjaxResult sendMes(@PathVariable String idcard){ return thBatchManagerService.sendMes(idcard); } } exam-system/src/main/java/com/gkhy/exam/institutionalaccess/controller/ThCourseManagerController.java
@@ -1,5 +1,6 @@ package com.gkhy.exam.institutionalaccess.controller; import com.gkhy.exam.institutionalaccess.entity.ThCourseDTO; import com.gkhy.exam.institutionalaccess.model.query.ThCourseQuery; import com.gkhy.exam.institutionalaccess.service.ThCourseManagerService; import com.ruoyi.common.core.controller.BaseController; @@ -34,4 +35,13 @@ public AjaxResult getStudent(@PathVariable String courseUuid) { return AjaxResult.success(courseManagerService.getSutdent(courseUuid)); } /** * 课程审核 */ @PostMapping("/checkCourse") public AjaxResult checkCourse(@RequestBody ThCourseDTO thCourseDTO){ return toAjax(courseManagerService.updateByCourse(thCourseDTO)); } } exam-system/src/main/java/com/gkhy/exam/institutionalaccess/entity/ThCourse.java
@@ -27,6 +27,9 @@ //删除标志(0代表存在 2代表删除) private Byte delFlag; //审核字段(0待审核,1审核通过,2审核驳回) private Byte status; /** 创建者 */ private String createBy; exam-system/src/main/java/com/gkhy/exam/institutionalaccess/entity/ThCourseDTO.java
对比新文件 @@ -0,0 +1,9 @@ package com.gkhy.exam.institutionalaccess.entity; import lombok.Data; @Data public class ThCourseDTO { private Long id; private Byte status; } exam-system/src/main/java/com/gkhy/exam/institutionalaccess/enums/CourseStatus.java
对比新文件 @@ -0,0 +1,33 @@ package com.gkhy.exam.institutionalaccess.enums; public enum CourseStatus { REVIEWED((byte)1,"待审核"), PASS((byte)2,"审核通过"), REJECT((byte)3,"审核驳回"); private Byte status; private String desc; CourseStatus(Byte status, String desc) { this.status = status; this.desc = desc; } public Byte getStatus() { return status; } public void setStatus(Byte status) { this.status = status; } public String getDesc() { return desc; } public void setDesc(String desc) { this.desc = desc; } } exam-system/src/main/java/com/gkhy/exam/institutionalaccess/model/resp/ThCourseRespDTO.java
@@ -1,5 +1,6 @@ package com.gkhy.exam.institutionalaccess.model.resp; import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.models.auth.In; import lombok.Data; @@ -21,6 +22,9 @@ //删除标志(0代表存在 2代表删除) private Byte delFlag; //审核字段 private Byte status; private String createBy; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime createTime; exam-system/src/main/java/com/gkhy/exam/institutionalaccess/service/ThBatchManagerService.java
@@ -7,6 +7,7 @@ import com.gkhy.exam.institutionalaccess.model.resp.ThStudentStudyRespDTO; import com.gkhy.exam.institutionalaccess.model.vo.ThBatchCourseVO; import com.gkhy.exam.institutionalaccess.model.vo.ThBatchVO; import com.ruoyi.common.core.domain.AjaxResult; import java.util.List; @@ -17,4 +18,5 @@ List<ThStudentStudyRespDTO> getStudent(String batchUuid); AjaxResult sendMes(String idcard); } exam-system/src/main/java/com/gkhy/exam/institutionalaccess/service/ThCourseManagerService.java
@@ -1,7 +1,6 @@ package com.gkhy.exam.institutionalaccess.service; import com.gkhy.exam.institutionalaccess.entity.ThStudent; import com.gkhy.exam.institutionalaccess.entity.ThStudentBatch; import com.gkhy.exam.institutionalaccess.entity.ThCourseDTO; import com.gkhy.exam.institutionalaccess.model.query.ThCourseQuery; import com.gkhy.exam.institutionalaccess.model.resp.ThCourseRespDTO; import com.gkhy.exam.institutionalaccess.model.resp.ThStudentStudyRespDTO; @@ -15,5 +14,7 @@ List<ThStudentStudyRespDTO> getSutdent(String courseUuid); Boolean updateByCourse(ThCourseDTO thCourseDTO); //List<ThStudentBatchR> getStudent(String ); } exam-system/src/main/java/com/gkhy/exam/institutionalaccess/service/ThStudentManagerService.java
@@ -7,4 +7,6 @@ public interface ThStudentManagerService { List<ThStudent> listByPage(ThStudentQuery query); ThStudent findByIdCard(String idcard); } exam-system/src/main/java/com/gkhy/exam/institutionalaccess/service/serviceImpl/ThBatchManagerServiceImpl.java
@@ -10,6 +10,8 @@ import com.gkhy.exam.institutionalaccess.model.vo.*; import com.gkhy.exam.institutionalaccess.service.*; import com.gkhy.exam.institutionalaccess.utils.ConvertTimeUtils; import com.gkhy.exam.institutionalaccess.utils.SendMessageUtil; import com.ruoyi.common.core.domain.AjaxResult; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -18,6 +20,7 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.stream.Collectors; @@ -35,6 +38,11 @@ private ThBatchCourseChapterService thBatchCourseChapterService; @Autowired private ThSubjectTypeService subjectTypeService; @Autowired private ThStudentManagerService thStudentManagerService; @Autowired private SendMessageUtil sendMessageUtil; @Override public List<ThBatchVO> listByPage(ThBatchQuery query) { @@ -180,6 +188,22 @@ return respDTOS; } //短信提醒 @Override public AjaxResult sendMes(String idcard) { ThStudent thStudent = thStudentManagerService.findByIdCard(idcard); if (StringUtils.isEmpty(thStudent.getPhone()) || thStudent.getPhone().equals("-")){ return AjaxResult.error("该学员未绑定手机号"); } //调用短信接口 String[] phone={thStudent.getPhone()}; HashMap<String, String> map = new HashMap<>(); map.put("name",thStudent.getName()); map.put("platform",thStudent.getInstitutionName()); sendMessageUtil.sendMessageCheck(phone,map); return AjaxResult.success(); } public String getObtainSuperiors(String code){ List<ThSubjectType> subjectTypeList = subjectTypeService.getSubjectTypeList(); if(StringUtils.isEmpty(code)){ exam-system/src/main/java/com/gkhy/exam/institutionalaccess/service/serviceImpl/ThCourseManagerServiceImpl.java
@@ -1,9 +1,7 @@ package com.gkhy.exam.institutionalaccess.service.serviceImpl; import com.gkhy.exam.institutionalaccess.entity.ThBatchCourse; import com.gkhy.exam.institutionalaccess.entity.ThCourse; import com.gkhy.exam.institutionalaccess.entity.ThCourseChapter; import com.gkhy.exam.institutionalaccess.entity.ThStudentBatch; import com.gkhy.exam.institutionalaccess.entity.*; import com.gkhy.exam.institutionalaccess.enums.CourseStatus; import com.gkhy.exam.institutionalaccess.enums.FinishStatus; import com.gkhy.exam.institutionalaccess.model.query.ThCourseQuery; import com.gkhy.exam.institutionalaccess.model.resp.ThCourseChapterRespDTO; @@ -22,7 +20,6 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -147,6 +144,22 @@ return respDTOS; } //课程审核 @Override public Boolean updateByCourse(ThCourseDTO thCourseDTO) { if (StringUtils.isEmpty(thCourseDTO.getStatus()) || StringUtils.isEmpty(thCourseDTO.getId())){ return false; } ThCourse byUuid = courseService.getById(thCourseDTO.getId()); if (!byUuid.getStatus().equals(CourseStatus.REVIEWED.getStatus())){ return false; } ThCourse thCourse = new ThCourse(); thCourse.setId(thCourseDTO.getId()); thCourse.setStatus(thCourseDTO.getStatus()); return courseService.updateById(thCourse); } //获取章节 private List<ThCourseChapterRespDTO> getChildren(List<ThCourseChapterVO> courseChapterVOS, String parentUuid) { List<ThCourseChapterRespDTO> chapterList = courseChapterVOS exam-system/src/main/java/com/gkhy/exam/institutionalaccess/service/serviceImpl/ThStudentManagerServiceImpl.java
@@ -24,4 +24,9 @@ .like(!StringUtils.isEmpty(query.getName()),ThStudent::getName, query.getName()) .eq(ThStudent::getDelFlag, DeleteStatusEnum.NO.getStatus()).orderByDesc(ThStudent::getUpdateTime)); } @Override public ThStudent findByIdCard(String idcard) { return thStudentService.getByIdcard(idcard); } } exam-system/src/main/java/com/gkhy/exam/institutionalaccess/service/serviceImpl/ThStudyRecordManagerServiceImpl.java
@@ -19,6 +19,7 @@ import com.ruoyi.common.signature.AESUtils; import com.ruoyi.system.domain.ThAccessAddress; import com.ruoyi.system.service.ThAccessAddressService; import lombok.extern.log4j.Log4j2; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -31,6 +32,7 @@ import java.util.stream.Collectors; @Service("ThStudyRecordManagerService") @Log4j2 public class ThStudyRecordManagerServiceImpl implements ThStudyRecordManagerService { private Logger logger = LoggerFactory.getLogger(ThStudyRecordManagerServiceImpl.class); @@ -131,9 +133,11 @@ Map<String,String> params = new HashMap<>(); params.put("idcard",query.getIdcard()); String json = HttpClientUtil.doGet(accessAddress.getUrl(), params); log.info("调用机构接口返回结果: "+json); ReturnVO<String> returnVo = JSONObject.parseObject(json, new TypeReference<ReturnVO<String>>() {}); if(returnVo.getCode() == null || returnVo.getCode() != 200){ log.info("获得第三方数据:"+returnVo); if(returnVo==null || returnVo.getCode() == null || returnVo.getCode() != 200){ throw new ServiceException("获取三方数据数据异常"); } ThPlatformStudentRespDTO thPlatformStudentRespDTO = null; @@ -141,6 +145,7 @@ String decrypt = ""; try { decrypt = AESUtils.decrypt(returnVo.getData()); log.info("解密后的数据为:"+decrypt); }catch (Exception e){ throw new BusinessException(this.getClass(), ResultConstants.SYSTEM_ERROR,"解密异常"); } exam-system/src/main/java/com/gkhy/exam/institutionalaccess/utils/SendMessageUtil.java
对比新文件 @@ -0,0 +1,48 @@ package com.gkhy.exam.institutionalaccess.utils; import com.qiniu.common.QiniuException; import com.qiniu.http.Response; import com.qiniu.sms.SmsManager; import com.qiniu.util.Auth; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; import java.util.Map; @Component public class SendMessageUtil { private static final Logger log = LoggerFactory.getLogger(SendMessageUtil.class); @Value("${safecheckqiniuymes.accesskey}") private String accesskey; @Value("${safecheckqiniuymes.secretkey}") private String secretkey; @Value("${safecheckqiniuymes.templateid}") private String templateid; /** * 发送短信提示 */ @Async("SocketTaskExecutor") public Boolean sendMessageCheck(String[] phone, Map<String, String> map){ Auth auth = Auth.create(accesskey, secretkey); SmsManager smsManager = new SmsManager(auth); try { Response resp = smsManager.sendMessage(templateid, phone , map); if(resp.statusCode == 200){ return true; }else { return false; } } catch (QiniuException e) { log.info("发生短信异常 =======================" ,e); } return false; } } ruoyi-admin/src/main/resources/application-pro.yml
@@ -122,4 +122,10 @@ queueCapacity: 10000 scheduling: #控制线程是否执行 true:执行;false:不执行 enabled: true enabled: true # 七牛云相关信息 safecheckqiniuymes: accesskey: 5YprpjY0BJiyjII2VqlHed7UhBEvvkPZicbwd8Kl secretkey: m3gGQNQ9cLmVBBZwPXZ5-Wzr0duzyAPPmJUx4_ay templateid: 1844221365930962944