Ledger Nano X - The secure hardware wallet
SHARE
TWEET

PegawaiController

a guest Apr 8th, 2020 197 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.jr.bpm.controller;
  2.  
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6.  
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.http.HttpHeaders;
  9. import org.springframework.http.HttpStatus;
  10. import org.springframework.http.ResponseEntity;
  11. import org.springframework.stereotype.Controller;
  12. import org.springframework.web.bind.annotation.DeleteMapping;
  13. import org.springframework.web.bind.annotation.GetMapping;
  14. import org.springframework.web.bind.annotation.PathVariable;
  15. import org.springframework.web.bind.annotation.PostMapping;
  16. import org.springframework.web.bind.annotation.PutMapping;
  17. import org.springframework.web.bind.annotation.RequestBody;
  18. import org.springframework.web.bind.annotation.RequestMapping;
  19. import org.springframework.web.util.UriComponentsBuilder;
  20.  
  21. import com.jr.bpm.entity.PegawaiEntity;
  22. import com.jr.bpm.implement.PegawaiImplement;
  23.  
  24.  
  25.  
  26. @Controller
  27. @RequestMapping("pegawai")
  28. public class PegawaiController {
  29.    
  30.     @Autowired
  31.     private PegawaiImplement pegawaiImplement;
  32.    
  33.    
  34. //  @GetMapping("getAll") //http://localhost:8080/pegawai/getAll
  35. //  public ResponseEntity<List<PegawaiEntity>> getAllPegawai() {
  36. //      List <PegawaiEntity> listPegawai = pegawaiImplement.getAllNama();
  37. //      return new ResponseEntity<List<PegawaiEntity>>(listPegawai, HttpStatus.OK);
  38. //  }
  39.    
  40.    
  41.     @GetMapping("getAll")
  42.     public ResponseEntity<Map<String, Object>> getAllPegawaiNew() {
  43.         List <PegawaiEntity> listPegawaiNew = pegawaiImplement.getAllNama();
  44.         Map <String, Object> map_listPegawai = new HashMap<>();
  45.        
  46.         map_listPegawai.put("code", HttpStatus.OK.value());
  47.         map_listPegawai.put("messages", HttpStatus.OK.getReasonPhrase());
  48.         map_listPegawai.put("data", listPegawaiNew);
  49.        
  50.         return new ResponseEntity<>(map_listPegawai, HttpStatus.OK);   
  51.     }
  52.  
  53.    
  54.     @GetMapping("getById/{id}")
  55.     public ResponseEntity<PegawaiEntity> getPegawaiById (@PathVariable("id") Long id) {
  56.         PegawaiEntity listPegawaiById = pegawaiImplement.getNamabyId(id);
  57.         return new ResponseEntity<PegawaiEntity>(listPegawaiById, HttpStatus.OK);
  58.     }
  59.    
  60.    
  61.     @PostMapping("create/pegawai")
  62.     public ResponseEntity<Void> addPegawai (@RequestBody PegawaiEntity nama, UriComponentsBuilder builder) {
  63.        
  64.         boolean flag = pegawaiImplement.addNama(nama);
  65.         if (flag == false) {
  66.             return new ResponseEntity<Void>(HttpStatus.CONFLICT);
  67.         }
  68.            
  69.         HttpHeaders headers = new HttpHeaders();
  70.         headers.setLocation(builder.path("/pegawai/getById/{id}").buildAndExpand(nama.getId()).toUri());
  71.        
  72.         return new ResponseEntity<Void>(headers, HttpStatus.OK);
  73.     }
  74.    
  75.     @PutMapping("edit/pegawai")
  76.     public ResponseEntity<PegawaiEntity> editPegawai(@RequestBody PegawaiEntity nama) {
  77.         pegawaiImplement.updateNama(nama);
  78.         return new ResponseEntity<PegawaiEntity>(nama, HttpStatus.OK);
  79.     }
  80.    
  81.    
  82.     @DeleteMapping("delete/{id}")
  83.     public ResponseEntity<Void> deletePegawai (@PathVariable("id") Long id) {
  84.         pegawaiImplement.deleteNama(id);
  85.         return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
  86.     }
  87.  
  88. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top