package com.ydtech.modules.protocol.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ydtech.exception.SystemException; import com.ydtech.modules.protocol.dao.PtlAgreementDeptMapper; import com.ydtech.modules.protocol.entity.po.PtlAgreementDept; import com.ydtech.modules.protocol.service.PtlAgreementDeptService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; /** * @author wenks * @description 针对表【ptl_agreement_dept(协议授权部门表)】的数据库操作Service实现 * @createDate 2023-07-03 09:31:16 */ @Service public class PtlAgreementDeptServiceImpl extends ServiceImpl implements PtlAgreementDeptService { @Override @Transactional public void saveBatchDept(String agreementId, List dept) { List ptlAgreementDeptList = PtlAgreementDept.toPtlAgreementDeptList(agreementId, dept); saveBatch(ptlAgreementDeptList); } @Override public List getByAgreementId(String agreementId) { return list(byAgreementId(agreementId)); } @Override public void deleteByAgreementId(String agreementId) { remove(byAgreementId(agreementId)); } @Override public void agreementIsAuthorized(String deptId, String agreementId) { List list = list(byAgreementId(agreementId).eq(PtlAgreementDept::getDeptId, deptId)); if (list.isEmpty()) { throw new SystemException("请联系团队长授权"); } } private LambdaQueryWrapper byAgreementId(String agreementId) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(PtlAgreementDept::getAgreementId, agreementId); return lambdaQueryWrapper; } }