Skip to content

Commit 0f864f4

Browse files
committed
admin entity and controller
1 parent 9e8fbc9 commit 0f864f4

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

src/main/java/com/serve/api/controler/TerminalController.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,30 @@ public class TerminalController {
3030
TerminalService service;
3131

3232
@GetMapping(ID)
33-
public TerminalDto get(@PathVariable Long id){
33+
public TerminalDto get(@PathVariable Long id) {
3434
return service.get(id);
3535
}
3636

3737
@GetMapping
38-
public List<TerminalDto> get(){
38+
public List<TerminalDto> get() {
3939
return service.get();
4040
}
4141

4242
@PostMapping
4343
@ResponseStatus(code = HttpStatus.CREATED)
44-
public void create(@RequestBody TerminalDto dto){
44+
public void create(@RequestBody TerminalDto dto) {
4545
service.create(dto);
4646
}
4747

4848
@DeleteMapping(ID)
4949
@ResponseStatus(code = HttpStatus.NO_CONTENT)
50-
public void delete(@PathVariable Long id){
50+
public void delete(@PathVariable Long id) {
5151
service.remove(id);
5252
}
5353

5454
@PutMapping(ID)
5555
@ResponseStatus(code = HttpStatus.ACCEPTED)
56-
public void update(@PathVariable Long id, @RequestBody TerminalDto dto){
56+
public void update(@PathVariable Long id, @RequestBody TerminalDto dto) {
5757
service.update(id, dto);
5858
}
5959
}

src/main/java/com/serve/api/mapper/TerminalMapper.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ public Terminal toModel(TerminalDto dto) {
1616

1717
if (Objects.isNull(dto)) throw new NullPointerException("Dto is null");
1818

19-
Terminal terminal = new Terminal();
20-
terminal.setName(dto.getName());
21-
terminal.setLocation(dto.getLocation());
22-
terminal.setDescription(dto.getDescription());
19+
Terminal terminal = new Terminal();
20+
terminal.setName(dto.getName());
21+
terminal.setLocation(dto.getLocation());
22+
terminal.setDescription(dto.getDescription());
2323

2424
return terminal;
2525
}
2626

27-
public Terminal update( Terminal updated, Terminal terminal){
27+
public Terminal update(Terminal updated, Terminal terminal) {
2828

2929
if (Objects.isNull(terminal)) throw new NullPointerException("Terminal is null");
3030

31-
if(Objects.nonNull(terminal.getName())) updated.setName(terminal.getName());
32-
if(Objects.nonNull(terminal.getLocation())) updated.setLocation(terminal.getLocation());
33-
if(Objects.nonNull(terminal.getDescription())) updated.setDescription(terminal.getDescription());
31+
if (Objects.nonNull(terminal.getName())) updated.setName(terminal.getName());
32+
if (Objects.nonNull(terminal.getLocation())) updated.setLocation(terminal.getLocation());
33+
if (Objects.nonNull(terminal.getDescription())) updated.setDescription(terminal.getDescription());
3434

3535
return terminal;
3636
}

src/main/java/com/serve/api/model/entity/Arrive.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.serve.api.model.entity;
22

3-
import com.serve.api.model.enumeration.Type;
43
import com.serve.api.model.base.BaseEntity;
4+
import com.serve.api.model.enumeration.Type;
55
import lombok.AccessLevel;
66
import lombok.Data;
77
import lombok.experimental.FieldDefaults;

src/main/java/com/serve/api/service/AdminService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ public class AdminService {
1818
AdminPswMapper pswMapper;
1919

2020
public AdminDto get(Long id) {
21-
if(Objects.isNull(id)) throw new NullPointerException("Id is null");
21+
if (Objects.isNull(id)) throw new NullPointerException("Id is null");
2222
return mapper.toDto(repository.findById(id).orElseThrow());
2323
}
2424

2525
public List<AdminDto> get() {
2626
return repository.findAll().stream().map(admin -> mapper.toDto(admin)).collect(Collectors.toList());
2727
}
2828

29-
public void create(AdminPswDto dto){
30-
if(Objects.isNull(dto)) throw new NullPointerException("Dto is null");
29+
public void create(AdminPswDto dto) {
30+
if (Objects.isNull(dto)) throw new NullPointerException("Dto is null");
3131
Admin admin = pswMapper.toModel(dto);
3232
repository.save(admin);
3333
}
3434

35-
public void remove(Long id){
36-
if(Objects.isNull(id)) throw new NullPointerException("Id is null");
35+
public void remove(Long id) {
36+
if (Objects.isNull(id)) throw new NullPointerException("Id is null");
3737
repository.deleteById(id);
3838
}
3939
}

src/main/java/com/serve/api/service/TerminalService.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ public class TerminalService {
1616
TerminalRepository repository;
1717
TerminalMapper mapper;
1818

19-
public TerminalDto get(Long id){
20-
if(Objects.isNull(id)) throw new NullPointerException("Id is null");
19+
public TerminalDto get(Long id) {
20+
if (Objects.isNull(id)) throw new NullPointerException("Id is null");
2121
return mapper.toDto(repository.getById(id));
2222
}
2323

24-
public List<TerminalDto> get(){
24+
public List<TerminalDto> get() {
2525
return repository
2626
.findAll()
2727
.stream()
@@ -37,17 +37,17 @@ public void create(TerminalDto dto) {
3737
repository.save(terminal);
3838
}
3939

40-
public void remove(Long id){
40+
public void remove(Long id) {
4141

42-
if(Objects.isNull(id)) throw new NullPointerException("Id is null");
42+
if (Objects.isNull(id)) throw new NullPointerException("Id is null");
4343

4444
repository.deleteById(id);
4545
}
4646

47-
public void update(Long id, TerminalDto dto){
47+
public void update(Long id, TerminalDto dto) {
4848

49-
if(Objects.isNull(id)) throw new NullPointerException("Id is null");
50-
if(Objects.isNull(dto)) throw new NullPointerException("Dto is null");
49+
if (Objects.isNull(id)) throw new NullPointerException("Id is null");
50+
if (Objects.isNull(dto)) throw new NullPointerException("Dto is null");
5151

5252
Terminal terminal = repository.findById(id).orElseThrow();
5353

0 commit comments

Comments
 (0)