All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.rexsheng.springboot.faster.system.auth.infrastructure.AuthGatewayImpl Maven / Gradle / Ivy

The newest version!
package com.github.rexsheng.springboot.faster.system.auth.infrastructure;

import com.github.rexsheng.springboot.faster.common.constant.CommonConstant;
import com.github.rexsheng.springboot.faster.system.auth.domain.gateway.AuthCodeDO;
import com.github.rexsheng.springboot.faster.system.auth.domain.gateway.AuthGateway;
import com.github.rexsheng.springboot.faster.system.entity.table.MenuTableDef;
import com.github.rexsheng.springboot.faster.system.entity.table.RoleMenuTableDef;
import com.github.rexsheng.springboot.faster.system.entity.table.RoleTableDef;
import com.github.rexsheng.springboot.faster.system.entity.table.UserRoleTableDef;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.Db;
import com.mybatisflex.core.row.Row;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.stream.Collectors;

@Repository
@ConditionalOnClass(BaseMapper.class)
public class AuthGatewayImpl implements AuthGateway {
    @Override
    public List queryAuthByUserId(Long userId) {
        QueryWrapper queryWrapper= QueryWrapper.create().select(RoleTableDef.ROLE.CODE.as(AuthCodeDO::getRoleCode), RoleMenuTableDef.ROLE_MENU.MENU_ID.as(AuthCodeDO::getMenuId))
                .from(UserRoleTableDef.USER_ROLE)
                .innerJoin(RoleTableDef.ROLE).on(UserRoleTableDef.USER_ROLE.ROLE_ID.eq(RoleTableDef.ROLE.ID))
                .innerJoin(RoleMenuTableDef.ROLE_MENU).on(RoleTableDef.ROLE.ID.eq(RoleMenuTableDef.ROLE_MENU.ROLE_ID))
                .innerJoin(MenuTableDef.MENU).on(RoleMenuTableDef.ROLE_MENU.MENU_ID.eq(MenuTableDef.MENU.ID))
                .where(RoleTableDef.ROLE.STATUS.eq(CommonConstant.STATUS_RUNNING))
                .and(RoleTableDef.ROLE.IS_DEL.eq(false))
                .and(MenuTableDef.MENU.STATUS.eq(CommonConstant.STATUS_RUNNING))
                .and(MenuTableDef.MENU.IS_DEL.eq(false))
                .and(UserRoleTableDef.USER_ROLE.USER_ID.eq(userId));
        List rowList= Db.selectListByQuery(queryWrapper);
        return rowList.stream().map(row->row.toEntity(AuthCodeDO.class)).collect(Collectors.toList());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy