mirror of https://gitee.com/stylefeng/roses
【8.0】【sys】更新角色名称的快速返回
parent
d00b9fd65d
commit
4b626f09b0
|
@ -42,4 +42,12 @@ public interface SysRoleServiceApi {
|
||||||
*/
|
*/
|
||||||
Long getDefaultRoleId();
|
Long getDefaultRoleId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过角色id获取角色名称
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/7/15 21:54
|
||||||
|
*/
|
||||||
|
String getRoleNameByRoleId(Long roleId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.api.format;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.format.BaseSimpleFieldFormatProcess;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.api.SysRoleServiceApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON响应对角色id的转化
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/5/4 21:20
|
||||||
|
*/
|
||||||
|
public class RoleNameFormatProcess extends BaseSimpleFieldFormatProcess {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getItemClass() {
|
||||||
|
return Long.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object simpleItemFormat(Object businessId) {
|
||||||
|
Long roleId = Convert.toLong(businessId);
|
||||||
|
SysRoleServiceApi bean = SpringUtil.getBean(SysRoleServiceApi.class);
|
||||||
|
return bean.getRoleNameByRoleId(roleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -133,6 +133,24 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRoleNameByRoleId(Long roleId) {
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(roleId)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<SysRole> sysRoleLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
sysRoleLambdaQueryWrapper.eq(SysRole::getRoleId, roleId);
|
||||||
|
sysRoleLambdaQueryWrapper.select(SysRole::getRoleName);
|
||||||
|
SysRole sysRole = this.getOne(sysRoleLambdaQueryWrapper, false);
|
||||||
|
if (sysRole != null) {
|
||||||
|
return sysRole.getRoleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取信息
|
* 获取信息
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue