CsdnController.java 3.3 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 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 15 16 17
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;

18
import java.util.Objects;
19

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

    @Autowired
27
    private CsdnService csdnService;
28
    @Autowired
29
    private CsdnAutoReplyService csdnAutoReplyService;
30
    @Autowired
31
    private CsdnUserInfoService csdnUserInfoService;
32

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

46
    @ApiOperation(value = "多人三连", nickname = "多人三连")
47 48 49
    @GetMapping("/multiTriplet")
    public Result multiTriplet() {
        csdnService.multiTriplet();
50 51
        return Result.ok("多人三连完成");
    }
52

53
    @ApiOperation(value = "自动回复", nickname = "自动回复")
54 55
    @GetMapping("/autoReply")
    public Result autoReply() {
56
        csdnAutoReplyService.commentSelf();
57 58
        return Result.ok("自动回复完成");
    }
59

60 61 62 63 64
    @ApiOperation(value = "重置全员新博客状态", nickname = "重置全员新博客状态")
    @GetMapping("/resetAllCurrentStatus")
    public Result resetAllCurrentStatus() {
        csdnUserInfoService.resetAllCurrentStatus();
        return Result.ok("重置全员新博客状态完成");
65 66
    }

67 68 69 70 71 72 73 74 75 76 77 78 79 80
    @ApiOperation(value = "重置指定人员新博客状态", nickname = "重置指定人员新博客状态")
    @GetMapping("/resetCsdnUserInfo")
    public Result resetCsdnUserInfo(@Param("username") String username) {
        QueryWrapper<CsdnUserInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("is_delete", 0);
        wrapper.eq("user_name", username).last("limit 1");
        final CsdnUserInfo csdnUserInfo = csdnUserInfoService.getOne(wrapper);
        if (Objects.nonNull(csdnUserInfo)) {
            csdnUserInfoService.resetCsdnUserInfo(csdnUserInfo);
        }
        return Result.ok("重置指定人员新博客状态完成");
    }

    @ApiOperation(value = "重置新一天用户状态", nickname = "重置新一天用户状态")
81 82 83 84 85
    @GetMapping("/resetUserDayStatus")
    public Result resetUserDayStatus() {
        csdnUserInfoService.resetUserDayStatus();
        return Result.ok("重置新一天用户状态完成");
    }
86
}