| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.yuanchu.mom.common.GetLook; |
| | | import com.yuanchu.mom.common.PrintChina; |
| | | import com.yuanchu.mom.dto.RolePowerDto; |
| | | import com.yuanchu.mom.dto.UserPageDto; |
| | | import com.yuanchu.mom.mapper.PowerMapper; |
| | | import com.yuanchu.mom.mapper.RoleMapper; |
| | | import com.yuanchu.mom.mapper.UserMapper; |
| | | import com.yuanchu.mom.pojo.Menu; |
| | | import com.yuanchu.mom.pojo.Power; |
| | | import com.yuanchu.mom.pojo.Role; |
| | | import com.yuanchu.mom.pojo.User; |
| | | import com.yuanchu.mom.service.RoleService; |
| | |
| | | import com.yuanchu.mom.utils.QueryWrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.DigestUtils; |
| | | |
| | | import java.util.HashMap; |
| | |
| | | |
| | | private RoleMapper roleMapper; |
| | | |
| | | private PowerMapper powerMapper; |
| | | |
| | | private GetLook getLook; |
| | | |
| | | @Override |
| | | public List<Role> selectList() { |
| | | return roleMapper.selectList(null); |
| | |
| | | public Map<String, Object> selectUserList(IPage<Role> page, Role role) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("head", PrintChina.printChina(Role.class)); |
| | | Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectRoleLists"); |
| | | if(map1.get("look")==1) role.setCreateUser(map1.get("userId")); |
| | | map.put("body", roleMapper.selectPage(page, QueryWrappers.queryWrappers(role))); |
| | | return map; |
| | | } |
| | |
| | | public int delRole(Integer id) { |
| | | return roleMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int addRole(RolePowerDto rolePowerDto) { |
| | | Role role = new Role(); |
| | | role.setName(rolePowerDto.getRoleName()); |
| | | int insert = roleMapper.insert(role); |
| | | if (insert == 1){ |
| | | rolePowerDto.getPowers().forEach(a->{ |
| | | a.setRoleId(role.getId()); |
| | | powerMapper.insert(a); |
| | | }); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | @Override |
| | | public List<Menu> selectMenuList() { |
| | | return roleMapper.selectMenuList(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int upRole(RolePowerDto rolePowerDto) { |
| | | Role role = new Role(); |
| | | role.setName(rolePowerDto.getRoleName()); |
| | | role.setId(rolePowerDto.getRoleId2()); |
| | | int up = roleMapper.updateById(role); |
| | | if (up == 1){ |
| | | powerMapper.delete(Wrappers.<Power>lambdaUpdate().eq(Power::getRoleId, role.getId())); |
| | | rolePowerDto.getPowers().forEach(a->{ |
| | | a.setRoleId(role.getId()); |
| | | powerMapper.insert(a); |
| | | }); |
| | | } |
| | | return 1; |
| | | } |
| | | } |