用户身份新增经理身份
This commit is contained in:
parent
2d99283aa7
commit
a4b71c7032
@ -9,6 +9,12 @@ import java.util.Objects;
|
|||||||
* @since 2021/16
|
* @since 2021/16
|
||||||
*/
|
*/
|
||||||
public enum RoomRolesEnum {
|
public enum RoomRolesEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 经理
|
||||||
|
*/
|
||||||
|
MANAGER,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 超级管理员.
|
* 超级管理员.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -247,6 +247,7 @@ public class RoomEnterCmdExe {
|
|||||||
checkSysOrigin(cmd.requiredReqUserId(), manager.getSysOrigin());
|
checkSysOrigin(cmd.requiredReqUserId(), manager.getSysOrigin());
|
||||||
|
|
||||||
boolean appAdmin = isAppAdmin(cmd);
|
boolean appAdmin = isAppAdmin(cmd);
|
||||||
|
boolean appManager = isAppManager(cmd);
|
||||||
RoomSetting setting = manager.getSetting();
|
RoomSetting setting = manager.getSetting();
|
||||||
List<RoomProfile> roomProfileList = roomProfileManagerService.listProfileByRoomIds(Set.of(cmd.getRoomId()));
|
List<RoomProfile> roomProfileList = roomProfileManagerService.listProfileByRoomIds(Set.of(cmd.getRoomId()));
|
||||||
if (roomProfileList.size() > 0){
|
if (roomProfileList.size() > 0){
|
||||||
@ -267,7 +268,7 @@ public class RoomEnterCmdExe {
|
|||||||
}
|
}
|
||||||
manager.setSetting(setting);
|
manager.setSetting(setting);
|
||||||
// 非管理员情况下, 验证房间是否已关闭
|
// 非管理员情况下, 验证房间是否已关闭
|
||||||
if (!appAdmin) {
|
if (!appAdmin && !appManager ) {
|
||||||
ResponseAssert.isFalse(RoomErrorCode.ROOM_CLOSE,
|
ResponseAssert.isFalse(RoomErrorCode.ROOM_CLOSE,
|
||||||
Objects.equals(manager.getEvent(), RoomEventEnum.CLOSE.name()));
|
Objects.equals(manager.getEvent(), RoomEventEnum.CLOSE.name()));
|
||||||
}
|
}
|
||||||
@ -301,6 +302,13 @@ public class RoomEnterCmdExe {
|
|||||||
return administratorService.existsSupperAdmin(cmd.requiredReqUserId());
|
return administratorService.existsSupperAdmin(cmd.requiredReqUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验进来的用户是否为App经理.
|
||||||
|
*/
|
||||||
|
private boolean isAppManager(RoomEntryCmd cmd) {
|
||||||
|
return administratorService.existsManager(cmd.requiredReqUserId());
|
||||||
|
}
|
||||||
|
|
||||||
private RoomProfileDTO toRoomProfileDTO(RoomProfileManager manager, UserProfileDTO userProfile) {
|
private RoomProfileDTO toRoomProfileDTO(RoomProfileManager manager, UserProfileDTO userProfile) {
|
||||||
RoomProfileDTO roomProfile = roomProfileAppConvertor.toRoomProfileDTO(manager);
|
RoomProfileDTO roomProfile = roomProfileAppConvertor.toRoomProfileDTO(manager);
|
||||||
roomProfile.setCountryCode(userProfile.getCountryCode());
|
roomProfile.setCountryCode(userProfile.getCountryCode());
|
||||||
|
|||||||
@ -82,7 +82,8 @@ public class RoomManagerAuthsQueryExe {
|
|||||||
Boolean admin = Objects.equals(administrator.getRoles(), RoomRolesEnum.ADMIN.name())
|
Boolean admin = Objects.equals(administrator.getRoles(), RoomRolesEnum.ADMIN.name())
|
||||||
&& administratorRoomService.isRoomExist(administrator.getUserId(), roomId);
|
&& administratorRoomService.isRoomExist(administrator.getUserId(), roomId);
|
||||||
|
|
||||||
return superAdmin || admin;
|
Boolean manager = Objects.equals(administrator.getRoles(), RoomRolesEnum.MANAGER.name());
|
||||||
|
return superAdmin || admin || manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,15 +2,18 @@ package com.red.circle.other.app.service.user.user;
|
|||||||
|
|
||||||
|
|
||||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||||
|
import com.red.circle.framework.mybatis.constant.PageConstant;
|
||||||
import com.red.circle.other.app.dto.cmd.material.PropsStoreTypeQryCmd;
|
import com.red.circle.other.app.dto.cmd.material.PropsStoreTypeQryCmd;
|
||||||
import com.red.circle.other.app.dto.h5.UserIdentityVO;
|
import com.red.circle.other.app.dto.h5.UserIdentityVO;
|
||||||
import com.red.circle.other.app.service.team.TeamBdService;
|
import com.red.circle.other.app.service.team.TeamBdService;
|
||||||
|
import com.red.circle.other.infra.database.rds.entity.sys.Administrator;
|
||||||
import com.red.circle.other.infra.database.rds.service.sys.AdministratorAuthService;
|
import com.red.circle.other.infra.database.rds.service.sys.AdministratorAuthService;
|
||||||
import com.red.circle.other.infra.database.rds.service.sys.AdministratorService;
|
import com.red.circle.other.infra.database.rds.service.sys.AdministratorService;
|
||||||
import com.red.circle.other.inner.endpoint.team.bd.BdTeamInfoClient;
|
import com.red.circle.other.inner.endpoint.team.bd.BdTeamInfoClient;
|
||||||
import com.red.circle.other.inner.endpoint.team.bd.BdTeamLeaderClient;
|
import com.red.circle.other.inner.endpoint.team.bd.BdTeamLeaderClient;
|
||||||
import com.red.circle.other.inner.endpoint.team.target.TeamProfileClient;
|
import com.red.circle.other.inner.endpoint.team.target.TeamProfileClient;
|
||||||
import com.red.circle.other.inner.enums.material.PropsCommodityType;
|
import com.red.circle.other.inner.enums.material.PropsCommodityType;
|
||||||
|
import com.red.circle.other.inner.enums.sys.appmanager.RoomRolesEnum;
|
||||||
import com.red.circle.other.inner.enums.team.TeamMemberRole;
|
import com.red.circle.other.inner.enums.team.TeamMemberRole;
|
||||||
import com.red.circle.other.inner.model.dto.agency.agency.TeamMemberDTO;
|
import com.red.circle.other.inner.model.dto.agency.agency.TeamMemberDTO;
|
||||||
import com.red.circle.wallet.inner.endpoint.freight.FreightGoldClient;
|
import com.red.circle.wallet.inner.endpoint.freight.FreightGoldClient;
|
||||||
@ -19,6 +22,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@ -35,15 +39,28 @@ public class UserIdentityServiceImpl implements UserIdentityService {
|
|||||||
public UserIdentityVO getUserIdentity(Long userId) {
|
public UserIdentityVO getUserIdentity(Long userId) {
|
||||||
TeamMemberDTO teamMember = ResponseAssert.requiredSuccess(
|
TeamMemberDTO teamMember = ResponseAssert.requiredSuccess(
|
||||||
teamProfileClient.getByMemberId(userId));
|
teamProfileClient.getByMemberId(userId));
|
||||||
return new UserIdentityVO()
|
|
||||||
|
Administrator administrator = administratorService.getByUserId(userId);
|
||||||
|
boolean isAdmin = Optional.ofNullable(administrator)
|
||||||
|
.map(e -> RoomRolesEnum.ADMIN.eq(e.getRoles()))
|
||||||
|
.orElse(Boolean.FALSE);
|
||||||
|
boolean isSuperAdmin = Optional.ofNullable(administrator)
|
||||||
|
.map(e -> RoomRolesEnum.SUPER_ADMIN.eq(e.getRoles()))
|
||||||
|
.orElse(Boolean.FALSE);
|
||||||
|
boolean isManager = Optional.ofNullable(administrator)
|
||||||
|
.map(e -> RoomRolesEnum.MANAGER.eq(e.getRoles()))
|
||||||
|
.orElse(Boolean.FALSE);
|
||||||
|
|
||||||
|
return new UserIdentityVO()
|
||||||
.setAgent(Objects.nonNull(teamMember) && TeamMemberRole.OWN.eq(teamMember.getRole()))
|
.setAgent(Objects.nonNull(teamMember) && TeamMemberRole.OWN.eq(teamMember.getRole()))
|
||||||
.setAnchor(Objects.nonNull(teamMember))
|
.setAnchor(Objects.nonNull(teamMember))
|
||||||
.setBd(ResponseAssert.requiredSuccess(bdTeamInfoClient.check(userId)))
|
.setBd(ResponseAssert.requiredSuccess(bdTeamInfoClient.check(userId)))
|
||||||
.setFreightAgent(ResponseAssert.requiredSuccess(freightGoldClient.checkFreightAgent(userId)))
|
.setFreightAgent(ResponseAssert.requiredSuccess(freightGoldClient.checkFreightAgent(userId)))
|
||||||
.setSuperFreightAgent(ResponseAssert.requiredSuccess(freightGoldClient.checkSuperFreightAgent(userId)))
|
.setSuperFreightAgent(ResponseAssert.requiredSuccess(freightGoldClient.checkSuperFreightAgent(userId)))
|
||||||
.setSuperAdmin(administratorService.existsSupperAdmin(userId))
|
.setSuperAdmin(isSuperAdmin)
|
||||||
.setAdmin(administratorService.existsAdmin(userId))
|
.setAdmin(isAdmin)
|
||||||
.setBdLeader(ResponseAssert.requiredSuccess(bdTeamLeaderClient.check(userId)))
|
.setBdLeader(ResponseAssert.requiredSuccess(bdTeamLeaderClient.check(userId)))
|
||||||
|
.setManager(isManager)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,6 +54,11 @@ public class UserIdentityVO implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Boolean superAdmin;
|
private Boolean superAdmin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是经理
|
||||||
|
*/
|
||||||
|
private Boolean manager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 历史身份.
|
* 历史身份.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -40,11 +40,19 @@ public interface AdministratorService extends BaseService<Administrator> {
|
|||||||
/**
|
/**
|
||||||
* 是否是超级管理员.
|
* 是否是超级管理员.
|
||||||
*
|
*
|
||||||
* @param userId 验证用户是否是管理员
|
* @param userId 验证用户是否是超级管理员
|
||||||
* @return true 是,false 不是
|
* @return true 是,false 不是
|
||||||
*/
|
*/
|
||||||
boolean existsSupperAdmin(Long userId);
|
boolean existsSupperAdmin(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是经理.
|
||||||
|
*
|
||||||
|
* @param userId 验证用户是否是经理
|
||||||
|
* @return true 是,false 不是
|
||||||
|
*/
|
||||||
|
boolean existsManager(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户组是否存在可用管理员.
|
* 用户组是否存在可用管理员.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -65,6 +65,16 @@ public class AdministratorServiceImpl extends
|
|||||||
.orElse(Boolean.FALSE);
|
.orElse(Boolean.FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean existsManager(Long userId) {
|
||||||
|
return query()
|
||||||
|
.select(Administrator::getId)
|
||||||
|
.eq(Administrator::getUserId, userId)
|
||||||
|
.eq(Administrator::getStatus, 1)
|
||||||
|
.eq(Administrator::getRoles, RoomRolesEnum.MANAGER.name())
|
||||||
|
.last(PageConstant.LIMIT_ONE).getOne() != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean existsAvailable(Set<Long> userIds) {
|
public boolean existsAvailable(Set<Long> userIds) {
|
||||||
return Optional.ofNullable(
|
return Optional.ofNullable(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user