master
mzh820631607 4 years ago
parent d190715ffa
commit 2cdb8658e0
  1. 15
      pom.xml
  2. 2
      src/main/java/com/yipin/liuwanr/controller/ProjectManagementController.java
  3. 20
      src/main/java/com/yipin/liuwanr/mapper/ProjectManagementMapper.java
  4. 68
      src/test/java/com/yipin/liuwanr/Project_ManagementTest.java

@ -30,11 +30,11 @@
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.2</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.mybatis.spring.boot</groupId>-->
<!-- <artifactId>mybatis-spring-boot-starter</artifactId>-->
<!-- <version>2.1.2</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
@ -95,6 +95,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>3.4.1</version>
</dependency>
</dependencies>
<build>

@ -53,7 +53,7 @@ public class ProjectManagementController {
/**
* 首页面查询
* <p>
* <p>updateProjectManagement
*
* @param projectPermissions:权限
* @param founder:创建人

@ -26,7 +26,7 @@ public interface ProjectManagementMapper {
* @param projectName
* @return
*/
@Select("select count(*) from hr_project_management where projectName=#{projectName}")
@Select("select count(*) from hr_project_management where projectName=#{projectName} and isdel = 0")
Integer getByprojectName(String projectName);
/**
@ -103,7 +103,7 @@ public interface ProjectManagementMapper {
* @param projectId
* @return
*/
@Select("select projectId,projectName,projectPermissions,experimentalGoal,caseDescription,experimentSuggests,state,isstartexperimental,isstartexperimentSuggests,userId,knowledgePoints,experimentIntroduction from hr_project_management where isdel=0 and projectId=#{projectId}")
@Select("select knowledgePointsIsEnable,experimentIntroductionIsEnable,isstartexperimentSuggests,projectId,projectName,projectPermissions,experimentalGoal,caseDescription,experimentSuggests,state,isstartexperimental,isstartexperimentSuggests,userId,knowledgePoints,experimentIntroduction from hr_project_management where isdel=0 and projectId=#{projectId}")
ProjectManagement getProjectId(Integer projectId);
/**
@ -164,10 +164,14 @@ public interface ProjectManagementMapper {
* @param ids
* @param projectId
*/
@Update("<script>" +
"<foreach collection = 'ids' item ='id' open='' close='' separator=';'>"
+ "update hr_role set projectId=#{projectId} where roleId=#{ids}</foreach>"
+ "</script>")
// @Update("<script>" +
// "<foreach collection = 'ids' item ='id' open='' close='' separator=';'>"
// + "update hr_role set projectId=#{projectId} where roleId=#{ids}</foreach>"
// + "</script>")
@Update({"<script>" +
"update hr_role set projectId=#{projectId} where roleId in" +
"<foreach collection = 'ids' item ='id' open='(' close=')' separator=','>#{id}</foreach>" +
"</script>"})
void updateRoleProjectId(@Param("ids") List<Integer> ids, @Param("projectId") Integer projectId);
@ -277,8 +281,8 @@ public interface ProjectManagementMapper {
*
* @param management
*/
@Insert("INSERT INTO hr_project_management(projectName,projectPermissions,experimentalGoal,caseDescription,experimentSuggests,state,founder,systemId,creationTime,isstartexperimental,isstartexperimentSuggests,userId,knowledgePoints,experimentIntroduction,knowledgePointsIsEnable,experimentIntroductionIsEnable)"
+ " VALUES (#{projectName},#{projectPermissions},#{experimentalGoal},#{caseDescription},#{experimentSuggests},#{state},#{founder},#{systemId},now(),#{isstartexperimental},#{isstartexperimentSuggests},#{userId},#{knowledgePoints},#{experimentIntroduction},#{knowledgePointsIsEnable},#{experimentIntroductionIsEnable})")
@Insert("INSERT INTO hr_project_management(roleId,projectName,projectPermissions,experimentalGoal,caseDescription,experimentSuggests,state,founder,systemId,creationTime,isstartexperimental,isstartexperimentSuggests,userId,knowledgePoints,experimentIntroduction,knowledgePointsIsEnable,experimentIntroductionIsEnable)"
+ " VALUES (#{founder},#{projectName},#{projectPermissions},#{experimentalGoal},#{caseDescription},#{experimentSuggests},#{state},#{founder},#{systemId},now(),#{isstartexperimental},#{isstartexperimentSuggests},#{userId},#{knowledgePoints},#{experimentIntroduction},#{knowledgePointsIsEnable},#{experimentIntroductionIsEnable})")
@Options(useGeneratedKeys = true, keyProperty = "projectId", keyColumn = "projectId")
void insertProjectManagement(ProjectManagement management);

@ -223,40 +223,40 @@ public class Project_ManagementTest {
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
/**
* 添加项目管理信息
*/
@Transactional //在单元测试中 Transaction注解会对数据库的更新(insert update delete)进行回滚 ,以保证数据不污染
@Test
public void testInsertProjectManagement() {
/*ProjectManagement pro = new ProjectManagement();
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<Judgment_Points> points = new ArrayList<>();
Judgment_Points judgmentPoints = new Judgment_Points();
judgmentPoints.setJudgmentPointsId(205);
judgmentPoints.setExperimentalRequirements("按要求写出代码并正确运行显示小明考核结果");
judgmentPoints.setScore(100);
points.add(judgmentPoints);
List<Integer> roles = new ArrayList<>();
roles.add(433);*/
ProjectManagement pro = projectManagementMapper.getProjectId(302);
pro.setProjectId(null);
pro.setFounder(0);
List<Judgment_Points> points = projectManagementMapper.queryProjectIds(302);
List<Integer> roles = projectManagementMapper.getByRoleProjectId(302);
HashMap<String, Object> map = managementService.insertProjectManagement(pro, points, roles);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
// /**
// * 添加项目管理信息
// */
// @Transactional //在单元测试中 Transaction注解会对数据库的更新(insert update delete)进行回滚 ,以保证数据不污染
// @Test
// public void testInsertProjectManagement() {
// /*ProjectManagement pro = new ProjectManagement();
// 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<Judgment_Points> points = new ArrayList<>();
// Judgment_Points judgmentPoints = new Judgment_Points();
// judgmentPoints.setJudgmentPointsId(205);
// judgmentPoints.setExperimentalRequirements("按要求写出代码并正确运行显示小明考核结果");
// judgmentPoints.setScore(100);
// points.add(judgmentPoints);
// List<Integer> roles = new ArrayList<>();
// roles.add(433);*/
// ProjectManagement pro = projectManagementMapper.getProjectId(302);
// pro.setProjectId(null);
// pro.setFounder(0);
// List<Judgment_Points> points = projectManagementMapper.queryProjectIds(302);
// List<Integer> roles = projectManagementMapper.getByRoleProjectId(302);
// HashMap<String, Object> map = managementService.insertProjectManagement(pro, points, roles);
// map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
// }
/**

Loading…
Cancel
Save