|
@@ -1,32 +1,30 @@
|
|
package com.qmth.themis.business.service.impl;
|
|
package com.qmth.themis.business.service.impl;
|
|
|
|
|
|
-import java.io.File;
|
|
|
|
-import java.io.IOException;
|
|
|
|
-import java.io.InputStream;
|
|
|
|
-import java.util.Map;
|
|
|
|
-
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
-
|
|
|
|
-import com.google.gson.Gson;
|
|
|
|
-import com.qmth.themis.business.dto.cache.TEStudentCacheDto;
|
|
|
|
-import com.qmth.themis.business.util.RedisUtil;
|
|
|
|
-import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
-
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.google.gson.Gson;
|
|
import com.qmth.themis.business.bean.backend.StudentPhotoUploadResponseBean;
|
|
import com.qmth.themis.business.bean.backend.StudentPhotoUploadResponseBean;
|
|
import com.qmth.themis.business.config.SystemConfig;
|
|
import com.qmth.themis.business.config.SystemConfig;
|
|
import com.qmth.themis.business.dao.TEStudentMapper;
|
|
import com.qmth.themis.business.dao.TEStudentMapper;
|
|
|
|
+import com.qmth.themis.business.dto.cache.TEStudentCacheDto;
|
|
import com.qmth.themis.business.dto.response.TEStudentDto;
|
|
import com.qmth.themis.business.dto.response.TEStudentDto;
|
|
import com.qmth.themis.business.dto.response.TEStudentExamRecordDto;
|
|
import com.qmth.themis.business.dto.response.TEStudentExamRecordDto;
|
|
import com.qmth.themis.business.entity.TEStudent;
|
|
import com.qmth.themis.business.entity.TEStudent;
|
|
import com.qmth.themis.business.service.TEStudentService;
|
|
import com.qmth.themis.business.service.TEStudentService;
|
|
import com.qmth.themis.business.util.OssUtil;
|
|
import com.qmth.themis.business.util.OssUtil;
|
|
|
|
+import com.qmth.themis.business.util.RedisUtil;
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.InputStream;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: 学生档案 服务实现类
|
|
* @Description: 学生档案 服务实现类
|
|
@@ -40,7 +38,7 @@ public class TEStudentServiceImpl extends ServiceImpl<TEStudentMapper, TEStudent
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
TEStudentMapper teStudentMapper;
|
|
TEStudentMapper teStudentMapper;
|
|
-
|
|
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
SystemConfig systemConfig;
|
|
SystemConfig systemConfig;
|
|
|
|
|
|
@@ -54,11 +52,12 @@ public class TEStudentServiceImpl extends ServiceImpl<TEStudentMapper, TEStudent
|
|
* @param identity
|
|
* @param identity
|
|
* @param name
|
|
* @param name
|
|
* @param enable
|
|
* @param enable
|
|
|
|
+ * @param orgId
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public IPage<TEStudentDto> studentQuery(IPage<Map> iPage, String identity, String name, Integer enable) {
|
|
|
|
- return teStudentMapper.studentQuery(iPage, identity, name, enable);
|
|
|
|
|
|
+ public IPage<TEStudentDto> studentQuery(IPage<Map> iPage, String identity, String name, Integer enable, Long orgId) {
|
|
|
|
+ return teStudentMapper.studentQuery(iPage, identity, name, enable, orgId);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -73,40 +72,40 @@ public class TEStudentServiceImpl extends ServiceImpl<TEStudentMapper, TEStudent
|
|
public IPage<TEStudentExamRecordDto> studentExamRecordQuery(IPage<Map> iPage, Long studentId, Long examId) {
|
|
public IPage<TEStudentExamRecordDto> studentExamRecordQuery(IPage<Map> iPage, Long studentId, Long examId) {
|
|
return teStudentMapper.studentExamRecordQuery(iPage, studentId, examId);
|
|
return teStudentMapper.studentExamRecordQuery(iPage, studentId, examId);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
public StudentPhotoUploadResponseBean photoUpload(Long orgId, String identity, MultipartFile file, String md5) {
|
|
public StudentPhotoUploadResponseBean photoUpload(Long orgId, String identity, MultipartFile file, String md5) {
|
|
- QueryWrapper<TEStudent> wrapper = new QueryWrapper<>();
|
|
|
|
- wrapper.lambda().eq(TEStudent::getOrgId, orgId);
|
|
|
|
- wrapper.lambda().eq(TEStudent::getIdentity, identity);
|
|
|
|
- TEStudent student=this.getOne(wrapper);
|
|
|
|
- if(student==null) {
|
|
|
|
- throw new BusinessException("学生不存在");
|
|
|
|
- }
|
|
|
|
- String fileName = file.getOriginalFilename();
|
|
|
|
- String suffix = fileName.substring(fileName.lastIndexOf(".")+1).toLowerCase();
|
|
|
|
- String filePath = "base_photo/"+orgId+"/"+student.getId()+"."+suffix;
|
|
|
|
|
|
+ QueryWrapper<TEStudent> wrapper = new QueryWrapper<>();
|
|
|
|
+ wrapper.lambda().eq(TEStudent::getOrgId, orgId);
|
|
|
|
+ wrapper.lambda().eq(TEStudent::getIdentity, identity);
|
|
|
|
+ TEStudent student = this.getOne(wrapper);
|
|
|
|
+ if (student == null) {
|
|
|
|
+ throw new BusinessException("学生不存在");
|
|
|
|
+ }
|
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
|
+ String suffix = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
|
|
|
+ String filePath = "base_photo/" + orgId + "/" + student.getId() + "." + suffix;
|
|
InputStream in = null;
|
|
InputStream in = null;
|
|
try {
|
|
try {
|
|
- String fileMd5 = DigestUtils.md5Hex(file.getBytes());
|
|
|
|
- if (!md5.equals(fileMd5)) {
|
|
|
|
- throw new BusinessException("文件md5不一致");
|
|
|
|
- }
|
|
|
|
- student.setBasePhotoPath(filePath);
|
|
|
|
- this.saveOrUpdate(student);
|
|
|
|
|
|
+ String fileMd5 = DigestUtils.md5Hex(file.getBytes());
|
|
|
|
+ if (!md5.equals(fileMd5)) {
|
|
|
|
+ throw new BusinessException("文件md5不一致");
|
|
|
|
+ }
|
|
|
|
+ student.setBasePhotoPath(filePath);
|
|
|
|
+ this.saveOrUpdate(student);
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
TEStudentCacheDto teStudentCacheDto = gson.fromJson(gson.toJson(student), TEStudentCacheDto.class);
|
|
TEStudentCacheDto teStudentCacheDto = gson.fromJson(gson.toJson(student), TEStudentCacheDto.class);
|
|
redisUtil.setStudent(student.getId(), teStudentCacheDto);
|
|
redisUtil.setStudent(student.getId(), teStudentCacheDto);
|
|
in = file.getInputStream();
|
|
in = file.getInputStream();
|
|
OssUtil.ossUploadStream(systemConfig.getOssEnv(3), filePath, in);
|
|
OssUtil.ossUploadStream(systemConfig.getOssEnv(3), filePath, in);
|
|
String url = systemConfig.getProperty("aliyun.oss.url") + File.separator + filePath;
|
|
String url = systemConfig.getProperty("aliyun.oss.url") + File.separator + filePath;
|
|
- StudentPhotoUploadResponseBean ret=new StudentPhotoUploadResponseBean();
|
|
|
|
|
|
+ StudentPhotoUploadResponseBean ret = new StudentPhotoUploadResponseBean();
|
|
ret.setPhotoUrl(url);
|
|
ret.setPhotoUrl(url);
|
|
return ret;
|
|
return ret;
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
- throw new BusinessException("文件读取出错");
|
|
|
|
|
|
+ throw new BusinessException("文件读取出错");
|
|
} finally {
|
|
} finally {
|
|
if (in != null) {
|
|
if (in != null) {
|
|
try {
|
|
try {
|