whycxzp
2020-12-18 e5c227d7992ca6171b998ed2b73b1f0cbaf1ccfe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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);
    }
}