微信服务与端链接传递参数为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 com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import cn.lili.modules.message.entity.dos.ShortLink;
|
import cn.lili.modules.message.entity.dos.ShortLink;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 短链接 业务层
|
* 短链接 业务层
|
||||||
|
*
|
||||||
* @author Chopper
|
* @author Chopper
|
||||||
*/
|
*/
|
||||||
public interface ShortLinkService extends IService<ShortLink> {
|
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.entity.dos.ShortLink;
|
||||||
import cn.lili.modules.message.mapper.ShortLinkMapper;
|
import cn.lili.modules.message.mapper.ShortLinkMapper;
|
||||||
import cn.lili.modules.message.service.ShortLinkService;
|
import cn.lili.modules.message.service.ShortLinkService;
|
||||||
|
import cn.lili.mybatis.util.PageUtil;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 短链接 业务实现
|
* 短链接 业务实现
|
||||||
|
*
|
||||||
* @author Chopper
|
* @author Chopper
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class ShortLinkServiceImpl extends ServiceImpl<ShortLinkMapper, ShortLink> implements ShortLinkService {
|
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;
|
package cn.lili.modules.wechat.util;
|
||||||
|
|
||||||
|
import cn.lili.common.enums.ClientTypeEnum;
|
||||||
import cn.lili.common.enums.ResultCode;
|
import cn.lili.common.enums.ResultCode;
|
||||||
import cn.lili.common.exception.ServiceException;
|
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.entity.dos.ShortLink;
|
||||||
import cn.lili.modules.message.service.ShortLinkService;
|
import cn.lili.modules.message.service.ShortLinkService;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
@ -100,16 +99,14 @@ public class WechatMpCodeUtil {
|
|||||||
|
|
||||||
//短链接存储
|
//短链接存储
|
||||||
ShortLink shortLink = new ShortLink();
|
ShortLink shortLink = new ShortLink();
|
||||||
//已经保存过则不再保存
|
shortLink.setOriginalParams(scene);
|
||||||
LambdaQueryWrapper<ShortLink> queryWrapper = new LambdaQueryWrapper();
|
List<ShortLink> shortLinks = shortLinkService.queryShortLinks(shortLink);
|
||||||
queryWrapper.eq(ShortLink::getOriginalParams, scene);
|
|
||||||
List<ShortLink> shortLinks = shortLinkService.list(queryWrapper);
|
|
||||||
if (shortLinks.size() > 0) {
|
if (shortLinks.size() > 0) {
|
||||||
shortLink = shortLinks.get(0);
|
shortLink = shortLinks.get(0);
|
||||||
} else {
|
} else {
|
||||||
shortLink.setOriginalParams(scene);
|
shortLink.setOriginalParams(scene);
|
||||||
shortLinkService.save(shortLink);
|
shortLinkService.save(shortLink);
|
||||||
shortLink = shortLinkService.getOne(queryWrapper);
|
shortLink = shortLinkService.queryShortLinks(shortLink).get(0);
|
||||||
}
|
}
|
||||||
String accessToken = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP);
|
String accessToken = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP);
|
||||||
Map<String, String> params = new HashMap<>(4);
|
Map<String, String> params = new HashMap<>(4);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user