package com.braimatics.training.controller;

import com.braimatics.training.dao.MateriDao;
import com.braimatics.training.entity.Materi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/materi")
public class MateriRestController {
    
    @Autowired private MateriDao md;
    
    @RequestMapping("/")
    public Page<Materi> daftarMateri(Pageable page){
        return md.findAll(page);
    }
}

@@ -130,16 +130,47 @@
 Materi;%0A
+import javax.validation.Valid;%0A
 import o
@@ -349,42 +349,271 @@
 ork.
-web.bind.annotation.RequestMapping
+http.HttpStatus;%0Aimport org.springframework.web.bind.annotation.RequestBody;%0Aimport org.springframework.web.bind.annotation.RequestMapping;%0Aimport org.springframework.web.bind.annotation.RequestMethod;%0Aimport org.springframework.web.bind.annotation.ResponseStatus
 ;%0Aim
@@ -828,11 +828,45 @@
 ing(
-%22/%22
+value=%22/%22, method = RequestMethod.GET
 )%0A  
@@ -955,10 +955,195 @@
 ;%0A    %7D%0A
+    %0A    @RequestMapping(value=%22/%22, method = RequestMethod.POST)%0A    @ResponseStatus(HttpStatus.CREATED)%0A    public void create(@RequestBody @Valid Materi m)%7B%0A        md.save(m);%0A    %7D%0A
 %7D%0A

implement create record via rest