update 功能安全中心成员-删除
This commit is contained in:
+4
-1
@@ -1,16 +1,19 @@
|
|||||||
package com.jero.functionalsafetycenter.mapper;
|
package com.jero.functionalsafetycenter.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.jero.functionalsafetycenter.entity.SafetyCenterSubitem;
|
import com.jero.functionalsafetycenter.entity.SafetyCenterSubitem;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author liJiaRao
|
* @author liJiaRao
|
||||||
* @date 2024-06-12 16:40
|
* @date 2024-06-12 16:40
|
||||||
*/
|
*/
|
||||||
public interface SafetyCenterSubitemMapper extends BaseMapper<SafetyCenterSubitem> {
|
public interface SafetyCenterSubitemMapper extends BaseMapper<SafetyCenterSubitem> {
|
||||||
IPage<SafetyCenterSubitem> pageList(Page<SafetyCenterSubitem> page, @Param("safetyCenterSubitem") SafetyCenterSubitem safetyCenterSubitem);
|
IPage<SafetyCenterSubitem> pageList(Page<SafetyCenterSubitem> page, @Param("safetyCenterSubitem") SafetyCenterSubitem safetyCenterSubitem);
|
||||||
|
|
||||||
|
List<SafetyCenterSubitem> listByParentIdAndCompanyId(@Param("parentId") String parentId, @Param("companyId") String companyId);
|
||||||
}
|
}
|
||||||
+10
@@ -30,4 +30,14 @@
|
|||||||
</where>
|
</where>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="listByParentIdAndCompanyId" resultMap="BaseResultMap">
|
||||||
|
select pfscs.*
|
||||||
|
from pay_functional_safety_center_subitem pfscs
|
||||||
|
left join pay_functional_safety_center pfsc on pfsc.id = pfscs.project_id
|
||||||
|
<where>
|
||||||
|
pfsc.parent_id = #{parentId}
|
||||||
|
and pfscs.company_id = #{companyId}
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
+12
-1
@@ -1,9 +1,14 @@
|
|||||||
package com.jero.functionalsafetycenter.service;
|
package com.jero.functionalsafetycenter.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.jero.functionalsafetycenter.entity.SafetyCenterSubitemContacts;
|
import com.jero.functionalsafetycenter.entity.SafetyCenterSubitemContacts;
|
||||||
import com.jero.functionalsafetycenter.mapper.SafetyCenterSubitemContactsMapper;
|
import com.jero.functionalsafetycenter.mapper.SafetyCenterSubitemContactsMapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*@author liJiaRao
|
*@author liJiaRao
|
||||||
@@ -11,5 +16,11 @@ import com.jero.functionalsafetycenter.mapper.SafetyCenterSubitemContactsMapper;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SafetyCenterSubitemContactsService extends ServiceImpl<SafetyCenterSubitemContactsMapper, SafetyCenterSubitemContacts> {
|
public class SafetyCenterSubitemContactsService extends ServiceImpl<SafetyCenterSubitemContactsMapper, SafetyCenterSubitemContacts> {
|
||||||
|
public void deleteBySubitemId(String subitemId){
|
||||||
|
LambdaQueryWrapper<SafetyCenterSubitemContacts> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SafetyCenterSubitemContacts::getSubitemId,subitemId);
|
||||||
|
List<SafetyCenterSubitemContacts> list = this.list(wrapper);
|
||||||
|
List<String> idList = list.stream().map(SafetyCenterSubitemContacts::getId).collect(Collectors.toList());
|
||||||
|
this.removeByIds(idList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+25
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.jero.common.exception.JeroBootException;
|
import com.jero.common.exception.JeroBootException;
|
||||||
|
import com.jero.functionalsafetycenter.common.SafetyCenterCommon;
|
||||||
import com.jero.functionalsafetycenter.entity.SafetyCenter;
|
import com.jero.functionalsafetycenter.entity.SafetyCenter;
|
||||||
import com.jero.functionalsafetycenter.entity.SafetyCenterSubitemContacts;
|
import com.jero.functionalsafetycenter.entity.SafetyCenterSubitemContacts;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -104,7 +105,21 @@ public class SafetyCenterSubitemService extends ServiceImpl<SafetyCenterSubitemM
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deleteById(String id) {
|
public void deleteById(String id) {
|
||||||
|
SafetyCenterSubitem subitem = this.getById(id);
|
||||||
|
String projectId = subitem.getProjectId();
|
||||||
|
SafetyCenter safetyCenter = safetyCenterService.getById(projectId);
|
||||||
|
Integer projectType = safetyCenter.getProjectType();
|
||||||
|
if (SafetyCenterCommon.PROJECT_TYPE_3 != projectType){
|
||||||
|
//删除下级同企业成员
|
||||||
|
List<SafetyCenterSubitem> subitemList = this.listByParentIdAndCompanyId(projectId, subitem.getCompanyId());
|
||||||
|
for (SafetyCenterSubitem safetyCenterSubitem : subitemList) {
|
||||||
|
deleteById(safetyCenterSubitem.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//删除成员
|
||||||
this.removeById(id);
|
this.removeById(id);
|
||||||
|
//删除联系人
|
||||||
|
contactsService.deleteBySubitemId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteByIds(List<String> idList) {
|
public void deleteByIds(List<String> idList) {
|
||||||
@@ -140,4 +155,14 @@ public class SafetyCenterSubitemService extends ServiceImpl<SafetyCenterSubitemM
|
|||||||
}
|
}
|
||||||
return pageList;
|
return pageList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据父项目id和企业id查询子项目中相同公司的成员
|
||||||
|
* @param parentId
|
||||||
|
* @param companyId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<SafetyCenterSubitem> listByParentIdAndCompanyId(String parentId,String companyId){
|
||||||
|
return baseMapper.listByParentIdAndCompanyId(parentId,companyId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user