PtlAgreementDeptServiceImpl.java 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package com.ydtech.modules.protocol.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4. import com.ydtech.exception.SystemException;
  5. import com.ydtech.modules.protocol.dao.PtlAgreementDeptMapper;
  6. import com.ydtech.modules.protocol.entity.po.PtlAgreementDept;
  7. import com.ydtech.modules.protocol.service.PtlAgreementDeptService;
  8. import org.springframework.stereotype.Service;
  9. import org.springframework.transaction.annotation.Transactional;
  10. import java.util.List;
  11. /**
  12. * @author wenks
  13. * @description 针对表【ptl_agreement_dept(协议授权部门表)】的数据库操作Service实现
  14. * @createDate 2023-07-03 09:31:16
  15. */
  16. @Service
  17. public class PtlAgreementDeptServiceImpl extends ServiceImpl<PtlAgreementDeptMapper, PtlAgreementDept>
  18. implements PtlAgreementDeptService {
  19. @Override
  20. @Transactional
  21. public void saveBatchDept(String agreementId, List<String> dept) {
  22. List<PtlAgreementDept> ptlAgreementDeptList = PtlAgreementDept.toPtlAgreementDeptList(agreementId, dept);
  23. saveBatch(ptlAgreementDeptList);
  24. }
  25. @Override
  26. public List<PtlAgreementDept> getByAgreementId(String agreementId) {
  27. return list(byAgreementId(agreementId));
  28. }
  29. @Override
  30. public void deleteByAgreementId(String agreementId) {
  31. remove(byAgreementId(agreementId));
  32. }
  33. @Override
  34. public void agreementIsAuthorized(String deptId, String agreementId) {
  35. List<PtlAgreementDept> list = list(byAgreementId(agreementId).eq(PtlAgreementDept::getDeptId, deptId));
  36. if (list.isEmpty()) {
  37. throw new SystemException("请联系团队长授权");
  38. }
  39. }
  40. private LambdaQueryWrapper<PtlAgreementDept> byAgreementId(String agreementId) {
  41. LambdaQueryWrapper<PtlAgreementDept> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  42. lambdaQueryWrapper.eq(PtlAgreementDept::getAgreementId, agreementId);
  43. return lambdaQueryWrapper;
  44. }
  45. }