|
|
@@ -0,0 +1,101 @@
|
|
|
+package com.storlead.trade.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.storlead.framework.common.constant.CommonConstant;
|
|
|
+import com.storlead.framework.common.result.Result;
|
|
|
+import com.storlead.framework.mybatis.service.impl.MyBaseServiceImpl;
|
|
|
+import com.storlead.trade.dto.MarketEmailsDTO;
|
|
|
+import com.storlead.trade.entity.MarketEmailsEntity;
|
|
|
+import com.storlead.trade.mapper.MarketEmailsMapper;
|
|
|
+import com.storlead.trade.service.MarketEmailsService;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMapper, MarketEmailsEntity>
|
|
|
+ implements MarketEmailsService {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result<Object> getList(MarketEmailsDTO dto) {
|
|
|
+ Page<MarketEmailsEntity> page = new Page<>(dto.getPageIndex(), dto.getPageSize());
|
|
|
+ LambdaQueryWrapper<MarketEmailsEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0);
|
|
|
+ wrapper.orderByDesc(MarketEmailsEntity::getCreateTime);
|
|
|
+
|
|
|
+ if (!ObjectUtils.isEmpty(dto.getId())) {
|
|
|
+ wrapper.eq(MarketEmailsEntity::getId, dto.getId());
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(dto.getCustomerAnalysisId())) {
|
|
|
+ wrapper.eq(MarketEmailsEntity::getCustomerAnalysisId, dto.getCustomerAnalysisId());
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(dto.getMarketingCampaignId())) {
|
|
|
+ wrapper.eq(MarketEmailsEntity::getMarketingCampaignId, dto.getMarketingCampaignId());
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(dto.getSopDetailId())) {
|
|
|
+ wrapper.eq(MarketEmailsEntity::getSopDetailId, dto.getSopDetailId());
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(dto.getEmailId())) {
|
|
|
+ wrapper.eq(MarketEmailsEntity::getEmailId, dto.getEmailId());
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(dto.getStatus())) {
|
|
|
+ wrapper.eq(MarketEmailsEntity::getStatus, dto.getStatus());
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(dto.getHasReader())) {
|
|
|
+ wrapper.eq(MarketEmailsEntity::getHasReader, dto.getHasReader());
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(dto.getHasReply())) {
|
|
|
+ wrapper.eq(MarketEmailsEntity::getHasReply, dto.getHasReply());
|
|
|
+ }
|
|
|
+
|
|
|
+ IPage<MarketEmailsEntity> iPage = this.page(page, wrapper);
|
|
|
+ List<MarketEmailsEntity> records = iPage.getRecords();
|
|
|
+ if (CollectionUtils.isEmpty(records)) {
|
|
|
+ records = new ArrayList<>();
|
|
|
+ }
|
|
|
+ Page<MarketEmailsEntity> pageVO = new Page<>();
|
|
|
+ pageVO.setRecords(records);
|
|
|
+ pageVO.setTotal(iPage.getTotal());
|
|
|
+ pageVO.setCurrent(iPage.getCurrent());
|
|
|
+ pageVO.setSize(iPage.getSize());
|
|
|
+
|
|
|
+ return Result.result(pageVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
+ public Result<Object> add(MarketEmailsDTO dto) {
|
|
|
+ MarketEmailsEntity entity = new MarketEmailsEntity();
|
|
|
+ BeanUtils.copyProperties(dto, entity);
|
|
|
+ boolean isOk = this.save(entity);
|
|
|
+ if (!isOk) {
|
|
|
+ return Result.error("添加失败");
|
|
|
+ }
|
|
|
+ return Result.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
+ public Result<Object> edit(MarketEmailsDTO dto) {
|
|
|
+ if (ObjectUtils.isEmpty(dto.getId())) {
|
|
|
+ return Result.error("id不能为空");
|
|
|
+ }
|
|
|
+ MarketEmailsEntity entity = this.getById(dto.getId());
|
|
|
+ if (ObjectUtils.isEmpty(entity)) {
|
|
|
+ return Result.error("记录不存在");
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(dto, entity);
|
|
|
+ boolean isOk = this.updateById(entity);
|
|
|
+ if (!isOk) {
|
|
|
+ return Result.error("修改失败");
|
|
|
+ }
|
|
|
+ return Result.ok();
|
|
|
+ }
|
|
|
+}
|