首页>代码>Spring Boot整合VueJS+spring data jpa实现待办事项TODO项目实例>/springboot-todomvc-mysql-vuejs/src/main/java/com/hellokoding/springboot/fullstack/todo/TodoAPI.java
package com.hellokoding.springboot.fullstack.todo;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


@RestController
@RequestMapping("/api/v1/todos")
@Slf4j
public class TodoAPI {
    private final TodoService stockService;

    @Autowired
    public TodoAPI(TodoService stockService) {
        this.stockService = stockService;
    }

    @GetMapping
    public ResponseEntity<List<Todo>> findAll() {
        return ResponseEntity.ok(stockService.findAll());
    }

    @PostMapping
    public ResponseEntity saveAll(@Valid @RequestBody List<Todo> todos) {
        log.info(todos.toString());
        return ResponseEntity.ok(stockService.saveAll(todos));
    }
}
最近下载更多
nuxgod  LV1 4月10日
asidun  LV1 2022年12月29日
ajsfkl  LV3 2022年8月19日
taoyi123  LV16 2021年3月25日
浙江螃蟹  LV7 2020年12月2日
zhangvsxun  LV2 2020年12月1日
sunyongf  LV3 2020年11月18日
ningmeng2020  LV2 2020年11月10日
sinbero  LV8 2020年11月10日
最近浏览更多
nuxgod  LV1 4月10日
zolscy  LV12 3月24日
1049066887  LV12 3月3日
lingtiejing  LV15 2023年10月1日
woldxy  LV12 2023年9月28日
漫步的海星  LV4 2023年9月26日
zhy1989wz  LV6 2023年9月26日
skook7  LV2 2023年8月31日
38735466  LV11 2023年8月25日
dzlwindy  LV8 2023年7月12日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友