|
@@ -1,14 +1,20 @@
|
|
package com.management.platform.service.impl;
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.management.platform.entity.Project;
|
|
import com.management.platform.entity.Project;
|
|
|
|
+import com.management.platform.entity.Report;
|
|
import com.management.platform.mapper.ProjectMapper;
|
|
import com.management.platform.mapper.ProjectMapper;
|
|
|
|
+import com.management.platform.mapper.ReportMapper;
|
|
import com.management.platform.service.ProjectService;
|
|
import com.management.platform.service.ProjectService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.management.platform.util.HttpRespMsg;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
- * 服务实现类
|
|
|
|
|
|
+ * 服务实现类
|
|
* </p>
|
|
* </p>
|
|
*
|
|
*
|
|
* @author 吴涛涛
|
|
* @author 吴涛涛
|
|
@@ -16,5 +22,47 @@ import org.springframework.stereotype.Service;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements ProjectService {
|
|
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements ProjectService {
|
|
|
|
+ @Resource
|
|
|
|
+ private ProjectMapper projectMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private ReportMapper reportMapper;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg getProjectList() {
|
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
+ httpRespMsg.data = projectMapper.selectList(new QueryWrapper<>());
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg editProject(Integer id, String name) {
|
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
+ if (id == null) {
|
|
|
|
+ //新增项目
|
|
|
|
+ if (name == null) {
|
|
|
|
+ httpRespMsg.setError("请填写项目名称");
|
|
|
|
+ } else {
|
|
|
|
+ if (projectMapper.insert(new Project().setProjectName(name)) == 0) {
|
|
|
|
+ httpRespMsg.setError("操作失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //修改项目
|
|
|
|
+ if (projectMapper.updateById(new Project().setProjectName(name).setId(id)) == 0) {
|
|
|
|
+ httpRespMsg.setError("操作失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg deleteProject(Integer id) {
|
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
+ if (reportMapper.selectCount(new QueryWrapper<Report>().eq("project_id", id)) > 0) {
|
|
|
|
+ httpRespMsg.setError("项目存在相关报告 无法删除");
|
|
|
|
+ } else if (projectMapper.deleteById(id) == 0) {
|
|
|
|
+ httpRespMsg.setError("操作失败");
|
|
|
|
+ }
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
}
|
|
}
|