CsdnController.java 1.6 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 7
import com.kwan.springbootkwan.entity.Result;
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 17
import java.util.List;

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

    @Autowired
24
    private CsdnService csdnService;
25
    @Autowired
26
    private CsdnUserInfoService csdnUserInfoService;
27

28 29
    @GetMapping("/singleTriplet")
    public Result singleTriplet(@Param("username") String username) {
30 31 32 33 34 35 36 37
        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);
        }
38
        return Result.ok("单人三连完成");
39 40 41 42 43
    }

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