【项目信息编辑】

This commit is contained in:
weizhihong 2022-10-12 18:08:07 +08:00
parent 9d070b43d5
commit 1089d2d410
3 changed files with 8 additions and 10 deletions

View File

@ -59,8 +59,8 @@ public class ProjectInfoController {
} }
@PutMapping("/setDefaultOrg") @PutMapping("/setDefaultOrg")
public void setProjectDefaultOrg(Long id, Long orgId) { public void setProjectDefaultOrg(@RequestBody Project project) {
projectService.setProjectDefaultOrg(id, orgId); projectService.setProjectDefaultOrg(project.getId(), project.getDefaultOrg());
} }
@GetMapping("/{id}/orgList") @GetMapping("/{id}/orgList")
@ -69,9 +69,9 @@ public class ProjectInfoController {
} }
@PostMapping("/{id}/createDefaultOrg") @PostMapping("/{id}/createDefaultOrg")
public ProjectInfoVO quickCreateDefaultOrg(@PathVariable Long id, String name public ProjectInfoVO quickCreateDefaultOrg(@PathVariable Long id, @RequestBody CompanyVO companyVO
, @RequestAttribute(AuthenticateInterceptor.LOGIN_USER_KEY) AccountVO user) { , @RequestAttribute(AuthenticateInterceptor.LOGIN_USER_KEY) AccountVO user) {
return projectService.quickCreateDefaultOrg(id, name, user); return projectService.quickCreateDefaultOrg(id, companyVO, user);
} }
@GetMapping("/viewSetting/page") @GetMapping("/viewSetting/page")

View File

@ -62,7 +62,7 @@ public interface ProjectService {
/** /**
* 快速创建默认组织 * 快速创建默认组织
*/ */
ProjectInfoVO quickCreateDefaultOrg(Long id, String name, AccountVO user); ProjectInfoVO quickCreateDefaultOrg(Long id, CompanyVO companyVO, AccountVO user);
/** /**
* 前端设置信息分页 * 前端设置信息分页

View File

@ -165,7 +165,7 @@ public class ProjectServiceImpl implements ProjectService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@CacheEvict(cacheNames = "project", allEntries = true) @CacheEvict(cacheNames = "project", allEntries = true)
public ProjectInfoVO quickCreateDefaultOrg(Long id, String name, AccountVO user) { public ProjectInfoVO quickCreateDefaultOrg(Long id, CompanyVO companyVO, AccountVO user) {
Project project = projectDAO.selectByPrimaryKey(id); Project project = projectDAO.selectByPrimaryKey(id);
if (project == null) { if (project == null) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "项目不存在"); throw new SimulationException(SimulationExceptionType.Illegal_Argument, "项目不存在");
@ -175,15 +175,13 @@ public class ProjectServiceImpl implements ProjectService {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "存在关联组织,请设置"); throw new SimulationException(SimulationExceptionType.Illegal_Argument, "存在关联组织,请设置");
} }
// 保存默认组织 // 保存默认组织
CompanyVO companyVO = new CompanyVO();
companyVO.setName(name);
companyVO.setProjectCodes(List.of(project.getCode())); companyVO.setProjectCodes(List.of(project.getCode()));
CompanyVO resultCompany = orgService.createTopOrg(companyVO, user); CompanyVO resultCompany = orgService.createTopOrg(companyVO, user);
// 修改项目信息 // 修改项目信息
setProjectDefaultOrg(id, resultCompany.getId()); setProjectDefaultOrg(id, resultCompany.getId());
ProjectInfoVO projectVO = new ProjectInfoVO(project); ProjectInfoVO projectVO = new ProjectInfoVO(project);
projectVO.setOrgList(List.of(name)); projectVO.setOrgList(List.of(resultCompany.getName()));
projectVO.setDefaultOrgName(name); projectVO.setDefaultOrgName(resultCompany.getName());
return projectVO; return projectVO;
} }