This commit is contained in:
chenxudong 2024-12-27 10:29:01 +08:00
commit 952efbd78d
2 changed files with 13 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import com.electromagnetic.industry.software.manage.pojo.models.Role;
import com.electromagnetic.industry.software.manage.pojo.req.RoleDTO; import com.electromagnetic.industry.software.manage.pojo.req.RoleDTO;
import com.electromagnetic.industry.software.manage.pojo.req.RolePageDTO; import com.electromagnetic.industry.software.manage.pojo.req.RolePageDTO;
import java.util.HashMap;
import java.util.List; import java.util.List;
public interface RoleService extends IService<Role> { public interface RoleService extends IService<Role> {
@ -55,7 +56,7 @@ public interface RoleService extends IService<Role> {
* *
* @return * @return
*/ */
List<String> getAllRoleNames(); List<HashMap<String, String>> getAllRoleNames();
/** /**
* 通过角色名称查看角色权限 * 通过角色名称查看角色权限

View File

@ -235,11 +235,20 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
*/ */
@Transactional @Transactional
@Override @Override
public List<String> getAllRoleNames() { public List<HashMap<String, String>> getAllRoleNames() {
LambdaQueryWrapper<Role> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Role> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(Role::getRoleName) queryWrapper.select(Role::getRoleName)
.eq(Role::getEffectFlag, EffectFlagEnum.EFFECT.code); .eq(Role::getEffectFlag, EffectFlagEnum.EFFECT.code);
return this.listObjs(queryWrapper).stream().map(Object::toString).collect(Collectors.toList());
List<String> roleNames = this.listObjs(queryWrapper).stream().map(Object::toString).collect(Collectors.toList());
List<HashMap<String,String>> result = new ArrayList<>();
for (String roleName : roleNames) {
HashMap<String, String> map = new HashMap<>();
map.put("value", roleName);
map.put("label", roleName);
result.add(map);
}
return result;
} }
/** /**