项目列表修改 和创建实验的项目列表接口

master
mzh820631607 4 years ago
parent 8381216bf4
commit 02d4b20116
  1. 99
      src/main/java/com/yipin/liuwanr/controller/ProjectManagementController.java
  2. 26
      src/main/java/com/yipin/liuwanr/mapper/ProjectManagementMapper.java
  3. 41
      src/main/java/com/yipin/liuwanr/service/ProjectManagementService.java
  4. 2
      src/main/resources/application.properties
  5. 115
      src/test/java/com/yipin/liuwanr/Project_ManagementTest.java

@ -70,9 +70,7 @@ public class ProjectManagementController {
@ApiParam(name = "state", value = "项目状态(0、草稿箱 1、已发布)", required = false) @RequestParam(required = false) Integer state,
@ApiParam(name = "projectName", value = "项目名称", required = false) @RequestParam(required = false) String projectName,
@ApiParam(name = "systemId", value = "系统id", required = true) @RequestParam Integer systemId,
@ApiParam(name = "userId", value = "用户id", required = true) @RequestParam Integer userId,
@ApiParam(name = "pageNo", value = "第几页,页码", required = true) @RequestParam Integer pageNo,
@ApiParam(name = "pageSize", value = "每页展示的数据条数", required = true) @RequestParam Integer pageSize) {
@ApiParam(name = "userId", value = "用户id", required = true) @RequestParam Integer userId) {
Response resp = new Response();
ProjectManagement vo = new ProjectManagement();
if (null != projectPermissions) {
@ -93,7 +91,7 @@ public class ProjectManagementController {
if (null != userId) {
vo.setUserId(userId);
}
HashMap<String, Object> ret = service.queryAllManagements(vo, pageNo, pageSize);
HashMap<String, Object> ret = service.queryAllManagements(vo);
int status = (int) ret.get("retcode");
if (status == 200) {
resp.setStatus(status);
@ -104,6 +102,99 @@ public class ProjectManagementController {
}
return resp;
}
// /**
// * 首页面查询
// * <p>
// *
// * @param projectPermissions:权限
// * @param founder:创建人
// * @param state:状态
// * @param projectName:项目名称
// * @param systemId
// * @return
// */
// @ApiOperation(value = "项目管理列表", notes = "项目管理列表")
// @GetMapping("/queryAllManagements")
// Response queryAllManagements(
// @ApiParam(name = "projectPermissions", value = "项目权限(0、练习 1、考核 2、竞赛)", required = false) @RequestParam(required = false) Integer projectPermissions,
// @ApiParam(name = "founder", value = "项目创建人(0、系统 1、老师)", required = false) @RequestParam(required = false) Integer founder,
// @ApiParam(name = "state", value = "项目状态(0、草稿箱 1、已发布)", required = false) @RequestParam(required = false) Integer state,
// @ApiParam(name = "projectName", value = "项目名称", required = false) @RequestParam(required = false) String projectName,
// @ApiParam(name = "systemId", value = "系统id", required = true) @RequestParam Integer systemId,
// @ApiParam(name = "userId", value = "用户id", required = true) @RequestParam Integer userId,
// @ApiParam(name = "pageNo", value = "第几页,页码", required = true) @RequestParam Integer pageNo,
// @ApiParam(name = "pageSize", value = "每页展示的数据条数", required = true) @RequestParam Integer pageSize) {
// Response resp = new Response();
// ProjectManagement vo = new ProjectManagement();
// if (null != projectPermissions) {
// vo.setProjectPermissions(projectPermissions);
// }
// if (null != founder) {
// vo.setFounder(founder);
// }
// if (null != state) {
// vo.setState(state);
// }
// if (null != systemId) {
// vo.setSystemId(systemId);
// }
// if (null != projectName && projectName != "") {
// vo.setProjectName(projectName);
// }
// if (null != userId) {
// vo.setUserId(userId);
// }
// HashMap<String, Object> ret = service.queryAllManagements(vo, pageNo, pageSize);
// int status = (int) ret.get("retcode");
// if (status == 200) {
// resp.setStatus(status);
// resp.setMessage(ret.get("retvalue"));
// } else {
// resp.setStatus(status);
// resp.setErrmessage(ret.get("retvalue").toString());
// }
// return resp;
// }
/**
* 页面查询,排除练习
* <p>
*
* @param systemId
* @return
*/
@ApiOperation(value = "项目列表(排除练习)", notes = "项目列表(用于创建实验,排除练习项目)")
@GetMapping("/queryManagements")
Response queryManagements(
@ApiParam(name = "systemId", value = "系统id", required = true) @RequestParam(required = false) Integer systemId,
@ApiParam(name = "userId", value = "用户id", required = true) @RequestParam(required = false) Integer userId,
@ApiParam(name = "pageNo", value = "第几页,页码", required = true) @RequestParam Integer pageNo,
@ApiParam(name = "pageSize", value = "每页展示的数据条数", required = true) @RequestParam Integer pageSize) {
Response resp = new Response();
ProjectManagement vo = new ProjectManagement();
if (null != systemId) {
vo.setSystemId(systemId);
}
if (null != userId) {
vo.setUserId(userId);
}
HashMap<String, Object> ret = service.queryManagements(vo,pageNo,pageSize);
int status = (int) ret.get("retcode");
if (status == 200) {
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
}
return resp;
}
/**
* 批量删除

@ -52,7 +52,7 @@ public interface ProjectManagementMapper {
// " <if test='founder!=null'> and founder=#{founder}</if>",
// " <if test='userId!=null'> and (userId=#{userId} or founder = 0)</if>",
// " <if test='userId==null and founder!=null '> and founder=#{founder}</if>",//服务端跳项目管理
" <if test='userId!=null'> and userId=#{userId}</if>",//教师端,一开始进入项目管理,看见自己创建的和其他人看见的
" <if test='userId!=null'> and (userId=#{userId} or roleId not like '%3%')</if>",//教师端,一开始进入项目管理,看见自己创建的和其他人看见的
" <if test='founder!=null'> and founder=#{founder}</if>",//教师选择创建人为系统
// " <if test='userId!=null and founder==1'> and userId=#{userId}</if>",//教师选则创建人为老师
" <if test='state!=null'> and state=#{state}</if>",
@ -61,6 +61,30 @@ public interface ProjectManagementMapper {
" ORDER BY creationTime desc",
"</script>"})
List<ProjectManagement> queryManagements(ProjectManagement management);
// @Select({"<script>",
//// "select projectId,projectName,projectPermissions,founder,creationTime,state,knowledgePoints,experimentIntroduction from hr_project_management where isdel=0",
// "select * from hr_project_management where isdel=0",
// " <if test='projectPermissions!=null'> and projectPermissions=#{projectPermissions}</if>",
//// " <if test='founder!=null'> and founder=#{founder}</if>",
//// " <if test='userId!=null'> and (userId=#{userId} or founder = 0)</if>",
//// " <if test='userId==null and founder!=null '> and founder=#{founder}</if>",//服务端跳项目管理
// " <if test='userId!=null'> and userId=#{userId}</if>",//教师端,一开始进入项目管理,看见自己创建的和其他人看见的
// " <if test='founder!=null'> and founder=#{founder}</if>",//教师选择创建人为系统
//// " <if test='userId!=null and founder==1'> and userId=#{userId}</if>",//教师选则创建人为老师
// " <if test='state!=null'> and state=#{state}</if>",
// " <if test='systemId!=null'> and systemId=#{systemId}</if>",
// " <if test='projectName!=null'> and projectName like concat('%',#{projectName},'%')</if>",
// " ORDER BY creationTime desc",
// "</script>"})
// List<ProjectManagement> queryManagements(ProjectManagement management);
@Select({"<script>",
"select * from hr_project_management where isdel=0 and projectPermissions !=0",
" <if test='userId!=null'> and (userId=#{userId} or roleId not like '%3%')</if>",//教师端,一开始进入项目管理,看见自己创建的和其他人看见的
" <if test='systemId!=null'> and systemId=#{systemId}</if>",
" ORDER BY creationTime desc",
"</script>"})
List<ProjectManagement> queryManagementsExportTest(ProjectManagement management);
/**

@ -69,12 +69,12 @@ public class ProjectManagementService {
/**
* 分页查询+条件查询
* 条件查询
*
* @param vo
* @return
*/
public HashMap<String, Object> queryAllManagements(ProjectManagement vo, Integer pageNo, Integer pageSize) {
public HashMap<String, Object> queryManagements(ProjectManagement vo, Integer pageNo, Integer pageSize) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
//获取用户的角色信息
@ -93,7 +93,7 @@ public class ProjectManagementService {
}
PageHelper.startPage(pageNo, pageSize);
//条件查询
List<ProjectManagement> list = mapper.queryManagements(vo);
List<ProjectManagement> list = mapper.queryManagementsExportTest(vo);
PageInfo<ProjectManagement> info = new PageInfo<ProjectManagement>(list);
resp.put("retvalue", new PageResult(info.getTotal(), list));
resp.put("retcode", 200);
@ -105,6 +105,41 @@ public class ProjectManagementService {
}
return resp;
}
/**
* 分页查询+条件查询
*
* @param vo
* @return
*/
public HashMap<String, Object> queryAllManagements(ProjectManagement vo) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
//获取用户的角色信息
Integer roleId = mapper.queryRoleId(vo.getUserId());
if (null != roleId) {
//角色不对(学生没有权限)
if (roleId == 4) {
resp.put("retcode", 300);
resp.put("retvalue", "抱歉,您的权限不能访问该地址!");
return resp;
}
//角色等于管理员或者超级管理员
else if (roleId == 1 ) {
vo.setUserId(null);
}
}
//条件查询
List<ProjectManagement> list = mapper.queryManagements(vo);
resp.put("retvalue",list);
resp.put("retcode", 200);
} catch (Exception e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "Inquiry Failed");
return resp;
}
return resp;
}
/**

@ -6,6 +6,6 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jackson.default-property-inclusion=non-null
server.port=1010
server.servlet.context-path=
server.servlet.context-path=/project
logging.level.com.yipin.liuwanr.mapper=debug

@ -39,63 +39,64 @@ public class Project_ManagementTest {
/**
* 分页查询+条件查询
*/
@Test
public void testQueryAllManagements() {
Integer projectPermissions = null;
Integer founder = null;
Integer state = null;
String projectName = null;
Integer systemId = 1;
Integer userId = 4;
ProjectManagement vo = new ProjectManagement();
if (null != projectPermissions) {
vo.setProjectPermissions(projectPermissions);
}
if (null != founder) {
vo.setFounder(founder);
}
if (null != state) {
vo.setState(state);
}
if (null != systemId) {
vo.setSystemId(systemId);
}
if (null != projectName && projectName != "") {
vo.setProjectName(projectName);
}
if (null != userId) {
vo.setUserId(userId);
}
Integer pageNo = 1;
Integer pageSize = 10;
HashMap<String, Object> map = managementService.queryAllManagements(vo, pageNo, pageSize);
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<ProjectManagement> rows = (List<ProjectManagement>) pageResult.getRows();
rows.forEach(item -> {
System.out.println(item.toString());
});
} else {
String msg = (String) map.get("retvalue");
System.out.println(msg);
}
}
// @Test
// public void testQueryAllManagements() {
//
// Integer projectPermissions = null;
// Integer founder = null;
// Integer state = null;
// String projectName = null;
// Integer systemId = 1;
// Integer userId = 4;
//
// ProjectManagement vo = new ProjectManagement();
// if (null != projectPermissions) {
// vo.setProjectPermissions(projectPermissions);
// }
// if (null != founder) {
// vo.setFounder(founder);
// }
// if (null != state) {
// vo.setState(state);
// }
// if (null != systemId) {
// vo.setSystemId(systemId);
// }
// if (null != projectName && projectName != "") {
// vo.setProjectName(projectName);
// }
// if (null != userId) {
// vo.setUserId(userId);
// }
//
// Integer pageNo = 1;
// Integer pageSize = 10;
//
// HashMap<String, Object> map = managementService.queryAllManagements(vo);
//// HashMap<String, Object> map = managementService.queryAllManagements(vo, pageNo, pageSize);
//
// 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<ProjectManagement> rows = (List<ProjectManagement>) pageResult.getRows();
//
// rows.forEach(item -> {
// System.out.println(item.toString());
// });
//
// } else {
// String msg = (String) map.get("retvalue");
// System.out.println(msg);
// }
// }
/**

Loading…
Cancel
Save