Commit 0ff1459d authored by muhong's avatar muhong

修改 小程序藏品

parent 2fb3688d
......@@ -305,6 +305,10 @@ public class FavoritesServiceImpl implements FavoritesService {
@Override
public Result addItem(ItemRequestDto dto) {
try {
if (favoritesItemsRelationDao.isCollected(dto.getUserId(), dto.getId())) {
Result.failed("您已经收藏过该藏品");
}
Favorites favorites = favoritesDao.info(dto.getFavoritesId());
if (Objects.isNull(favorites)) {
Result.failed("数据异常,收藏册不存在");
......
......@@ -72,6 +72,8 @@ public class ItemServiceImpl implements ItemService {
count --;
}
vo.setCollectCount(count);
vo.setSourceType(item.getSourceType());
vo.setIsMine(0);
AgentTranceResponseVo agentTranceResponseVo = new AgentTranceResponseVo();
agentTranceResponseVo.setAgentTraceInfo_("");
......
......@@ -29,7 +29,11 @@ public class LoginInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
logger.info("-------------进入拦截器");
logger.info("请求头名称:" + JSON.toJSONString(request.getHeaderNames()));
String token = request.getHeader("kl_token");
if (StringUtils.isBlank(token)) {
token = request.getHeader("kltoken");
}
logger.info("token的值是:" + token);
if (StringUtils.isBlank(token)) {
return true;
......
......@@ -11,8 +11,10 @@ import com.wwdz.ch.db.domain.Footprint;
import com.wwdz.ch.db.domain.Item;
import com.wwdz.ch.wx.annotation.LoginUser;
import com.wwdz.ch.wx.entity.request.FootPrintRequestDto;
import com.wwdz.ch.wx.entity.request.KlDataRequestDto;
import com.wwdz.ch.wx.service.FootPrintService;
import org.apache.commons.collections.CollectionUtils;
import com.xxdxxs.utils.JsonUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -20,6 +22,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
/**
* 用户访问足迹服务
......@@ -126,28 +129,52 @@ public class WxFootprintController {
}
@PostMapping("/page")
public Result page(@RequestBody FootPrintRequestDto dto) {
logger.info("【请求开始】用户足迹列表查询,请求参数,userId:{}", dto.getUserId());
if (Objects.isNull(dto.getUserId())) {
public Result page(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】用户足迹列表查询,请求参数,kl_data:{}", json);
String userId = JsonUtils.getValueByPath(json, "userId");
String page = JsonUtils.getValueByPath(json, "page");
String size = JsonUtils.getValueByPath(json, "size");
if (StringUtils.isBlank(userId)) {
return Result.failed("用户id不能为空");
}
if (Objects.isNull(dto.getPage())) {
if (StringUtils.isBlank(page)) {
return Result.failed("当前页不能为空");
}
if (Objects.isNull(dto.getSize())) {
if (StringUtils.isBlank(size)) {
return Result.failed("页面大小不能为空");
}
if (StringUtils.isBlank(userId)) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(page)) {
return Result.failed("当前页不能为空");
}
if (StringUtils.isBlank(size)) {
return Result.failed("页面大小不能为空");
}
FootPrintRequestDto dto = new FootPrintRequestDto();
dto.setUserId(Long.parseLong(userId));
dto.setPage(Integer.parseInt(page));
dto.setSize(Integer.parseInt(size));
return footPrintService.page(dto);
}
@PostMapping("/del")
public Result delete(@RequestBody FootPrintRequestDto dto) {
logger.info("【请求开始】用户足迹删除,请求参数,ids:{}", dto.getIds());
if (CollectionUtils.isEmpty(dto.getIds())) {
return Result.failed("请选择足迹");
public Result delete(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】收藏册收藏,请求参数,kl_data:{}", json);
String ids = JsonUtils.getValueByPath(json, "ids");
if (StringUtils.isBlank(ids)) {
return Result.failed("收藏册id不能为空");
}
List<Long> idss = Arrays.stream(ids.substring(1, ids.length() - 1).split(","))
.map(Long::valueOf).collect(Collectors.toList());
FootPrintRequestDto dto = new FootPrintRequestDto();
dto.setIds(idss);
return footPrintService.delete(dto);
}
......
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