package com.cesgroup.controller;

import com.cesgroup.entity.Article;
import com.cesgroup.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by chenpt on 2019/12/2.
 */
@Controller
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;


    @RequestMapping("/queryAll")
    @ResponseBody
    public List<Article> queryAll(){
        return articleService.queryAll();
    }


    @RequestMapping("/batchAdd")
    @ResponseBody
    public Integer batchAdd(){
        List<Article> articles = new ArrayList<>();
        for (int i=0; i<1000; i++){
            Article article = new Article();
            article.setTitle("title-"+i);
            article.setContent("content-"+i);
            articles.add(article);
        }
        return articleService.batchAdd(articles);
    }

}
