Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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(Integer id){
return articleService.queryAll(id);
}
@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);
}
}