新增全局报错处理统 优化代码结构 article基础代码完成
This commit is contained in:
@@ -5,6 +5,7 @@ import com.qf.myafterprojecy.pojo.ResponseMessage;
|
||||
import com.qf.myafterprojecy.pojo.dto.ArticleDto;
|
||||
import com.qf.myafterprojecy.service.IArticleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@@ -17,14 +18,24 @@ public class ArticleController {
|
||||
@Autowired
|
||||
IArticleService ArticleService;
|
||||
|
||||
@PostMapping
|
||||
public ResponseMessage<Iterable<Article>> getArticle(){
|
||||
return ArticleService.getArticleAll();
|
||||
};
|
||||
@GetMapping
|
||||
public ResponseMessage<Article> geybyID(@RequestBody ArticleDto articleDto){
|
||||
System.out.println("id:"+ articleDto.getArticleid());
|
||||
return ArticleService.getArticleByid(Integer.valueOf(articleDto.getArticleid()));
|
||||
public ResponseMessage<Iterable<Article>> getArticleAllByID(@Validated @RequestBody ArticleDto articleDto){
|
||||
return ArticleService.getArticleAllByID(articleDto);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public ResponseMessage<Article> UpdateArticle(@RequestBody ArticleDto articleDto){
|
||||
return ArticleService.SaveArticle(articleDto);
|
||||
};
|
||||
|
||||
@PostMapping
|
||||
public ResponseMessage<Article> AddArticle(@RequestBody ArticleDto articleDto){
|
||||
return ArticleService.SaveArticle(articleDto);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public ResponseMessage<Article> DeleteArticle(@RequestBody ArticleDto articleDto){
|
||||
return ArticleService.deleteArticle(articleDto.getArticleid());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user