| | |
| | | package com.zt.life.modules.project.controller; |
| | | |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.zt.common.annotation.LogOperation; |
| | | import com.zt.common.constant.Constant; |
| | | import com.zt.common.annotation.QueryParam; |
| | |
| | | import com.zt.common.validator.group.AddGroup; |
| | | import com.zt.common.validator.group.DefaultGroup; |
| | | import com.zt.common.validator.group.UpdateGroup; |
| | | import com.zt.core.context.User; |
| | | import com.zt.core.context.UserContext; |
| | | import com.zt.core.sys.model.SysUser; |
| | | import com.zt.life.modules.project.dto.ProjectUserDto; |
| | | import com.zt.life.modules.project.model.Project; |
| | | import com.zt.life.modules.project.service.ProjectService; |
| | | import com.zt.modules.coderule.service.SysCodeRuleService; |
| | | import com.zt.modules.sys.service.SysUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | | /** |
| | | * project |
| | | * |
| | | * @author zt generator |
| | | * @author zt generator |
| | | * @since 1.0.0 2023-11-07 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/project/") |
| | | @Api(tags="project") |
| | | @RequestMapping("/project/Project/") |
| | | @Api(tags = "project") |
| | | public class ProjectController { |
| | | @Autowired |
| | | private ProjectService projectService; |
| | | @Autowired |
| | | private SysCodeRuleService sysCodeRuleService; |
| | | |
| | | @Autowired |
| | | private SysUserService sysUserService; |
| | | |
| | | @GetMapping("page") |
| | | @ApiOperation("分页") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = Constant.Q.PAGE, value = Constant.QV.PAGE, required = true, dataType = Constant.QT.INT), |
| | | @ApiImplicitParam(name = Constant.Q.LIMIT, value = Constant.QV.LIMIT, required = true, dataType = Constant.QT.INT), |
| | | @ApiImplicitParam(name = Constant.Q.ORDER_FIELD, value = Constant.QV.ORDER_FIELD, dataType = Constant.QT.STRING), |
| | | @ApiImplicitParam(name = Constant.Q.ORDER, value = Constant.QV.ORDER, dataType = Constant.QT.STRING), |
| | | @ApiImplicitParam(name = "entrustUnitName", value = "委托单位名称", dataType = Constant.QT.STRING, format = "entrust_unit_name^LK"), @ApiImplicitParam(name = "developUnitName", value = "开发单位名称", dataType = Constant.QT.STRING, format = "develop_unit_name^LK"), @ApiImplicitParam(name = "software", value = "软件名称", dataType = Constant.QT.STRING, format = "software^LK"), @ApiImplicitParam(name = "code", value = "项目编号", dataType = Constant.QT.STRING, format = "CODE^LK"), @ApiImplicitParam(name = "identity", value = "项目标识", dataType = Constant.QT.STRING, format = "IDENTITY^LK"), @ApiImplicitParam(name = "criticalLevel", value = "关键等级", dataType = Constant.QT.STRING, format = "critical_level^EQ"), @ApiImplicitParam(name = "testLevel", value = "测试级别", dataType = Constant.QT.STRING, format = "test_level^EQ") }) |
| | | public PageResult<Project> page(@ApiIgnore @QueryParam QueryFilter queryFilter){ |
| | | |
| | | return PageResult.ok(projectService.page(queryFilter)); |
| | | @ApiImplicitParam(name = Constant.Q.PAGE, value = Constant.QV.PAGE, required = true, dataType = Constant.QT.INT), |
| | | @ApiImplicitParam(name = Constant.Q.LIMIT, value = Constant.QV.LIMIT, required = true, dataType = Constant.QT.INT), |
| | | @ApiImplicitParam(name = Constant.Q.ORDER_FIELD, value = Constant.QV.ORDER_FIELD, dataType = Constant.QT.STRING), |
| | | @ApiImplicitParam(name = Constant.Q.ORDER, value = Constant.QV.ORDER, dataType = Constant.QT.STRING), |
| | | @ApiImplicitParam(name = "softwareName", value = "软件名称", dataType = Constant.QT.STRING, format = "software_name^LK"), |
| | | @ApiImplicitParam(name = "secretClass", value = "密级", dataType = Constant.QT.STRING, format = "secret_class^EQ"), |
| | | @ApiImplicitParam(name = "criticalLevel", value = "关键等级", dataType = Constant.QT.STRING, format = "critical_level^EQ"), |
| | | @ApiImplicitParam(name = "softwareType", value = "软件类型", dataType = Constant.QT.STRING, format = "software_type^EQ"), |
| | | @ApiImplicitParam(name = "isContract", value = "是否签署合同", dataType = Constant.QT.STRING, format = "is_contract^EQ"), |
| | | @ApiImplicitParam(name = "tableName", value = "功能表", dataType = Constant.QT.STRING), |
| | | @ApiImplicitParam(name = "pageCode", value = "页面标识", dataType = Constant.QT.STRING), |
| | | }) |
| | | public PageResult<Project> page(@ApiIgnore @QueryParam QueryFilter queryFilter) { |
| | | if (queryFilter.getParams().containsValue("baseline_release") || queryFilter.getParams().containsValue("config_item_warehouse") || queryFilter.getParams().containsValue("test_review_comment")) { |
| | | queryFilter.getParams().replace("tableName", ""); |
| | | } |
| | | List<Project> Project = projectService.page(queryFilter); |
| | | for (Project project2 :Project){ |
| | | String leaderName = project2.getProjectLeader(); |
| | | if (leaderName.length()>10){ |
| | | leaderName=sysUserService.getNames(leaderName); |
| | | } |
| | | project2.setProjectLeader(leaderName); |
| | | } |
| | | return PageResult.ok(Project); |
| | | } |
| | | |
| | | @GetMapping("{id}") |
| | | @ApiOperation("信息") |
| | | public Result<Project> get(@PathVariable("id") Long id){ |
| | | public Result<Project> get(@PathVariable("id") Long id) { |
| | | Project data = projectService.get(id); |
| | | |
| | | if (data.getBizDeptId() == null) { |
| | | data.setBizDeptId(UserContext.getDeptId().toString()); |
| | | } |
| | | User user = UserContext.getUser(); |
| | | Integer secretClass = user.getSecretClass(); |
| | | data.setUsersecretClass(secretClass); |
| | | return Result.ok(data); |
| | | } |
| | | |
| | | @PostMapping |
| | | @ApiOperation("新增") |
| | | @LogOperation("新增") |
| | | public Result insert(@RequestBody Project project){ |
| | | public Result insert(@RequestBody Project project) { |
| | | //效验数据 |
| | | ValidatorUtils.validateEntity(project, AddGroup.class, DefaultGroup.class); |
| | | projectService.insert(project); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); |
| | | String year = sdf.format(new Date()); |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("funCode", "project"); |
| | | map.put("year", year); |
| | | project.setYear(year); |
| | | project.setCode(sysCodeRuleService.getNewCode(map)); |
| | | |
| | | projectService.insert(project); |
| | | return Result.ok(); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation("修改") |
| | | @LogOperation("修改") |
| | | public Result update(@RequestBody Project project){ |
| | | public Result update(@RequestBody Project project) { |
| | | //效验数据 |
| | | ValidatorUtils.validateEntity(project, UpdateGroup.class, DefaultGroup.class); |
| | | projectService.update(project); |
| | | |
| | | return Result.ok(); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @DeleteMapping("deleteProject") |
| | | @ApiOperation("删除") |
| | | @LogOperation("删除") |
| | | public Result delete(@RequestBody Long[] ids){ |
| | | public Result delete(@RequestBody Long[] ids) { |
| | | //效验数据 |
| | | AssertUtils.isArrayEmpty(ids, "id"); |
| | | projectService.delete(ids); |
| | |
| | | return Result.ok(); |
| | | } |
| | | |
| | | @GetMapping("getUsersLists") |
| | | @ApiOperation("返回用户列表") |
| | | @LogOperation("返回用户列表") |
| | | public Result<ProjectUserDto> getUsersLists(String deptId) { |
| | | ProjectUserDto projectUserDto = new ProjectUserDto(); |
| | | projectUserDto.setZrr(sysUserService.getUsersList("zrr", deptId)); |
| | | projectUserDto.setCsry(sysUserService.getUsersList("csry", deptId)); |
| | | projectUserDto.setShry(sysUserService.getUsersList("shry", deptId)); |
| | | projectUserDto.setPzry(sysUserService.getUsersList("pzry", deptId)); |
| | | return Result.ok(projectUserDto); |
| | | } |
| | | |
| | | } |