commit
88dc929256
33 changed files with 473 additions and 281 deletions
@ -1,41 +1,15 @@ |
||||
package com.msdw.tms.common.utils; |
||||
|
||||
public class FilesResult { |
||||
import lombok.Data; |
||||
import lombok.ToString; |
||||
|
||||
@Data |
||||
@ToString |
||||
public class FilesResult { |
||||
// 文件名
|
||||
private String fileName; |
||||
// 文件在储存空间的路径
|
||||
private String fileUrl; |
||||
// 上传状态
|
||||
private String status; |
||||
|
||||
public String getFileName() { |
||||
return fileName; |
||||
} |
||||
|
||||
public void setFileName(String fileName) { |
||||
this.fileName = fileName; |
||||
} |
||||
|
||||
public String getFileUrl() { |
||||
return fileUrl; |
||||
} |
||||
|
||||
public void setFileUrl(String fileUrl) { |
||||
this.fileUrl = fileUrl; |
||||
} |
||||
|
||||
public String getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public void setStatus(String status) { |
||||
this.status = status; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "UploadFilesResult [fileName=" + fileName + ", fileUrl=" + fileUrl + ", status=" + status + "]"; |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,18 @@ |
||||
package com.msdw.tms.config; |
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
@Configuration |
||||
public class MybatisPlusConfig { |
||||
/** |
||||
* mybatis-plus分页插件 |
||||
*/ |
||||
@Bean |
||||
public PaginationInterceptor paginationInterceptor() { |
||||
PaginationInterceptor page = new PaginationInterceptor(); |
||||
page.setDialectType("mysql"); |
||||
return page; |
||||
} |
||||
} |
Binary file not shown.
@ -0,0 +1,62 @@ |
||||
package com.msdw.tms.service; |
||||
|
||||
import com.msdw.tms.common.utils.FilesResult; |
||||
import org.apache.commons.fileupload.FileItem; |
||||
import org.apache.commons.fileupload.disk.DiskFileItem; |
||||
import org.apache.commons.io.IOUtils; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.mock.web.MockHttpServletResponse; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
import org.springframework.web.multipart.commons.CommonsMultipartFile; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.IOException; |
||||
import java.nio.file.Files; |
||||
|
||||
@SpringBootTest |
||||
class AliyunOssServiceTest { |
||||
|
||||
@Autowired |
||||
AliyunOssService aliyunOssService; |
||||
|
||||
/** |
||||
* 测试上传文件 |
||||
*/ |
||||
@Test |
||||
void testUploadFiles() throws IOException { |
||||
File file = new File("D:\\pic\\1.jpg"); |
||||
FileItem fileItem = new DiskFileItem("file", |
||||
Files.probeContentType(file.toPath()), |
||||
false, |
||||
file.getName(), |
||||
(int) file.length(), |
||||
file.getParentFile()); |
||||
IOUtils.copy(new FileInputStream(file), fileItem.getOutputStream()); |
||||
MultipartFile multipartFile = new CommonsMultipartFile(fileItem); |
||||
FilesResult filesResult = aliyunOssService.uploadFiles(multipartFile); |
||||
System.out.println(filesResult.toString()); |
||||
} |
||||
|
||||
/** |
||||
* 测试下载文件 |
||||
*/ |
||||
@Test |
||||
void testDownloadFiles() throws IOException { |
||||
HttpServletResponse response = new MockHttpServletResponse(); |
||||
AliyunOssService aliyunOssService = this.aliyunOssService; |
||||
aliyunOssService.downloadFiles(response, |
||||
"http://liuwanr.oss-cn-shenzhen.aliyuncs.com/jpg/20200807/1596787474773.jpg"); |
||||
} |
||||
|
||||
/** |
||||
* 测试根据文件路径+文件名称,删除该文件 |
||||
*/ |
||||
@Test |
||||
void testDeleteFile() { |
||||
aliyunOssService.deleteFile("http://liuwanr.oss-cn-shenzhen.aliyuncs.com/jpg/20200807/1596787474773.jpg"); |
||||
} |
||||
} |
@ -0,0 +1,35 @@ |
||||
package com.msdw.tms.service; |
||||
|
||||
import com.msdw.tms.entity.EvaluationRulesEntity; |
||||
import com.msdw.tms.entity.vo.EvaluationRulesVO; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
/** |
||||
* 测评规则信息记录,只记录一条信息 |
||||
* |
||||
* @author gongsj |
||||
*/ |
||||
@SpringBootTest |
||||
class EvaluationRulesServiceTest { |
||||
|
||||
@Autowired |
||||
EvaluationRulesService evaluationRulesService; |
||||
|
||||
@Test |
||||
void getEvaluationRules() { |
||||
EvaluationRulesVO evaluationRules = evaluationRulesService.getEvaluationRules(); |
||||
System.out.println(evaluationRules.toString()); |
||||
} |
||||
|
||||
@Test |
||||
@Transactional |
||||
void updateEvaluationRulesById() { |
||||
EvaluationRulesEntity evaluationRules = new EvaluationRulesEntity(); |
||||
boolean b = evaluationRulesService.updateEvaluationRulesById(evaluationRules); |
||||
System.out.println(b); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,128 @@ |
||||
package com.msdw.tms.service; |
||||
|
||||
import com.msdw.tms.common.utils.FilesResult; |
||||
import com.msdw.tms.common.utils.PageUtils; |
||||
import com.msdw.tms.entity.request.QuestionsAddRequest; |
||||
import com.msdw.tms.entity.request.QuestionsQueryRequest; |
||||
import com.msdw.tms.entity.request.QuestionsUpdateRequest; |
||||
import com.msdw.tms.entity.vo.EvaluationVO; |
||||
import com.msdw.tms.entity.vo.QuestionsDetailVO; |
||||
import org.apache.commons.fileupload.FileItem; |
||||
import org.apache.commons.fileupload.disk.DiskFileItem; |
||||
import org.apache.commons.io.IOUtils; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
import org.springframework.web.multipart.commons.CommonsMultipartFile; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.IOException; |
||||
import java.nio.file.Files; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 记录试题信息 |
||||
* |
||||
* @author gongsj |
||||
*/ |
||||
@SpringBootTest |
||||
class QuestionsServiceTest { |
||||
|
||||
@Autowired |
||||
QuestionsService questionsService; |
||||
|
||||
@Test |
||||
void queryQuestionsPage() { |
||||
Integer page = 1; |
||||
Integer size = 10; |
||||
QuestionsQueryRequest request = new QuestionsQueryRequest(); |
||||
PageUtils pageUtils = questionsService.queryQuestionsPage(page, size, request); |
||||
System.out.println(pageUtils.toString()); |
||||
} |
||||
|
||||
@Test |
||||
void getQuestionDetailById() { |
||||
Integer id = 1; |
||||
QuestionsDetailVO detail = questionsService.getQuestionDetailById(id); |
||||
System.out.println(detail.toString()); |
||||
} |
||||
|
||||
@Test |
||||
@Transactional |
||||
void saveQuestion() { |
||||
QuestionsAddRequest questions = new QuestionsAddRequest(); |
||||
System.out.println(questionsService.saveQuestion(questions)); |
||||
} |
||||
|
||||
@Test |
||||
@Transactional |
||||
void updateQuestionById() { |
||||
QuestionsUpdateRequest questions = new QuestionsUpdateRequest(); |
||||
System.out.println(questionsService.updateQuestionById(questions)); |
||||
} |
||||
|
||||
@Test |
||||
@Transactional |
||||
void isnable() { |
||||
Integer id = 1; |
||||
System.out.println(questionsService.isnable(id)); |
||||
} |
||||
|
||||
@Test |
||||
@Transactional |
||||
void deleteByIds() { |
||||
List<Integer> asList = new ArrayList<>(); |
||||
System.out.println(questionsService.deleteByIds(asList)); |
||||
} |
||||
|
||||
@Test |
||||
@Transactional |
||||
void importQuestion() throws IOException { |
||||
File file = new File("D:\\pic\\1.jpg"); |
||||
FileItem fileItem = new DiskFileItem("file", |
||||
Files.probeContentType(file.toPath()), |
||||
false, |
||||
file.getName(), |
||||
(int) file.length(), |
||||
file.getParentFile()); |
||||
IOUtils.copy(new FileInputStream(file), fileItem.getOutputStream()); |
||||
MultipartFile multipartFile = new CommonsMultipartFile(fileItem); |
||||
|
||||
boolean b = questionsService.importQuestion(multipartFile); |
||||
|
||||
System.out.println(b); |
||||
} |
||||
|
||||
@Test |
||||
void uploadFiles() throws IOException { |
||||
File file = new File("D:\\pic\\1.jpg"); |
||||
FileItem fileItem = new DiskFileItem("file", |
||||
Files.probeContentType(file.toPath()), |
||||
false, |
||||
file.getName(), |
||||
(int) file.length(), |
||||
file.getParentFile()); |
||||
IOUtils.copy(new FileInputStream(file), fileItem.getOutputStream()); |
||||
MultipartFile multipartFile = new CommonsMultipartFile(fileItem); |
||||
FilesResult filesResult = questionsService.uploadFiles(multipartFile); |
||||
System.out.println(filesResult.toString()); |
||||
} |
||||
|
||||
@Test |
||||
void downloadFiles() throws IOException { |
||||
HttpServletResponse response = null; |
||||
questionsService.downloadFiles(response); |
||||
} |
||||
|
||||
@Test |
||||
void evaluation() { |
||||
EvaluationVO evaluation = questionsService.evaluation(); |
||||
System.out.println(evaluation.toString()); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue