-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Potreban merge zbog mikroservisa (#99)
* popravljen model * popravljen model * dodat id za kontnu grupu * implementiran model za zaposlenog i platu * popravka modela * ispravka greski prilikom kucanja * Uradjen Crud zaposleni. * Bug fix.. * CRUD Plata (#81) * popravljen model * wip * wip * zavrsen crud za platu * vraceno ime user tabele na default * sklonjena dupla anotacija * popravljena put ruta da se slaze sa ostatkom api-ja * ispravljene sonar greske * napisan test i prebaceno pravljenje plate u servis Co-authored-by: ncvetinovic7619rn <[email protected]> Co-authored-by: Milutin Milicevic <[email protected]> * Premestena logika za otkazZaposlenog iz kontrolera u zaposleniService, i uradjene sitne izmene. * Dodati exceptioni u ZaposleniController. * Dovrsen staz u createZaposleni. * Dodate relacije * Dodate relacije za StatusZaposlenog i RadnaPozicija * Dodata ruta za dohvatanje svih plata * Filtriranje po atributu iz druge tabele koja nije primarni kljuc * CRUD koeficijent (#73) * #6 get sume - Controller metoda i service metode za sumiranje. * merge * @gojkovicmatija99 komentari ispravke i sonar ispravke * #19 CRUD kontne grupe * #19 sonar izmene * #19 ispravke * #19 - refaktorisanje posle promene modela * #19 - ispravke * #19 @mstosic99 komentari ispravke * #58 CRUD koeficijent * #58 ispravke * Update popravka * Kontne grupe popravka * Kontne grupe popravka * Zaposleni POST fix * Zaposleni bug fix1 (#93) * Popravljen update zaposleni. * Delete zaposleni. * Sredjen delte zaposleni. * Zavrseno CRUD zaposlen. * Fix za update plate * Fix za glavnu knjigu * Reverted updateDatumDoNaStarojPlati * Dodat komentar Co-authored-by: ncvetinovic7619rn <[email protected]> Co-authored-by: Luka Mitrovic <[email protected]> Co-authored-by: Marec99 <[email protected]> Co-authored-by: Bagelax <[email protected]> Co-authored-by: Milutin Milicevic <[email protected]> Co-authored-by: Aleksa Dačić <[email protected]> Co-authored-by: Marko Radisic <[email protected]>
- Loading branch information
1 parent
b23c9c1
commit 72f80ac
Showing
32 changed files
with
1,116 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/rs/raf/demo/controllers/KoeficijentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package rs.raf.demo.controllers; | ||
|
||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import rs.raf.demo.model.Koeficijent; | ||
import rs.raf.demo.services.IService; | ||
import rs.raf.demo.services.impl.KoeficijentService; | ||
|
||
import javax.persistence.EntityNotFoundException; | ||
|
||
@CrossOrigin | ||
@RestController | ||
@SecurityRequirement(name = "bearerAuth") | ||
@RequestMapping("/api/koeficijenti") | ||
public class KoeficijentController { | ||
private final IService<Koeficijent, Long> koeficijentService; | ||
|
||
public KoeficijentController(KoeficijentService koeficijentService) { | ||
this.koeficijentService = koeficijentService; | ||
} | ||
|
||
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<?> findAll() { | ||
return ResponseEntity.ok(koeficijentService.findAll()); | ||
} | ||
|
||
@PutMapping(produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<?> update(@RequestBody Koeficijent koeficijent) { | ||
if (koeficijentService.findById(koeficijent.getKoeficijentId()).isPresent()) | ||
return ResponseEntity.ok(koeficijentService.save(koeficijent)); | ||
throw new EntityNotFoundException(); | ||
} | ||
|
||
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<?> create(@RequestBody Koeficijent koeficijent) { | ||
return ResponseEntity.ok(koeficijentService.save(koeficijent)); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
src/main/java/rs/raf/demo/controllers/PlataRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package rs.raf.demo.controllers; | ||
|
||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import org.springframework.data.jpa.domain.Specification; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import rs.raf.demo.model.Plata; | ||
import rs.raf.demo.requests.PlataRequest; | ||
import rs.raf.demo.services.impl.PlataService; | ||
import rs.raf.demo.utils.SearchUtil; | ||
|
||
import javax.persistence.EntityNotFoundException; | ||
import javax.validation.Valid; | ||
import java.util.Optional; | ||
|
||
@CrossOrigin | ||
@RestController | ||
@SecurityRequirement(name = "bearerAuth") | ||
@RequestMapping("/api") | ||
public class PlataRestController { | ||
private final PlataService plataService; | ||
private final SearchUtil<Plata> searchUtil; | ||
|
||
public PlataRestController(PlataService plataService) { | ||
this.plataService = plataService; | ||
this.searchUtil = new SearchUtil<>(); | ||
} | ||
|
||
@GetMapping(value = "/zaposleni/{id}/plata", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<?> getPlataForZaposleni(@PathVariable("id") Long zaposleniId) { | ||
return ResponseEntity.ok(this.plataService.findByZaposleniZaposleniId(zaposleniId)); | ||
} | ||
|
||
@GetMapping(value = "/plata", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<?> getPlata(@RequestParam(name = "search", required = false, defaultValue = "") String search) { | ||
Specification<Plata> spec = this.searchUtil.getSpec(search); | ||
return ResponseEntity.ok(this.plataService.findAll(spec)); | ||
} | ||
|
||
@GetMapping(value = "/plata/all", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<?> getAllPlata() { | ||
return ResponseEntity.ok(this.plataService.findAll()); | ||
} | ||
|
||
@GetMapping(value = "/plata/{id}", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<?> getPlataById(@PathVariable("id") Long plataId) { | ||
Optional<Plata> optionalPlata = this.plataService.findById(plataId); | ||
if (optionalPlata.isPresent()) | ||
return ResponseEntity.ok(optionalPlata.get()); | ||
throw new EntityNotFoundException(); | ||
} | ||
|
||
@PostMapping(value = "/plata", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<?> newPlata(@Valid @RequestBody PlataRequest plata) { | ||
try { | ||
return ResponseEntity.ok(this.plataService.save(plata)); | ||
} catch (Exception e) { | ||
throw new EntityNotFoundException(); | ||
} | ||
} | ||
|
||
@PutMapping(value = "/plata", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<?> editPlata(@Valid @RequestBody PlataRequest plata) { | ||
Optional<Plata> optionalPlata = this.plataService.findById(plata.getPlataId()); | ||
if (optionalPlata.isPresent()) { | ||
try { | ||
return ResponseEntity.ok(this.plataService.save(plata)); | ||
} catch (Exception e) { | ||
throw new EntityNotFoundException(); | ||
} | ||
} | ||
throw new EntityNotFoundException(); | ||
} | ||
|
||
@DeleteMapping(value = "/plata/{id}", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<?> deletePlata(@PathVariable("id") Long plataId) { | ||
Optional<Plata> optionalPlata = this.plataService.findById(plataId); | ||
if (optionalPlata.isPresent()) { | ||
this.plataService.deleteById(plataId); | ||
return ResponseEntity.ok().build(); | ||
} | ||
throw new EntityNotFoundException(); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
src/main/java/rs/raf/demo/controllers/ZaposleniRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package rs.raf.demo.controllers; | ||
|
||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import org.springframework.data.jpa.domain.Specification; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import rs.raf.demo.model.Zaposleni; | ||
import rs.raf.demo.services.IZaposleniService; | ||
import rs.raf.demo.specifications.RacunSpecificationsBuilder; | ||
|
||
import javax.persistence.EntityNotFoundException; | ||
import javax.validation.Valid; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
@CrossOrigin | ||
@RestController | ||
@SecurityRequirement(name = "bearerAuth") | ||
@RequestMapping("/api/zaposleni") | ||
public class ZaposleniRestController { | ||
|
||
private final IZaposleniService iZaposleniService; | ||
|
||
public ZaposleniRestController(IZaposleniService iZaposleniService) { | ||
this.iZaposleniService = iZaposleniService; | ||
|
||
} | ||
|
||
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<?> createZaposleni(@Valid @RequestBody Zaposleni zaposleni) { | ||
return ResponseEntity.ok(iZaposleniService.save(zaposleni)); | ||
} | ||
|
||
@PutMapping(value = "/{id}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<?> updateZaposleni(@Valid @RequestBody Zaposleni zaposleni, @PathVariable Long id) { | ||
if (iZaposleniService.findById(id).isPresent()) | ||
return ResponseEntity.ok(iZaposleniService.updateZaposleni(zaposleni)); | ||
throw new EntityNotFoundException(); | ||
} | ||
|
||
@DeleteMapping(value = "/{id}") | ||
public ResponseEntity<?> zaposleniOtkaz(@PathVariable("id") Long id) { | ||
Optional<Zaposleni> optionalZaposleni = iZaposleniService.findById(id); | ||
if(optionalZaposleni.isPresent()){ | ||
return ResponseEntity.ok(iZaposleniService.otkazZaposleni(optionalZaposleni.get())); | ||
} | ||
throw new EntityNotFoundException(); | ||
} | ||
|
||
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<?> getZaposleniId(@PathVariable("id") Long id) { | ||
Optional<Zaposleni> optionalZaposleni = iZaposleniService.findById(id); | ||
if (optionalZaposleni.isPresent()) { | ||
return ResponseEntity.ok(iZaposleniService.findById(id)); | ||
} | ||
throw new EntityNotFoundException(); | ||
} | ||
|
||
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<?> search(@RequestParam(name = "search") String search) { | ||
RacunSpecificationsBuilder<Zaposleni> builder = new RacunSpecificationsBuilder<>(); | ||
|
||
Pattern pattern = Pattern.compile("(\\w+?)(:|<|>)(\\w+?),"); | ||
Matcher matcher = pattern.matcher(search + ","); | ||
while (matcher.find()) { | ||
builder.with(matcher.group(1), matcher.group(2), matcher.group(3)); | ||
} | ||
|
||
Specification<Zaposleni> spec = builder.build(); | ||
|
||
List<Zaposleni> result = iZaposleniService.findAll(spec); | ||
|
||
if (result.isEmpty()) { | ||
throw new EntityNotFoundException(); | ||
} | ||
|
||
return ResponseEntity.ok(result); | ||
} | ||
} |
Oops, something went wrong.