CsdnController.java 1.9 KB
Newer Older
1 2
package com.kwan.springbootkwan.controller;

3 4 5
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kwan.springbootkwan.entity.CsdnUserInfo;
6
import com.kwan.springbootkwan.entity.Result;
7
import com.kwan.springbootkwan.service.CsdnCommentService;
8
import com.kwan.springbootkwan.service.CsdnService;
9
import com.kwan.springbootkwan.service.CsdnUserInfoService;
10
import lombok.extern.slf4j.Slf4j;
11
import org.apache.ibatis.annotations.Param;
12 13 14 15 16
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

17 18
import java.util.List;

19 20 21 22 23 24
@Slf4j
@RestController
@RequestMapping("/csdn")
public class CsdnController {

    @Autowired
25
    private CsdnService csdnService;
26
    @Autowired
27 28
    private CsdnCommentService csdnCommentService;
    @Autowired
29
    private CsdnUserInfoService csdnUserInfoService;
30

31 32
    @GetMapping("/singleTriplet")
    public Result singleTriplet(@Param("username") String username) {
33 34 35 36 37 38 39 40
        QueryWrapper<CsdnUserInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("is_delete", 0);
        wrapper.eq("user_name", username);
        final List<CsdnUserInfo> list = csdnUserInfoService.list(wrapper);
        if (CollectionUtil.isNotEmpty(list)) {
            final CsdnUserInfo csdnUserInfo = list.get(0);
            csdnService.singleArticle(csdnUserInfo);
        }
41
        return Result.ok("单人三连完成");
42 43 44 45 46
    }

    @GetMapping("/multiTriplet")
    public Result multiTriplet() {
        csdnService.multiTriplet();
47 48
        return Result.ok("多人三连完成");
    }
49 50 51 52 53 54

    @GetMapping("/autoReply")
    public Result autoReply() {
        csdnCommentService.commentSelf();
        return Result.ok("自动回复完成");
    }
55
}