-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
360 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
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
69 changes: 69 additions & 0 deletions
69
hr-microservice-hexagonal/src/main/java/com/example/hr/config/SwaggerConfig.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,69 @@ | ||
package com.example.hr.config; | ||
|
||
import java.util.Date; | ||
|
||
import javax.servlet.ServletContext; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
import springfox.documentation.builders.ApiInfoBuilder; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.builders.RequestHandlerSelectors; | ||
import springfox.documentation.service.ApiInfo; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.paths.RelativePathProvider; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
@Configuration | ||
@EnableSwagger2 | ||
public class SwaggerConfig implements WebMvcConfigurer { | ||
@Value("${major.version}") | ||
private String majorVersion; | ||
@Value("${minor.version}") | ||
private String minorVersion; | ||
@Value("${timestamp}") | ||
private long timestamp; | ||
@Value("${server.servlet.context-path}") | ||
private String contextPath; | ||
@Value("${spring.mvc.servlet.path}") | ||
private String servletPath; | ||
|
||
@Value("${server.address}") | ||
private String host; | ||
|
||
@Value("${server.port}") | ||
private long port; | ||
|
||
@Bean | ||
public Docket api(ServletContext servletContext) { | ||
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any()) | ||
.paths(PathSelectors.any()).build().host(host.concat(":").concat(Long.toString(port))) | ||
.pathProvider(new RelativePathProvider(servletContext) { | ||
@Override | ||
public String getApplicationBasePath() { | ||
return contextPath; | ||
} | ||
}).apiInfo(apiInfo()); | ||
} | ||
|
||
private ApiInfo apiInfo() { | ||
|
||
return new ApiInfoBuilder().title("Market Service") | ||
.description("<b>Client FrontEnd API</b><br /><br />Updated: [" + (new Date(timestamp)).toString() | ||
+ " ]" + " <script>document.title = \"Market Service\";" | ||
+ " document.getElementById('header').remove();" + "</script>") | ||
.version(majorVersion + "." + minorVersion).build(); | ||
} | ||
|
||
@Override | ||
public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); | ||
|
||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); | ||
} | ||
} |
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
91 changes: 91 additions & 0 deletions
91
hr-microservice-hexagonal/src/main/java/com/example/hr/dto/EmployeeRequest.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 |
---|---|---|
@@ -1,5 +1,96 @@ | ||
package com.example.hr.dto; | ||
|
||
import com.example.hr.domain.Department; | ||
import com.example.hr.domain.Employee; | ||
import com.example.hr.domain.MoneyCurrency; | ||
|
||
public class EmployeeRequest { | ||
private String identity; | ||
private String fullname; | ||
private double salary; | ||
private String iban; | ||
private boolean fulltime; | ||
private int birthYear; | ||
private byte[] photo; | ||
private Department department; | ||
|
||
public EmployeeRequest() { | ||
} | ||
|
||
public String getIdentity() { | ||
return identity; | ||
} | ||
|
||
public void setIdentity(String identity) { | ||
this.identity = identity; | ||
} | ||
|
||
public String getFullname() { | ||
return fullname; | ||
} | ||
|
||
public void setFullname(String fullname) { | ||
this.fullname = fullname; | ||
} | ||
|
||
public double getSalary() { | ||
return salary; | ||
} | ||
|
||
public void setSalary(double salary) { | ||
this.salary = salary; | ||
} | ||
|
||
public String getIban() { | ||
return iban; | ||
} | ||
|
||
public void setIban(String iban) { | ||
this.iban = iban; | ||
} | ||
|
||
public boolean isFulltime() { | ||
return fulltime; | ||
} | ||
|
||
public void setFulltime(boolean fulltime) { | ||
this.fulltime = fulltime; | ||
} | ||
|
||
public int getBirthYear() { | ||
return birthYear; | ||
} | ||
|
||
public void setBirthYear(int birthYear) { | ||
this.birthYear = birthYear; | ||
} | ||
|
||
public byte[] getPhoto() { | ||
return photo; | ||
} | ||
|
||
public void setPhoto(byte[] photo) { | ||
this.photo = photo; | ||
} | ||
|
||
public Department getDepartment() { | ||
return department; | ||
} | ||
|
||
public void setDepartment(Department department) { | ||
this.department = department; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "EmployeeRequest [identity=" + identity + ", fullname=" + fullname + ", salary=" + salary + ", iban=" | ||
+ iban + ", fulltime=" + fulltime + ", birthYear=" + birthYear + ", department=" + department + "]"; | ||
} | ||
|
||
public Employee toEmployee() { | ||
String[] tokens = fullname.split("\\w+"); | ||
return new Employee.Builder(identity).fullname(tokens[0], tokens[1]).iban(iban).salary(salary, MoneyCurrency.TL) | ||
.birthYear(birthYear).fulltime(fulltime).department(department).photo(photo).build(); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
hr-microservice-hexagonal/src/main/java/com/example/hr/dto/EmployeeResponse.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 |
---|---|---|
@@ -1,5 +1,14 @@ | ||
package com.example.hr.dto; | ||
|
||
public class EmployeeResponse { | ||
private String status; | ||
|
||
public EmployeeResponse(String status) { | ||
this.status = status; | ||
} | ||
|
||
public String getStatus() { | ||
return status; | ||
} | ||
|
||
} |
Oops, something went wrong.