获取所有角色名返回结果更改

This commit is contained in:
s2042968 2024-12-27 10:26:31 +08:00
parent 35a3ee5b77
commit 205fb40864
2 changed files with 15 additions and 4 deletions

View File

@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.electromagnetic.industry.software.manage.pojo.models.Role; 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 org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List; import java.util.List;
public interface RoleService extends IService<Role> { public interface RoleService extends IService<Role> {
@ -48,9 +48,10 @@ public interface RoleService extends IService<Role> {
/** /**
* 获取所有角色名 * 获取所有角色名
*
* @return * @return
*/ */
List<String> getAllRoleNames(); List<HashMap<String, String>> getAllRoleNames();
/** /**
* 通过角色名称查看角色权限 * 通过角色名称查看角色权限

View File

@ -218,15 +218,25 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
/** /**
* 获取所有角色名 * 获取所有角色名
*
* @return * @return
*/ */
@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;
} }
/** /**