Commit 1d77f013 authored by muhong's avatar muhong

修改 发送消息和浏览量

parent 0e0babdf
...@@ -102,5 +102,38 @@ public class MessageEnum { ...@@ -102,5 +102,38 @@ public class MessageEnum {
} }
} }
public enum ContentTextEnum {
ITEM_SHARE(1, "分享了您的藏品"),
ITEM_COLLECT(2, "收藏了您的藏品"),
FAVORITES_SHARE(3, "分享了您的收藏册"),
FAVORITES_COLLECT(3, "收藏了您的收藏册"),
;
private int code;
private String des;
ContentTextEnum(int code, String des) {
this.code = code;
this.des = des;
}
public static String getNameByCode(int code) {
for (ContentTextEnum contentTextEnum : ContentTextEnum.values()) {
if (code == contentTextEnum.getCode()) {
return contentTextEnum.getDes();
}
}
return null;
}
public int getCode() {
return code;
}
public String getDes() {
return des;
}
}
} }
...@@ -39,7 +39,7 @@ public interface FootPrintDao { ...@@ -39,7 +39,7 @@ public interface FootPrintDao {
* @param itemIds * @param itemIds
* @return * @return
*/ */
long countByItemIds(Long itemId, List<Long> itemIds); long countByItemIds(Long userId, Long itemId, List<Long> itemIds);
/** /**
* 批量删除记录 * 批量删除记录
......
...@@ -58,11 +58,12 @@ public class FootPrintDaoImpl implements FootPrintDao { ...@@ -58,11 +58,12 @@ public class FootPrintDaoImpl implements FootPrintDao {
} }
@Override @Override
public long countByItemIds(Long itemId, List<Long> itemIds) { public long countByItemIds(Long userId, Long itemId, List<Long> itemIds) {
FootprintExample example = new FootprintExample(); FootprintExample example = new FootprintExample();
FootprintExample.Criteria criteria = example.createCriteria(); FootprintExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(itemId, criteria::andItemIdEqualTo); JdbcHelper.ifPresent(itemId, criteria::andItemIdEqualTo);
JdbcHelper.ifPresent(itemIds, criteria::andItemIdIn); JdbcHelper.ifPresent(itemIds, criteria::andItemIdIn);
JdbcHelper.ifPresent(userId, criteria::andUserIdNotEqualTo);
criteria.andDeletedEqualTo(false); criteria.andDeletedEqualTo(false);
return footprintMapper.countByExample(example); return footprintMapper.countByExample(example);
} }
......
...@@ -47,4 +47,6 @@ public class ItemRequestDto implements Entity { ...@@ -47,4 +47,6 @@ public class ItemRequestDto implements Entity {
private Integer loginType; private Integer loginType;
// 查看权限(0所有人,1仅自己可见) // 查看权限(0所有人,1仅自己可见)
private Integer viewPermission; private Integer viewPermission;
// 分享类型(0、藏品,1、收藏册,2、用户主页)
private Integer shareType;
} }
...@@ -273,7 +273,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -273,7 +273,7 @@ public class FavoritesServiceImpl implements FavoritesService {
itemCommonService.getNicknameAvatar(item.getId(), vo); itemCommonService.getNicknameAvatar(item.getId(), vo);
vo.setViewPermission(item.getViewPermission()); vo.setViewPermission(item.getViewPermission());
// 设置浏览量 // 设置浏览量
vo.setViewsNumber(item.getViewPermission().equals(ViewPermissionEnum.ALL.getCode()) ? StringUtil.formatCount(footPrintDao.countByItemIds(item.getId(), null)) : "0"); vo.setViewsNumber(item.getViewPermission().equals(ViewPermissionEnum.ALL.getCode()) ? StringUtil.formatCount(footPrintDao.countByItemIds(vo.getItemUserId(), item.getId(), null)) : "0");
// 设置图片或视频 // 设置图片或视频
vo.setHomePageImage(MediaUtil.getHomePageImage(item.getImages(), item.getVideos())); vo.setHomePageImage(MediaUtil.getHomePageImage(item.getImages(), item.getVideos()));
......
...@@ -91,11 +91,14 @@ public class ItemCommonServiceImpl implements ItemCommonService { ...@@ -91,11 +91,14 @@ public class ItemCommonServiceImpl implements ItemCommonService {
List<Long> itemIds = userItemsRelations.stream() List<Long> itemIds = userItemsRelations.stream()
.map(UserItemsRelation::getItemId).collect(Collectors.toList()); .map(UserItemsRelation::getItemId).collect(Collectors.toList());
collectionsNumber = favoritesItemsRelationDao.countByItemIds(itemIds); collectionsNumber = favoritesItemsRelationDao.countByItemIds(itemIds);
viewsNumber = footPrintDao.countByItemIds(null, itemIds);
CoinRequestDto coinRequestDto = new CoinRequestDto(); CoinRequestDto coinRequestDto = new CoinRequestDto();
coinRequestDto.setIds(itemIds); coinRequestDto.setIds(itemIds);
List<Item> itemList = itemDao.findListNotDeleted(coinRequestDto); List<Item> itemList = itemDao.findListNotDeleted(coinRequestDto);
allNumber = itemList.stream().filter(s -> s.getViewPermission().equals(ViewPermissionEnum.ALL.getCode())).count(); List<Item> allItemList = itemList.stream().filter(s -> s.getViewPermission().equals(ViewPermissionEnum.ALL.getCode())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(allItemList)) {
allNumber = allItemList.size();
viewsNumber = footPrintDao.countByItemIds(userInfo.getUserId(), null, allItemList.stream().map(Item::getId).collect(Collectors.toList()));
}
privacyNumber = itemList.stream().filter(s -> s.getViewPermission().equals(ViewPermissionEnum.ONLY_ONESELF.getCode())).count(); privacyNumber = itemList.stream().filter(s -> s.getViewPermission().equals(ViewPermissionEnum.ONLY_ONESELF.getCode())).count();
} }
......
...@@ -5,7 +5,6 @@ import com.wwdz.ch.wx.entity.request.ItemRequestDto; ...@@ -5,7 +5,6 @@ import com.wwdz.ch.wx.entity.request.ItemRequestDto;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public interface ItemService { public interface ItemService {
/** /**
...@@ -93,18 +92,22 @@ public interface ItemService { ...@@ -93,18 +92,22 @@ public interface ItemService {
* *
* @param page * @param page
* @param scene * @param scene
* @param response * @param loginType
* @param request
* @return * @return
*/ */
Result getAcode(String page, String scene, Integer loginType, HttpServletRequest request, HttpServletResponse response); Result getAcode(String page, String scene, Integer loginType, HttpServletRequest request);
/** /**
* 获取小程序链接 * 获取小程序链接
* *
* @param pageUrl * @param pageUrl
* @param loginType
* @param shareType
* @param request
* @return * @return
*/ */
Result getLink(String pageUrl, Integer loginType, HttpServletRequest request); Result getLink(String pageUrl, Integer loginType, Integer shareType, HttpServletRequest request);
/** /**
* 上传图片 * 上传图片
......
...@@ -70,4 +70,8 @@ public class StringUtil { ...@@ -70,4 +70,8 @@ public class StringUtil {
public static String formatMessageKey(long sendId, int type, long receiverId) { public static String formatMessageKey(long sendId, int type, long receiverId) {
return "" + sendId + ":" + type + ":" + receiverId; return "" + sendId + ":" + type + ":" + receiverId;
} }
public static String formatCollectMessageKey(long sendId, int type, long receiverId, int idType, long id) {
return "" + sendId + ":" + type + ":" + receiverId + ":" + idType + ":" + id;
}
} }
...@@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.*; ...@@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
...@@ -176,7 +175,7 @@ public class WxItemController { ...@@ -176,7 +175,7 @@ public class WxItemController {
@ApiOperation(value = "小程序码") @ApiOperation(value = "小程序码")
@GetMapping("/getAcode") @GetMapping("/getAcode")
public Result getAcode(String page, String scene, Integer loginType, HttpServletRequest request, HttpServletResponse response) { public Result getAcode(String page, String scene, Integer loginType, HttpServletRequest request) {
logger.info("【请求开始】获小程序码,请求参数:{}", "page=" + page + ",scene=" + scene + ",loginType=" + loginType); logger.info("【请求开始】获小程序码,请求参数:{}", "page=" + page + ",scene=" + scene + ",loginType=" + loginType);
if (StringUtils.isBlank(page)) { if (StringUtils.isBlank(page)) {
return Result.failed("页面路径不能为空"); return Result.failed("页面路径不能为空");
...@@ -187,7 +186,7 @@ public class WxItemController { ...@@ -187,7 +186,7 @@ public class WxItemController {
if (Objects.isNull(loginType)) { if (Objects.isNull(loginType)) {
return Result.failed("请提供请求的环境类型"); return Result.failed("请提供请求的环境类型");
} }
return itemService.getAcode(page, scene, loginType, request, response); return itemService.getAcode(page, scene, loginType, request);
} }
@ApiOperation(value = "小程序链接") @ApiOperation(value = "小程序链接")
...@@ -200,15 +199,18 @@ public class WxItemController { ...@@ -200,15 +199,18 @@ public class WxItemController {
if (Objects.isNull(dto.getLoginType())) { if (Objects.isNull(dto.getLoginType())) {
return Result.failed("请提供请求的环境类型"); return Result.failed("请提供请求的环境类型");
} }
return itemService.getLink(dto.getPageUrl(), dto.getLoginType(), request); if (Objects.isNull(dto.getShareType())) {
return Result.failed("请提供分享类型");
}
return itemService.getLink(dto.getPageUrl(), dto.getLoginType(), dto.getShareType(), request);
} }
@ApiOperation(value = "分享发送消息") @ApiOperation(value = "分享发送消息")
@PostMapping("/shareSendMessage") @PostMapping("/shareSendMessage")
public Result shareSendMessage(@RequestBody ItemRequestDto dto, HttpServletRequest request) { public Result shareSendMessage(@RequestBody ItemRequestDto dto, HttpServletRequest request) {
logger.info("【请求开始】分享发送消息,请求参数:{}", JSON.toJSONString(dto)); logger.info("【请求开始】分享发送消息,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getItemId())) { if (Objects.isNull(dto.getId())) {
return Result.failed("请选择被分享的藏品"); return Result.failed("请选择被分享的对象");
} }
return itemService.shareSendMessage(dto, request); return itemService.shareSendMessage(dto, request);
} }
......
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