提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.report.service.goview; |
H |
2 |
|
|
3 |
import com.iailab.framework.common.enums.CommonStatusEnum; |
|
4 |
import com.iailab.framework.common.pojo.PageParam; |
|
5 |
import com.iailab.framework.common.pojo.PageResult; |
|
6 |
import com.iailab.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; |
|
7 |
import com.iailab.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; |
|
8 |
import com.iailab.module.report.convert.goview.GoViewProjectConvert; |
|
9 |
import com.iailab.module.report.dal.dataobject.goview.GoViewProjectDO; |
|
10 |
import com.iailab.module.report.dal.mysql.goview.GoViewProjectMapper; |
|
11 |
import org.springframework.stereotype.Service; |
|
12 |
import org.springframework.validation.annotation.Validated; |
|
13 |
|
|
14 |
import javax.annotation.Resource; |
|
15 |
|
|
16 |
import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
17 |
import static com.iailab.module.report.enums.ErrorCodeConstants.GO_VIEW_PROJECT_NOT_EXISTS; |
|
18 |
|
|
19 |
/** |
|
20 |
* GoView 项目 Service 实现类 |
|
21 |
* |
|
22 |
* @author iailab |
|
23 |
*/ |
|
24 |
@Service |
|
25 |
@Validated |
|
26 |
public class GoViewProjectServiceImpl implements GoViewProjectService { |
|
27 |
|
|
28 |
@Resource |
|
29 |
private GoViewProjectMapper goViewProjectMapper; |
|
30 |
|
|
31 |
@Override |
|
32 |
public Long createProject(GoViewProjectCreateReqVO createReqVO) { |
|
33 |
// 插入 |
|
34 |
GoViewProjectDO goViewProject = GoViewProjectConvert.INSTANCE.convert(createReqVO) |
|
35 |
.setStatus(CommonStatusEnum.DISABLE.getStatus()); |
|
36 |
goViewProjectMapper.insert(goViewProject); |
|
37 |
// 返回 |
|
38 |
return goViewProject.getId(); |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public void updateProject(GoViewProjectUpdateReqVO updateReqVO) { |
|
43 |
// 校验存在 |
|
44 |
validateProjectExists(updateReqVO.getId()); |
|
45 |
// 更新 |
|
46 |
GoViewProjectDO updateObj = GoViewProjectConvert.INSTANCE.convert(updateReqVO); |
|
47 |
goViewProjectMapper.updateById(updateObj); |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
public void deleteProject(Long id) { |
|
52 |
// 校验存在 |
|
53 |
validateProjectExists(id); |
|
54 |
// 删除 |
|
55 |
goViewProjectMapper.deleteById(id); |
|
56 |
} |
|
57 |
|
|
58 |
private void validateProjectExists(Long id) { |
|
59 |
if (goViewProjectMapper.selectById(id) == null) { |
|
60 |
throw exception(GO_VIEW_PROJECT_NOT_EXISTS); |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public GoViewProjectDO getProject(Long id) { |
|
66 |
return goViewProjectMapper.selectById(id); |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public PageResult<GoViewProjectDO> getMyProjectPage(PageParam pageReqVO, Long userId) { |
|
71 |
return goViewProjectMapper.selectPage(pageReqVO, userId); |
|
72 |
} |
|
73 |
|
|
74 |
} |