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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.unis.crk.basic.entity.UserRole;
import com.unis.crk.basic.mapper.UserRoleMapper;
import com.unis.crk.basic.service.IUserRoleService;
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 UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements IUserRoleService {
    @Resource
    private  UserRoleMapper userRoleMapper;

    @Override
    public List<UserRole> getUserRole(String userId) {
        QueryWrapper<UserRole> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("user_id",userId);
        List<UserRole> userRoles = userRoleMapper.selectList(objectQueryWrapper);
        return userRoles;
    }

    @Override
    public void deleteByUserID(String userId) {
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.eq("user_id",userId);
        userRoleMapper.delete(updateWrapper);

    }
}
