package com.whyc.service;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.whyc.mapper.RolePrivilegeMapper;
|
import com.whyc.pojo.Privilege;
|
import com.whyc.pojo.RolePrivilege;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import javax.annotation.Resource;
|
import java.util.List;
|
|
/**
|
* 角色-权限
|
*/
|
@Service
|
public class RolePrivilegeService {
|
|
@Resource
|
private RolePrivilegeMapper mapper;
|
|
public boolean bindingUserWithRole(int roleId, int privilegeId) {
|
return mapper.insert(new RolePrivilege(roleId,privilegeId))>0;
|
}
|
|
@Transactional
|
public boolean bindingUserWithRoleBatch(List<RolePrivilege> rolePrivileges) {
|
return mapper.insertBatchSomeColumn(rolePrivileges)==rolePrivileges.size();
|
}
|
|
public List<Privilege> getPrivileges(Integer userId) {
|
return mapper.getPrivileges(userId);
|
}
|
}
|