渠道链接业务修改(未测)

master
yqy 10 months ago
parent 55d1d8459e
commit 4cafa95965

@ -27,8 +27,8 @@ public class ClueController {
private final ClueService clueService;
private final ApplicationContext publisher;
@GetMapping("/page")
@Operation(summary = "分页查询资源")
public R<PageResult<ClueVO>> getClueRecordPage(@Validated PageParam pageParam, ClueQo qo) {

@ -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<PageResult<PushLinkVO>> getClueRecordPage(@Validated PageParam pageParam, PushLinkQo qo) {
qo.setCreateBy(SecurityUtils.getCurrentUserId());
return R.ok(pushLinkService.queryPage(pageParam, qo));
}
@PostMapping("/add")
@Operation(summary = "新增(生成)链接", description = "新增(生成)链接")
public R<String> save(@Validated({ CreateGroup.class }) @RequestBody PushLinkDTO pushLinkDTO) {
return R.ok(pushLinkService.add(pushLinkDTO));
}
@PostMapping("/update")
@Operation(summary = "修改链接", description = "修改链接")
public R<Object> update(@Validated({UpdateGroup.class}) @RequestBody PushLinkDTO pushLinkDTO) {
return pushLinkService.update(pushLinkDTO) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "修改失败");
}
}

@ -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);
}

@ -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;

@ -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<String> 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;
}

@ -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;
}

@ -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<PushLinkEntity> {
default PageResult<PushLinkVO> queryPage(PageParam pageParam, PushLinkQo qo) {
IPage<PushLinkVO> page = this.prodPage(pageParam);
LambdaAliasQueryWrapperX<PushLinkEntity> 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<PushLinkVO> selectByPage(IPage<PushLinkVO> page, @Param(Constants.WRAPPER) Wrapper<PushLinkEntity> wrapper);
default PushLinkEntity selectByAppKey(String appKey) {
return this.selectOne(Wrappers.<PushLinkEntity>lambdaQuery().eq(PushLinkEntity::getAppKey, appKey));
}
}

@ -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;
}

@ -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<PushLinkEntity> {
/**
*
*/
PageResult<PushLinkVO> queryPage(PageParam pageParam, PushLinkQo qo);
/**
*
*/
@ -16,4 +25,8 @@ public interface PushLinkService extends ExtendService<PushLinkEntity> {
*/
PushLinkEntity getByAppKey(String appKey);
/**
*
*/
boolean update(PushLinkDTO pushLinkDTO);
}

@ -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<PushLinkMapper, PushLinkEntity> implements PushLinkService {
private final ClueRecordService clueRecordService;
private final UrlsProperties urlsProperties;
private final DistributeTaskService distributeTaskService;
@Override
public PageResult<PushLinkVO> queryPage(PageParam pageParam, PushLinkQo qo) {
PageResult<PushLinkVO> pushLinkVOPageResult = baseMapper.queryPage(pageParam, qo);
List<PushLinkVO> 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<PushLinkEntity>().eq(PushLinkEntity::getUserId, userId));
if (pushLinkEntity != null) {
dbPushUrl = dbPushUrl.concat(pushLinkEntity.getAppKey()).concat("?dataType=detail&encrypt=1");
PushLinkEntity linkEntity = baseMapper.selectOne(new LambdaQueryWrapper<PushLinkEntity>()
.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<PushLinkEntity>().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<PushLinkEntity>().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);
}
}

@ -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;
}

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baiye.modules.distribute.mapper.PushLinkMapper">
<sql id="Base_Alias_Column_List">
pl.id,
pl.name,
pl.app_key,
pl.channel_identifying,
pl.channel_url,
pl.channel_type,
pl.status,
pl.create_time,
pl.create_by
</sql>
<select id="selectByPage" resultType="com.baiye.modules.distribute.vo.PushLinkVO">
SELECT
<include refid="Base_Alias_Column_List"/>
FROM
tb_push_link pl
${ew.customSqlSegment}
</select>
</mapper>
Loading…
Cancel
Save