-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
spring: | ||
cloud: | ||
config: | ||
uri: http://10.124.11.103:8888 | ||
# uri: http://localhost:8888 | ||
config: | ||
import: "configserver:" | ||
application: | ||
name: api-gateway-application |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.bilgeadam.rabbitmq.consumer; | ||
|
||
import com.bilgeadam.mapper.IAuthMapper; | ||
import com.bilgeadam.rabbitmq.model.UpdateUserProfileModel; | ||
import com.bilgeadam.service.AuthService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.amqp.rabbit.annotation.RabbitListener; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class UpdateUserConsumer { | ||
|
||
private final AuthService authService; | ||
|
||
|
||
@RabbitListener(queues =("${rabbitmq.queueUpdate}") ) | ||
public void newUserCreate(UpdateUserProfileModel model){ | ||
log.info("User:{}",model.toString()); | ||
authService.save(IAuthMapper.INSTANCE.toUserAuth(model)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.bilgeadam.rabbitmq.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
|
||
public class EmailSenderModel implements Serializable { | ||
|
||
private String email; | ||
private String activationCode; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.bilgeadam.rabbitmq.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
|
||
public class NewCreateUserModel implements Serializable { | ||
private Long authId; | ||
private String email; | ||
private String username; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.bilgeadam.rabbitmq.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
|
||
public class UpdateUserProfileModel implements Serializable { | ||
private String email; | ||
private String activationCode; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.bilgeadam; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class CompanyMicroserviceApplication { | ||
public static void main(String[] args){ | ||
SpringApplication.run(CompanyMicroserviceApplication.class); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.bilgeadam.constants; | ||
|
||
public class RestApi { | ||
public static final String VERSION = "/v1"; | ||
public static final String COMPANY = VERSION+"/company"; | ||
public static final String COMPANYGETALL = "/companygetall"; | ||
public static final String CREATECOMPANY = "/createcompany"; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.bilgeadam.controller; | ||
|
||
import com.bilgeadam.dto.request.CreateCompanyRequestDto; | ||
import com.bilgeadam.dto.response.CompanyGetAllResponseDto; | ||
import com.bilgeadam.service.CompanyService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
import static com.bilgeadam.constants.RestApi.*; | ||
|
||
|
||
@RestController | ||
@RequestMapping(COMPANY) | ||
@RequiredArgsConstructor | ||
public class CompanyController { | ||
private final CompanyService companyService; | ||
|
||
@PostMapping(CREATECOMPANY) | ||
public ResponseEntity<String> CreateCompany(@RequestBody CreateCompanyRequestDto dto) { | ||
|
||
companyService.createCompany(dto); | ||
return ResponseEntity.ok("başarıyla kaydedildi"); | ||
} | ||
@GetMapping(COMPANYGETALL) | ||
public ResponseEntity<List<CompanyGetAllResponseDto>> getAllCorporations(){ | ||
return ResponseEntity.ok(companyService.companyGetAll()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.bilgeadam.dto.request; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.Date; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
|
||
public class CreateCompanyRequestDto { | ||
String name; | ||
String title; | ||
String mersisNo; | ||
String taxNo; | ||
String taxOffice; | ||
String logo; | ||
String phone; | ||
String address; | ||
String email; | ||
int numberOfEmployees; | ||
String foundationYear; | ||
Date contractStartDate; | ||
Date contractEndDate; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.bilgeadam.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
|
||
public class CompanyGetAllResponseDto { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.bilgeadam.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.Date; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
|
||
public class CreateCompanyResponseDto { | ||
String name; | ||
String title; | ||
String mersisNo; | ||
String taxNo; | ||
String taxOffice; | ||
String logo; | ||
String phone; | ||
String address; | ||
String email; | ||
int numberOfEmployees; | ||
String foundationYear; | ||
Date contractStartDate; | ||
Date contractEndDate; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.bilgeadam.exception; | ||
|
||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class CompanyMicroserviceException extends RuntimeException{ | ||
private final ErrorType errorType; | ||
|
||
public CompanyMicroserviceException(ErrorType errorType){ | ||
super(errorType.getMessage()); | ||
this.errorType = errorType; | ||
} | ||
|
||
public CompanyMicroserviceException(ErrorType errorType, String message){ | ||
super(message); | ||
this.errorType = errorType; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.bilgeadam.exception; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Data | ||
@Builder | ||
@Component | ||
public class ErrorMessage { | ||
int code; | ||
String message; | ||
List<String> fields; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.bilgeadam.exception; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
public enum ErrorType { | ||
INTERNAL_ERROR(5100,"Sunucu Hatası", HttpStatus.INTERNAL_SERVER_ERROR), | ||
BAD_REQUEST(1100,"Parametre Hatası",HttpStatus.BAD_REQUEST), | ||
COMPANY_NOT_CREATED(1100,"Şirket kaydedilmedi",HttpStatus.BAD_REQUEST), | ||
|
||
DUPLICATE_EMAIL_ERROR(1116,"Girdiginiz E-mail kullanilmakta.",HttpStatus.BAD_REQUEST); | ||
|
||
|
||
int code; | ||
String message; | ||
HttpStatus httpStatus; | ||
} |