Commit 3a65bab0 by 水库浪子

修改素材发送BUG

1 parent a71d1850
......@@ -35,7 +35,12 @@ public class WeChatCollectionController extends BaseController {
@Log(title = "添加收藏", businessType = BusinessType.INSERT)
@PostMapping("addCollection")
public AjaxResult addCollection(@RequestBody WeChatCollectionDto chatCollectionDto) {
return toAjax(weChatCollectionService.addCollection(chatCollectionDto.getMaterialId(), chatCollectionDto.getUserId()));
boolean b =
weChatCollectionService.addCollection(chatCollectionDto.getMaterialId(), chatCollectionDto.getUserId());
if(weChatCollectionService.addCollection(chatCollectionDto.getMaterialId(), chatCollectionDto.getUserId())){
return AjaxResult.success();
}
return AjaxResult.success("当前素材不可重复收藏");
}
......
......@@ -52,12 +52,12 @@ public class WeMaterialController extends BaseController {
List<WeMaterial> list;
if(StringUtils.isNotBlank(mediaType) && mediaType.equals(MediaType.POSTER.getType())){
list = wePosterService.list(StringUtils.isBlank(categoryId)?null:Long.valueOf(categoryId),search).stream().map(wePoster -> {
WeMaterial weMaterial = new WeMaterial();
weMaterial.setMaterialName(wePoster.getTitle());
weMaterial.setMaterialUrl(wePoster.getSampleImgPath());
weMaterial.setCategoryId(wePoster.getCategoryId());
weMaterial.setId(wePoster.getId());
return weMaterial;
WeMaterial weMaterial = new WeMaterial();
weMaterial.setMaterialName(wePoster.getTitle());
weMaterial.setMaterialUrl(wePoster.getSampleImgPath());
weMaterial.setCategoryId(wePoster.getCategoryId());
weMaterial.setId(wePoster.getId());
return weMaterial;
}).collect(Collectors.toList());
}else {
list = materialService.findWeMaterials(categoryId, search,mediaType);
......@@ -122,19 +122,29 @@ public class WeMaterialController extends BaseController {
return AjaxResult.success();
}
// //@PreAuthorize("@ss.hasPermi('wechat:material:temporaryMaterialMediaId')")
// @Log(title = "获取素材media_id", businessType = BusinessType.OTHER)
// @PostMapping("/temporaryMaterialMediaId")
// @ApiOperation("获取素材media_id")
// public AjaxResult temporaryMaterialMediaId(@RequestBody TemporaryMaterialDto temporaryMaterialDto){
// WeMediaDto weMediaDto = materialService.uploadTemporaryMaterial(temporaryMaterialDto.getUrl(),
// temporaryMaterialDto.getType()
// ,temporaryMaterialDto.getName());
// return AjaxResult.success(weMediaDto);
// }
//@PreAuthorize("@ss.hasPermi('wechat:material:temporaryMaterialMediaId')")
@Log(title = "获取素材media_id", businessType = BusinessType.OTHER)
@PostMapping("/temporaryMaterialMediaId")
@GetMapping("/temporaryMaterialMediaId")
@ApiOperation("获取素材media_id")
public AjaxResult temporaryMaterialMediaId(@RequestBody TemporaryMaterialDto temporaryMaterialDto){
WeMediaDto weMediaDto = materialService.uploadTemporaryMaterial(temporaryMaterialDto.getUrl(),
temporaryMaterialDto.getType()
,temporaryMaterialDto.getName());
public AjaxResult temporaryMaterialMediaId(String url,String type,String name){
WeMediaDto weMediaDto = materialService.uploadTemporaryMaterial(url,
type
,name);
return AjaxResult.success(weMediaDto);
}
@Log(title = "上传素材图片", businessType = BusinessType.OTHER)
@PostMapping("/uploadimg")
@ApiOperation("上传素材图片")
......
package com.linkwechat.framework.security.filter;
import java.io.IOException;
import java.util.Enumeration;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
......@@ -33,6 +34,9 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter
throws ServletException, IOException
{
LoginUser loginUser = tokenService.getLoginUser(request);
Enumeration<String> parameterNames = request.getParameterNames();
if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication()))
{
tokenService.verifyToken(loginUser);
......
......@@ -20,7 +20,7 @@ public interface IWeChatCollectionService extends IService<WeChatCollection> {
* @param userId 用户id
* @return 结果
*/
public int addCollection( Long materialId, String userId);
public boolean addCollection( Long materialId, String userId);
/**
* 取消收藏
......
......@@ -27,18 +27,19 @@ public class WeChatCollectionServiceImpl extends ServiceImpl<WeChatCollectionMap
@Override
public int addCollection(Long materialId, String userId) {
public boolean addCollection(Long materialId, String userId) {
QueryWrapper<WeChatCollection> wrapper = new QueryWrapper<>();
wrapper.eq("material_id",materialId).eq("user_id",userId);
WeChatCollection queryCollection = weChatCollectionMapper.selectOne(wrapper);
if(null!=queryCollection){
throw new CustomException("你已收藏");
return false;
}
WeChatCollection chatCollection=new WeChatCollection();
chatCollection.setCollectionId(SnowFlakeUtil.nextId());
chatCollection.setMaterialId(materialId);
chatCollection.setUserId(userId);
return weChatCollectionMapper.addCollection(chatCollection);
weChatCollectionMapper.addCollection(chatCollection);
return true;
}
@Override
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!