后台赠送道具新增权限校验
This commit is contained in:
parent
a59a4f9561
commit
af1fb4604a
@ -184,7 +184,14 @@ public enum ConsoleErrorCode implements IResponseErrorCode {
|
||||
/**
|
||||
* 用户动态不能重复插入
|
||||
*/
|
||||
USER_DYNAMICS_CANNOT_BE_INSERTED_REPEATEDLY(10034, "User dynamics cannot be inserted repeatedly");
|
||||
USER_DYNAMICS_CANNOT_BE_INSERTED_REPEATEDLY(10034, "User dynamics cannot be inserted repeatedly"),
|
||||
|
||||
/**
|
||||
* 账号无权限
|
||||
*/
|
||||
ACCOUNT_NOT_PERMISSIONS(10035,"The account has no permissions."),
|
||||
|
||||
;
|
||||
|
||||
private final Integer code;
|
||||
|
||||
|
||||
@ -21,4 +21,7 @@ public class AccountButtonsAliasesQryExe {
|
||||
return menuService.getUserPermButtonAliases(cmd.requiredReqUserId().intValue());
|
||||
}
|
||||
|
||||
public boolean hasButtonAlias(Integer userId, String alias) {
|
||||
return menuService.hasUserButtonAlias(userId, alias);
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,6 +89,11 @@ public class UserAccountServiceImpl implements UserAccountService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasButtonsAlias(Integer userId, String alias) {
|
||||
return accountButtonsAliasesQryExe.hasButtonAlias(userId, alias);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<UserCO> pageUser(UserPageQryCmd cmd) {
|
||||
return userPageQryExe.execute(cmd);
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.red.circle.common.business.enums.DiamondOrigin;
|
||||
import com.red.circle.common.business.enums.PropsActivityRewardEnum;
|
||||
import com.red.circle.common.business.enums.SendPropsOrigin;
|
||||
import com.red.circle.console.app.dto.cmd.app.props.PropsGiveUserCmd;
|
||||
import com.red.circle.console.app.service.admin.UserAccountService;
|
||||
import com.red.circle.console.inner.error.ConsoleErrorCode;
|
||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||
import com.red.circle.other.inner.endpoint.live.RoomManagerClient;
|
||||
@ -15,6 +16,7 @@ import com.red.circle.other.inner.endpoint.material.props.PropsCommodityStoreCli
|
||||
import com.red.circle.other.inner.endpoint.material.props.PropsNobleVipClient;
|
||||
import com.red.circle.other.inner.endpoint.material.props.PropsSourceClient;
|
||||
import com.red.circle.other.inner.endpoint.material.props.RoomThemeBackpackClient;
|
||||
import com.red.circle.other.inner.endpoint.user.user.SysUserProfileClient;
|
||||
import com.red.circle.other.inner.enums.material.BadgeBackpackExpireTypeEnum;
|
||||
import com.red.circle.other.inner.enums.material.ConsolePropsTypeEnum;
|
||||
import com.red.circle.other.inner.enums.material.SysNobleVipTypeEnum;
|
||||
@ -71,6 +73,7 @@ public class PropsGiveServiceImpl implements PropsGiveService {
|
||||
private final PropsNobleVipClient propsNobleVipClient;
|
||||
private final RoomThemeBackpackClient roomThemeBackpackClient;
|
||||
private final PropsCommodityStoreClient propsCommodityStoreClient;
|
||||
private final UserAccountService userAccountService;
|
||||
|
||||
@Override
|
||||
public String give(PropsGiveUserCmd cmd) {
|
||||
@ -121,6 +124,9 @@ public class PropsGiveServiceImpl implements PropsGiveService {
|
||||
String sysOrigin = getUserSysOrigin(cmd.getReceiverId());
|
||||
ResponseAssert.isFalse(UserErrorCode.USER_INFO_NOT_FOUND, StringUtils.isBlank(sysOrigin));
|
||||
|
||||
// 后台赠送道具校验权限
|
||||
checkUserAccountAlias(cmd);
|
||||
|
||||
if (Objects.equals(cmd.getType(), PropsActivityRewardEnum.PROPS.name())) {
|
||||
|
||||
isNullStr(cmd.getSecondaryType());
|
||||
@ -167,6 +173,15 @@ public class PropsGiveServiceImpl implements PropsGiveService {
|
||||
ResponseAssert.failure(ConsoleErrorCode.NOT_DATA);
|
||||
}
|
||||
|
||||
private void checkUserAccountAlias(PropsGiveUserCmd cmd) {
|
||||
|
||||
boolean hassed = userAccountService.hasButtonsAlias(cmd.getOpsUser().intValue(), "send:props:" + cmd.getSecondaryType());
|
||||
if (!hassed) {
|
||||
ResponseAssert.failure(ConsoleErrorCode.ACCOUNT_NOT_PERMISSIONS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private StringBuilder getErrorAccounts(Set<String> accounts, List<UserProfileDTO> users) {
|
||||
|
||||
StringBuilder errorAccounts = new StringBuilder();
|
||||
|
||||
@ -55,6 +55,11 @@ public interface UserAccountService {
|
||||
*/
|
||||
Set<String> listAccountButtonsAliases(CommonCommand cmd);
|
||||
|
||||
/**
|
||||
* 是否有指定按钮的权限
|
||||
*/
|
||||
boolean hasButtonsAlias(Integer userId, String alias);
|
||||
|
||||
/**
|
||||
* 查询所有用户(分页.
|
||||
*/
|
||||
|
||||
@ -24,4 +24,5 @@ public interface MenuDAO extends BaseDAO<Menu> {
|
||||
@Param("statusType") StatusEnum statusType,
|
||||
@Param("menuTypes") List<MenuTypeEnum> menuTypes);
|
||||
|
||||
MenuTreeDTO findUserPermMenu(@Param("uid") Integer uid, @Param("alias") String alias);
|
||||
}
|
||||
|
||||
@ -51,4 +51,9 @@ public interface MenuService extends BaseService<Menu> {
|
||||
*/
|
||||
Set<String> getUserPermButtonAliases(Integer uid);
|
||||
|
||||
/**
|
||||
* 是否有指定的权限
|
||||
*/
|
||||
boolean hasUserButtonAlias(Integer userId, String alias);
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.red.circle.console.infra.database.rds.service.admin.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.red.circle.console.infra.database.rds.dao.admin.MenuDAO;
|
||||
import com.red.circle.console.infra.database.rds.dto.admin.MenuTreeDTO;
|
||||
import com.red.circle.console.infra.database.rds.entity.admin.Menu;
|
||||
@ -114,4 +115,14 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuDAO, Menu> implements M
|
||||
.map(MenuTreeDTO::getAlias)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasUserButtonAlias(Integer userId, String alias) {
|
||||
if (userId == null || StringUtils.isEmpty(alias)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MenuTreeDTO userPermMenu = baseDAO.findUserPermMenu(userId, alias);
|
||||
return userPermMenu != null && alias.equals(userPermMenu.getAlias());
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,4 +33,24 @@
|
||||
) tmp
|
||||
ORDER BY tmp.sort DESC
|
||||
</select>
|
||||
|
||||
<select id="findUserPermMenu" resultType="com.red.circle.console.infra.database.rds.dto.admin.MenuTreeDTO">
|
||||
SELECT
|
||||
sm.id,
|
||||
sm.parent_id,
|
||||
sm.menu_name,
|
||||
sm.menu_type,
|
||||
sm.router,
|
||||
sm.alias,
|
||||
sm.icon,
|
||||
sm.path,
|
||||
sm.sort
|
||||
FROM
|
||||
sys_menu sm
|
||||
LEFT JOIN sys_role_menu srm ON sm.id = srm.menu_id
|
||||
LEFT JOIN sys_user_role sur ON sur.role_id = srm.role_id
|
||||
LEFT JOIN sys_user su ON su.uid = sur.uid
|
||||
WHERE
|
||||
su.uid = #{uid} and sm.status = 0 and sm.alias = #{alias}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user