Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
mertycom committed Feb 1, 2023
1 parent faf7d1f commit 3cc2415
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 16 deletions.
Binary file modified .gradle/7.5.1/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/7.5.1/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/7.5.1/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.5.1/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/file-system.probe
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
package com.bilgeadam.dto.request;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class DoLoginRequestDto {
@NotBlank(message = "Kullanıcı adı boş geçilemez.")
@Size(min = 3, max = 32)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ public class AuthService extends ServiceManager<Auth,Long> {
* kullanmak istediğiniz interface, services, component gibi sınıflardan nesne türetmeke için 2 yolunuz va r
* @Autowired ile işaretlemek ya da Constructor Injection ile kullanmak.
*/

private final IUserProfileManager userProfileManager;

private final JwtTokenManager jwtTokenManager;

//private final CreateUserProducer createUserProducer; CreateUserProducer createUserProducer
public AuthService(IAuthRepository repository, IUserProfileManager userProfileManager,
JwtTokenManager jwtTokenManager){
Expand Down Expand Up @@ -67,17 +70,13 @@ public RegisterResponseDto save(RegisterRequestDto dto){
throw new AuthMicroserviceException(ErrorType.REGISTER_KULLANICIADI_KAYITLI);

Auth auth = save(IAuthMapper.INSTANCE.fromRegisterRequestDto(dto));
createUserProducer.converdAndSendMessageCreateUser(CreateUser.builder()
.authid(auth.getId())
.username(auth.getUsername())
.email(auth.getEmail())
.build());
// userProfileManager.createProfile(CreateProfileRequestDto.builder()
// .token("")
// .authid(auth.getId())
// .username(auth.getUsername())
// .email(auth.getEmail())
// .build());

userProfileManager.createProfile(CreateProfileRequestDto.builder()
.token("")
.authid(auth.getId())
.username(auth.getUsername())
.email(auth.getEmail())
.build());
RegisterResponseDto result = IAuthMapper.INSTANCE.fromAuth(auth);
result.setRegisterstate(100);
result.setContent(auth.getEmail()+" ile başarı şekilde kayıt oldunuz.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package com.bilgeadam.controller;

import com.bilgeadam.dto.request.CreateProfileRequestDto;
import com.bilgeadam.repository.entity.UserProfile;
import com.bilgeadam.service.UserProfileService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

import static com.bilgeadam.constants.RestApi.*;

@RestController
Expand All @@ -13,5 +21,14 @@ public class UserProfileController {

private final UserProfileService userProfileService;

@PostMapping(CREATE)
public ResponseEntity<Boolean> createProfile(@RequestBody @Valid CreateProfileRequestDto dto) {

userProfileService.save(UserProfile.builder()
.authid(dto.getAuthid())
.email(dto.getEmail())
.name(dto.getName())
.build());
return ResponseEntity.ok(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.bilgeadam.dto.request;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class CreateProfileRequestDto {
@NotNull
Long authid;
@NotBlank
private String name;
@NotBlank
private String middleName;
@NotBlank
private String lastName;
@NotBlank
private String lastName2;
@NotBlank
@Email
String email;
String token;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public ResponseEntity<ErrorMessage> handlerRuntimeException(Exception exception)
return new ResponseEntity<>(createErrorMessage(exception,errorType),HttpStatus.INTERNAL_SERVER_ERROR);
}

@ExceptionHandler(UserprofileExecption.class)
@ExceptionHandler(UserProfileException.class)
@ResponseBody
public ResponseEntity<ErrorMessage> handlerAuthMicroseviceException(UserprofileExecption exception){
public ResponseEntity<ErrorMessage> handlerAuthMicroseviceException(UserProfileException exception){
return new ResponseEntity<>(createErrorMessage(exception,exception.getErrorType()), HttpStatus.BAD_REQUEST);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import lombok.Getter;

@Getter
public class UserprofileExecption extends RuntimeException{
public class UserProfileException extends RuntimeException{

private final ErrorType errorType;

public UserprofileExecption(ErrorType errorType) {
public UserProfileException(ErrorType errorType) {
super(errorType.getMessage());
this.errorType = errorType;
}

public UserprofileExecption(ErrorType errorType, String message) {
public UserProfileException(ErrorType errorType, String message) {
super(message);
this.errorType = errorType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class UserProfile extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private long authid;
private String name;
private String middleName;
private String lastName;
Expand Down

0 comments on commit 3cc2415

Please sign in to comment.