Skip to content

Commit d59d720

Browse files
committed
Atualizando o projeto
1 parent beb1668 commit d59d720

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+751
-176
lines changed

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2323
hs_err_pid*
24-
/target/
2524

2625
target/*
2726
.settings/*
@@ -31,7 +30,10 @@ target/*
3130
.attach_pid*
3231
.idea
3332
*.iml
34-
/target
3533
.sts4-cache/
3634
.vscode
37-
_site/
35+
_site/
36+
/target/
37+
/Postman_collections/
38+
/docker-compose.yml
39+
/Diagrama DB PET-SCHEDULE.mwb

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@
113113
<version>3.8.0</version>
114114
</dependency>
115115

116+
<!-- for Model Mapper support -->
117+
<dependency>
118+
<groupId>com.github.dozermapper</groupId>
119+
<artifactId>dozer-core</artifactId>
120+
<version>6.4.1</version>
121+
</dependency>
122+
116123
<dependency>
117124
<groupId>org.springframework.boot</groupId>
118125
<artifactId>spring-boot-starter-jdbc</artifactId>

src/.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/bin/
2+
/target/
3+
4+
target/*
5+
.settings/*
6+
.classpath
7+
.project
8+
.factorypath
9+
.attach_pid*
10+
.idea
11+
*.iml
12+
/target
13+
.sts4-cache/
14+
.vscode
15+
_site/

src/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM openjdk:11-jdk-slim
2+
VOLUME /tmp
3+
ADD app/target/docker-from-pet-schedule-0.0.1-SNAPSHOT.jar app.jar
4+
EXPOSE 8080
5+
RUN bash -c 'touch /app.jar'
6+
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/app.jar"]

src/main/java/com/sippulse/pet/PetSchedule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static void main(String[] args) {
1414
SpringApplication.run(PetSchedule.class, args);
1515

1616
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(16);
17-
String result = bCryptPasswordEncoder.encode("admin123");
17+
String result = bCryptPasswordEncoder.encode("123admin");
1818
System.out.println("My hash " + result);
1919
}
2020
}

src/main/java/com/sippulse/pet/controller/AuthController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* @author Fábio Figueiredo da Silva
3333
*
3434
*/
35-
@Api(tags = "AuthenticationEndpoint")
35+
@Api(value = "Pet-Shedule_Endpoints", description = "REST API for Signin", tags = { "AuthenticationEndpoint" })
3636
@RestController
3737
@RequestMapping("/auth")
3838
public class AuthController {
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
*
3+
*/
4+
package com.sippulse.pet.controller;
5+
6+
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
7+
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
8+
9+
import org.springframework.beans.factory.annotation.Autowired;
10+
import org.springframework.http.ResponseEntity;
11+
import org.springframework.web.bind.annotation.PathVariable;
12+
import org.springframework.web.bind.annotation.RequestBody;
13+
import org.springframework.web.bind.annotation.RequestMapping;
14+
import org.springframework.web.bind.annotation.RequestMethod;
15+
import org.springframework.web.bind.annotation.RestController;
16+
17+
import com.sippulse.pet.data.vo.v1.OwnerVO;
18+
import com.sippulse.pet.service.OwnerService;
19+
20+
import io.swagger.annotations.Api;
21+
import io.swagger.annotations.ApiOperation;
22+
23+
/**
24+
* @author Fábio Figueiredo da Silva
25+
*
26+
*/
27+
@Api(value = "Pet-Shedule_Endpoints", description = "REST API for Owner", tags = { "OwnerEndpoint" })
28+
@RestController
29+
@RequestMapping("/api/owner/v1")
30+
public class OwnerController {
31+
32+
@Autowired
33+
private OwnerService service;
34+
35+
// @Autowired
36+
// private PagedResourcesAssembler<OwnerVO> assembler;
37+
38+
39+
@ApiOperation(value = "Create a new Owner")
40+
@RequestMapping(method = RequestMethod.POST,
41+
consumes = { "application/json", "application/xml", "application/x-yaml" },
42+
produces = { "application/json", "application/xml", "application/x-yaml" })
43+
public OwnerVO create(@RequestBody OwnerVO owner){
44+
OwnerVO ownerVO = service.create(owner);
45+
ownerVO.add(linkTo(methodOn(OwnerController.class).get(ownerVO.getKey())).withSelfRel());
46+
return ownerVO;
47+
}
48+
49+
@ApiOperation(value = "Update a specific Owner")
50+
@RequestMapping(method = RequestMethod.PUT,
51+
consumes = { "application/json", "application/xml", "application/x-yaml" })
52+
public OwnerVO update(@RequestBody OwnerVO owner){
53+
OwnerVO ownerVO = service.update(owner);
54+
ownerVO.add(linkTo(methodOn(OwnerController.class).get(ownerVO.getKey())).withSelfRel());
55+
return ownerVO;
56+
}
57+
58+
@ApiOperation(value = "Find a specific Owner by your ID" )
59+
@RequestMapping(value = "/{id}",
60+
method = RequestMethod.GET,
61+
produces = { "application/json", "application/xml", "application/x-yaml" })
62+
public OwnerVO get(@PathVariable(value = "id") Long id){
63+
OwnerVO ownerVO = service.findById(id);
64+
ownerVO.add(linkTo(methodOn(OwnerController.class).get(id)).withSelfRel());
65+
return ownerVO;
66+
}
67+
68+
@ApiOperation(value = "Find a specific Owner by your CPF" )
69+
@RequestMapping(value = "/{cpf}",
70+
method = RequestMethod.GET,
71+
produces = { "application/json", "application/xml", "application/x-yaml" })
72+
public OwnerVO getByCpf(@PathVariable(value = "cpf") String cpf){
73+
OwnerVO ownerVO = service.findByCpf(cpf);
74+
ownerVO.add(linkTo(methodOn(OwnerController.class).getByCpf(cpf)).withSelfRel());
75+
return ownerVO;
76+
}
77+
78+
79+
@ApiOperation(value = "Set a specific Owner by to disabled")
80+
@RequestMapping(value = "/{id}",
81+
method = RequestMethod.PATCH)
82+
public OwnerVO disable(@PathVariable(value = "id") Long id){
83+
OwnerVO ownerVO = service.disableOwner(id);
84+
ownerVO.add(linkTo(methodOn(OwnerController.class).get(ownerVO.getKey())).withSelfRel());
85+
return ownerVO;
86+
}
87+
88+
@ApiOperation(value = "Delete a specific Owner by your ID")
89+
@RequestMapping(value = "/{id}",
90+
method = RequestMethod.DELETE)
91+
public ResponseEntity<?> delete(@PathVariable(value = "id") Long id){
92+
service.delete(id);
93+
return ResponseEntity.ok().build();
94+
}
95+
96+
}

src/main/java/com/sippulse/pet/controller/PetController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import io.swagger.annotations.Api;
88

9-
@Api(value = "PetEndpoint", description = "REST API for Pet", tags = { "PetEndpoint" })
9+
@Api(value = "Pet-Shedule_Endpoints", description = "REST API for Pet", tags = { "PetEndpoint" })
1010
@RestController
1111
@RequestMapping("/api/pet/v1")
1212
public class PetController {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
*
3+
*/
4+
package com.sippulse.pet.converter;
5+
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
9+
import com.github.dozermapper.core.DozerBeanMapperBuilder;
10+
import com.github.dozermapper.core.Mapper;
11+
12+
/**
13+
* @author Fábio Figueiredo da Silva
14+
*
15+
*/
16+
public class DozerConverter {
17+
18+
private static Mapper mapper = DozerBeanMapperBuilder.buildDefault();
19+
20+
public static <O, D> D parseObject(O origin, Class<D> destination) {
21+
return mapper.map(origin, destination);
22+
}
23+
24+
public static <O, D> List<D> parseListObjects(List<O> origin, Class<D> destination) {
25+
List<D> destinationObjects = new ArrayList<D>();
26+
for (Object o : origin) {
27+
destinationObjects.add(mapper.map(o, destination));
28+
}
29+
return destinationObjects;
30+
}
31+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
*
3+
*/
4+
package com.sippulse.pet.data.vo.v1;
5+
6+
import java.io.Serializable;
7+
8+
import org.springframework.hateoas.ResourceSupport;
9+
10+
import com.fasterxml.jackson.annotation.JsonProperty;
11+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
12+
import com.github.dozermapper.core.Mapping;
13+
14+
import lombok.AllArgsConstructor;
15+
import lombok.Data;
16+
import lombok.EqualsAndHashCode;
17+
import lombok.NoArgsConstructor;
18+
19+
/**
20+
* @author Fábio Figueiredo da Silva
21+
*
22+
*/
23+
@AllArgsConstructor
24+
@NoArgsConstructor
25+
@EqualsAndHashCode(callSuper=false)
26+
@Data
27+
@JsonPropertyOrder({ "id", "firstName", "lastName", "cpf", "cellPhone", "email", "address","enabled" })
28+
public class OwnerVO extends ResourceSupport implements Serializable{
29+
30+
private static final long serialVersionUID = 1L;
31+
32+
@Mapping("id")
33+
@JsonProperty("id")
34+
private Long key;
35+
private String firstName;
36+
private String lastName;
37+
private String cpf;
38+
private String cellPhone;
39+
private String email;
40+
private String address;
41+
private Boolean enabled;
42+
43+
}

0 commit comments

Comments
 (0)