|
@@ -0,0 +1,72 @@
|
|
|
+package com.management.platform.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.management.platform.entity.Participation;
|
|
|
+import com.management.platform.mapper.ParticipationMapper;
|
|
|
+import com.management.platform.mapper.ProjectMapper;
|
|
|
+import com.management.platform.mapper.UserMapper;
|
|
|
+import com.management.platform.service.ParticipationService;
|
|
|
+import com.management.platform.util.HttpRespMsg;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 人员参与项目的情况 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author 吴涛涛
|
|
|
+ * @since 2020-02-12
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ParticipationServiceImpl extends ServiceImpl<ParticipationMapper, Participation> implements ParticipationService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private UserMapper userMapper;
|
|
|
+ @Resource
|
|
|
+ private ProjectMapper projectMapper;
|
|
|
+ @Resource
|
|
|
+ private ParticipationMapper participationMapper;
|
|
|
+
|
|
|
+ //获取某个项目的所有参与者id
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getParticipation(Integer projectId, HttpServletRequest request) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ try {
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
+ if (projectMapper.selectById(projectId).getCompanyId().equals(companyId)) {
|
|
|
+ httpRespMsg.data = participationMapper.getParticipator(projectId);
|
|
|
+ } else {
|
|
|
+ httpRespMsg.setError("无法查看其他公司的项目");
|
|
|
+ }
|
|
|
+ } catch (NullPointerException e) {
|
|
|
+ httpRespMsg.setError("验证失败");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+ //编辑某个项目的参与者id
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg editParticipation(Integer projectId, String[] userIds, HttpServletRequest request) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ try {
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
+ if (projectMapper.selectById(projectId).getCompanyId().equals(companyId)) {
|
|
|
+ participationMapper.delete(new QueryWrapper<Participation>().eq("project_id", projectId));
|
|
|
+ for (String userId : userIds) {
|
|
|
+ participationMapper.insert(new Participation().setProjectId(projectId).setUserId(userId));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ httpRespMsg.setError("无法编辑其他公司的项目");
|
|
|
+ }
|
|
|
+ } catch (NullPointerException e) {
|
|
|
+ httpRespMsg.setError("验证失败");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+}
|