靓号规则处理
This commit is contained in:
parent
37184400e0
commit
ea5e7a5595
@ -2,6 +2,7 @@ package com.red.circle.other.adapter.app.user.user;
|
||||
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.framework.web.controller.BaseController;
|
||||
import com.red.circle.other.app.dto.cmd.user.user.UserSpecialIdApplyCmd;
|
||||
import com.red.circle.other.app.service.user.user.BeautifulNumberApplyService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
@ -34,7 +35,7 @@ public class BeautifulNumberApplyRestController extends BaseController {
|
||||
* @eo.request-type formdata
|
||||
*/
|
||||
@PostMapping
|
||||
public void apply(AppExtCommand cmd) {
|
||||
public void apply(UserSpecialIdApplyCmd cmd) {
|
||||
beautifulNumberApplyService.apply(cmd);
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,10 @@ package com.red.circle.other.app.command.user;
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
||||
import com.red.circle.other.app.dto.cmd.user.user.UserSpecialIdApplyCmd;
|
||||
import com.red.circle.other.infra.database.mongo.entity.user.profile.UserSpecialId;
|
||||
import com.red.circle.other.infra.database.mongo.service.user.profile.UserSpecialIdService;
|
||||
import com.red.circle.other.infra.enums.user.user.SpecialIdPatternEnum;
|
||||
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||
import com.red.circle.other.infra.database.rds.entity.user.user.UserBeautifulNumberApply;
|
||||
@ -22,14 +26,29 @@ public class UserBeautifulNumberApplyCmdExe {
|
||||
|
||||
private final UserProfileGateway userProfileGateway;
|
||||
private final UserBeautifulNumberApplyService userBeautifulNumberApplyService;
|
||||
private final UserSpecialIdService userSpecialIdService;
|
||||
|
||||
public void execute(AppExtCommand cmd) {
|
||||
public void execute(UserSpecialIdApplyCmd cmd) {
|
||||
|
||||
ResponseAssert.isTrue(
|
||||
UserErrorCode.INSUFFICIENT_LEVEL_30_ERROR, getUserLevelExperience(cmd) >= 30);
|
||||
// 验证账号是否符合当前等级的靓号规则
|
||||
boolean isValidForLevel = SpecialIdPatternEnum.isValidForLevel(
|
||||
cmd.getAccount(),
|
||||
cmd.getWealthLevel()
|
||||
);
|
||||
ResponseAssert.isTrue(CommonErrorCode.SAVE_FAILURE,"The account does not meet the current wealth level rules", isValidForLevel);
|
||||
|
||||
// 检查靓号是否已存在
|
||||
boolean exists = userSpecialIdService.exists(cmd.getReqSysOrigin().getOrigin(), cmd.getAccount());
|
||||
ResponseAssert.isFalse(CommonErrorCode.SAVE_FAILURE, "The beautiful number already exists",exists);
|
||||
|
||||
ResponseAssert.isFalse(CommonErrorCode.REPEATED_SUBMISSION, isExistPending(cmd));
|
||||
|
||||
// 检查用户是否已有靓号,如果有则删除
|
||||
UserSpecialId oldSpecialId = userSpecialIdService.getByUserId(cmd.getUserId());
|
||||
if (oldSpecialId != null) {
|
||||
userSpecialIdService.remove(oldSpecialId.getId());
|
||||
}
|
||||
|
||||
userBeautifulNumberApplyService.save(new UserBeautifulNumberApply()
|
||||
.setId(IdWorkerUtils.getId())
|
||||
.setApplyUser(cmd.requiredReqUserId())
|
||||
|
||||
@ -3,6 +3,7 @@ package com.red.circle.other.app.service.user.user;
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.other.app.command.user.UserBeautifulNumberApplyCmdExe;
|
||||
import com.red.circle.other.app.command.user.query.ExistUserBeautifulNumberQryExe;
|
||||
import com.red.circle.other.app.dto.cmd.user.user.UserSpecialIdApplyCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -19,7 +20,7 @@ public class BeautifulNumberApplyServiceImpl implements BeautifulNumberApplyServ
|
||||
private final ExistUserBeautifulNumberQryExe existUserBeautifulNumberQryExe;
|
||||
|
||||
@Override
|
||||
public void apply(AppExtCommand cmd) {
|
||||
public void apply(UserSpecialIdApplyCmd cmd) {
|
||||
userBeautifulNumberApplyCmdExe.execute(cmd);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
package com.red.circle.other.app.dto.cmd.user.user;
|
||||
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class UserSpecialIdApplyCmd extends AppExtCommand {
|
||||
|
||||
private String account;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Integer wealthLevel;
|
||||
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package com.red.circle.other.app.service.user.user;
|
||||
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.other.app.dto.cmd.user.user.UserSpecialIdApplyCmd;
|
||||
|
||||
/**
|
||||
* 用户注册登录等相关服务.
|
||||
@ -9,7 +10,7 @@ import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
*/
|
||||
public interface BeautifulNumberApplyService {
|
||||
|
||||
void apply(AppExtCommand cmd);
|
||||
void apply(UserSpecialIdApplyCmd cmd);
|
||||
|
||||
Boolean existRecord(AppExtCommand cmd);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user