commit
fcc34b7f50
19 changed files with 1003 additions and 400 deletions
@ -0,0 +1,70 @@ |
||||
package com.yipin.liuwanr; |
||||
|
||||
import com.yipin.liuwanr.service.AliyunOssService; |
||||
import org.apache.commons.fileupload.FileItem; |
||||
import org.apache.commons.fileupload.disk.DiskFileItem; |
||||
import org.apache.commons.io.IOUtils; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.mock.web.MockHttpServletResponse; |
||||
import org.springframework.test.context.junit4.SpringRunner; |
||||
import org.springframework.test.web.servlet.MockMvc; |
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders; |
||||
import org.springframework.web.context.WebApplicationContext; |
||||
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.HashMap; |
||||
|
||||
@RunWith(SpringRunner.class) |
||||
@SpringBootTest |
||||
public class AliyunOssServiceTest { |
||||
|
||||
@Autowired |
||||
private AliyunOssService aliyunOssService; |
||||
|
||||
/** |
||||
* 测试上传文件 |
||||
*/ |
||||
@Test |
||||
public 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); |
||||
HashMap<String, Object> map = aliyunOssService.uploadFiles(multipartFile); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
/** |
||||
* 测试下载文件 |
||||
*/ |
||||
@Test |
||||
public 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 |
||||
public void testDeleteFile() throws IOException { |
||||
aliyunOssService.deleteFile("http://liuwanr.oss-cn-shenzhen.aliyuncs.com/jpg/20200807/1596787474773.jpg"); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,37 @@ |
||||
package com.yipin.liuwanr; |
||||
|
||||
import com.yipin.liuwanr.service.AssesmentRecordService; |
||||
import com.yipin.liuwanr.vo.AssesmentRecordVo; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.test.context.junit4.SpringRunner; |
||||
|
||||
import java.util.HashMap; |
||||
|
||||
@RunWith(SpringRunner.class) |
||||
@SpringBootTest |
||||
public class AssesmentRecordServiceTest { |
||||
|
||||
@Autowired |
||||
private AssesmentRecordService assesmentRecordService; |
||||
|
||||
/** |
||||
* 根据课程id查询学生信息 |
||||
* studentId, courseId |
||||
*/ |
||||
@Test |
||||
public void testQueryCity() { |
||||
HashMap<String, Object> map = assesmentRecordService.queryStudentAssessment(68, 72); |
||||
Integer retcode = (Integer) map.get("retcode"); |
||||
System.out.println(retcode); |
||||
if (retcode == 200) { |
||||
AssesmentRecordVo assesmentRecordVo = (AssesmentRecordVo) map.get("retvalue"); |
||||
System.out.println(assesmentRecordVo.toString()); |
||||
} else { |
||||
String msg = (String) map.get("retvalue"); |
||||
System.out.println(msg); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,36 @@ |
||||
package com.yipin.liuwanr; |
||||
|
||||
import com.yipin.liuwanr.entity.SutdentClass; |
||||
import com.yipin.liuwanr.service.ClassService; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.test.context.junit4.SpringRunner; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
|
||||
@RunWith(SpringRunner.class) |
||||
@SpringBootTest |
||||
public class ClassServiceTest { |
||||
|
||||
@Autowired |
||||
private ClassService classService; |
||||
|
||||
@Test |
||||
public void testQueryGetByClassName() { |
||||
HashMap<String, Object> map = classService.queryGetByClassName(""); |
||||
Integer retcode = (Integer) map.get("retcode"); |
||||
System.out.println(retcode); |
||||
if (retcode == 200) { |
||||
List<SutdentClass> classes = (List<SutdentClass>) map.get("retvalue"); |
||||
classes.forEach(item -> { |
||||
System.out.println(item.toString()); |
||||
}); |
||||
} else { |
||||
String msg = (String) map.get("retvalue"); |
||||
System.out.println(msg); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,230 @@ |
||||
package com.yipin.liuwanr; |
||||
|
||||
import com.yipin.liuwanr.entity.Course; |
||||
import com.yipin.liuwanr.entity.CourseLink; |
||||
import com.yipin.liuwanr.entity.CoursePermissions; |
||||
import com.yipin.liuwanr.entity.ServiceConfig; |
||||
import com.yipin.liuwanr.mapper.CoursePermissionsMapper; |
||||
import com.yipin.liuwanr.service.CoursePermissionsService; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.test.context.junit4.SpringRunner; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import java.util.HashMap; |
||||
|
||||
@RunWith(SpringRunner.class) |
||||
@SpringBootTest |
||||
public class CoursePermissionsServiceTest { |
||||
|
||||
@Autowired |
||||
private CoursePermissionsService coursePermissionsService; |
||||
|
||||
@Autowired |
||||
private CoursePermissionsMapper coursePermissionsMapper; |
||||
|
||||
/** |
||||
* 新增课程权限 |
||||
*/ |
||||
@Test |
||||
@Transactional |
||||
public void testAddCoursePermissions() { |
||||
CoursePermissions coursePermissions = new CoursePermissions(); |
||||
coursePermissions.setUsePeriod(30); |
||||
coursePermissions.setMarketPrice(12.8); |
||||
coursePermissions.setTransactionPrice(90); |
||||
coursePermissions.setDiscount(703); |
||||
coursePermissions.setPortAddressId(1); |
||||
coursePermissions.setIsDeliverGoods(0); |
||||
coursePermissions.setCourseId(77); |
||||
coursePermissions.setOrderId(117); |
||||
|
||||
HashMap<String, Object> map = coursePermissionsService.addCoursePermissions(coursePermissions); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
/** |
||||
* 查询课程详情 |
||||
*/ |
||||
@Test |
||||
public void testQueryCourseDetails() { |
||||
HashMap<String, Object> map = coursePermissionsService.queryCourseDetails(84); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
/*Integer retcode = (Integer) map.get("retcode"); |
||||
System.out.println(retcode); |
||||
if (retcode == 200) { |
||||
List<Course> classes = (List<Course>) map.get("retvalue"); |
||||
classes.forEach(item -> { |
||||
System.out.println(item.toString()); |
||||
}); |
||||
} else { |
||||
String msg = (String) map.get("retvalue"); |
||||
System.out.println(msg); |
||||
}*/ |
||||
} |
||||
|
||||
/** |
||||
* 删除课程 |
||||
*/ |
||||
@Test |
||||
@Transactional |
||||
public void testDeleteCourse() { |
||||
HashMap<String, Object> map = coursePermissionsService.deleteCourse(84); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
/** |
||||
* 修改课程 |
||||
*/ |
||||
@Test |
||||
@Transactional |
||||
public void testUpdateCourse() { |
||||
Course course = new Course(); |
||||
course.setCourseId(84); |
||||
course.setCourseName("Python程序设计实训课(测试2)"); |
||||
course.setCourseType(2); |
||||
course.setDisciplineId(1); |
||||
course.setProfessionalClassId(1); |
||||
course.setProfessionalId(7); |
||||
course.setCourseHours(1); |
||||
course.setMarketPrice(12.8); |
||||
course.setCourseIntroduction("一门学习python编程的基础实训课"); |
||||
course.setTeachingGoal("掌握Python编程的基础语法"); |
||||
HashMap<String, Object> map = coursePermissionsService.updateCourse(course); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
/** |
||||
* 查询学科 |
||||
*/ |
||||
@Test |
||||
public void testQueryCourseDiscipline() { |
||||
HashMap<String, Object> map = coursePermissionsService.queryCourseDiscipline(); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
/** |
||||
* 查询课程专业班级 |
||||
*/ |
||||
@Test |
||||
public void testQueryCourseProfessionalClass() { |
||||
HashMap<String, Object> map = coursePermissionsService.queryCourseProfessionalClass(1); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
/** |
||||
* 查询课程专业 |
||||
*/ |
||||
@Test |
||||
public void testQueryCourseProfessional() { |
||||
HashMap<String, Object> map = coursePermissionsService.queryCourseProfessional(1); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
/** |
||||
* 查询APP配置 |
||||
*/ |
||||
@Test |
||||
public void testQueryAppConfig() { |
||||
ServiceConfig serviceConfig = new ServiceConfig(); |
||||
HashMap<String, Object> map = coursePermissionsService.queryAppConfig(serviceConfig); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
/** |
||||
* 查询练习配置 |
||||
*/ |
||||
@Test |
||||
public void queryTrainingConfig() { |
||||
Integer courseId = 77; |
||||
Integer pageNo = 1; |
||||
Integer pageSize = 10; |
||||
HashMap<String, Object> map = coursePermissionsService.queryTrainingConfig(courseId, pageNo, pageSize); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
/** |
||||
* 新增练习配置 |
||||
*/ |
||||
@Test |
||||
@Transactional |
||||
public void addTrainingConfig() { |
||||
Course course = new Course(); |
||||
course.setCourseId(77); |
||||
course.setCourseName("Python程序设计实训课(测试2)"); |
||||
course.setCourseType(2); |
||||
course.setDisciplineId(1); |
||||
course.setProfessionalClassId(1); |
||||
course.setProfessionalId(7); |
||||
course.setCourseHours(1); |
||||
course.setMarketPrice(12.8); |
||||
course.setCourseIntroduction("一门学习python编程的基础实训课"); |
||||
course.setTeachingGoal("掌握Python编程的基础语法"); |
||||
HashMap<String, Object> map = coursePermissionsService.addTrainingConfig(course); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
/** |
||||
* 查询链接详情 |
||||
*/ |
||||
@Test |
||||
public void queryLinkDetails() { |
||||
Integer linkId = 9; |
||||
HashMap<String, Object> map = coursePermissionsService.queryLinkDetails(linkId); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
/** |
||||
* 修改链接 |
||||
*/ |
||||
@Test |
||||
@Transactional |
||||
public void updateLink() { |
||||
CourseLink courseLink = new CourseLink(); |
||||
courseLink.setFileLink("qweqweqwe"); |
||||
courseLink.setLinkName("qweqewqe"); |
||||
courseLink.setProjectId(12); |
||||
courseLink.setLinkId(3); |
||||
HashMap<String, Object> map = coursePermissionsService.updateLink(courseLink); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
/** |
||||
* 删除练习配置 |
||||
*/ |
||||
@Test |
||||
@Transactional |
||||
public void deleteTrainingConfig() { |
||||
Course course = new Course(); |
||||
course.setCourseId(77); |
||||
HashMap<String, Object> map = coursePermissionsService.deleteTrainingConfig(course); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
/** |
||||
* 选择是否展示 |
||||
*/ |
||||
@Test |
||||
@Transactional |
||||
public void isShow() { |
||||
Course course = new Course(); |
||||
course.setCourseId(77); |
||||
HashMap<String, Object> map = coursePermissionsService.isShow(course); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
/** |
||||
* 选择是否上架 |
||||
*/ |
||||
@Test |
||||
@Transactional |
||||
public void isShelves() { |
||||
Course course = new Course(); |
||||
course.setCourseId(77); |
||||
HashMap<String, Object> map = coursePermissionsService.isShelves(course); |
||||
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue