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

3
import cn.hutool.core.collection.CollectionUtil;
4
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 10
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
11
import lombok.extern.slf4j.Slf4j;
12
import org.apache.ibatis.annotations.Param;
13 14
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
15 16
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
17 18 19
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

20
import java.util.List;
21
import java.util.Objects;
22

23 24
@Slf4j
@RestController
25
@Api(tags = "csdn三连用户管理")
26 27 28 29
@RequestMapping("/csdn")
public class CsdnController {

    @Autowired
30
    private CsdnService csdnService;
31
    @Autowired
32
    private CsdnAutoReplyService csdnAutoReplyService;
33
    @Autowired
34
    private CsdnUserInfoService csdnUserInfoService;
35

36
    @ApiOperation(value = "单人三连", nickname = "单人三连")
37 38
    @GetMapping("/singleTriplet")
    public Result singleTriplet(@Param("username") String username) {
39
        CsdnUserInfo csdnUserInfo = csdnUserInfoService.getUserByUserName(username);
40
        if (Objects.nonNull(csdnUserInfo)) {
41 42
            csdnService.singleArticle(csdnUserInfo);
        }
43
        return Result.ok("单人三连完成");
44 45
    }

46
    @ApiOperation(value = "多人三连", nickname = "多人三连")
47 48 49 50 51 52 53
    @PostMapping("/multiTriplet")
    public Result multiTriplet(@RequestBody List<String> userNames) {
        if (CollectionUtil.isNotEmpty(userNames)) {
            for (String userName : userNames) {
                singleTriplet(userName);
            }
        }
54 55
        return Result.ok("多人三连完成");
    }
56

57 58 59 60 61 62 63
    @ApiOperation(value = "全员三连", nickname = "全员三连")
    @GetMapping("/allTriplet")
    public Result allTriplet() {
        csdnService.allTriplet();
        return Result.ok("全员三连完成");
    }

64
    @ApiOperation(value = "自动回复", nickname = "自动回复")
65 66
    @GetMapping("/autoReply")
    public Result autoReply() {
67
        csdnAutoReplyService.commentSelf();
68 69
        return Result.ok("自动回复完成");
    }
70

71 72 73 74 75
    @ApiOperation(value = "重置全员新博客状态", nickname = "重置全员新博客状态")
    @GetMapping("/resetAllCurrentStatus")
    public Result resetAllCurrentStatus() {
        csdnUserInfoService.resetAllCurrentStatus();
        return Result.ok("重置全员新博客状态完成");
76 77
    }

78 79 80
    @ApiOperation(value = "重置指定人员新博客状态", nickname = "重置指定人员新博客状态")
    @GetMapping("/resetCsdnUserInfo")
    public Result resetCsdnUserInfo(@Param("username") String username) {
81
        CsdnUserInfo csdnUserInfo = csdnUserInfoService.getUserByUserName(username);
82 83 84 85 86 87
        if (Objects.nonNull(csdnUserInfo)) {
            csdnUserInfoService.resetCsdnUserInfo(csdnUserInfo);
        }
        return Result.ok("重置指定人员新博客状态完成");
    }

88 89 90 91 92 93 94 95 96 97 98
    @ApiOperation(value = "重置多个人员新博客", nickname = "重置多个人员新博客")
    @PostMapping("/resetCsdnUserInfo")
    public Result resetCsdnUserInfo(@RequestBody List<String> userNames) {
        if (CollectionUtil.isNotEmpty(userNames)) {
            for (String userName : userNames) {
                resetCsdnUserInfo(userName);
            }
        }
        return Result.ok("重置多个人员新博客状态完成");
    }

99
    @ApiOperation(value = "重置新一天用户状态", nickname = "重置新一天用户状态")
100 101 102 103 104
    @GetMapping("/resetUserDayStatus")
    public Result resetUserDayStatus() {
        csdnUserInfoService.resetUserDayStatus();
        return Result.ok("重置新一天用户状态完成");
    }
105 106 107 108 109 110 111 112

    @ApiOperation(value = "给指定人员添加10篇博客", nickname = "给指定人员添加10篇博客")
    @GetMapping("/add10Blog")
    public Result add10Blog(@Param("username") String username) {
        csdnUserInfoService.add10Blog(username);
        return Result.ok("给指定人员添加10篇博客完成");
    }

113
}