|
|
@@ -0,0 +1,175 @@
|
|
|
+package com.storlead.trade.controller;
|
|
|
+
|
|
|
+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.result.Result;
|
|
|
+import com.storlead.trade.dto.MarketingCampaignSopDetailDTO;
|
|
|
+import com.storlead.trade.entity.MarketingCampaignSopDetailEntity;
|
|
|
+import com.storlead.trade.service.MarketingCampaignSopDetailService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 营销活动SOP明细 Controller
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/marketing/campaign/sop-detail")
|
|
|
+@Api(tags = "营销: 营销活动SOP详情明细")
|
|
|
+public class MarketingCampaignSopDetailController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private MarketingCampaignSopDetailService marketingCampaignSopDetailService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id查询详情
|
|
|
+ */
|
|
|
+ @GetMapping("/get/{id}")
|
|
|
+ @ApiOperation(value = "根据id查询营销活动SOP明细详情", notes = "根据主键id查询详情")
|
|
|
+ public Result<Object> getById(@PathVariable Long id) {
|
|
|
+ MarketingCampaignSopDetailEntity entity = marketingCampaignSopDetailService.getById(id);
|
|
|
+ if (entity == null) {
|
|
|
+ return Result.error("数据不存在");
|
|
|
+ }
|
|
|
+ return Result.result(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询
|
|
|
+ */
|
|
|
+ @PostMapping("/list")
|
|
|
+ @ApiOperation(value = "分页查询营销活动SOP明细", notes = "支持按营销活动id筛选")
|
|
|
+ public Result<Object> list(@RequestBody MarketingCampaignSopDetailDTO dto) {
|
|
|
+ Page<MarketingCampaignSopDetailEntity> page = new Page<>(dto.getPageIndex(), dto.getPageSize());
|
|
|
+ LambdaQueryWrapper<MarketingCampaignSopDetailEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ // 按营销活动id筛选
|
|
|
+ if (!ObjectUtils.isEmpty(dto.getMarketingCampaignId())) {
|
|
|
+ wrapper.eq(MarketingCampaignSopDetailEntity::getMarketingCampaignId, dto.getMarketingCampaignId());
|
|
|
+ }
|
|
|
+ // 按SOP明细id筛选
|
|
|
+ if (!ObjectUtils.isEmpty(dto.getSopDetailId())) {
|
|
|
+ wrapper.eq(MarketingCampaignSopDetailEntity::getSopDetailId, dto.getSopDetailId());
|
|
|
+ }
|
|
|
+ // 按步骤序号筛选
|
|
|
+ if (!ObjectUtils.isEmpty(dto.getStep())) {
|
|
|
+ wrapper.eq(MarketingCampaignSopDetailEntity::getStep, dto.getStep());
|
|
|
+ }
|
|
|
+ // 按触达渠道筛选
|
|
|
+ if (!ObjectUtils.isEmpty(dto.getType())) {
|
|
|
+ wrapper.eq(MarketingCampaignSopDetailEntity::getType, dto.getType());
|
|
|
+ }
|
|
|
+ // 按创建时间倒序
|
|
|
+ wrapper.orderByDesc(MarketingCampaignSopDetailEntity::getCreateTime);
|
|
|
+ // 分页查询
|
|
|
+ IPage<MarketingCampaignSopDetailEntity> iPage = marketingCampaignSopDetailService.page(page, wrapper);
|
|
|
+ return Result.result(iPage);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增
|
|
|
+ */
|
|
|
+ @PostMapping("/add")
|
|
|
+ @ApiOperation(value = "新增营销活动SOP明细", notes = "支持单条新增")
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
+ public Result<?> add(@RequestBody MarketingCampaignSopDetailDTO dto) {
|
|
|
+ if (ObjectUtils.isEmpty(dto.getMarketingCampaignId())) {
|
|
|
+ return Result.error("营销活动id不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isEmpty(dto.getSopDetailId())) {
|
|
|
+ return Result.error("SOP明细id不能为空");
|
|
|
+ }
|
|
|
+ MarketingCampaignSopDetailEntity entity = new MarketingCampaignSopDetailEntity();
|
|
|
+ BeanUtils.copyProperties(dto, entity);
|
|
|
+ boolean isOk = marketingCampaignSopDetailService.save(entity);
|
|
|
+ if (!isOk) {
|
|
|
+ return Result.error("添加失败");
|
|
|
+ }
|
|
|
+ return Result.result(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量新增
|
|
|
+ */
|
|
|
+ @PostMapping("/add/batch")
|
|
|
+ @ApiOperation(value = "批量新增营销活动SOP明细", notes = "支持批量新增")
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
+ public Result<?> addBatch(@RequestBody List<MarketingCampaignSopDetailDTO> dtoList) {
|
|
|
+ if (CollectionUtils.isEmpty(dtoList)) {
|
|
|
+ return Result.error("数据不能为空");
|
|
|
+ }
|
|
|
+ List<MarketingCampaignSopDetailEntity> entityList = new ArrayList<>();
|
|
|
+ for (MarketingCampaignSopDetailDTO dto : dtoList) {
|
|
|
+ MarketingCampaignSopDetailEntity entity = new MarketingCampaignSopDetailEntity();
|
|
|
+ BeanUtils.copyProperties(dto, entity);
|
|
|
+ entityList.add(entity);
|
|
|
+ }
|
|
|
+ boolean isOk = marketingCampaignSopDetailService.saveBatch(entityList);
|
|
|
+ if (!isOk) {
|
|
|
+ return Result.error("批量添加失败");
|
|
|
+ }
|
|
|
+ return Result.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ */
|
|
|
+ @PostMapping("/edit")
|
|
|
+ @ApiOperation(value = "编辑营销活动SOP明细", notes = "编辑营销活动SOP明细")
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
+ public Result<?> edit(@RequestBody MarketingCampaignSopDetailDTO dto) {
|
|
|
+ if (ObjectUtils.isEmpty(dto.getId())) {
|
|
|
+ return Result.error("id不能为空");
|
|
|
+ }
|
|
|
+ MarketingCampaignSopDetailEntity entity = new MarketingCampaignSopDetailEntity();
|
|
|
+ BeanUtils.copyProperties(dto, entity);
|
|
|
+ boolean isOk = marketingCampaignSopDetailService.updateById(entity);
|
|
|
+ if (!isOk) {
|
|
|
+ return Result.error("修改失败");
|
|
|
+ }
|
|
|
+ return Result.result(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ */
|
|
|
+ @PostMapping("/delete")
|
|
|
+ @ApiOperation(value = "删除营销活动SOP明细", notes = "支持单条id或批量idList删除")
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
+ public Result<?> delete(@RequestBody MarketingCampaignSopDetailDTO dto) {
|
|
|
+ boolean isOk = false;
|
|
|
+ Long id = dto.getId();
|
|
|
+ if (!ObjectUtils.isEmpty(id)) {
|
|
|
+ isOk = marketingCampaignSopDetailService.removeById(id);
|
|
|
+ }
|
|
|
+ List<Long> idList = dto.getIdList();
|
|
|
+ if (!CollectionUtils.isEmpty(idList)) {
|
|
|
+ isOk = marketingCampaignSopDetailService.removeByIds(idList);
|
|
|
+ }
|
|
|
+ if (!isOk) {
|
|
|
+ return Result.error("删除失败");
|
|
|
+ }
|
|
|
+ return Result.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据营销活动id查询SOP明细列表
|
|
|
+ */
|
|
|
+ @GetMapping("/campaign/{marketingCampaignId}")
|
|
|
+ @ApiOperation(value = "根据营销活动id查询SOP明细列表", notes = "查询该营销活动关联的所有SOP明细")
|
|
|
+ public Result<Object> getByCampaignId(@PathVariable Long marketingCampaignId) {
|
|
|
+ LambdaQueryWrapper<MarketingCampaignSopDetailEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(MarketingCampaignSopDetailEntity::getMarketingCampaignId, marketingCampaignId);
|
|
|
+ wrapper.orderByAsc(MarketingCampaignSopDetailEntity::getStep);
|
|
|
+ List<MarketingCampaignSopDetailEntity> list = marketingCampaignSopDetailService.list(wrapper);
|
|
|
+ return Result.result(list);
|
|
|
+ }
|
|
|
+}
|