无关风月
2024-08-20 f237a61c412870933f47316a011237cd538de9bc
guns-admin/src/main/java/com/stylefeng/guns/modular/api/FindController.java
@@ -63,7 +63,11 @@
    })
    public ResultUtil<List<MessagesVO>> messageList(MessageQuery req) {
        req.setPageNum((req.getPageNum() - 1) * req.getPageSize());
        Integer id = appUserService.getAppUser().getId();
        AppUser appUser = appUserService.getAppUser();
        if (appUser == null){
            return ResultUtil.tokenErr("登录失效");
        }
        Integer id = appUser.getId();
        List<MessagesVO> res = messageService.selectMessages(id,req);
        SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
        for (MessagesVO re : res) {
@@ -100,8 +104,12 @@
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil<Integer> messageCount() {
        AppUser appUser = appUserService.getAppUser();
        if (appUser == null){
            return ResultUtil.tokenErr("登录失效");
        }
        int size = messageService.selectList(new EntityWrapper<Message>()
                .eq("userId", appUserService.getAppUser().getId())
                .eq("userId", appUser.getId())
                .eq("isRead", 0)).size();
        return ResultUtil.success(size);
    }
@@ -119,6 +127,10 @@
            @ApiImplicitParam(name = "content", value = "回复内容", required = true),
    })
    public ResultUtil addComment(Integer findId,Integer pid,Integer replyUserId,String content,Integer replyCommentId) {
        AppUser appUser = appUserService.getAppUser();
        if (appUser == null){
            return ResultUtil.tokenErr("登录失效");
        }
        AuditVO content1 = auditUtil.content(content);
        switch (content1.getType()){
            case "terrorism":
@@ -174,12 +186,17 @@
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil collectCourse(AddFindDTO dto) {
    public ResultUtil collectCourse(AddFindDTO dto) throws InterruptedException {
        AppUser appUser = appUserService.getAppUser();
        if (appUser == null){
            return ResultUtil.tokenErr("登录失效");
        }
        if (StringUtils.hasLength(dto.getVideo())){
                // 根据id回查
                String id = auditUtil.video(dto.getVideo());
                String audit = auditUtil.audit(id);
                while(audit.equals("running")){
                    Thread.sleep(500);
                    audit = auditUtil.audit(id);
                    System.err.println("未审核完");
                }
@@ -261,6 +278,10 @@
            @ApiImplicitParam(name = "id", value = "动态id", required = true)
    })
    public ResultUtil<FindVO> findDetail(Integer id) {
        AppUser appUser = appUserService.getAppUser();
        if (appUser == null){
            return ResultUtil.tokenErr("登录失效");
        }
        Find find1 = findService.selectById(id);
        FindVO findVO = new FindVO();
        findVO.setId(find1.getId());
@@ -282,7 +303,7 @@
                .eq("findId", find1.getId())
                .eq("isShow", 1)).size();
        findVO.setComment(size);
        AppUser appUser = appUserService.selectById(find1.getUserId());
        findVO.setHeadImg(appUser.getHeadImg());
        findVO.setUserName(appUser.getName());
        findVO.setClockIn(appUser.getClockIn());
@@ -308,6 +329,10 @@
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil<List<CommentVO>> findDetail(CommentQuery query) throws ParseException {
        AppUser appUser = appUserService.getAppUser();
        if (appUser == null){
            return ResultUtil.tokenErr("登录失效");
        }
        query.setPageNum((query.getPageNum() - 1) * query.getPageSize());
        // 查询一级评论
        List<CommentVO> one = findCommentService.getCommentOne(query);
@@ -413,6 +438,10 @@
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil<List<CommentVO>> findCommentListOne(CommentQuery query) {
        AppUser appUser = appUserService.getAppUser();
        if (appUser == null){
            return ResultUtil.tokenErr("登录失效");
        }
        // 查询一级评论
        List<CommentVO> one = findCommentService.getCommentThree(query);
        for (CommentVO commentVO : one) {
@@ -499,6 +528,10 @@
            @ApiImplicitParam(name = "type", value = "类型 1 = 点赞动态 2 = 点赞评论", required = true)
    })
    public ResultUtil cancelLike(Integer id,Integer type) {
        AppUser appUser = appUserService.getAppUser();
        if (appUser == null){
            return ResultUtil.tokenErr("登录失效");
        }
        Like like = likeService.selectOne(new EntityWrapper<Like>()
                .eq("userId", appUserService.getAppUser().getId())
                .eq("type", type)
@@ -518,8 +551,11 @@
            @ApiImplicitParam(name = "type", value = "类型 1 = 点赞动态 2 = 点赞评论", required = true)
    })
    public ResultUtil Like(Integer id,Integer type,Integer findCommentId) {
        // 点赞之后要加入一条消息
        AppUser appUser = appUserService.getAppUser();
        if (appUser == null){
            return ResultUtil.tokenErr("登录失效");
        }
        // 点赞之后要加入一条消息
        Message message = new Message();
        message.setType(2);
        message.setFindId(id);
@@ -601,6 +637,10 @@
            @ApiImplicitParam(name = "type", value = "类型 1 = 举报动态 2 = 举报评论", required = true)
    })
    public ResultUtil report(Integer id,String content,Integer type) {
        AppUser appUser = appUserService.getAppUser();
        if (appUser == null){
            return ResultUtil.tokenErr("登录失效");
        }
        AuditVO content1 = auditUtil.content(content);
        switch (content1.getType()){
            case "terrorism":
@@ -639,6 +679,8 @@
        return ResultUtil.success("举报成功");
    }
    @Autowired
    private IUserBlackService userBlackService;
    @ResponseBody
    @PostMapping("/base/find/findList")
    @ApiOperation(value = "主页", tags = {"发现"})
@@ -647,13 +689,29 @@
    })
    public ResultUtil<List<FindVO>> findList(FindQuery query) {
        AppUser appUser = appUserService.getAppUser();
        if (appUser == null){
            return ResultUtil.tokenErr("登录失效");
        }
        EntityWrapper<Find> wrapper = new EntityWrapper<>();
        if (StringUtils.hasLength(query.getUserNameOrTitle())){
            wrapper.like("title",query.getUserNameOrTitle());
        }
        List<FindVO> result = findService.findList(query.getUserNameOrTitle());
        for (FindVO find : result) {
        List<FindVO> res = new ArrayList<>();
        // 被拉黑用户ids
        List<Integer> collect = userBlackService.selectList(new EntityWrapper<UserBlack>()
                .eq("userId", appUser.getId())).stream().map(UserBlack::getBlackUserId).collect(Collectors.toList());
        // todo 2.0新增 被拉黑不查看双方动态
        for (FindVO find : result) {
            // 如果用户拉黑了 那么不展示该条动态
            if (collect.size()>0){
                if (collect.contains(find.getUserId())){
                    // 如果当前动态的发布用户id 是登录用户的黑名单 那过滤掉该条动态
                    continue;
                }
            }
            FindVO temp = new FindVO();
            BeanUtils.copyProperties(find,temp);
            Like like = likeService.selectOne(new EntityWrapper<Like>()
@@ -671,8 +729,9 @@
                    .eq("findId", find.getId())
                    .eq("isShow", 1)).size();
            find.setComment(size);
            res.add(find);
        }
        List<FindVO> testing = testing(result.size(), query.getPageNum(), query.getPageSize(), result);
        List<FindVO> testing = testing(res.size(), query.getPageNum(), query.getPageSize(), res);
        return ResultUtil.success(testing);
    }
    public static List<FindVO> testing(long total, long current, long size, List<FindVO> str){