renkang
2025-01-24 d3767d594de66cb5f9d1294931acefea1866f783
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwTempConfigServiceImpl.java
@@ -1,10 +1,13 @@
package com.doumee.service.business.impl;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.YwTempConfigMapper;
import com.doumee.dao.business.dto.YwCallTempDataDTO;
import com.doumee.dao.business.model.YwTempConfig;
import com.doumee.dao.business.vo.YwCallTempDataVO;
import com.doumee.service.business.YwTempConfigService;
@@ -12,11 +15,14 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -182,6 +188,66 @@
    @Override
    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
    public void updTempConfig(YwCallTempDataDTO ywCallTempDataDTO){
        if(Objects.isNull(ywCallTempDataDTO)
            || Objects.isNull(ywCallTempDataDTO.getSmsTemp())
            || Objects.isNull(ywCallTempDataDTO.getEmailTemp())
            || Objects.isNull(ywCallTempDataDTO.getLeaseTemp())
            || Objects.isNull(ywCallTempDataDTO.getOtherTemp())
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        YwTempConfig smsTemp = ywCallTempDataDTO.getSmsTemp();
        if(Objects.isNull(smsTemp.getId())
            || Objects.isNull(smsTemp.getTitle())){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"短息模板参数错误");
        }
        ywTempConfigMapper.update(new UpdateWrapper<YwTempConfig>().lambda()
                .set(YwTempConfig::getTitle,smsTemp.getTitle())
                .eq(YwTempConfig::getId,smsTemp.getId())
        );
        YwTempConfig emailTemp = ywCallTempDataDTO.getEmailTemp();
        if(Objects.isNull(emailTemp.getId())
                || Objects.isNull(emailTemp.getTitle())){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"邮件模板参数错误");
        }
        ywTempConfigMapper.update(new UpdateWrapper<YwTempConfig>().lambda()
                .set(YwTempConfig::getTitle,emailTemp.getTitle())
                .eq(YwTempConfig::getId,emailTemp.getId())
        );
        YwTempConfig leasesTemp = ywCallTempDataDTO.getLeaseTemp();
        if(Objects.isNull(leasesTemp.getId())
                || Objects.isNull(leasesTemp.getTitle())
                || StringUtils.isBlank(leasesTemp.getUrl())
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"租赁通知单模板参数错误");
        }
        ywTempConfigMapper.update(new UpdateWrapper<YwTempConfig>().lambda()
                .set(YwTempConfig::getTitle,leasesTemp.getTitle())
                .set(YwTempConfig::getUrl,leasesTemp.getUrl())
                .eq(YwTempConfig::getId,leasesTemp.getId())
        );
        YwTempConfig otherTemp = ywCallTempDataDTO.getOtherTemp();
        if(Objects.isNull(otherTemp.getId())
                || Objects.isNull(otherTemp.getTitle())
                || StringUtils.isBlank(otherTemp.getUrl())
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"其他通知单模板参数错误");
        }
        ywTempConfigMapper.update(new UpdateWrapper<YwTempConfig>().lambda()
                .set(YwTempConfig::getTitle,otherTemp.getTitle())
                .set(YwTempConfig::getUrl,otherTemp.getUrl())
                .eq(YwTempConfig::getId,otherTemp.getId())
        );
    }