diff --git a/admin/src/main/java/com/baiye/modules/distribute/controller/ClueController.java b/admin/src/main/java/com/baiye/modules/distribute/controller/ClueController.java index 1d0d4f8..b76405e 100644 --- a/admin/src/main/java/com/baiye/modules/distribute/controller/ClueController.java +++ b/admin/src/main/java/com/baiye/modules/distribute/controller/ClueController.java @@ -27,8 +27,8 @@ public class ClueController { private final ClueService clueService; - private final ApplicationContext publisher; + @GetMapping("/page") @Operation(summary = "分页查询资源") public R> getClueRecordPage(@Validated PageParam pageParam, ClueQo qo) { diff --git a/admin/src/main/java/com/baiye/modules/distribute/controller/PushLinkController.java b/admin/src/main/java/com/baiye/modules/distribute/controller/PushLinkController.java index 39e49a1..bc4824a 100644 --- a/admin/src/main/java/com/baiye/modules/distribute/controller/PushLinkController.java +++ b/admin/src/main/java/com/baiye/modules/distribute/controller/PushLinkController.java @@ -1,17 +1,21 @@ package com.baiye.modules.distribute.controller; +import com.baiye.domain.PageParam; +import com.baiye.domain.PageResult; import com.baiye.modules.distribute.dto.PushLinkDTO; +import com.baiye.modules.distribute.qo.PushLinkQo; import com.baiye.modules.distribute.service.PushLinkService; +import com.baiye.modules.distribute.vo.PushLinkVO; +import com.baiye.result.BaseResultCode; import com.baiye.result.R; +import com.baiye.security.util.SecurityUtils; import com.baiye.validation.group.CreateGroup; +import com.baiye.validation.group.UpdateGroup; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RequiredArgsConstructor @RestController @@ -21,10 +25,23 @@ public class PushLinkController { private final PushLinkService pushLinkService; + @GetMapping("/page") + @Operation(summary = "分页查询") + public R> getClueRecordPage(@Validated PageParam pageParam, PushLinkQo qo) { + qo.setCreateBy(SecurityUtils.getCurrentUserId()); + return R.ok(pushLinkService.queryPage(pageParam, qo)); + } + @PostMapping("/add") @Operation(summary = "新增(生成)链接", description = "新增(生成)链接") public R save(@Validated({ CreateGroup.class }) @RequestBody PushLinkDTO pushLinkDTO) { return R.ok(pushLinkService.add(pushLinkDTO)); } + @PostMapping("/update") + @Operation(summary = "修改链接", description = "修改链接") + public R update(@Validated({UpdateGroup.class}) @RequestBody PushLinkDTO pushLinkDTO) { + return pushLinkService.update(pushLinkDTO) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "修改失败"); + } + } diff --git a/admin/src/main/java/com/baiye/modules/distribute/converter/PushLinkConverter.java b/admin/src/main/java/com/baiye/modules/distribute/converter/PushLinkConverter.java new file mode 100644 index 0000000..108ce1f --- /dev/null +++ b/admin/src/main/java/com/baiye/modules/distribute/converter/PushLinkConverter.java @@ -0,0 +1,20 @@ +package com.baiye.modules.distribute.converter; + +import com.baiye.modules.distribute.dto.PushLinkDTO; +import com.baiye.modules.distribute.entity.PushLinkEntity; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface PushLinkConverter { + + PushLinkConverter INSTANCE = Mappers.getMapper(PushLinkConverter.class); + + /** + * 修改DTO 转 PO + * @param dto 修改DTO + * @return ClueEntity PO + */ + PushLinkEntity dtoToPo(PushLinkDTO dto); + +} diff --git a/admin/src/main/java/com/baiye/modules/distribute/dto/DBPushClueDTO.java b/admin/src/main/java/com/baiye/modules/distribute/dto/DBPushClueDTO.java index a69c010..3f4b0f7 100644 --- a/admin/src/main/java/com/baiye/modules/distribute/dto/DBPushClueDTO.java +++ b/admin/src/main/java/com/baiye/modules/distribute/dto/DBPushClueDTO.java @@ -1,63 +1,27 @@ package com.baiye.modules.distribute.dto; -import cn.hutool.json.JSONArray; import lombok.Data; @Data public class DBPushClueDTO { - private String app_id; - - private Long startTime; - - private Long endTime; - - private String recId; - - private Long ringTime; - - private Long talkTime; - - private String wordId; - - private Integer notConnectStatus; - - private Long actId; - - private String actType; - - private String batchId; - + /** + * 手机号 + */ private String mobile; - private String extAccount; - - private String jobNumber; - - private String actName; - - private String audioUrl; - - private String clientTypeName; - + /** + * 人工评级 + */ private String empClientTypeName; - private JSONArray audioText; - - private Integer sender; - - private String context; - - private String tag; - - private String sms_content; - - private Integer sms_status; - + /** + * 备注 + */ private String remark; /** - * 人工审核推送手机号, mobile就不是手机号字段了 + * 人工评级推送的手机号, mobile就不是手机号字段了 */ private String called; diff --git a/admin/src/main/java/com/baiye/modules/distribute/dto/PushLinkDTO.java b/admin/src/main/java/com/baiye/modules/distribute/dto/PushLinkDTO.java index 1c86a75..b575734 100644 --- a/admin/src/main/java/com/baiye/modules/distribute/dto/PushLinkDTO.java +++ b/admin/src/main/java/com/baiye/modules/distribute/dto/PushLinkDTO.java @@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import javax.validation.constraints.NotNull; +import java.util.List; @Data public class PushLinkDTO { @@ -22,7 +23,18 @@ public class PushLinkDTO { private String appKey; @Schema(title = "业务方、公司 用户ID") - @NotNull(message = "用户不能为空", groups = { CreateGroup.class }) private Long userId; + @Schema(title = "渠道标识") + private List channelIdentifyingList; + + @Schema(title = "渠道链接") + private String channelUrl; + + @Schema(title = "渠道类型(0-大坝,1-飞鱼,2-第三方)") + @NotNull(message = "请选择渠道类型", groups = { CreateGroup.class }) + private Integer channelType; + + @Schema(title = "状态(1-启用接收,0-拒绝接收)") + private Integer status; } diff --git a/admin/src/main/java/com/baiye/modules/distribute/entity/PushLinkEntity.java b/admin/src/main/java/com/baiye/modules/distribute/entity/PushLinkEntity.java index 94c1f8c..1436df9 100644 --- a/admin/src/main/java/com/baiye/modules/distribute/entity/PushLinkEntity.java +++ b/admin/src/main/java/com/baiye/modules/distribute/entity/PushLinkEntity.java @@ -1,6 +1,7 @@ package com.baiye.modules.distribute.entity; import com.baiye.entity.BaseEntity; +import com.baiye.extend.mybatis.plus.alias.TableAlias; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.v3.oas.annotations.media.Schema; @@ -11,6 +12,7 @@ import lombok.Setter; @Setter @TableName("tb_push_link") @Schema(title = "推送链接") +@TableAlias("pl") public class PushLinkEntity extends BaseEntity { private static final long serialVersionUID = 1L; @@ -31,4 +33,15 @@ public class PushLinkEntity extends BaseEntity { @Schema(title = "业务方、公司 用户ID") private Long userId; + @Schema(title = "渠道标识") + private String channelIdentifying; + + @Schema(title = "渠道链接") + private String channelUrl; + + @Schema(title = "渠道类型(0-大坝,1-飞鱼,2-第三方)") + private Integer channelType; + + @Schema(title = "状态(1-启用接收,0-拒绝接收)") + private Integer status; } diff --git a/admin/src/main/java/com/baiye/modules/distribute/mapper/PushLinkMapper.java b/admin/src/main/java/com/baiye/modules/distribute/mapper/PushLinkMapper.java index 908c19b..dc9f671 100644 --- a/admin/src/main/java/com/baiye/modules/distribute/mapper/PushLinkMapper.java +++ b/admin/src/main/java/com/baiye/modules/distribute/mapper/PushLinkMapper.java @@ -1,13 +1,40 @@ package com.baiye.modules.distribute.mapper; +import com.baiye.domain.PageParam; +import com.baiye.domain.PageResult; +import com.baiye.extend.mybatis.plus.conditions.query.LambdaAliasQueryWrapperX; import com.baiye.extend.mybatis.plus.mapper.ExtendMapper; +import com.baiye.extend.mybatis.plus.toolkit.WrappersX; import com.baiye.modules.distribute.entity.PushLinkEntity; +import com.baiye.modules.distribute.qo.PushLinkQo; +import com.baiye.modules.distribute.vo.PushLinkVO; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import org.apache.ibatis.annotations.Param; public interface PushLinkMapper extends ExtendMapper { + default PageResult queryPage(PageParam pageParam, PushLinkQo qo) { + IPage page = this.prodPage(pageParam); + + LambdaAliasQueryWrapperX wrapperX = WrappersX.lambdaAliasQueryX(PushLinkEntity.class); + wrapperX.likeIfPresent(PushLinkEntity::getName, qo.getName()) + .eqIfPresent(PushLinkEntity::getCreateBy, qo.getCreateBy()) + .eqIfPresent(PushLinkEntity::getChannelType, qo.getChannelType()); + + if (StringUtils.isNotBlank(qo.getStartTime()) && StringUtils.isNotBlank(qo.getEndTime())) { + wrapperX.between(PushLinkEntity::getCreateTime, qo.getStartTime(), qo.getEndTime()); + } + this.selectByPage(page, wrapperX); + return new PageResult<>(page.getRecords(), page.getTotal()); + } + + IPage selectByPage(IPage page, @Param(Constants.WRAPPER) Wrapper wrapper); + default PushLinkEntity selectByAppKey(String appKey) { return this.selectOne(Wrappers.lambdaQuery().eq(PushLinkEntity::getAppKey, appKey)); } - } diff --git a/admin/src/main/java/com/baiye/modules/distribute/qo/PushLinkQo.java b/admin/src/main/java/com/baiye/modules/distribute/qo/PushLinkQo.java new file mode 100644 index 0000000..0dd90d9 --- /dev/null +++ b/admin/src/main/java/com/baiye/modules/distribute/qo/PushLinkQo.java @@ -0,0 +1,24 @@ +package com.baiye.modules.distribute.qo; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class PushLinkQo { + + @Schema(title = "业务名") + private String name; + + @Schema(title = "渠道类型(0-大坝,1-飞鱼,2-第三方)") + private Integer channelType; + + @Schema(title = "创建者") + private Long createBy; + + @Parameter(description = "开始时间") + private String startTime; + + @Parameter(description = "结束时间") + private String endTime; +} diff --git a/admin/src/main/java/com/baiye/modules/distribute/service/PushLinkService.java b/admin/src/main/java/com/baiye/modules/distribute/service/PushLinkService.java index 947f67a..f96f9a8 100644 --- a/admin/src/main/java/com/baiye/modules/distribute/service/PushLinkService.java +++ b/admin/src/main/java/com/baiye/modules/distribute/service/PushLinkService.java @@ -1,11 +1,20 @@ package com.baiye.modules.distribute.service; +import com.baiye.domain.PageParam; +import com.baiye.domain.PageResult; import com.baiye.extend.mybatis.plus.service.ExtendService; import com.baiye.modules.distribute.dto.PushLinkDTO; import com.baiye.modules.distribute.entity.PushLinkEntity; +import com.baiye.modules.distribute.qo.PushLinkQo; +import com.baiye.modules.distribute.vo.PushLinkVO; public interface PushLinkService extends ExtendService { + /** + * 分页查询 + */ + PageResult queryPage(PageParam pageParam, PushLinkQo qo); + /** * 生成推送链接 */ @@ -16,4 +25,8 @@ public interface PushLinkService extends ExtendService { */ PushLinkEntity getByAppKey(String appKey); + /** + * 修改 + */ + boolean update(PushLinkDTO pushLinkDTO); } diff --git a/admin/src/main/java/com/baiye/modules/distribute/service/impl/PushLinkServiceImpl.java b/admin/src/main/java/com/baiye/modules/distribute/service/impl/PushLinkServiceImpl.java index 01af016..ca3119f 100644 --- a/admin/src/main/java/com/baiye/modules/distribute/service/impl/PushLinkServiceImpl.java +++ b/admin/src/main/java/com/baiye/modules/distribute/service/impl/PushLinkServiceImpl.java @@ -1,73 +1,102 @@ package com.baiye.modules.distribute.service.impl; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.json.JSONUtil; +import com.baiye.domain.PageParam; +import com.baiye.domain.PageResult; +import com.baiye.exception.BadRequestException; import com.baiye.extend.mybatis.plus.service.impl.ExtendServiceImpl; +import com.baiye.modules.distribute.converter.PushLinkConverter; import com.baiye.modules.distribute.dto.PushLinkDTO; -import com.baiye.modules.distribute.entity.ClueRecordEntity; import com.baiye.modules.distribute.entity.PushLinkEntity; import com.baiye.modules.distribute.mapper.PushLinkMapper; -import com.baiye.modules.distribute.service.ClueRecordService; -import com.baiye.modules.distribute.service.DistributeTaskService; +import com.baiye.modules.distribute.qo.PushLinkQo; import com.baiye.modules.distribute.service.PushLinkService; +import com.baiye.modules.distribute.vo.PushLinkVO; import com.baiye.properties.UrlsProperties; import com.baiye.security.util.SecurityUtils; import com.baiye.util.AppUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; import lombok.RequiredArgsConstructor; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Collections; +import java.util.List; @Service @RequiredArgsConstructor public class PushLinkServiceImpl extends ExtendServiceImpl implements PushLinkService { - private final ClueRecordService clueRecordService; - private final UrlsProperties urlsProperties; - private final DistributeTaskService distributeTaskService; + @Override + public PageResult queryPage(PageParam pageParam, PushLinkQo qo) { + PageResult pushLinkVOPageResult = baseMapper.queryPage(pageParam, qo); + + List records = pushLinkVOPageResult.getRecords(); + if (CollUtil.isNotEmpty(records)){ + for (PushLinkVO record : records) { + if (StringUtils.isNotBlank(record.getChannelIdentifying())){ + record.setChannelIdentifyingList(JSONUtil.parseArray(record.getChannelIdentifying())); + record.setChannelIdentifying(""); + } + } + } + return pushLinkVOPageResult; + } @Override @Transactional(rollbackFor = Exception.class) public String add(PushLinkDTO pushLinkDTO) { - String dtoName = pushLinkDTO.getName(); + Long currentUserId = SecurityUtils.getCurrentUserId(); + String name = pushLinkDTO.getName(); + Integer channelType = pushLinkDTO.getChannelType(); String dbPushUrl = urlsProperties.getDbPushUrl(); - Long userId = pushLinkDTO.getUserId(); + PushLinkEntity pushLinkEntity = PushLinkConverter.INSTANCE.dtoToPo(pushLinkDTO); - PushLinkEntity pushLinkEntity = baseMapper.selectOne(new LambdaQueryWrapper().eq(PushLinkEntity::getUserId, userId)); - if (pushLinkEntity != null) { - dbPushUrl = dbPushUrl.concat(pushLinkEntity.getAppKey()).concat("?dataType=detail&encrypt=1"); + PushLinkEntity linkEntity = baseMapper.selectOne(new LambdaQueryWrapper() + .eq(PushLinkEntity::getName, name) + .eq(PushLinkEntity::getCreateBy, currentUserId)); + if (ObjectUtil.isNotNull(linkEntity)) throw new BadRequestException("渠道名称重复,请重新输入"); + + String appKey = AppUtils.getAppId(); + while (true) { + PushLinkEntity entity = baseMapper.selectOne(new LambdaQueryWrapper().eq(PushLinkEntity::getAppKey, appKey)); + if (ObjectUtil.isNull(entity)) break; + appKey = AppUtils.getAppId(); } - else { - // 生成的appKey标识重复,重新生成 - String appKey = AppUtils.getAppId(); - while (true) { - PushLinkEntity entity = baseMapper.selectOne(new LambdaQueryWrapper().eq(PushLinkEntity::getAppKey, appKey)); - if (entity == null) break; - appKey = AppUtils.getAppId(); - } + + // 大坝推送接口参数拼接 + if (channelType == 0){ dbPushUrl = dbPushUrl.concat(appKey).concat("?dataType=detail&encrypt=1"); - // 创建记录(任务) - ClueRecordEntity clueRecordEntity = clueRecordService.addDefaultRecordService(SecurityUtils.getCurrentUserId(), dtoName, dtoName); + }else if (channelType == 1){ + // 飞鱼推送接口 TODO + } - Long recordId = clueRecordEntity.getClueRecordId(); - PushLinkEntity saveEntity = new PushLinkEntity(); - saveEntity.setUserId(userId); - saveEntity.setAppKey(appKey); - saveEntity.setName(dtoName); - saveEntity.setClueRecordId(recordId); - baseMapper.insert(saveEntity); - // 检验数据--创建默认的执行任务 - distributeTaskService.inspectUserTask(Collections.singletonList(userId)); - distributeTaskService.addDefaultTask(dtoName, dbPushUrl, recordId.toString(), SecurityUtils.getCurrentUserId(), userId); + pushLinkEntity.setAppKey(appKey); + pushLinkEntity.setChannelUrl(dbPushUrl); + if (CollUtil.isNotEmpty(pushLinkDTO.getChannelIdentifyingList())){ + pushLinkEntity.setChannelIdentifying(JSONUtil.toJsonStr(pushLinkDTO.getChannelIdentifyingList())); } + baseMapper.insert(pushLinkEntity); return dbPushUrl; } + @Override + @Transactional(rollbackFor = Exception.class) + public boolean update(PushLinkDTO pushLinkDTO) { + PushLinkEntity pushLinkEntity = PushLinkConverter.INSTANCE.dtoToPo(pushLinkDTO); + if (CollUtil.isNotEmpty(pushLinkDTO.getChannelIdentifyingList())){ + pushLinkEntity.setChannelIdentifying(JSONUtil.toJsonStr(pushLinkDTO.getChannelIdentifyingList())); + } + return SqlHelper.retBool(baseMapper.updateById(pushLinkEntity)); + } + @Override public PushLinkEntity getByAppKey(String appKey) { return baseMapper.selectByAppKey(appKey); } - } diff --git a/admin/src/main/java/com/baiye/modules/distribute/vo/PushLinkVO.java b/admin/src/main/java/com/baiye/modules/distribute/vo/PushLinkVO.java new file mode 100644 index 0000000..c8177e5 --- /dev/null +++ b/admin/src/main/java/com/baiye/modules/distribute/vo/PushLinkVO.java @@ -0,0 +1,40 @@ +package com.baiye.modules.distribute.vo; + +import cn.hutool.json.JSONArray; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +public class PushLinkVO { + + @TableId + @Schema(title = "ID") + private Long id; + + @Schema(title = "业务名") + private String name; + + @Schema(title = "渠道标识集合") + private JSONArray channelIdentifyingList; + + @Schema(title = "渠道标识") + private String channelIdentifying; + + @Schema(title = "渠道链接") + private String channelUrl; + + @Schema(title = "渠道类型(0-大坝,1-飞鱼,2-第三方)") + private Integer channelType; + + @Schema(title = "状态(1-启用接收,0-拒绝接收)") + private Integer status; + + @Schema(title = "创建者") + private Long createBy; + + @Schema(title = "创建时间") + private LocalDateTime createTime; +} diff --git a/admin/src/main/resources/mapper/PushLinkMapper.xml b/admin/src/main/resources/mapper/PushLinkMapper.xml new file mode 100644 index 0000000..2d965c3 --- /dev/null +++ b/admin/src/main/resources/mapper/PushLinkMapper.xml @@ -0,0 +1,23 @@ + + + + + pl.id, + pl.name, + pl.app_key, + pl.channel_identifying, + pl.channel_url, + pl.channel_type, + pl.status, + pl.create_time, + pl.create_by + + + +