Commit 8a493daf authored by shiyu's avatar shiyu

Merge remote-tracking branch 'origin/master'

parents 137be25f 585358a5
...@@ -3,6 +3,7 @@ package com.wwdz.ch.wx.entity.vo; ...@@ -3,6 +3,7 @@ package com.wwdz.ch.wx.entity.vo;
import com.xxdxxs.entity.Entity; import com.xxdxxs.entity.Entity;
import lombok.Data; import lombok.Data;
import java.util.List;
import java.util.Map; import java.util.Map;
@Data @Data
...@@ -26,4 +27,6 @@ public class ItemResponseVo implements Entity { ...@@ -26,4 +27,6 @@ public class ItemResponseVo implements Entity {
private Boolean isDeleted; private Boolean isDeleted;
private String itemNickname; private String itemNickname;
private Integer timeType; private Integer timeType;
private List<Map<String, Object>> imagesList;
private List<Map<String, Object>> videosList;
} }
...@@ -455,7 +455,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -455,7 +455,7 @@ public class FavoritesServiceImpl implements FavoritesService {
String[] image = item.getImages().split(";"); String[] image = item.getImages().split(";");
homePageMap.put("url", image[0]); homePageMap.put("url", image[0]);
if (image[0].contains("_")) { if (image[0].contains("_")) {
homePageMap = getImageMap(image[0]); homePageMap = getAspect(image[0]);
homePageMap.put("url", image[0]); homePageMap.put("url", image[0]);
homePageMap.put("type", 2); homePageMap.put("type", 2);
} }
...@@ -464,7 +464,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -464,7 +464,7 @@ public class FavoritesServiceImpl implements FavoritesService {
String[] vedioImage = item.getVideos().split(";"); String[] vedioImage = item.getVideos().split(";");
if (vedioImage[0].contains(",")) { if (vedioImage[0].contains(",")) {
String[] video = vedioImage[0].split(","); String[] video = vedioImage[0].split(",");
homePageMap = getImageMap(video[1]); homePageMap = getAspect(video[1]);
homePageMap.put("url", video[1]); homePageMap.put("url", video[1]);
homePageMap.put("type", 1); homePageMap.put("type", 1);
} }
...@@ -478,7 +478,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -478,7 +478,7 @@ public class FavoritesServiceImpl implements FavoritesService {
* @param image * @param image
* @return * @return
*/ */
private Map<String, Object> getImageMap(String image) { private Map<String, Object> getAspect(String image) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
String[] _image = image.split("_"); String[] _image = image.split("_");
String[] infoImage = _image[1].split("\\."); String[] infoImage = _image[1].split("\\.");
......
...@@ -153,7 +153,7 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -153,7 +153,7 @@ public class FootPrintServiceImpl implements FootPrintService {
String[] image = item.getImages().split(";"); String[] image = item.getImages().split(";");
homePageMap.put("url", image[0]); homePageMap.put("url", image[0]);
if (image[0].contains("_")) { if (image[0].contains("_")) {
homePageMap = getImageMap(image[0]); homePageMap = getAspect(image[0]);
homePageMap.put("url", image[0]); homePageMap.put("url", image[0]);
homePageMap.put("type", 2); homePageMap.put("type", 2);
} }
...@@ -162,7 +162,7 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -162,7 +162,7 @@ public class FootPrintServiceImpl implements FootPrintService {
String[] vedioImage = item.getVideos().split(";"); String[] vedioImage = item.getVideos().split(";");
if (vedioImage[0].contains(",")) { if (vedioImage[0].contains(",")) {
String[] video = vedioImage[0].split(","); String[] video = vedioImage[0].split(",");
homePageMap = getImageMap(video[1]); homePageMap = getAspect(video[1]);
homePageMap.put("url", video[1]); homePageMap.put("url", video[1]);
homePageMap.put("type", 1); homePageMap.put("type", 1);
} }
...@@ -176,7 +176,7 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -176,7 +176,7 @@ public class FootPrintServiceImpl implements FootPrintService {
* @param image * @param image
* @return * @return
*/ */
private Map<String, Object> getImageMap(String image) { private Map<String, Object> getAspect(String image) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
String[] _image = image.split("_"); String[] _image = image.split("_");
String[] infoImage = _image[1].split("\\."); String[] infoImage = _image[1].split("\\.");
......
...@@ -15,8 +15,8 @@ import com.wwdz.ch.db.es.ItemEsDao; ...@@ -15,8 +15,8 @@ import com.wwdz.ch.db.es.ItemEsDao;
import com.wwdz.ch.wx.entity.request.ItemRequestDto; import com.wwdz.ch.wx.entity.request.ItemRequestDto;
import com.wwdz.ch.wx.entity.vo.AgentTranceResponseVo; import com.wwdz.ch.wx.entity.vo.AgentTranceResponseVo;
import com.wwdz.ch.wx.entity.vo.ItemResponseVo; import com.wwdz.ch.wx.entity.vo.ItemResponseVo;
import com.wwdz.ch.wx.manager.WxLoginManager;
import com.wwdz.ch.wx.service.ItemService; import com.wwdz.ch.wx.service.ItemService;
import com.wwdz.ch.wx.service.WxLoginService;
import com.wwdz.ch.wx.util.StringUtil; import com.wwdz.ch.wx.util.StringUtil;
import com.xxdxxs.utils.CommonUtils; import com.xxdxxs.utils.CommonUtils;
import com.xxdxxs.utils.DateUtils; import com.xxdxxs.utils.DateUtils;
...@@ -57,7 +57,7 @@ public class ItemServiceImpl implements ItemService { ...@@ -57,7 +57,7 @@ public class ItemServiceImpl implements ItemService {
@Autowired @Autowired
private FavoritesDao favoritesDao; private FavoritesDao favoritesDao;
@Autowired @Autowired
private WxLoginService wxLoginService; private WxLoginManager wxLoginManager;
@Autowired @Autowired
private QiniuStorage qiniuStorage; private QiniuStorage qiniuStorage;
@Autowired @Autowired
...@@ -178,7 +178,7 @@ public class ItemServiceImpl implements ItemService { ...@@ -178,7 +178,7 @@ public class ItemServiceImpl implements ItemService {
item.setSort(100); item.setSort(100);
item.setImages(dto.getImages()); item.setImages(dto.getImages());
if (StringUtils.isNotBlank(dto.getVideos())) { if (StringUtils.isNotBlank(dto.getVideos())) {
item.setVideos(getVediosImage(dto.getVideos())); item.setVideos(getVideosImage(dto.getVideos()));
} }
item.setPrice(Long.parseLong(dto.getPrice()) * 100); item.setPrice(Long.parseLong(dto.getPrice()) * 100);
item.setDetail(dto.getDetail()); item.setDetail(dto.getDetail());
...@@ -266,6 +266,10 @@ public class ItemServiceImpl implements ItemService { ...@@ -266,6 +266,10 @@ public class ItemServiceImpl implements ItemService {
} }
itemResponseVo.setVideos(stringBuilder.substring(0, stringBuilder.length() - 1)); itemResponseVo.setVideos(stringBuilder.substring(0, stringBuilder.length() - 1));
} }
// 设置图片列表
itemResponseVo.setImagesList(getImagesMapList(item.getImages()));
// 设置视频列表
itemResponseVo.setVideosList(StringUtils.isNotBlank(item.getVideos()) ? getVideosMapList(item.getVideos()) : new ArrayList<>());
// 设置分类id和名称 // 设置分类id和名称
itemResponseVo.setCid(item.getCid()); itemResponseVo.setCid(item.getCid());
Category category = categoryDao.findById(item.getCid()); Category category = categoryDao.findById(item.getCid());
...@@ -415,7 +419,7 @@ public class ItemServiceImpl implements ItemService { ...@@ -415,7 +419,7 @@ public class ItemServiceImpl implements ItemService {
item.setImages(dto.getImages()); item.setImages(dto.getImages());
item.setVideos(""); item.setVideos("");
if (StringUtils.isNotBlank(dto.getVideos())) { if (StringUtils.isNotBlank(dto.getVideos())) {
item.setVideos(getVediosImage(dto.getVideos())); item.setVideos(getVideosImage(dto.getVideos()));
} }
item.setPrice(Long.parseLong(dto.getPrice()) * 100); item.setPrice(Long.parseLong(dto.getPrice()) * 100);
item.setDetail(dto.getDetail()); item.setDetail(dto.getDetail());
...@@ -460,7 +464,7 @@ public class ItemServiceImpl implements ItemService { ...@@ -460,7 +464,7 @@ public class ItemServiceImpl implements ItemService {
String keyName = CommConsts.UPLOAD_PRE_WXACODE_DIRECTORY + page + "/" + scene + "." + MediaTypeEnum.IMAGE_JPG.getExt(); String keyName = CommConsts.UPLOAD_PRE_WXACODE_DIRECTORY + page + "/" + scene + "." + MediaTypeEnum.IMAGE_JPG.getExt();
FileInfo fileInfo = (FileInfo) qiniuStorage.checkFile(keyName); FileInfo fileInfo = (FileInfo) qiniuStorage.checkFile(keyName);
if (Objects.isNull(fileInfo)) { if (Objects.isNull(fileInfo)) {
InputStream inputStream = wxLoginService.getWxacodeStream(page, scene); InputStream inputStream = wxLoginManager.getWxacodeStream(page, scene);
if (Objects.isNull(inputStream)) { if (Objects.isNull(inputStream)) {
return Result.failed("获取微信小程序流失败"); return Result.failed("获取微信小程序流失败");
} }
...@@ -482,7 +486,7 @@ public class ItemServiceImpl implements ItemService { ...@@ -482,7 +486,7 @@ public class ItemServiceImpl implements ItemService {
@Override @Override
public Result getWxLink(String pageUrl) { public Result getWxLink(String pageUrl) {
try { try {
String link = wxLoginService.getLink(pageUrl); String link = wxLoginManager.getLink(pageUrl);
if (StringUtils.isBlank(link)) { if (StringUtils.isBlank(link)) {
return Result.failed("获取微信小程序链接失败"); return Result.failed("获取微信小程序链接失败");
} }
...@@ -537,8 +541,8 @@ public class ItemServiceImpl implements ItemService { ...@@ -537,8 +541,8 @@ public class ItemServiceImpl implements ItemService {
} }
} }
private String getVediosImage(String vedios) { private String getVideosImage(String vedios) {
String vedio = ""; String video = "";
String[] images = vedios.split(";"); String[] images = vedios.split(";");
StringBuffer stringBuffer = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer();
Arrays.stream(images).parallel().forEach(image -> { Arrays.stream(images).parallel().forEach(image -> {
...@@ -560,8 +564,8 @@ public class ItemServiceImpl implements ItemService { ...@@ -560,8 +564,8 @@ public class ItemServiceImpl implements ItemService {
logger.error("视频图片上传失败", e); logger.error("视频图片上传失败", e);
} }
}); });
vedio = stringBuffer.toString(); video = stringBuffer.toString();
return vedio; return video;
} }
/** /**
...@@ -597,7 +601,7 @@ public class ItemServiceImpl implements ItemService { ...@@ -597,7 +601,7 @@ public class ItemServiceImpl implements ItemService {
String[] image = es.getImages().split(";"); String[] image = es.getImages().split(";");
homePageMap.put("url", image[0]); homePageMap.put("url", image[0]);
if (image[0].contains("_")) { if (image[0].contains("_")) {
homePageMap = getImageMap(image[0]); homePageMap = getAspect(image[0]);
homePageMap.put("url", image[0]); homePageMap.put("url", image[0]);
homePageMap.put("type", 2); homePageMap.put("type", 2);
} }
...@@ -606,7 +610,7 @@ public class ItemServiceImpl implements ItemService { ...@@ -606,7 +610,7 @@ public class ItemServiceImpl implements ItemService {
String[] vedioImage = es.getVideos().split(";"); String[] vedioImage = es.getVideos().split(";");
if (vedioImage[0].contains(",")) { if (vedioImage[0].contains(",")) {
String[] video = vedioImage[0].split(","); String[] video = vedioImage[0].split(",");
homePageMap = getImageMap(video[1]); homePageMap = getAspect(video[1]);
homePageMap.put("url", video[1]); homePageMap.put("url", video[1]);
homePageMap.put("type", 1); homePageMap.put("type", 1);
} }
...@@ -614,13 +618,63 @@ public class ItemServiceImpl implements ItemService { ...@@ -614,13 +618,63 @@ public class ItemServiceImpl implements ItemService {
return homePageMap; return homePageMap;
} }
/**
* 获取图片对象列表
*
* @param images
* @return
*/
private List<Map<String, Object>> getImagesMapList(String images) {
List<Map<String, Object>> list = new ArrayList<>();
String[] image = images.split(";");
for (int i = 0; i < image.length; i++) {
Map<String, Object> map = new HashMap<>();
if (image[i].contains("_")) {
map = getAspect(image[i]);
} else {
map.put("width", "0");
map.put("type", "0");
}
map.put("url", image[i]);
map.put("type", 2);
list.add(map);
}
return list;
}
/**
* 获取视频对象列表
*
* @param videos
* @return
*/
private List<Map<String, Object>> getVideosMapList(String videos) {
List<Map<String, Object>> list = new ArrayList<>();
String[] video = videos.split(";");
for (int i = 0; i < video.length; i++) {
Map<String, Object> map = new HashMap<>();
if (video[i].contains(",")) {
String[] image = video[i].split(",");
map = getAspect(image[1]);
map.put("url", image[0]);
} else {
map.put("width", "0");
map.put("type", "0");
map.put("url", video[i]);
}
map.put("type", 1);
list.add(map);
}
return list;
}
/** /**
* 获取图片的长宽 * 获取图片的长宽
* *
* @param image * @param image
* @return * @return
*/ */
private Map<String, Object> getImageMap(String image) { private Map<String, Object> getAspect(String image) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
String[] _image = image.split("_"); String[] _image = image.split("_");
String[] infoImage = _image[1].split("\\."); String[] infoImage = _image[1].split("\\.");
......
package com.wwdz.ch.wx.impl; package com.wwdz.ch.wx.manager;
import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
...@@ -7,8 +7,6 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; ...@@ -7,8 +7,6 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.wwdz.ch.core.util.OkHttpUtil; import com.wwdz.ch.core.util.OkHttpUtil;
import com.wwdz.ch.wx.entity.request.UserRequestDto; import com.wwdz.ch.wx.entity.request.UserRequestDto;
import com.wwdz.ch.wx.service.WxLoginService;
import com.wwdz.ch.wx.util.RedisUtil;
import com.xxdxxs.utils.JsonUtils; import com.xxdxxs.utils.JsonUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -21,7 +19,7 @@ import java.util.HashMap; ...@@ -21,7 +19,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
@Service @Service
public class WxLoginServiceImpl implements WxLoginService { public class WxLoginManager {
private static final Logger logger = LoggerFactory.getLogger(WxMaServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(WxMaServiceImpl.class);
private static final String appid = "wx5b4409448bf2c72b"; private static final String appid = "wx5b4409448bf2c72b";
...@@ -33,11 +31,8 @@ public class WxLoginServiceImpl implements WxLoginService { ...@@ -33,11 +31,8 @@ public class WxLoginServiceImpl implements WxLoginService {
@Autowired @Autowired
private WxMaService wxMaService; private WxMaService wxMaService;
@Autowired
private RedisUtil redisUtil;
@Override
public String getPhone(UserRequestDto dto) { public String getPhone(UserRequestDto dto) {
String phone = ""; String phone = "";
if (dto.getType() == 1) { if (dto.getType() == 1) {
...@@ -88,27 +83,9 @@ public class WxLoginServiceImpl implements WxLoginService { ...@@ -88,27 +83,9 @@ public class WxLoginServiceImpl implements WxLoginService {
return phone; return phone;
} }
@Override
public String getAccessToken() { public String getAccessToken() {
logger.info("开始获取access_token----------------"); logger.info("开始获取access_token----------------");
try { try {
// if (redisUtil.hasKey(CacheCodeConstants.WX_ACCESS_TOKEN)) {
// logger.info("从redis获取access_token成功");
// return redisUtil.get(CacheCodeConstants.WX_ACCESS_TOKEN).toString();
// } else {
// String accessTokenUrl = String.format(GET_ACCESS_TOKEN_URL, appid, secret);
// String res = OkHttpUtil.builder().url(accessTokenUrl)
// .get().sync();
// logger.info("获取access_token结果:" + res);
// if (!res.contains("access_token")) {
// logger.error("获取accessToken出错,返回结果是:" + res);
// return null;
// }
// String accessToken = JsonUtils.getValueByPath(res, "access_token");
// String expiresIn = JsonUtils.getValueByPath(res, "expires_in");
// redisUtil.set(CacheCodeConstants.WX_ACCESS_TOKEN, accessToken, Long.parseLong(expiresIn));
// return accessToken;
// }
String accessTokenUrl = String.format(GET_ACCESS_TOKEN_URL, appid, secret); String accessTokenUrl = String.format(GET_ACCESS_TOKEN_URL, appid, secret);
String res = OkHttpUtil.builder().url(accessTokenUrl) String res = OkHttpUtil.builder().url(accessTokenUrl)
.get().sync(); .get().sync();
...@@ -124,7 +101,6 @@ public class WxLoginServiceImpl implements WxLoginService { ...@@ -124,7 +101,6 @@ public class WxLoginServiceImpl implements WxLoginService {
} }
} }
@Override
public InputStream getWxacodeStream(String page, String scene) { public InputStream getWxacodeStream(String page, String scene) {
try { try {
String accessToken = getAccessToken(); String accessToken = getAccessToken();
...@@ -141,7 +117,6 @@ public class WxLoginServiceImpl implements WxLoginService { ...@@ -141,7 +117,6 @@ public class WxLoginServiceImpl implements WxLoginService {
} }
} }
@Override
public String getLink (String pageUrl) { public String getLink (String pageUrl) {
try { try {
String accessToken = getAccessToken(); String accessToken = getAccessToken();
......
package com.wwdz.ch.wx.service;
import com.wwdz.ch.wx.entity.request.UserRequestDto;
import java.io.InputStream;
public interface WxLoginService {
/**
* 获取微信用户手机号
*
* @param dto
* @return
*/
String getPhone(UserRequestDto dto);
/**
* 获取微信用户授权access_token
*
* @return
*/
String getAccessToken();
/**
* 获取微信小程序小程序码图片流
*
* @param path
* @param scene
* @return
*/
InputStream getWxacodeStream(String path, String scene);
/**
* 获取微信小程序短链接
*
* @param pageUrl
* @return
*/
String getLink (String pageUrl);
}
...@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON; ...@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.entity.request.ItemRequestDto; import com.wwdz.ch.wx.entity.request.ItemRequestDto;
import com.wwdz.ch.wx.service.ItemService; import com.wwdz.ch.wx.service.ItemService;
import com.wwdz.ch.wx.service.WxLoginService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -15,8 +14,6 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -15,8 +14,6 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
@RestController @RestController
...@@ -26,8 +23,6 @@ public class WxItemController { ...@@ -26,8 +23,6 @@ public class WxItemController {
@Autowired @Autowired
private ItemService itemService; private ItemService itemService;
@Autowired
private WxLoginService wxLoginService;
@ApiOperation(value = "藏品名称联想") @ApiOperation(value = "藏品名称联想")
@PostMapping("/findNames") @PostMapping("/findNames")
...@@ -139,18 +134,6 @@ public class WxItemController { ...@@ -139,18 +134,6 @@ public class WxItemController {
return itemService.cancel(dto); return itemService.cancel(dto);
} }
@ApiOperation(value = "小程序授权码")
@PostMapping("/getAccessToken")
public Result getAccessToken() {
String accessToken = wxLoginService.getAccessToken();
if (StringUtils.isBlank(accessToken)) {
return Result.failed("获取access_token失败");
}
Map<String, Object> map = new HashMap<>();
map.put("access_token", accessToken);
return Result.success(map);
}
@ApiOperation(value = "小程序码") @ApiOperation(value = "小程序码")
@GetMapping("/getWxacode") @GetMapping("/getWxacode")
public Result getWxacode(String page, String scene, HttpServletResponse response) { public Result getWxacode(String page, String scene, HttpServletResponse response) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment