package com.unis.crk.basic.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.unis.crk.basic.entity.RoleInfo;
import com.unis.crk.basic.entity.UserRole;
import com.unis.crk.basic.mapper.RoleInfoMapper;
import com.unis.crk.basic.mapper.UserInfoMapper;
import com.unis.crk.basic.service.IRoleInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 角色信息表 服务实现类
 * </p>
 *
 * @author ghh
 * @since 2021-09-26
 */
@Service
public class RoleInfoServiceImpl extends ServiceImpl<RoleInfoMapper, RoleInfo> implements IRoleInfoService {

    @Resource
    private RoleInfoMapper roleInfoMapper;
    @Override
    public List<RoleInfo> getUserRoleByUserID(String userId) {

        return roleInfoMapper.getUserRoleByUserID(userId);
    }

    @Override
    public Boolean validRoleName(String roleName) {
        QueryWrapper<RoleInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("role_name",roleName);
        List<RoleInfo> roleInfos = roleInfoMapper.selectList(queryWrapper);
        if(roleInfos == null || roleInfos.size()>0){
            return false;
        }else{
            return true;
        }

    }


}
