From 251da427b73dba747f38714a65672e01e2732b46 Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Fri, 7 Aug 2020 17:49:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 + .../controller/AliyunOssController.java | 76 +++++----- .../java/com/yipin/liuwanr/entity/City.java | 9 ++ .../yipin/liuwanr/entity/SutdentClass.java | 9 +- .../liuwanr/service/AliyunOssService.java | 143 +++++++++--------- .../yipin/liuwanr/service/CityService.java | 1 + .../yipin/liuwanr/AliyunOssServiceTest.java | 70 +++++++++ .../com/yipin/liuwanr/CityServiceTest.java | 54 ++++++- .../com/yipin/liuwanr/ClassServiceTest.java | 40 +++++ 9 files changed, 299 insertions(+), 109 deletions(-) create mode 100644 src/test/java/com/yipin/liuwanr/AliyunOssServiceTest.java create mode 100644 src/test/java/com/yipin/liuwanr/ClassServiceTest.java diff --git a/pom.xml b/pom.xml index 0fbc240..6087b9b 100644 --- a/pom.xml +++ b/pom.xml @@ -232,6 +232,12 @@ slf4j-api 1.7.21 + + commons-fileupload + commons-fileupload + 1.4 + test + ROOT diff --git a/src/main/java/com/yipin/liuwanr/controller/AliyunOssController.java b/src/main/java/com/yipin/liuwanr/controller/AliyunOssController.java index 74fedab..4595c11 100644 --- a/src/main/java/com/yipin/liuwanr/controller/AliyunOssController.java +++ b/src/main/java/com/yipin/liuwanr/controller/AliyunOssController.java @@ -19,50 +19,52 @@ import com.yipin.liuwanr.service.AliyunOssService; @RequestMapping("/aliyun") public class AliyunOssController { - @Autowired - private AliyunOssService ossService; + @Autowired + private AliyunOssService ossService; /** * 上传文件 + * * @param file * @return */ - @PostMapping("/uploadFiles") - Response uploadFiles(MultipartFile file) { - Response resp = new Response(); - HashMap ret = ossService.uploadFiles(file); - int status = (int) ret.get("retcode"); - if (200 == status) { - resp.setStatus(status); - resp.setMessage(ret.get("retvalue")); - } else { - resp.setStatus(status); - resp.setErrmessage(ret.get("retvalue").toString()); - } - return resp; + @PostMapping("/uploadFiles") + Response uploadFiles(MultipartFile file) { + Response resp = new Response(); + HashMap ret = ossService.uploadFiles(file); + int status = (int) ret.get("retcode"); + if (200 == status) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + return resp; - } - - /** - * 下载文件 - * @param objectName:在阿里云的文件路径 - * @param fileurl:本地路径 - * @return - */ - @GetMapping("/downloadFiles") - Response downloadFiles(HttpServletResponse response,@RequestParam String objectName) { - Response resp = new Response(); - try { - ossService.downloadFiles(response,objectName); - resp.setStatus(200); - resp.setMessage("下载成功!"); - } catch (Exception e) { - resp.setStatus(300); - resp.setErrmessage("下载失败"); - } - return null; + } + /** + * 下载文件 + * + * @param objectName:在阿里云的文件路径 + * @param fileurl:本地路径 + * @return + */ + @GetMapping("/downloadFiles") + Response downloadFiles(HttpServletResponse response, @RequestParam String objectName) { + Response resp = new Response(); + try { + ossService.downloadFiles(response, objectName); + resp.setStatus(200); + resp.setMessage("下载成功!"); + } catch (Exception e) { + resp.setStatus(300); + resp.setErrmessage("下载失败"); + } + return null; + + + } - } - } diff --git a/src/main/java/com/yipin/liuwanr/entity/City.java b/src/main/java/com/yipin/liuwanr/entity/City.java index 250a13f..2e77b08 100644 --- a/src/main/java/com/yipin/liuwanr/entity/City.java +++ b/src/main/java/com/yipin/liuwanr/entity/City.java @@ -26,4 +26,13 @@ public class City { public void setProvinceId(Integer provinceId) { this.provinceId = provinceId; } + + @Override + public String toString() { + return "City{" + + "cityId=" + cityId + + ", cityName='" + cityName + '\'' + + ", provinceId=" + provinceId + + '}'; + } } diff --git a/src/main/java/com/yipin/liuwanr/entity/SutdentClass.java b/src/main/java/com/yipin/liuwanr/entity/SutdentClass.java index 62dc59e..d36a360 100644 --- a/src/main/java/com/yipin/liuwanr/entity/SutdentClass.java +++ b/src/main/java/com/yipin/liuwanr/entity/SutdentClass.java @@ -36,5 +36,12 @@ public class SutdentClass { this.gradeId = gradeId; } - + @Override + public String toString() { + return "SutdentClass{" + + "classId=" + classId + + ", className='" + className + '\'' + + ", gradeId=" + gradeId + + '}'; + } } diff --git a/src/main/java/com/yipin/liuwanr/service/AliyunOssService.java b/src/main/java/com/yipin/liuwanr/service/AliyunOssService.java index 9035d6b..aca3225 100644 --- a/src/main/java/com/yipin/liuwanr/service/AliyunOssService.java +++ b/src/main/java/com/yipin/liuwanr/service/AliyunOssService.java @@ -19,76 +19,79 @@ import com.yipin.liuwanr.helper.OssConfigUtil; @Service public class AliyunOssService { - @Autowired - private AliyunOssConfig config; - - @Autowired - private BeanFactory beanFactory; - - private static Logger logger = Logger.getLogger(AliyunOssService.class); + @Autowired + private AliyunOssConfig config; + + @Autowired + private BeanFactory beanFactory; + + private static Logger logger = Logger.getLogger(AliyunOssService.class); + + /** + * 上传文件 + * + * @param file 上传文件 + * @return + */ + public HashMap uploadFiles(MultipartFile file) { + HashMap resp = new HashMap(); + try { + OSSClient client = beanFactory.getBean(OSSClient.class); + FilesResult result = OssConfigUtil.uploadFiles(file, client, config); + resp.put("retcode", 200); + resp.put("retvalue", result); + } catch (Exception e) { + logger.info(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Upload Fail"); + return resp; + } + return resp; + } + + + /** + * 下载文件 + * + * @param objectName 要下载的文件(路径+文件名) + * @param fileurl 本地路径 + * @return + */ + public void downloadFiles(HttpServletResponse response, String objectName) { + HashMap resp = new HashMap(); + try { + OSSClient client = beanFactory.getBean(OSSClient.class); + OssConfigUtil.downloadFiles(response, client, config, objectName); + resp.put("retcode", 200); + resp.put("retvalue", "Download SUCCESS"); + } catch (Exception e) { + logger.info(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Download Fail"); + } + } + + /** + * 根据文件路径+文件名称,删除该文件 + * + * @param filename + * @return + */ + public HashMap deleteFile(String filename) { + HashMap resp = new HashMap(); + try { + OSSClient client = beanFactory.getBean(OSSClient.class); + OssConfigUtil.deleteFile(client, config.getBucketName(), filename); + resp.put("retcode", 200); + resp.put("retvalue", "Delete SUCCESS"); + } catch (RuntimeException e) { + logger.info(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Delete Fail"); + return resp; + } + return resp; + } - /** - * 上传文件 - * @param file 上传文件 - * @return - */ - public HashMap uploadFiles(MultipartFile file) { - HashMap resp = new HashMap(); - try { - OSSClient client=beanFactory.getBean(OSSClient.class); - FilesResult result=OssConfigUtil.uploadFiles(file, client, config); - resp.put("retcode", 200); - resp.put("retvalue", result); - } catch (Exception e) { - logger.info(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Upload Fail"); - return resp; - } - return resp; - } - - /** - * 下载文件 - * @param objectName 要下载的文件(路径+文件名) - * @param fileurl 本地路径 - * @return - */ - public void downloadFiles(HttpServletResponse response,String objectName) { - HashMap resp = new HashMap(); - try { - OSSClient client=beanFactory.getBean(OSSClient.class); - OssConfigUtil.downloadFiles(response,client, config, objectName); - resp.put("retcode", 200); - resp.put("retvalue","Download SUCCESS" ); - } catch (Exception e) { - logger.info(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Download Fail"); - } - } - - /** - * 根据文件路径+文件名称,删除该文件 - * @param filename - * @return - */ - public HashMap deleteFile(String filename) { - HashMap resp = new HashMap(); - try { - OSSClient client=beanFactory.getBean(OSSClient.class); - OssConfigUtil.deleteFile(client, config.getBucketName(), filename); - resp.put("retcode", 200); - resp.put("retvalue","Delete SUCCESS" ); - } catch (RuntimeException e) { - logger.info(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Delete Fail"); - return resp; - } - return resp; - } - - } diff --git a/src/main/java/com/yipin/liuwanr/service/CityService.java b/src/main/java/com/yipin/liuwanr/service/CityService.java index f34e224..65ee31c 100644 --- a/src/main/java/com/yipin/liuwanr/service/CityService.java +++ b/src/main/java/com/yipin/liuwanr/service/CityService.java @@ -24,6 +24,7 @@ public class CityService { resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); + System.out.println(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Inquiry Failed"); return resp; diff --git a/src/test/java/com/yipin/liuwanr/AliyunOssServiceTest.java b/src/test/java/com/yipin/liuwanr/AliyunOssServiceTest.java new file mode 100644 index 0000000..ed82dc6 --- /dev/null +++ b/src/test/java/com/yipin/liuwanr/AliyunOssServiceTest.java @@ -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 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"); + } + +} diff --git a/src/test/java/com/yipin/liuwanr/CityServiceTest.java b/src/test/java/com/yipin/liuwanr/CityServiceTest.java index 5a4b911..b580097 100644 --- a/src/test/java/com/yipin/liuwanr/CityServiceTest.java +++ b/src/test/java/com/yipin/liuwanr/CityServiceTest.java @@ -1,14 +1,17 @@ package com.yipin.liuwanr; import com.yipin.liuwanr.entity.City; +import com.yipin.liuwanr.mapper.CityMapper; import com.yipin.liuwanr.service.CityService; 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; +import java.util.List; @RunWith(SpringRunner.class) @SpringBootTest @@ -17,13 +20,62 @@ public class CityServiceTest { @Autowired private CityService cityService; + @Autowired + private CityMapper cityMapper; + /** * 新增城市信息方法测试 */ - @Test + /*@Test + @Transactional public void testAddCity() { City city = new City(); + city.setCityName("hhhh"); + city.setProvinceId(2); HashMap map = cityService.addCity(city); map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value)); + }*/ + + /** + * 查询城市信息方法测试 + */ + @Test + public void testQueryCity() { + HashMap map = cityService.queryCity(1); + Integer retcode = (Integer) map.get("retcode"); + System.out.println(retcode); + if (retcode == 200) { + List cities = (List) map.get("retvalue"); + cities.forEach(item -> { + System.out.println(item.toString()); + }); + } else { + String msg = (String) map.get("retvalue"); + System.out.println(msg); + } + } + + /** + * 删除城市信息方法测试 + */ + @Test + @Transactional + public void testDeleteCity() { + HashMap map = cityService.deleteCity(1); + map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); + } + + /** + * 删除城市信息方法测试 + */ + @Test + @Transactional + public void testUpdateCity() { + City city = new City(); + city.setCityId(1); + city.setCityName("hhhh"); + city.setProvinceId(2); + HashMap map = cityService.updateCity(city); + map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); } } diff --git a/src/test/java/com/yipin/liuwanr/ClassServiceTest.java b/src/test/java/com/yipin/liuwanr/ClassServiceTest.java new file mode 100644 index 0000000..7850a20 --- /dev/null +++ b/src/test/java/com/yipin/liuwanr/ClassServiceTest.java @@ -0,0 +1,40 @@ +package com.yipin.liuwanr; + +import com.yipin.liuwanr.entity.City; +import com.yipin.liuwanr.entity.SutdentClass; +import com.yipin.liuwanr.mapper.CityMapper; +import com.yipin.liuwanr.service.CityService; +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 org.springframework.transaction.annotation.Transactional; + +import java.util.HashMap; +import java.util.List; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class ClassServiceTest { + + @Autowired + private ClassService classService; + + @Test + public void testQueryGetByClassName() { + HashMap map = classService.queryGetByClassName(""); + Integer retcode = (Integer) map.get("retcode"); + System.out.println(retcode); + if (retcode == 200) { + List classes = (List) map.get("retvalue"); + classes.forEach(item -> { + System.out.println(item.toString()); + }); + } else { + String msg = (String) map.get("retvalue"); + System.out.println(msg); + } + } +} From 58bcff898707340b58303719da0caed8bce91f89 Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Wed, 12 Aug 2020 11:42:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?CoursePermissionsService=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yipin/liuwanr/entity/Course.java | 292 ++++++++++-------- .../com/yipin/liuwanr/entity/CourseLink.java | 121 +++++--- .../com/yipin/liuwanr/entity/Discipline.java | 9 + .../yipin/liuwanr/entity/Professional.java | 9 + .../liuwanr/entity/ProfessionalClass.java | 9 + .../yipin/liuwanr/entity/ServiceConfig.java | 234 ++++++++------ .../service/AssesmentRecordService.java | 93 +++--- .../yipin/liuwanr/vo/AssesmentRecordVo.java | 11 + .../liuwanr/AssesmentRecordServiceTest.java | 37 +++ .../com/yipin/liuwanr/ClassServiceTest.java | 4 - .../liuwanr/CoursePermissionsServiceTest.java | 230 ++++++++++++++ 11 files changed, 732 insertions(+), 317 deletions(-) create mode 100644 src/test/java/com/yipin/liuwanr/AssesmentRecordServiceTest.java create mode 100644 src/test/java/com/yipin/liuwanr/CoursePermissionsServiceTest.java diff --git a/src/main/java/com/yipin/liuwanr/entity/Course.java b/src/main/java/com/yipin/liuwanr/entity/Course.java index 53efdd1..0178504 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Course.java +++ b/src/main/java/com/yipin/liuwanr/entity/Course.java @@ -1,125 +1,175 @@ package com.yipin.liuwanr.entity; public class Course { - //主键ID - private Integer courseId; - //课程名称 - private String courseName; - //课程类别 - private Integer courseType; - //绑定学科id - private Integer disciplineId; - //绑定专业类id - private Integer professionalClassId; - //绑定专业id - private Integer professionalId; - //预计课时 - private Integer courseHours; - //市场价格 - private double marketPrice; - //课程简介 - private String courseIntroduction; - //教学目标 - private String teachingGoal; - //搜索内容 - private String searchContent; - //绑定系统Id - private String systemId; - //绑定系统名称 - private String systemName; - //是否上架 - private Integer isShelves; - //创建时间 - private String creationTime; - - public String getCreationTime() { - return creationTime; - } - public void setCreationTime(String creationTime) { - this.creationTime = creationTime; - } - public String getSystemName() { - return systemName; - } - public void setSystemName(String systemName) { - this.systemName = systemName; - } - public Integer getIsShelves() { - return isShelves; - } - public void setIsShelves(Integer isShelves) { - this.isShelves = isShelves; - } - public String getSystemId() { - return systemId; - } - public void setSystemId(String systemId) { - this.systemId = systemId; - } - public Integer getCourseId() { - return courseId; - } - public void setCourseId(Integer courseId) { - this.courseId = courseId; - } - public String getCourseName() { - return courseName; - } - public void setCourseName(String courseName) { - this.courseName = courseName; - } - public Integer getCourseType() { - return courseType; - } - public void setCourseType(Integer courseType) { - this.courseType = courseType; - } - public Integer getDisciplineId() { - return disciplineId; - } - public void setDisciplineId(Integer disciplineId) { - this.disciplineId = disciplineId; - } - public Integer getProfessionalClassId() { - return professionalClassId; - } - public void setProfessionalClassId(Integer professionalClassId) { - this.professionalClassId = professionalClassId; - } - public Integer getProfessionalId() { - return professionalId; - } - public void setProfessionalId(Integer professionalId) { - this.professionalId = professionalId; - } - public Integer getCourseHours() { - return courseHours; - } - public void setCourseHours(Integer courseHours) { - this.courseHours = courseHours; - } - public String getCourseIntroduction() { - return courseIntroduction; - } - public void setCourseIntroduction(String courseIntroduction) { - this.courseIntroduction = courseIntroduction; - } - public String getTeachingGoal() { - return teachingGoal; - } - public void setTeachingGoal(String teachingGoal) { - this.teachingGoal = teachingGoal; - } - public String getSearchContent() { - return searchContent; - } - public void setSearchContent(String searchContent) { - this.searchContent = searchContent; - } - public double getMarketPrice() { - return marketPrice; - } - public void setMarketPrice(double marketPrice) { - this.marketPrice = marketPrice; - } + //主键ID + private Integer courseId; + //课程名称 + private String courseName; + //课程类别 + private Integer courseType; + //绑定学科id + private Integer disciplineId; + //绑定专业类id + private Integer professionalClassId; + //绑定专业id + private Integer professionalId; + //预计课时 + private Integer courseHours; + //市场价格 + private double marketPrice; + //课程简介 + private String courseIntroduction; + //教学目标 + private String teachingGoal; + //搜索内容 + private String searchContent; + //绑定系统Id + private String systemId; + //绑定系统名称 + private String systemName; + //是否上架 + private Integer isShelves; + //创建时间 + private String creationTime; + + public String getCreationTime() { + return creationTime; + } + + public void setCreationTime(String creationTime) { + this.creationTime = creationTime; + } + + public String getSystemName() { + return systemName; + } + + public void setSystemName(String systemName) { + this.systemName = systemName; + } + + public Integer getIsShelves() { + return isShelves; + } + + public void setIsShelves(Integer isShelves) { + this.isShelves = isShelves; + } + + public String getSystemId() { + return systemId; + } + + public void setSystemId(String systemId) { + this.systemId = systemId; + } + + public Integer getCourseId() { + return courseId; + } + + public void setCourseId(Integer courseId) { + this.courseId = courseId; + } + + public String getCourseName() { + return courseName; + } + + public void setCourseName(String courseName) { + this.courseName = courseName; + } + + public Integer getCourseType() { + return courseType; + } + + public void setCourseType(Integer courseType) { + this.courseType = courseType; + } + + public Integer getDisciplineId() { + return disciplineId; + } + + public void setDisciplineId(Integer disciplineId) { + this.disciplineId = disciplineId; + } + + public Integer getProfessionalClassId() { + return professionalClassId; + } + + public void setProfessionalClassId(Integer professionalClassId) { + this.professionalClassId = professionalClassId; + } + + public Integer getProfessionalId() { + return professionalId; + } + + public void setProfessionalId(Integer professionalId) { + this.professionalId = professionalId; + } + + public Integer getCourseHours() { + return courseHours; + } + + public void setCourseHours(Integer courseHours) { + this.courseHours = courseHours; + } + + public String getCourseIntroduction() { + return courseIntroduction; + } + + public void setCourseIntroduction(String courseIntroduction) { + this.courseIntroduction = courseIntroduction; + } + + public String getTeachingGoal() { + return teachingGoal; + } + + public void setTeachingGoal(String teachingGoal) { + this.teachingGoal = teachingGoal; + } + + public String getSearchContent() { + return searchContent; + } + + public void setSearchContent(String searchContent) { + this.searchContent = searchContent; + } + + public double getMarketPrice() { + return marketPrice; + } + + public void setMarketPrice(double marketPrice) { + this.marketPrice = marketPrice; + } + + @Override + public String toString() { + return "Course{" + + "courseId=" + courseId + + ", courseName='" + courseName + '\'' + + ", courseType=" + courseType + + ", disciplineId=" + disciplineId + + ", professionalClassId=" + professionalClassId + + ", professionalId=" + professionalId + + ", courseHours=" + courseHours + + ", marketPrice=" + marketPrice + + ", courseIntroduction='" + courseIntroduction + '\'' + + ", teachingGoal='" + teachingGoal + '\'' + + ", searchContent='" + searchContent + '\'' + + ", systemId='" + systemId + '\'' + + ", systemName='" + systemName + '\'' + + ", isShelves=" + isShelves + + ", creationTime='" + creationTime + '\'' + + '}'; + } } diff --git a/src/main/java/com/yipin/liuwanr/entity/CourseLink.java b/src/main/java/com/yipin/liuwanr/entity/CourseLink.java index 5d8c9af..5cf54d4 100644 --- a/src/main/java/com/yipin/liuwanr/entity/CourseLink.java +++ b/src/main/java/com/yipin/liuwanr/entity/CourseLink.java @@ -4,53 +4,76 @@ import java.util.List; public class CourseLink { - //课程环节主键id - private Integer linkId; - //项目id - private Integer projectId; - //文件链接 - private String fileLink; - //环节名称 - private String linkName; - //绑定课程id - private Integer courseId; - private List courseLink; - - - public Integer getCourseId() { - return courseId; - } - public void setCourseId(Integer courseId) { - this.courseId = courseId; - } - public List getCourseLink() { - return courseLink; - } - public void setCourseLink(List courseLink) { - this.courseLink = courseLink; - } - public Integer getLinkId() { - return linkId; - } - public void setLinkId(Integer linkId) { - this.linkId = linkId; - } - public Integer getProjectId() { - return projectId; - } - public void setProjectId(Integer projectId) { - this.projectId = projectId; - } - public String getFileLink() { - return fileLink; - } - public void setFileLink(String fileLink) { - this.fileLink = fileLink; - } - public String getLinkName() { - return linkName; - } - public void setLinkName(String linkName) { - this.linkName = linkName; - } + //课程环节主键id + private Integer linkId; + //项目id + private Integer projectId; + //文件链接 + private String fileLink; + //环节名称 + private String linkName; + //绑定课程id + private Integer courseId; + private List courseLink; + + + public Integer getCourseId() { + return courseId; + } + + public void setCourseId(Integer courseId) { + this.courseId = courseId; + } + + public List getCourseLink() { + return courseLink; + } + + public void setCourseLink(List courseLink) { + this.courseLink = courseLink; + } + + public Integer getLinkId() { + return linkId; + } + + public void setLinkId(Integer linkId) { + this.linkId = linkId; + } + + public Integer getProjectId() { + return projectId; + } + + public void setProjectId(Integer projectId) { + this.projectId = projectId; + } + + public String getFileLink() { + return fileLink; + } + + public void setFileLink(String fileLink) { + this.fileLink = fileLink; + } + + public String getLinkName() { + return linkName; + } + + public void setLinkName(String linkName) { + this.linkName = linkName; + } + + @Override + public String toString() { + return "CourseLink{" + + "linkId=" + linkId + + ", projectId=" + projectId + + ", fileLink='" + fileLink + '\'' + + ", linkName='" + linkName + '\'' + + ", courseId=" + courseId + + ", courseLink=" + courseLink + + '}'; + } } diff --git a/src/main/java/com/yipin/liuwanr/entity/Discipline.java b/src/main/java/com/yipin/liuwanr/entity/Discipline.java index 50b2e5b..9cb39ce 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Discipline.java +++ b/src/main/java/com/yipin/liuwanr/entity/Discipline.java @@ -26,4 +26,13 @@ public class Discipline { public void setDisciplineLevelId(Integer disciplineLevelId) { this.disciplineLevelId = disciplineLevelId; } + + @Override + public String toString() { + return "Discipline{" + + "disciplineId=" + disciplineId + + ", disciplineName='" + disciplineName + '\'' + + ", disciplineLevelId=" + disciplineLevelId + + '}'; + } } diff --git a/src/main/java/com/yipin/liuwanr/entity/Professional.java b/src/main/java/com/yipin/liuwanr/entity/Professional.java index ad10e71..db12a40 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Professional.java +++ b/src/main/java/com/yipin/liuwanr/entity/Professional.java @@ -49,4 +49,13 @@ public class Professional { this.professionalClassId = professionalClassId; } + @Override + public String toString() { + return "Professional{" + + "professionalId=" + professionalId + + ", professionalName='" + professionalName + '\'' + + ", professionalClassId=" + professionalClassId + + ", grade=" + grade + + '}'; + } } diff --git a/src/main/java/com/yipin/liuwanr/entity/ProfessionalClass.java b/src/main/java/com/yipin/liuwanr/entity/ProfessionalClass.java index fe91035..002cf4f 100644 --- a/src/main/java/com/yipin/liuwanr/entity/ProfessionalClass.java +++ b/src/main/java/com/yipin/liuwanr/entity/ProfessionalClass.java @@ -27,4 +27,13 @@ public class ProfessionalClass { public void setDisciplineId(String disciplineId) { this.disciplineId = disciplineId; } + + @Override + public String toString() { + return "ProfessionalClass{" + + "professionalClassId=" + professionalClassId + + ", professionalClassName='" + professionalClassName + '\'' + + ", disciplineId='" + disciplineId + '\'' + + '}'; + } } diff --git a/src/main/java/com/yipin/liuwanr/entity/ServiceConfig.java b/src/main/java/com/yipin/liuwanr/entity/ServiceConfig.java index 60445f3..c9d641b 100644 --- a/src/main/java/com/yipin/liuwanr/entity/ServiceConfig.java +++ b/src/main/java/com/yipin/liuwanr/entity/ServiceConfig.java @@ -1,102 +1,142 @@ package com.yipin.liuwanr.entity; public class ServiceConfig { + //主键ID + private Integer systemId; + //系统名称 + private String systemName; + //系统类型 + private Integer systemType; + //系统归属 + private Integer systemAttribution; + //系统状态 + private Integer systemStatus; + //搜索内容 + private String searchContent; + //项目名称 + private String projectName; + //绑定课程Id + private Integer courseId; + //多个系统Id + private String systemIds; + //项目id + private Integer projectId; + //项目是否展示 + private Integer isShow; + //系统地址 + private String systemAddress; - //主键ID - private Integer systemId; - //系统名称 - private String systemName; - //系统类型 - private Integer systemType; - //系统归属 - private Integer systemAttribution; - //系统状态 - private Integer systemStatus; - //搜索内容 - private String searchContent; - //项目名称 - private String projectName; - //绑定课程Id - private Integer courseId; - //多个系统Id - private String systemIds; - //项目id - private Integer projectId; - //项目是否展示 - private Integer isShow; - //系统地址 - private String systemAddress; - - public String getSystemIds() { - return systemIds; - } - public void setSystemIds(String systemIds) { - this.systemIds = systemIds; - } - public String getSystemAddress() { - return systemAddress; - } - public void setSystemAddress(String systemAddress) { - this.systemAddress = systemAddress; - } - public Integer getIsShow() { - return isShow; - } - public void setIsShow(Integer isShow) { - this.isShow = isShow; - } - public Integer getProjectId() { - return projectId; - } - public void setProjectId(Integer projectId) { - this.projectId = projectId; - } - public Integer getCourseId() { - return courseId; - } - public void setCourseId(Integer courseId) { - this.courseId = courseId; - } - public String getProjectName() { - return projectName; - } - public void setProjectName(String projectName) { - this.projectName = projectName; - } - public Integer getSystemId() { - return systemId; - } - public void setSystemId(Integer systemId) { - this.systemId = systemId; - } - public String getSystemName() { - return systemName; - } - public void setSystemName(String systemName) { - this.systemName = systemName; - } - public Integer getSystemType() { - return systemType; - } - public void setSystemType(Integer systemType) { - this.systemType = systemType; - } - public Integer getSystemAttribution() { - return systemAttribution; - } - public void setSystemAttribution(Integer systemAttribution) { - this.systemAttribution = systemAttribution; - } - public Integer getSystemStatus() { - return systemStatus; - } - public void setSystemStatus(Integer systemStatus) { - this.systemStatus = systemStatus; - } - public String getSearchContent() { - return searchContent; - } - public void setSearchContent(String searchContent) { - this.searchContent = searchContent; - } + public String getSystemIds() { + return systemIds; + } + + public void setSystemIds(String systemIds) { + this.systemIds = systemIds; + } + + public String getSystemAddress() { + return systemAddress; + } + + public void setSystemAddress(String systemAddress) { + this.systemAddress = systemAddress; + } + + public Integer getIsShow() { + return isShow; + } + + public void setIsShow(Integer isShow) { + this.isShow = isShow; + } + + public Integer getProjectId() { + return projectId; + } + + public void setProjectId(Integer projectId) { + this.projectId = projectId; + } + + public Integer getCourseId() { + return courseId; + } + + public void setCourseId(Integer courseId) { + this.courseId = courseId; + } + + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public Integer getSystemId() { + return systemId; + } + + public void setSystemId(Integer systemId) { + this.systemId = systemId; + } + + public String getSystemName() { + return systemName; + } + + public void setSystemName(String systemName) { + this.systemName = systemName; + } + + public Integer getSystemType() { + return systemType; + } + + public void setSystemType(Integer systemType) { + this.systemType = systemType; + } + + public Integer getSystemAttribution() { + return systemAttribution; + } + + public void setSystemAttribution(Integer systemAttribution) { + this.systemAttribution = systemAttribution; + } + + public Integer getSystemStatus() { + return systemStatus; + } + + public void setSystemStatus(Integer systemStatus) { + this.systemStatus = systemStatus; + } + + public String getSearchContent() { + return searchContent; + } + + public void setSearchContent(String searchContent) { + this.searchContent = searchContent; + } + + @Override + public String toString() { + return "ServiceConfig{" + + "systemId=" + systemId + + ", systemName='" + systemName + '\'' + + ", systemType=" + systemType + + ", systemAttribution=" + systemAttribution + + ", systemStatus=" + systemStatus + + ", searchContent='" + searchContent + '\'' + + ", projectName='" + projectName + '\'' + + ", courseId=" + courseId + + ", systemIds='" + systemIds + '\'' + + ", projectId=" + projectId + + ", isShow=" + isShow + + ", systemAddress='" + systemAddress + '\'' + + '}'; + } } diff --git a/src/main/java/com/yipin/liuwanr/service/AssesmentRecordService.java b/src/main/java/com/yipin/liuwanr/service/AssesmentRecordService.java index 6f27470..5164b14 100644 --- a/src/main/java/com/yipin/liuwanr/service/AssesmentRecordService.java +++ b/src/main/java/com/yipin/liuwanr/service/AssesmentRecordService.java @@ -1,13 +1,12 @@ package com.yipin.liuwanr.service; -import java.util.HashMap; - +import com.yipin.liuwanr.mapper.AssesmentRecordMapper; +import com.yipin.liuwanr.vo.AssesmentRecordVo; import org.jboss.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.yipin.liuwanr.mapper.AssesmentRecordMapper; -import com.yipin.liuwanr.vo.AssesmentRecordVo; +import java.util.HashMap; @Service /** @@ -16,50 +15,52 @@ import com.yipin.liuwanr.vo.AssesmentRecordVo; * */ public class AssesmentRecordService { - - private static Logger logger = Logger.getLogger(AssesmentRecordService.class); - @Autowired - private AssesmentRecordMapper mapper; + private static Logger logger = Logger.getLogger(AssesmentRecordService.class); + + @Autowired + private AssesmentRecordMapper mapper; + + /** + * 根据课程id查询学生信息 + * + * @param studentId + * @param courseId + * @return + */ + public HashMap queryStudentAssessment(Integer studentId, Integer courseId) { + HashMap resp = new HashMap(); + AssesmentRecordVo vo = null; + try { + if (studentId != null && courseId != null) { + vo = mapper.getByStudentId(studentId, courseId);//学生信息 + Integer schoolHeight = mapper.getBySchool(courseId, studentId);//学校最高平均分 + if (schoolHeight != null) { + vo.setSchoolheightscore(schoolHeight); + } else { + vo.setSchoolheightscore(0); + } + AssesmentRecordVo vo1 = mapper.getByCountry(courseId);//全国信息 + if (vo1 != null) { + vo.setCountryavgscore(vo1.getCountryavgscore()); + vo.setCountryheightscore(vo1.getCountryheightscore()); + } else { + vo.setCountryavgscore(0.0); + vo.setCountryheightscore(0.0); + } + } + resp.put("retvalue", vo); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + System.out.println(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "考核记录信息查询失败"); + return resp; + } + return resp; + } - /** - * 根据课程id查询学生信息 - * @param studentId - * @param courseId - * @return - */ - public HashMap queryStudentAssessment(Integer studentId,Integer courseId){ - HashMap resp = new HashMap(); - AssesmentRecordVo vo=null; - try { - if(studentId!=null&&courseId!=null){ - vo=mapper.getByStudentId(studentId,courseId);//学生信息 - Integer schoolHeight=mapper.getBySchool(courseId,studentId);//学校最高平均分 - if(schoolHeight!=null) { - vo.setSchoolheightscore(schoolHeight); - }else { - vo.setSchoolheightscore(0); - } - AssesmentRecordVo vo1=mapper.getByCountry(courseId);//全国信息 - if(vo1!=null) { - vo.setCountryavgscore(vo1.getCountryavgscore()); - vo.setCountryheightscore(vo1.getCountryheightscore()); - }else { - vo.setCountryavgscore(0.0); - vo.setCountryheightscore(0.0); - } - } - resp.put("retvalue", vo); - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "考核记录信息查询失败"); - return resp; - } - return resp; - } - } diff --git a/src/main/java/com/yipin/liuwanr/vo/AssesmentRecordVo.java b/src/main/java/com/yipin/liuwanr/vo/AssesmentRecordVo.java index 41c550e..4d48b85 100644 --- a/src/main/java/com/yipin/liuwanr/vo/AssesmentRecordVo.java +++ b/src/main/java/com/yipin/liuwanr/vo/AssesmentRecordVo.java @@ -63,4 +63,15 @@ public class AssesmentRecordVo { this.countryheightscore = countryheightscore; } + @Override + public String toString() { + return "AssesmentRecordVo{" + + "studentName='" + studentName + '\'' + + ", heightscore=" + heightscore + + ", avgscore=" + avgscore + + ", schoolheightscore=" + schoolheightscore + + ", countryavgscore=" + countryavgscore + + ", countryheightscore=" + countryheightscore + + '}'; + } } diff --git a/src/test/java/com/yipin/liuwanr/AssesmentRecordServiceTest.java b/src/test/java/com/yipin/liuwanr/AssesmentRecordServiceTest.java new file mode 100644 index 0000000..7f0eca6 --- /dev/null +++ b/src/test/java/com/yipin/liuwanr/AssesmentRecordServiceTest.java @@ -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 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); + } + } +} diff --git a/src/test/java/com/yipin/liuwanr/ClassServiceTest.java b/src/test/java/com/yipin/liuwanr/ClassServiceTest.java index 7850a20..e705dbe 100644 --- a/src/test/java/com/yipin/liuwanr/ClassServiceTest.java +++ b/src/test/java/com/yipin/liuwanr/ClassServiceTest.java @@ -1,16 +1,12 @@ package com.yipin.liuwanr; -import com.yipin.liuwanr.entity.City; import com.yipin.liuwanr.entity.SutdentClass; -import com.yipin.liuwanr.mapper.CityMapper; -import com.yipin.liuwanr.service.CityService; 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 org.springframework.transaction.annotation.Transactional; import java.util.HashMap; import java.util.List; diff --git a/src/test/java/com/yipin/liuwanr/CoursePermissionsServiceTest.java b/src/test/java/com/yipin/liuwanr/CoursePermissionsServiceTest.java new file mode 100644 index 0000000..284868e --- /dev/null +++ b/src/test/java/com/yipin/liuwanr/CoursePermissionsServiceTest.java @@ -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 map = coursePermissionsService.addCoursePermissions(coursePermissions); + map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); + } + + /** + * 查询课程详情 + */ + @Test + public void testQueryCourseDetails() { + HashMap 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 classes = (List) 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 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 map = coursePermissionsService.updateCourse(course); + map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); + } + + /** + * 查询学科 + */ + @Test + public void testQueryCourseDiscipline() { + HashMap map = coursePermissionsService.queryCourseDiscipline(); + map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); + } + + /** + * 查询课程专业班级 + */ + @Test + public void testQueryCourseProfessionalClass() { + HashMap map = coursePermissionsService.queryCourseProfessionalClass(1); + map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); + } + + /** + * 查询课程专业 + */ + @Test + public void testQueryCourseProfessional() { + HashMap 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 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 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 map = coursePermissionsService.addTrainingConfig(course); + map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); + } + + /** + * 查询链接详情 + */ + @Test + public void queryLinkDetails() { + Integer linkId = 9; + HashMap 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 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 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 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 map = coursePermissionsService.isShelves(course); + map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); + } + +}