feat(pms): 添加日志注解并优化代码
- 在 ProjectDemandController、ProjectVersionController 和 WorkHourController 中添加了 @Log 注解,用于记录操作日志- 优化了 ProjectDemandServiceImpl 和 ProjectVersionServiceImpl 中的代码结构,提高了代码复用性 -修复了 WorkHourController 中的空指针异常问题dev_1.2.0
parent
86c262ed4d
commit
b5f0c88db3
|
@ -7,9 +7,11 @@ import org.springframework.web.bind.annotation.*;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import tech.unissense.pms.common.annotation.Log;
|
||||
import tech.unissense.pms.common.core.controller.BaseController;
|
||||
import tech.unissense.pms.common.core.domain.AjaxResult;
|
||||
import tech.unissense.pms.common.core.page.TableDataInfo;
|
||||
import tech.unissense.pms.common.enums.BusinessType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -44,6 +46,7 @@ public class ProjectDemandController extends BaseController {
|
|||
|
||||
|
||||
@PostMapping("/insert")
|
||||
@Log(title = "需求管理", businessType = BusinessType.INSERT)
|
||||
public AjaxResult add(@RequestBody ProjectDemand projectDemand) {
|
||||
return toAjax(projectDemandService.insert(projectDemand));
|
||||
}
|
||||
|
@ -51,6 +54,7 @@ public class ProjectDemandController extends BaseController {
|
|||
|
||||
@ApiOperation("编辑数据")
|
||||
@PutMapping("/update")
|
||||
@Log(title = "需求管理", businessType = BusinessType.UPDATE)
|
||||
public AjaxResult edit(@RequestBody ProjectDemand projectDemand) {
|
||||
return toAjax(projectDemandService.update(projectDemand));
|
||||
}
|
||||
|
@ -58,6 +62,7 @@ public class ProjectDemandController extends BaseController {
|
|||
|
||||
@ApiOperation("删除数据")
|
||||
@DeleteMapping("/{id}")
|
||||
@Log(title = "需求管理", businessType = BusinessType.DELETE)
|
||||
public AjaxResult remove(@PathVariable("id") Integer id) {
|
||||
return toAjax(projectDemandService.deleteById(id));
|
||||
}
|
||||
|
@ -67,6 +72,7 @@ public class ProjectDemandController extends BaseController {
|
|||
*/
|
||||
@ApiOperation(value = "批量删除")
|
||||
@DeleteMapping("/remove/batch/{ids}")
|
||||
@Log(title = "需求管理", businessType = BusinessType.DELETE)
|
||||
public AjaxResult batchRemove(@PathVariable("ids") Integer[] ids) {
|
||||
return AjaxResult.success(projectDemandService.batchRemove(ids));
|
||||
}
|
||||
|
|
|
@ -7,9 +7,11 @@ import tech.unissense.pms.business.version.service.IProjectVersionService;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import tech.unissense.pms.common.annotation.Log;
|
||||
import tech.unissense.pms.common.core.controller.BaseController;
|
||||
import tech.unissense.pms.common.core.domain.AjaxResult;
|
||||
import tech.unissense.pms.common.core.page.TableDataInfo;
|
||||
import tech.unissense.pms.common.enums.BusinessType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -49,6 +51,7 @@ public class ProjectVersionController extends BaseController {
|
|||
|
||||
@ApiOperation("新增数据")
|
||||
@PostMapping("/insert")
|
||||
@Log(title = "版本管理", businessType = BusinessType.INSERT)
|
||||
public AjaxResult add(@RequestBody ProjectVersion projectVersion) {
|
||||
return toAjax(projectVersionService.insert(projectVersion));
|
||||
}
|
||||
|
@ -56,6 +59,7 @@ public class ProjectVersionController extends BaseController {
|
|||
|
||||
@ApiOperation("编辑数据")
|
||||
@PutMapping("/update")
|
||||
@Log(title = "需求管理", businessType = BusinessType.UPDATE)
|
||||
public AjaxResult edit(@RequestBody ProjectVersion projectVersion) {
|
||||
return toAjax(projectVersionService.update(projectVersion));
|
||||
}
|
||||
|
@ -63,6 +67,7 @@ public class ProjectVersionController extends BaseController {
|
|||
|
||||
@ApiOperation("删除数据")
|
||||
@DeleteMapping("/{id}")
|
||||
@Log(title = "需求管理", businessType = BusinessType.DELETE)
|
||||
public AjaxResult remove(@PathVariable("id") Integer id) {
|
||||
return toAjax(projectVersionService.deleteById(id));
|
||||
}
|
||||
|
@ -72,6 +77,7 @@ public class ProjectVersionController extends BaseController {
|
|||
*/
|
||||
@ApiOperation(value = "批量删除")
|
||||
@DeleteMapping("/remove/batch/{ids}")
|
||||
@Log(title = "需求管理", businessType = BusinessType.DELETE)
|
||||
public AjaxResult batchRemove(@PathVariable("ids") Integer[] ids) {
|
||||
return AjaxResult.success(projectVersionService.batchRemove(ids));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package tech.unissense.pms.web.controller.business.work;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import tech.unissense.pms.business.project.domain.Project;
|
||||
|
@ -34,6 +35,7 @@ public class WorkHourController extends BaseController {
|
|||
@PostMapping("/add")
|
||||
@Log(title = "工作日志", businessType = BusinessType.INSERT)
|
||||
public AjaxResult addData(@RequestBody WorkLogger workLogger) {
|
||||
Assert.notNull(workLogger.getProjectId(), "项目不能为空");
|
||||
service.insert(workLogger);
|
||||
return success();
|
||||
}
|
||||
|
|
|
@ -72,9 +72,9 @@ public class ProjectDemandServiceImpl implements IProjectDemandService {
|
|||
if (project == null) {
|
||||
throw new ServiceException("项目不存在");
|
||||
}
|
||||
if (Project.ProjectStateEnum.JXZ.value().equals(project.getProjectState())) {
|
||||
throw new ServiceException("项目不处于进行中");
|
||||
}
|
||||
// if (Project.ProjectStateEnum.JXZ.value().equals(project.getProjectState())) {
|
||||
// throw new ServiceException("项目不处于进行中");
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -78,18 +78,7 @@ public class ProjectVersionServiceImpl implements IProjectVersionService {
|
|||
List<ProjectVersion> projectVersions = projectVersionMapper.queryAll(projectVersion);
|
||||
|
||||
// 构建需求查询参数(根据项目ID)
|
||||
ProjectDemand param = new ProjectDemand();
|
||||
param.setProjectId(projectVersion.getProjectId());
|
||||
if (projectVersion.getUserId() != null) {
|
||||
param.setResponsiblePerson(projectVersion.getUserId());
|
||||
}
|
||||
if (projectVersion.getQueryDate() != null) {
|
||||
param.setQueryDate(projectVersion.getQueryDate());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(projectVersion.getDemandStatusList())) {
|
||||
param.setDemandStatusList(projectVersion.getDemandStatusList());
|
||||
}
|
||||
List<ProjectDemand> allDemands = demandService.queryAll(param);
|
||||
List<ProjectDemand> allDemands = getProjectDemands(projectVersion);
|
||||
// 过滤出未关联版本的根需求(versionId为null的需求)
|
||||
List<ProjectDemand> rootDemands = allDemands.stream()
|
||||
.filter(d -> d.getVersionId() == null)
|
||||
|
@ -133,6 +122,21 @@ public class ProjectVersionServiceImpl implements IProjectVersionService {
|
|||
return versionTreeVoList;
|
||||
}
|
||||
|
||||
private List<ProjectDemand> getProjectDemands(ProjectVersion projectVersion) {
|
||||
ProjectDemand param = new ProjectDemand();
|
||||
param.setProjectId(projectVersion.getProjectId());
|
||||
if (projectVersion.getUserId() != null) {
|
||||
param.setResponsiblePerson(projectVersion.getUserId());
|
||||
}
|
||||
if (projectVersion.getQueryDate() != null) {
|
||||
param.setQueryDate(projectVersion.getQueryDate());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(projectVersion.getDemandStatusList())) {
|
||||
param.setDemandStatusList(projectVersion.getDemandStatusList());
|
||||
}
|
||||
return demandService.queryAll(param);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue