|
@@ -30,6 +30,7 @@ import org.springframework.beans.BeanUtils;
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
@@ -93,6 +94,76 @@ public class EasStuProfileServiceImpl implements EasStuProfileService {
|
|
return archivesDto;
|
|
return archivesDto;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public ArchivesDto upload(MultipartFile file, String studentNumber, String fileType) {
|
|
|
|
+ InputStream inputStream = null;
|
|
|
|
+ ArchivesDto archivesDto = null;
|
|
|
|
+ try {
|
|
|
|
+ inputStream = file.getInputStream();
|
|
|
|
+ String type = file.getOriginalFilename().substring(
|
|
|
|
+ file.getOriginalFilename().lastIndexOf(".") + 1).toUpperCase();
|
|
|
|
+ if ( FileType.valueOf(type) != null ) {
|
|
|
|
+ archivesDto = easArchivesFilesService.saveArchiveFile(studentNumber, inputStream, type);
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException ignore) {
|
|
|
|
+ } finally {
|
|
|
|
+ if (inputStream != null) {
|
|
|
|
+ try {
|
|
|
|
+ inputStream.close();
|
|
|
|
+ } catch (IOException ignore) {}
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return archivesDto;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 判断是否是图片后缀的文件
|
|
|
|
+ * @param path
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ private boolean isImage(String path) {
|
|
|
|
+ String filePath = path.toUpperCase();
|
|
|
|
+ return filePath.endsWith(".JPG") || filePath.endsWith(".JPEG")
|
|
|
|
+ || filePath.endsWith(".PNG") || filePath.endsWith(".GIF") ||
|
|
|
|
+ filePath.endsWith(".BMP") || filePath.endsWith(".TIF")
|
|
|
|
+ || filePath.endsWith(".TIFF") || filePath.endsWith(".ICO");
|
|
|
|
+ }
|
|
|
|
+ @Override
|
|
|
|
+ public boolean addArchives(EasArcArchives arc) {
|
|
|
|
+ String arctype = "";
|
|
|
|
+ if ( isImage(arc.getFilePath()) ) {
|
|
|
|
+ arctype = "IMAGE";
|
|
|
|
+ } else {
|
|
|
|
+ arctype = arc.getFilePath().substring(arc.getFilePath().lastIndexOf(".") + 1).toUpperCase();
|
|
|
|
+ }
|
|
|
|
+ String archiveNumber = arc.getFilePath().substring(
|
|
|
|
+ arc.getFilePath().lastIndexOf("\\") + 1,
|
|
|
|
+ arc.getFilePath().lastIndexOf("."));
|
|
|
|
+ arc.setArctype(arctype);
|
|
|
|
+ arc.setCreateTime(new Date());
|
|
|
|
+ arc.setModifyTime(new Date());
|
|
|
|
+ arc.setArchiveNumber( archiveNumber );
|
|
|
|
+ arc.setManagerId( SecurityManager.getLoginUid().intValue() );
|
|
|
|
+ arc.setCreateUid( SecurityManager.getLoginUid().intValue() );
|
|
|
|
+ arc.setCreateDate(new Date());
|
|
|
|
+ return easArcArchivesMapper.insert(arc) == 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean delArchives(Integer id) {
|
|
|
|
+ EasArcArchives easArcArchives = easArcArchivesMapper.selectByPrimaryKey(id);
|
|
|
|
+ if (
|
|
|
|
+ easArcArchives.getFiletype().equals("prefile") ||
|
|
|
|
+ easArcArchives.getFiletype().equals("attendance") ||
|
|
|
|
+ easArcArchives.getFiletype().equals("scores")
|
|
|
|
+ ) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ easArchivesFilesService.deleteArchiveFile(easArcArchives.getFilePath());
|
|
|
|
+ return easArcArchivesMapper.deleteByPrimaryKey(id) == 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public boolean add(EasArcTlsStudents easArcTlsStudents) {
|
|
public boolean add(EasArcTlsStudents easArcTlsStudents) {
|
|
|
|
|