-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
131 additions
and
9 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
18 changes: 18 additions & 0 deletions
18
src/main/java/com/sirius/spurt/common/validator/UserValidator.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,18 @@ | ||
package com.sirius.spurt.common.validator; | ||
|
||
import static com.sirius.spurt.common.meta.ResultCode.NOT_EXIST_USER; | ||
|
||
import com.sirius.spurt.common.exception.GlobalException; | ||
import com.sirius.spurt.store.repository.database.entity.UserEntity; | ||
|
||
public class UserValidator { | ||
public static void validator(UserEntity userEntity) { | ||
if (!isExistUser(userEntity)) { | ||
throw new GlobalException(NOT_EXIST_USER); | ||
} | ||
} | ||
|
||
private static boolean isExistUser(UserEntity userEntity) { | ||
return userEntity != null; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/sirius/spurt/service/business/user/DeleteUserBusiness.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,46 @@ | ||
package com.sirius.spurt.service.business.user; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.sirius.spurt.common.template.Business; | ||
import com.sirius.spurt.service.business.user.DeleteUserBusiness.Dto; | ||
import com.sirius.spurt.service.business.user.DeleteUserBusiness.Result; | ||
import com.sirius.spurt.store.provider.experience.ExperienceProvider; | ||
import com.sirius.spurt.store.provider.question.QuestionProvider; | ||
import com.sirius.spurt.store.provider.user.UserProvider; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class DeleteUserBusiness implements Business<Dto, Result> { | ||
private final UserProvider userProvider; | ||
private final ExperienceProvider experienceProvider; | ||
private final QuestionProvider questionProvider; | ||
|
||
@Override | ||
@Transactional | ||
public Result execute(Dto input) { | ||
experienceProvider.deleteExperienceByUser(input.getUserId()); | ||
questionProvider.deleteQuestionByUser(input.getUserId()); | ||
userProvider.deleteUser(input.getUserId()); | ||
return new Result(); | ||
} | ||
|
||
@Setter | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Dto implements Business.Dto { | ||
private String userId; | ||
} | ||
|
||
@JsonIgnoreProperties | ||
public static class Result implements Business.Result {} | ||
} |
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
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
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