package com.vincent.rsf.server.common.handler;
|
|
import cn.afterturn.easypoi.handler.inter.IExcelDictHandler;
|
import com.vincent.rsf.framework.common.SpringUtils;
|
import com.vincent.rsf.server.common.handler.global.GlobalDictService;
|
|
/**
|
* @Description: excel 字典处理类
|
* @Author: Ryan
|
* @CreateDate: 2019/10/29 17:42
|
* @Version: 1.0
|
*/
|
public class ExcelDictHandlerImpl implements IExcelDictHandler {
|
|
private ExcelDictHandlerImpl() {
|
}
|
|
private volatile static ExcelDictHandlerImpl INSTANCE;
|
|
public static ExcelDictHandlerImpl getInstance() {
|
if (INSTANCE == null) {
|
synchronized (ExcelDictHandlerImpl.class) {
|
INSTANCE = new ExcelDictHandlerImpl();
|
}
|
}
|
return INSTANCE;
|
}
|
|
@Override
|
public String toName(String dict, Object obj, String name, Object value) {
|
return getGlobalDictService().getDictLabel(dict, (value != null ? value.toString() : null), (value != null ? value.toString() : null));
|
}
|
|
@Override
|
public String toValue(String dict, Object obj, String name, Object value) {
|
return getGlobalDictService().getDictValue(dict, (value != null ? value.toString() : null), (value != null ? value.toString() : null));
|
}
|
|
private GlobalDictService getGlobalDictService() {
|
try {
|
return SpringUtils.getBean(GlobalDictService.class);
|
} catch (Exception e) {
|
return null;
|
}
|
}
|
|
|
}
|