mirror of https://gitee.com/stylefeng/roses
【7.6.0】format类增加字典id的转化
parent
fe55faf0a1
commit
8b910a6900
|
@ -66,4 +66,12 @@ public interface DictApi {
|
|||
*/
|
||||
void deleteByDictId(Long dictId);
|
||||
|
||||
/**
|
||||
* 通过字典id获取字典的名称
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/5/4 21:25
|
||||
*/
|
||||
String getDictNameByDictId(Long dictId);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package cn.stylefeng.roses.kernel.dict.api.format;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.stylefeng.roses.kernel.dict.api.DictApi;
|
||||
import cn.stylefeng.roses.kernel.rule.format.BaseSimpleFieldFormatProcess;
|
||||
|
||||
/**
|
||||
* JSON响应对组织字典id的转化
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/5/4 21:20
|
||||
*/
|
||||
public class DictFormatProcess extends BaseSimpleFieldFormatProcess {
|
||||
|
||||
@Override
|
||||
public Class<?> getItemClass() {
|
||||
return Long.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object simpleItemFormat(Object businessId) {
|
||||
Long orgId = Convert.toLong(businessId);
|
||||
DictApi bean = SpringUtil.getBean(DictApi.class);
|
||||
return bean.getDictNameByDictId(orgId);
|
||||
}
|
||||
|
||||
}
|
|
@ -224,6 +224,16 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, SysDict> implements
|
|||
this.removeById(dictId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDictNameByDictId(Long dictId) {
|
||||
SysDict sysDict = this.getById(dictId);
|
||||
if (sysDict == null) {
|
||||
return "";
|
||||
} else {
|
||||
return sysDict.getDictName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取详细信息
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue