Browse Source

举报提交

zjy 1 week ago
parent
commit
da422a081f

+ 9 - 7
alien-second/src/main/java/shop/alien/second/controller/SecondShieldController.java

@@ -3,7 +3,6 @@ package shop.alien.second.controller;
 import com.alibaba.fastjson.JSONObject;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
 import io.swagger.annotations.ApiSort;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -11,7 +10,6 @@ import org.apache.poi.ss.formula.functions.T;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
 import shop.alien.entity.second.SecondShield;
-import shop.alien.entity.second.vo.SecondGoodsVo;
 import shop.alien.mapper.second.SecondShieldMapper;
 import shop.alien.util.common.JwtUtil;
 
@@ -62,11 +60,15 @@ public class SecondShieldController {
      * 取消拉黑
      */
     @PostMapping("/deleteGoodsShield")
-    @ApiOperation("取消拉黑")
-    public R<Void> deleteGoodsShield(@ApiParam("取消拉黑") @RequestBody SecondGoodsVo secondGoods) {
-        log.info("SecondShieldController.GoodsShield?secondGoods={}", secondGoods.toString());
-        mapper.deleteById(secondGoods.getShieldId());
-        return R.success("取消拉黑成功");
+    public R<T> deleteGoodsShield(
+            @RequestParam(value = "id", required = false) Integer id) {
+        Integer num = mapper.deleteById(id);
+
+        if(num == 1) {
+            return R.success("取消拉黑成功");
+        }
+        return R.fail("取消拉黑失败");
+
     }
 
 }

+ 60 - 2
alien-second/src/main/java/shop/alien/second/service/impl/SecondRecommendServiceImpl.java

@@ -192,13 +192,25 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
             List<StoreImg> storeImgs = storeImgMapper.selectList(query);
             // 设置图片信息
             if (storeImgs.size() > 0) {
-                item.setImgList(storeImgs.stream().map(StoreImg::getImgUrl).toArray(String[]::new));
+                // 先按视频后缀排序,再按ImgSort排序
+                String[] items = storeImgs.stream()
+                        .sorted((o1, o2) -> {
+                            boolean o1IsMp4 = isVideoUrl(o1.getImgUrl());
+                            boolean o2IsMp4 = isVideoUrl(o2.getImgUrl());
+                            // 如果都是.mp4或都不是.mp4,则按ImgSort排序
+                            if (o1IsMp4 && o2IsMp4 || !o1IsMp4 && !o2IsMp4) {
+                                return o1.getImgSort().compareTo(o2.getImgSort());
+                            }
+                            // 否则,.mp4的排在前面
+                            return o1IsMp4 ? -1 : 1;
+                        }).map(StoreImg::getImgUrl).toArray(String[]::new);
+                item.setImgList(items);
             }
 
             // 查看是否关注
             QueryWrapper<LifeFans> query1 = new QueryWrapper<>();
             query1.lambda()
-                    .eq(LifeFans::getFollowedId, item.getUserPhone()) // 商品 图片
+                    .eq(LifeFans::getFollowedId, item.getUserPhone()) // 商品图片
                     .eq(LifeFans::getDeleteFlag, 0)
                     .eq(LifeFans::getFansId, "user_" + phoneId);
             List<LifeFans> lifeFans = lifeFansMapper.selectList(query1);
@@ -217,4 +229,50 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
             throw new Exception(e);
         }
     }
+
+    public static void main(String[] args) {
+        List<StoreImg> storeImgs = new ArrayList<>();
+        StoreImg storeImg = new StoreImg();
+        storeImg.setImgSort(4);
+        storeImg.setImgUrl("11111.mp4");
+        storeImgs.add(storeImg);
+        StoreImg storeImg1 = new StoreImg();
+        storeImg1.setImgSort(3);
+        storeImg1.setImgUrl("22222.jpg");
+        storeImgs.add(storeImg1);
+        StoreImg storeImg2 = new StoreImg();
+        storeImg2.setImgSort(2);
+        storeImg2.setImgUrl("33333.jpg");
+        storeImgs.add(storeImg2);
+        StoreImg storeImg3 = new StoreImg();
+        storeImg3.setImgSort(1);
+        storeImg3.setImgUrl("44444.mp4");
+        storeImgs.add(storeImg3);
+
+        // 先按视频后缀排序,再按ImgSort排序
+        String[] items = storeImgs.stream()
+                .sorted((o1, o2) -> {
+                    boolean o1IsMp4 = isVideoUrl(o1.getImgUrl());
+                    boolean o2IsMp4 = isVideoUrl(o2.getImgUrl());
+                    // 如果都是.mp4或都不是.mp4,则按ImgSort排序
+                    if (o1IsMp4 && o2IsMp4 || !o1IsMp4 && !o2IsMp4) {
+                        return o1.getImgSort().compareTo(o2.getImgSort());
+                    }
+                    // 否则,.mp4的排在前面
+                    return o1IsMp4 ? -1 : 1;
+                }).map(StoreImg::getImgUrl).toArray(String[]::new);
+
+        System.out.println(items);
+    }
+
+    private static boolean isVideoUrl(String url) {
+        if (url == null) return false;
+        url = url.toLowerCase();
+        return url.endsWith(".mp4") ||
+                url.endsWith(".avi") ||
+                url.endsWith(".mov") ||
+                url.endsWith(".flv") ||
+                url.endsWith(".wmv") ||
+                url.endsWith(".mkv");
+    }
 }

+ 12 - 0
alien-store/src/main/java/shop/alien/store/controller/UserViolationController.java

@@ -6,9 +6,11 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
+import shop.alien.entity.store.LifeNotice;
 import shop.alien.entity.store.LifeUserViolation;
 import shop.alien.entity.store.UserLoginInfo;
 import shop.alien.entity.store.dto.LifeUserViolationDto;
+import shop.alien.mapper.LifeNoticeMapper;
 import shop.alien.store.service.LifeUserViolationService;
 import shop.alien.util.common.TokenInfo;
 import springfox.documentation.annotations.ApiIgnore;
@@ -34,6 +36,8 @@ public class UserViolationController {
 
     private final LifeUserViolationService lifeUserViolationService;
 
+    private final LifeNoticeMapper lifeNoticeMapper;
+
     @ApiOperation("举报")
     @ApiOperationSupport(order = 1)
     @PostMapping("/reporting")
@@ -43,6 +47,14 @@ public class UserViolationController {
         if (0 == reporting) {
             return R.fail("举报失败");
         } else {
+            LifeNotice lifeNotice = new LifeNotice();
+            lifeNotice.setSenderId("system");
+            lifeNotice.setReceiverId(lifeuserViolation.getReportingUserId());
+            lifeNotice.setBusinessId(lifeuserViolation.getId());
+            lifeNotice.setTitle("平台已受理");
+            lifeNotice.setContext("平台已受理,感谢您的反馈!");
+            lifeNotice.setNoticeType(1);
+            lifeNoticeMapper.insert(lifeNotice);
             return R.data("举报成功");
         }
     }