package com.newfiber.api.pc.service.impl; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.newfiber.api.pc.dao.SmsTemplatePhoneMapper; import com.newfiber.api.pc.dto.SmsTemplateDTO; import com.newfiber.api.pc.model.entity.SmsTemplatePhone; import com.newfiber.api.pc.service.SmsTemplatePhoneService; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; /** * @ClassName SmsTemplatePhoneSerivceImpl * @Description TODO * @Author 张鸿志 * @Date 2021年8月4日16:23:44 16:23 * Version 1.0 **/ @Service public class SmsTemplatePhoneSerivceImpl extends ServiceImpl<SmsTemplatePhoneMapper, SmsTemplatePhone> implements SmsTemplatePhoneService { @Override public boolean config(SmsTemplateDTO smsTemplateDTO) { EntityWrapper<SmsTemplatePhone> entityWrapper = new EntityWrapper<>(); entityWrapper.eq("phone",smsTemplateDTO.getPhone()); this.delete(entityWrapper); if(smsTemplateDTO.getSmsCode().size() == 0){ return true; } List<SmsTemplatePhone> list = new ArrayList<>(); for (String smsCode : smsTemplateDTO.getSmsCode()) { SmsTemplatePhone smsTemplatePhone = new SmsTemplatePhone(); smsTemplatePhone.setPhone(smsTemplateDTO.getPhone()); smsTemplatePhone.setUserName(smsTemplateDTO.getUserName()); smsTemplatePhone.setSmsTemplateCode(smsCode); list.add(smsTemplatePhone); } return this.insertBatch(list); } }