首页>代码>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 2024年4月10日
asidun  LV1 2022年12月29日
ajsfkl  LV3 2022年8月19日
taoyi123  LV17 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日
最近浏览更多
Feel_可乐  LV10 3月5日
srmess  LV4 2024年12月31日
微信网友_6955249237250048  LV5 2024年12月28日
nuxgod  LV1 2024年4月10日
zolscy  LV24 2024年3月24日
1049066887  LV13 2024年3月3日
lingtiejing  LV15 2023年10月1日
woldxy  LV12 2023年9月28日
漫步的海星  LV4 2023年9月26日
zhy1989wz  LV7 2023年9月26日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友