package com.hs.admin.service.impl;

import com.hs.admin.mapper.SysRoleMapper;
import com.hs.admin.mapper.SysUserRoleRsMapper;
import com.hs.admin.model.SysRole;
import com.hs.admin.model.SysUserRoleRs;
import com.hs.admin.service.SysUserRoleRsService;
import org.springframework.stereotype.Service;

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

@Service
public class SysUserRoleServiceImpl implements SysUserRoleRsService {

    @Resource
    private SysUserRoleRsMapper sysUserRoleRsMapper;
    @Resource
    private SysRoleMapper sysRoleMapper;

    @Override
    public List<SysRole> getRoleListByUser(Integer userId) throws Exception {
        return sysRoleMapper.selectRoleByUser(userId);
    }

    @Override
    public int add(SysUserRoleRs sysUserRoleRs) {
        return sysUserRoleRsMapper.insert(sysUserRoleRs);
    }

    @Override
    public List<SysUserRoleRs> findAll() {
        return sysUserRoleRsMapper.selectAll();
    }

    @Override
    public SysUserRoleRs find(Integer id) {
        return sysUserRoleRsMapper.selectByPrimaryKey(id);
    }

    @Override
    public int delete(Integer id) {
        return sysUserRoleRsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int logicDelete(Integer id) {
        return 0;
    }

    @Override
    public int update(SysUserRoleRs sysUserRoleRs) {
        return sysUserRoleRsMapper.updateByPrimaryKey(sysUserRoleRs);
    }
}
