diff --git a/src/main/java/com/yipin/liuwanr/entity/Judgment_Points.java b/src/main/java/com/yipin/liuwanr/entity/Judgment_Points.java index f6cc41c..46ec6d8 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Judgment_Points.java +++ b/src/main/java/com/yipin/liuwanr/entity/Judgment_Points.java @@ -106,5 +106,18 @@ public class Judgment_Points { this.isdel = isdel; } - + @Override + public String toString() { + return "Judgment_Points{" + + "judgmentPointsId=" + judgmentPointsId + + ", judgmentPointsName='" + judgmentPointsName + '\'' + + ", experimentalRequirements='" + experimentalRequirements + '\'' + + ", projectId='" + projectId + '\'' + + ", judgmentPointsType=" + judgmentPointsType + + ", isdel=" + isdel + + ", systemId=" + systemId + + ", userId=" + userId + + ", score=" + score + + '}'; + } } diff --git a/src/main/java/com/yipin/liuwanr/entity/Role.java b/src/main/java/com/yipin/liuwanr/entity/Role.java index a2cc14f..eb4242b 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Role.java +++ b/src/main/java/com/yipin/liuwanr/entity/Role.java @@ -65,4 +65,14 @@ public class Role implements Serializable { this.roleAttribute = roleAttribute; } + @Override + public String toString() { + return "Role{" + + "roleId=" + roleId + + ", roleName='" + roleName + '\'' + + ", roleNumber=" + roleNumber + + ", roleType=" + roleType + + ", roleAttribute=" + roleAttribute + + '}'; + } } diff --git a/src/main/java/com/yipin/liuwanr/service/Project_ManagementService.java b/src/main/java/com/yipin/liuwanr/service/Project_ManagementService.java index 70efe93..2480e4c 100644 --- a/src/main/java/com/yipin/liuwanr/service/Project_ManagementService.java +++ b/src/main/java/com/yipin/liuwanr/service/Project_ManagementService.java @@ -459,6 +459,7 @@ public class Project_ManagementService { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Add Failed"); + System.out.println(e.getMessage()); throw new RuntimeException(); } return resp; diff --git a/src/test/java/com/yipin/liuwanr/Project_ManagementTest.java b/src/test/java/com/yipin/liuwanr/Project_ManagementTest.java index aa7d009..8babec7 100644 --- a/src/test/java/com/yipin/liuwanr/Project_ManagementTest.java +++ b/src/test/java/com/yipin/liuwanr/Project_ManagementTest.java @@ -1,14 +1,13 @@ package com.yipin.liuwanr; import com.yipin.liuwanr.entity.*; +import com.yipin.liuwanr.mapper.Project_ManagementMapper; import com.yipin.liuwanr.service.Project_ManagementService; -import io.swagger.annotations.ApiParam; 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.bind.annotation.RequestParam; import java.util.ArrayList; import java.util.HashMap; @@ -20,16 +19,21 @@ public class Project_ManagementTest { @Autowired private Project_ManagementService managementService; + @Autowired + private Project_ManagementMapper projectManagementMapper; + /** * 查询用户角色信息 */ @Test public void testQueryRole() { - int userid = 455; + Integer userid = 455; HashMap map = managementService.queryRole(userid); - map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value)); + map.forEach((key, value) -> { + System.out.println("key = " + key + " ===> value = " + value.toString()); + }); } /** @@ -69,10 +73,28 @@ public class Project_ManagementTest { Integer pageSize = 10; HashMap map = managementService.queryAllManagements(vo, pageNo, pageSize); - map.forEach((key, value) -> { - System.out.println("key = " + key + " ===> value = " + value); - }); + Integer retcode = (Integer) map.get("retcode"); + + System.out.println(retcode); + + if (retcode == 200) { + PageResult pageResult = (PageResult) map.get("retvalue"); + + Long total = pageResult.getTotal(); + + System.out.println("total = " + total); + + List rows = (List) pageResult.getRows(); + + rows.forEach(item -> { + System.out.println(item.toString()); + }); + + } else { + String msg = (String) map.get("retvalue"); + System.out.println(msg); + } } @@ -85,7 +107,7 @@ public class Project_ManagementTest { List point = new ArrayList<>(); point.add(1); HashMap map = managementService.deleteProjectManagement(point); - map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value)); + map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); } /** @@ -93,9 +115,9 @@ public class Project_ManagementTest { */ @Test public void testGetProjectId() { - Integer projectId = null; + Integer projectId = 299; HashMap map = managementService.getProjectId(projectId); - map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value)); + map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); } /** @@ -103,9 +125,21 @@ public class Project_ManagementTest { */ @Test public void testQueryAllJudgmentPoints() { - Judgment_Points points = null; + Judgment_Points points = new Judgment_Points(); + points.setSystemId(1); + points.setJudgmentPointsName(""); HashMap map = managementService.queryAllJudgmentPoints(points); - map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value)); + Integer retcode = (Integer) map.get("retcode"); + System.out.println(retcode); + if (retcode == 200) { + List list = (List) map.get("retvalue"); + list.forEach(item -> { + System.out.println(item.toString()); + }); + } else { + String msg = (String) map.get("retvalue"); + System.out.println(msg); + } } @@ -114,11 +148,22 @@ public class Project_ManagementTest { */ @Test public void testGetByjudgmentPointsId() { - List judgmentPointsId = null; - Integer projectId = null; - Integer userId = null; + List judgmentPointsId = new ArrayList<>(); + judgmentPointsId.add(187); + Integer projectId = 1; + Integer userId = 4; HashMap map = managementService.getByjudgmentPointsId(judgmentPointsId, projectId, userId); - map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value)); + Integer retcode = (Integer) map.get("retcode"); + System.out.println(retcode); + if (retcode == 200) { + List list = (List) map.get("retvalue"); + list.forEach(item -> { + System.out.println(item.toString()); + }); + } else { + String msg = (String) map.get("retvalue"); + System.out.println(msg); + } } /** @@ -126,7 +171,7 @@ public class Project_ManagementTest { */ @Test public void testAvgValues() { - Integer number = null; + Integer number = 66; HashMap map = managementService.avgValues(number); map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value)); } @@ -136,9 +181,10 @@ public class Project_ManagementTest { */ @Test public void testGetByRoleId() { - List roleId = null; + List roleId = new ArrayList<>(); + roleId.add(235); HashMap map = managementService.getByRoleId(roleId); - map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value)); + map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); } /** @@ -146,9 +192,17 @@ public class Project_ManagementTest { */ @Test public void testUpdateRole() { - Role role = null; + + List list = new ArrayList<>(); + list.add(235); + + List roleList = projectManagementMapper.getByRoleId(list); + Role role = roleList.get(0); + role.setRoleName("hh"); + //System.out.println(role.toString());//Role{roleId=235, roleName='null', roleNumber=1, roleType=1, roleAttribute=1} + HashMap map = managementService.updateRole(role); - map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value)); + map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); } /** @@ -156,9 +210,16 @@ public class Project_ManagementTest { */ @Test public void testInsertRole() { - Role role = null; + List list = new ArrayList<>(); + list.add(235); + + List roleList = projectManagementMapper.getByRoleId(list); + Role role = roleList.get(0); + role.setRoleId(null); + role.setRoleName("hh"); + HashMap map = managementService.insertRole(role); - map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value)); + map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); } /** @@ -167,14 +228,34 @@ public class Project_ManagementTest { @Transactional @Test public void testInsertProjectManagement() { - Project_Management pro = null; - List points = null; - List roles = null; + Project_Management pro = new Project_Management(); + pro.setProjectName("简单加法计算"); + pro.setProjectPermissions(1); + pro.setExperimentalGoal("本项目将会帮助学生了解简单的加法计算"); + pro.setCaseDescription("声明两个变量,让其相加,得到其和"); + pro.setIsstartexperimental(0); + pro.setExperimentSuggests("使用加号,将声明的变量相加"); + pro.setIsstartexperimentSuggests(0); + pro.setState(1); + pro.setSystemId(6); + pro.setUserId(4); + pro.setFounder(0); + List points = new ArrayList<>(); + Judgment_Points judgmentPoints = new Judgment_Points(); + judgmentPoints.setJudgmentPointsId(153); + judgmentPoints.setExperimentalRequirements("声明两个变量,让其相加,得到其和....."); + judgmentPoints.setScore(100); + points.add(judgmentPoints); + List roles = new ArrayList<>(); + roles.add(120); HashMap map = managementService.insertProjectManagement(pro, points, roles); map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value)); } + /** + * 根据项目名称查询 + */ @Test public void testGetByName() { String projectName = null;