| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.utils.page.BeanUtils; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.domain.Agreement; |
| | | import com.ruoyi.system.domain.dto.AgreementDTO; |
| | | import com.ruoyi.system.mapper.AgreementMapper; |
| | | import com.ruoyi.system.service.IAgreementService; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Optional; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | |
| | | wrapper.eq(Agreement::getDelFlag,0); |
| | | return this.getOne(wrapper); |
| | | } |
| | | |
| | | /** |
| | | * 保存协议 |
| | | * |
| | | * @param dto 协议对象 |
| | | */ |
| | | @Override |
| | | public void saveAgreement(AgreementDTO dto) { |
| | | Optional<Agreement> agreementOpt = this.lambdaQuery() |
| | | .eq(Agreement::getAgreementType, dto.getAgreementType()).oneOpt(); |
| | | Agreement agreement; |
| | | if (agreementOpt.isPresent()) { |
| | | agreement = agreementOpt.get(); |
| | | agreement.setAgreementType(dto.getAgreementType()); |
| | | agreement.setAgreementContent(dto.getAgreementContent()); |
| | | agreement.setUpdateBy(SecurityUtils.getUsername()); |
| | | agreement.setUpdateTime(LocalDateTime.now()); |
| | | this.updateById(agreement); |
| | | } else { |
| | | agreement = BeanUtils.copyBean(dto, Agreement.class); |
| | | agreement.setCreateBy(SecurityUtils.getUsername()); |
| | | agreement.setCreateTime(LocalDateTime.now()); |
| | | this.save(agreement); |
| | | } |
| | | |
| | | } |
| | | } |