Compare commits

...

2 Commits

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.req.RoleDTO;
import com.electromagnetic.industry.software.manage.pojo.req.RolePageDTO;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
public interface RoleService extends IService<Role> {
@ -48,9 +48,10 @@ public interface RoleService extends IService<Role> {
/**
* 获取所有角色名
*
* @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
*/
@Transactional
@Override
public List<String> getAllRoleNames() {
public List<HashMap<String, String>> getAllRoleNames() {
LambdaQueryWrapper<Role> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(Role::getRoleName)
.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;
}
/**