New file |
| | |
| | | package com.dsh.guns.modular.system.service.impl; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.course.mapper.RelationMapper; |
| | | import com.dsh.course.mapper.RoleMapper; |
| | | import com.dsh.course.model.node.ZTreeNode; |
| | | import com.dsh.guns.config.UserExt; |
| | | import com.dsh.guns.modular.system.controller.util.Convert; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.dsh.guns.modular.system.model.Relation; |
| | | import com.dsh.guns.modular.system.model.Role; |
| | | import com.dsh.guns.modular.system.service.IRoleService; |
| | | |
| | | @Service |
| | | public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService { |
| | | |
| | | @Resource |
| | | private RoleMapper roleMapper; |
| | | |
| | | @Resource |
| | | private RelationMapper relationMapper; |
| | | |
| | | @Override |
| | | @Transactional(readOnly = false) |
| | | public void setAuthority(Integer roleId, String ids) { |
| | | |
| | | // 删除该角色所有的权限 Delete all permissions for this role. |
| | | this.roleMapper.deleteRolesById(roleId); |
| | | |
| | | // 添加新的权限 add new permissions |
| | | for (Long id : Convert.toLongArray(true, Convert.toStrArray(",", ids))) { |
| | | Relation relation = new Relation(); |
| | | relation.setRoleid(roleId); |
| | | relation.setMenuid(id); |
| | | this.relationMapper.insert(relation); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(readOnly = false) |
| | | public void delRoleById(Integer roleId) { |
| | | //删除角色 delete role |
| | | this.roleMapper.deleteById(roleId); |
| | | |
| | | // 删除该角色所有的权限 Delete all permissions for this role. |
| | | this.roleMapper.deleteRolesById(roleId); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectRoles(String condition) { |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | return this.baseMapper.selectRoles(condition,objectType,objectId); |
| | | } |
| | | |
| | | @Override |
| | | public int deleteRolesById(Integer roleId) { |
| | | return this.baseMapper.deleteRolesById(roleId); |
| | | } |
| | | |
| | | @Override |
| | | public List<ZTreeNode> roleTreeList(Integer type,Integer id) { |
| | | return this.baseMapper.roleTreeList(type,id); |
| | | } |
| | | |
| | | @Override |
| | | public List<ZTreeNode> roleTreeListByRoleId(String[] roleId,Integer type,Integer id) { |
| | | return this.baseMapper.roleTreeListByRoleId(roleId,type,id); |
| | | } |
| | | |
| | | } |