|
|
@@ -26,7 +26,8 @@ import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
- * 二手商品服务实现类
|
|
|
+ * 二手商品推荐服务实现类
|
|
|
+ * 实现商品推荐、关注商品、新品商品等列表查询和商品详情查询等核心业务逻辑
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
@@ -40,10 +41,17 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
|
|
|
|
|
|
@Autowired
|
|
|
private LifeFansMapper lifeFansMapper;
|
|
|
+
|
|
|
/**
|
|
|
- * 获取二手商品推荐列表
|
|
|
+ * 获取二手商品推荐列表(分页)
|
|
|
+ * 根据用户位置和商品类型获取推荐商品,并处理价格和距离信息
|
|
|
+ *
|
|
|
* @param page 分页信息
|
|
|
- * @return 推荐列表
|
|
|
+ * @param longitude 经度信息
|
|
|
+ * @param latitude 纬度信息
|
|
|
+ * @param typeId 商品类型ID
|
|
|
+ * @return 分页的推荐商品列表
|
|
|
+ * @throws Exception 查询过程中可能发生的异常
|
|
|
*/
|
|
|
@Override
|
|
|
public IPage<SecondGoodsRecommendVo> getSecondRecommendByPage(
|
|
|
@@ -77,9 +85,13 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取二手商品关注列表
|
|
|
+ * 获取二手商品关注列表(分页)
|
|
|
+ * 获取用户关注的商品列表,并处理价格、距离和评论信息
|
|
|
+ *
|
|
|
* @param page 分页信息
|
|
|
- * @return 关注列表
|
|
|
+ * @param position 经纬度信息,格式为"经度,纬度"
|
|
|
+ * @return 分页的关注商品列表
|
|
|
+ * @throws Exception 查询过程中可能发生的异常
|
|
|
*/
|
|
|
public IPage<SecondGoodsRecommendVo> querySecondConcernByPage(
|
|
|
IPage<SecondGoodsRecommendVo> page, String position) throws Exception {
|
|
|
@@ -130,9 +142,13 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 获取二手商品新品列表
|
|
|
+ * 获取二手商品新品列表(分页)
|
|
|
+ * 获取平台最新的商品列表,并处理价格、距离和评论信息
|
|
|
+ *
|
|
|
* @param page 分页信息
|
|
|
- * @return 关注列表
|
|
|
+ * @param position 经纬度信息,格式为"经度,纬度"
|
|
|
+ * @return 分页的新品商品列表
|
|
|
+ * @throws Exception 查询过程中可能发生的异常
|
|
|
*/
|
|
|
public IPage<SecondGoodsRecommendVo> querySecondNewGoodsByPage(
|
|
|
IPage<SecondGoodsRecommendVo> page, String position) throws Exception {
|
|
|
@@ -181,6 +197,15 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询商品详情信息
|
|
|
+ * 获取商品的详细信息,包括图片、关注状态、距离、价格等
|
|
|
+ *
|
|
|
+ * @param goodsId 商品ID
|
|
|
+ * @param position 经纬度信息,格式为"经度,纬度"
|
|
|
+ * @return 商品详情信息
|
|
|
+ * @throws Exception 查询过程中可能发生的异常
|
|
|
+ */
|
|
|
public SecondGoodsRecommendVo querySecondGoodsDetail(Integer goodsId, String position) throws Exception {
|
|
|
try {
|
|
|
JSONObject data = JwtUtil.getCurrentUserInfo();
|
|
|
@@ -279,6 +304,12 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
|
|
|
System.out.println(items);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断URL是否为视频文件
|
|
|
+ *
|
|
|
+ * @param url 文件URL
|
|
|
+ * @return 如果是视频文件返回true,否则返回false
|
|
|
+ */
|
|
|
private static boolean isVideoUrl(String url) {
|
|
|
if (url == null) return false;
|
|
|
url = url.toLowerCase();
|