// Path: src/main/java/com/rizki/mufrizal/spring/oauth2/custom/domain/Mahasiswa.java
// @Entity
// @Table(name = "tb_mahasiswa")
// public class Mahasiswa implements Serializable {
// 
//     @Id
//     @Getter
//     @Setter
//     @Column(name = "npm")
//     private String npm;
// 
//     @Getter
//     @Setter
//     @Column(name = "nama", length = 50, nullable = false)
//     private String nama;
// 
//     @Getter
//     @Setter
//     @Column(name = "kelas", length = 6, nullable = false)
//     private String kelas;
// 
//     @Getter
//     @Setter
//     @Column(name = "jenis_kelamin")
//     @Enumerated(EnumType.STRING)
//     private JenisKelamin jenisKelamin;
// 
//     @Getter
//     @Setter
//     @Lob
//     @Column(name = "alamat")
//     private String alamat;
// 
//     @Getter
//     @Setter
//     @OneToMany(cascade = {CascadeType.ALL}, orphanRemoval = true, fetch = FetchType.LAZY, mappedBy = "mahasiswa")
//     private List<Peminjaman> peminjamans = new ArrayList<>();
// }
// 
// Path: src/main/java/com/rizki/mufrizal/spring/oauth2/custom/service/MahasiswaService.java
// public interface MahasiswaService {
// 
//     public void saveMahasiswa(Mahasiswa mahasiswa);
// 
//     public void updateMahasiswa(Mahasiswa mahasiswa);
// 
//     public void deleteMahasiswa(String idMahasiswa);
// 
//     public Mahasiswa getMahasiswa(String idMahasiswa);
// 
//     public Page<Mahasiswa> getMahasiswas(Pageable pageable);
// }


import com.rizki.mufrizal.spring.oauth2.custom.domain.Mahasiswa;
import com.rizki.mufrizal.spring.oauth2.custom.service.MahasiswaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
package com.rizki.mufrizal.spring.oauth2.custom.controller;


/**
 *
 * @Author Rizki Mufrizal <mufrizalrizki@gmail.com>
 * @Web <https://RizkiMufrizal.github.io>
 * @Since Feb 5, 2017
 * @Time 8:05:40 PM
 * @Encoding UTF-8
 * @Project Spring-OAuth2-Custom
 * @Package com.rizki.mufrizal.spring.oauth2.custom.controller
 *
 */
@RestController
@RequestMapping(value = "/api")
public class MahasiswaController {

    @Autowired
    private MahasiswaService mahasiswaService;

    @GetMapping(value = "/mahasiswas")
    @CrossOrigin
    public HttpEntity<Page<Mahasiswa>> getMahasiswas(Pageable pageable) {
        return new ResponseEntity<>(mahasiswaService.getMahasiswas(pageable), HttpStatus.OK);
    }

    @GetMapping(value = "/mahasiswas/{idMahasiswa}")
    @CrossOrigin
// Path: src/main/java/com/rizki/mufrizal/spring/oauth2/custom/domain/Mahasiswa.java
// @Entity
// @Table(name = "tb_mahasiswa")
// public class Mahasiswa implements Serializable {
// 
//     @Id
//     @Getter
//     @Setter
//     @Column(name = "npm")
//     private String npm;
// 
//     @Getter
//     @Setter
//     @Column(name = "nama", length = 50, nullable = false)
//     private String nama;
// 
//     @Getter
//     @Setter
//     @Column(name = "kelas", length = 6, nullable = false)
//     private String kelas;
// 
//     @Getter
//     @Setter
//     @Column(name = "jenis_kelamin")
//     @Enumerated(EnumType.STRING)
//     private JenisKelamin jenisKelamin;
// 
//     @Getter
//     @Setter
//     @Lob
//     @Column(name = "alamat")
//     private String alamat;
// 
//     @Getter
//     @Setter
//     @OneToMany(cascade = {CascadeType.ALL}, orphanRemoval = true, fetch = FetchType.LAZY, mappedBy = "mahasiswa")
//     private List<Peminjaman> peminjamans = new ArrayList<>();
// }
// 
// Path: src/main/java/com/rizki/mufrizal/spring/oauth2/custom/service/MahasiswaService.java
// public interface MahasiswaService {
// 
//     public void saveMahasiswa(Mahasiswa mahasiswa);
// 
//     public void updateMahasiswa(Mahasiswa mahasiswa);
// 
//     public void deleteMahasiswa(String idMahasiswa);
// 
//     public Mahasiswa getMahasiswa(String idMahasiswa);
// 
//     public Page<Mahasiswa> getMahasiswas(Pageable pageable);
// }


// Path: src/main/java/com/rizki/mufrizal/spring/oauth2/custom/controller/MahasiswaController.java
import com.rizki.mufrizal.spring.oauth2.custom.domain.Mahasiswa;
import com.rizki.mufrizal.spring.oauth2.custom.service.MahasiswaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

package com.rizki.mufrizal.spring.oauth2.custom.controller;


/**
 *
 * @Author Rizki Mufrizal <mufrizalrizki@gmail.com>
 * @Web <https://RizkiMufrizal.github.io>
 * @Since Feb 5, 2017
 * @Time 8:05:40 PM
 * @Encoding UTF-8
 * @Project Spring-OAuth2-Custom
 * @Package com.rizki.mufrizal.spring.oauth2.custom.controller
 *
 */
@RestController
@RequestMapping(value = "/api")
public class MahasiswaController {

    @Autowired
    private MahasiswaService mahasiswaService;

    @GetMapping(value = "/mahasiswas")
    @CrossOrigin
    public HttpEntity<Page<Mahasiswa>> getMahasiswas(Pageable pageable) {
        return new ResponseEntity<>(mahasiswaService.getMahasiswas(pageable), HttpStatus.OK);
    }

    @GetMapping(value = "/mahasiswas/{idMahasiswa}")
    @CrossOrigin
    public HttpEntity<Mahasiswa> getMahasiswa(@PathVariable("idMahasiswa") String idMahasiswa) {