微信服务与端链接传递参数为querywrapper调整
This commit is contained in:
parent
9ec3322574
commit
a7509e1125
@ -3,10 +3,20 @@ package cn.lili.modules.message.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import cn.lili.modules.message.entity.dos.ShortLink;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 短链接 业务层
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
public interface ShortLinkService extends IService<ShortLink> {
|
||||
|
||||
/**
|
||||
* 根据模型,查询返回的集合
|
||||
*
|
||||
* @param shortLink 短链接模型
|
||||
* @return 端链接集合
|
||||
*/
|
||||
List<ShortLink> queryShortLinks(ShortLink shortLink);
|
||||
}
|
@ -3,16 +3,24 @@ package cn.lili.modules.message.serviceimpl;
|
||||
import cn.lili.modules.message.entity.dos.ShortLink;
|
||||
import cn.lili.modules.message.mapper.ShortLinkMapper;
|
||||
import cn.lili.modules.message.service.ShortLinkService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 短链接 业务实现
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class ShortLinkServiceImpl extends ServiceImpl<ShortLinkMapper, ShortLink> implements ShortLinkService {
|
||||
|
||||
@Override
|
||||
public List<ShortLink> queryShortLinks(ShortLink shortLink) {
|
||||
return this.list(PageUtil.initWrapper(shortLink));
|
||||
}
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
package cn.lili.modules.wechat.util;
|
||||
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
import cn.lili.modules.message.entity.dos.ShortLink;
|
||||
import cn.lili.modules.message.service.ShortLinkService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.HttpEntity;
|
||||
@ -100,16 +99,14 @@ public class WechatMpCodeUtil {
|
||||
|
||||
//短链接存储
|
||||
ShortLink shortLink = new ShortLink();
|
||||
//已经保存过则不再保存
|
||||
LambdaQueryWrapper<ShortLink> queryWrapper = new LambdaQueryWrapper();
|
||||
queryWrapper.eq(ShortLink::getOriginalParams, scene);
|
||||
List<ShortLink> shortLinks = shortLinkService.list(queryWrapper);
|
||||
shortLink.setOriginalParams(scene);
|
||||
List<ShortLink> shortLinks = shortLinkService.queryShortLinks(shortLink);
|
||||
if (shortLinks.size() > 0) {
|
||||
shortLink = shortLinks.get(0);
|
||||
} else {
|
||||
shortLink.setOriginalParams(scene);
|
||||
shortLinkService.save(shortLink);
|
||||
shortLink = shortLinkService.getOne(queryWrapper);
|
||||
shortLink = shortLinkService.queryShortLinks(shortLink).get(0);
|
||||
}
|
||||
String accessToken = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP);
|
||||
Map<String, String> params = new HashMap<>(4);
|
||||
|
Loading…
x
Reference in New Issue
Block a user