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

3 4
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kwan.springbootkwan.entity.CsdnUserInfo;
5
import com.kwan.springbootkwan.entity.Result;
6
import com.kwan.springbootkwan.service.CsdnAutoReplyService;
7
import com.kwan.springbootkwan.service.CsdnService;
8
import com.kwan.springbootkwan.service.CsdnUserInfoService;
9
import lombok.extern.slf4j.Slf4j;
10
import org.apache.ibatis.annotations.Param;
11 12 13 14 15
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;

16
import java.util.Objects;
17

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

    @Autowired
24
    private CsdnService csdnService;
25
    @Autowired
26
    private CsdnAutoReplyService csdnAutoReplyService;
27
    @Autowired
28
    private CsdnUserInfoService csdnUserInfoService;
29

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

    @GetMapping("/multiTriplet")
    public Result multiTriplet() {
        csdnService.multiTriplet();
45 46
        return Result.ok("多人三连完成");
    }
47 48 49

    @GetMapping("/autoReply")
    public Result autoReply() {
50
        csdnAutoReplyService.commentSelf();
51 52
        return Result.ok("自动回复完成");
    }
53 54 55

    @GetMapping("/resetCurrentStatus")
    public Result resetCurrentStatus() {
56
        csdnUserInfoService.resetCurrentStatus();
57 58 59 60 61 62 63 64 65 66 67 68 69
        return Result.ok("重置新博客状态完成");
    }

    @GetMapping("/resetUserDayStatus")
    public Result resetUserDayStatus() {
        csdnUserInfoService.resetUserDayStatus();
        return Result.ok("重置新一天用户状态完成");
    }

    @GetMapping("/resetDayStatus")
    public Result resetDayStatus() {
        csdnUserInfoService.resetUserDayStatus();
        return Result.ok("重置新一天状态完成");
70
    }
71
}