112d434a455b27779b7d76ae31f7ae413df2d8df.svn-base
1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Copyright © 2015-2018 ODM All rights reserved.
*/
package com.thinkgem.jeesite.common.utils.excel.fieldtype;
import java.util.List;
import com.google.common.collect.Lists;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.common.utils.Collections3;
import com.thinkgem.jeesite.common.utils.SpringContextHolder;
import com.thinkgem.jeesite.modules.sys.entity.Role;
import com.thinkgem.jeesite.modules.sys.service.SystemService;
/**
* 字段类型转换
* @author ThinkGem
* @version 2013-5-29
*/
public class RoleListType {
private static SystemService systemService = SpringContextHolder.getBean(SystemService.class);
/**
* 获取对象值(导入)
*/
public static Object getValue(String val) {
List<Role> roleList = Lists.newArrayList();
List<Role> allRoleList = systemService.findAllRole();
for (String s : StringUtils.split(val, ",")){
for (Role e : allRoleList){
if (StringUtils.trimToEmpty(s).equals(e.getName())){
roleList.add(e);
}
}
}
return roleList.size()>0?roleList:null;
}
/**
* 设置对象值(导出)
*/
public static String setValue(Object val) {
if (val != null){
@SuppressWarnings("unchecked")
List<Role> roleList = (List<Role>)val;
return Collections3.extractToString(roleList, "name", ", ");
}
return "";
}
}