yufeng0528 пре 4 година
родитељ
комит
4106eca77a

+ 32 - 0
spring5-auth/spring5-auth-server/src/main/java/com/yaozhitech/spring5/controller/ArticleController.java

@@ -0,0 +1,32 @@
1
+package com.yaozhitech.spring5.controller;
2
+
3
+import java.util.ArrayList;
4
+import java.util.List;
5
+
6
+import org.springframework.http.ResponseEntity;
7
+import org.springframework.web.bind.annotation.GetMapping;
8
+import org.springframework.web.bind.annotation.PathVariable;
9
+import org.springframework.web.bind.annotation.RequestMapping;
10
+import org.springframework.web.bind.annotation.RestController;
11
+
12
+import com.yaozhitech.spring5.dto.ArticleDto;
13
+
14
+@RestController
15
+@RequestMapping("/article")
16
+public class ArticleController {
17
+
18
+    @GetMapping("/list")
19
+    public ResponseEntity<List<ArticleDto>> list(){
20
+    	List<ArticleDto> list = new ArrayList<ArticleDto>();
21
+    	
22
+    	list.add(ArticleDto.toArticle("title"));
23
+        return ResponseEntity.ok(list);
24
+    }
25
+
26
+    @GetMapping("/{id}")
27
+    public ResponseEntity<ArticleDto> read(@PathVariable Long id){
28
+        return null;
29
+    }
30
+
31
+
32
+}

+ 27 - 0
spring5-auth/spring5-auth-server/src/main/java/com/yaozhitech/spring5/dto/ArticleDto.java

@@ -0,0 +1,27 @@
1
+package com.yaozhitech.spring5.dto;
2
+
3
+import java.util.Date;
4
+
5
+import lombok.Data;
6
+
7
+@Data
8
+public class ArticleDto {
9
+
10
+	private Long id;
11
+    private String title;
12
+    private String author;
13
+    private Date issueTime;
14
+    private Date created;
15
+    private Date modified;
16
+    private Long createUserId;
17
+    private String createUserName;
18
+    private Integer status; //0:待发布, 1:已发布,  2:已删除
19
+    private String content;
20
+    private String headImgUrl;  //标题图片
21
+    
22
+    public static ArticleDto toArticle(String title) {
23
+    	ArticleDto articleDto = new ArticleDto();
24
+    	articleDto.setTitle(title);
25
+    	return articleDto;
26
+    }
27
+}