代码优化

This commit is contained in:
thinkgem
2021-11-30 17:15:43 +08:00
parent a13fbf45e8
commit d4ecc7d0b5
2 changed files with 10 additions and 6 deletions

View File

@@ -4,6 +4,7 @@
*/
package com.jeesite.common.utils.excel.fieldtype;
import java.util.ArrayList;
import java.util.List;
import com.jeesite.common.collect.ListUtils;
@@ -31,14 +32,15 @@ public class PostListType implements FieldType {
* 获取对象值(导入)
*/
public Object getValue(String val) {
List<String> list = new ArrayList<String>();
for (String s : StringUtils.split(val, ",")) {
for (Post e : postList) {
if (StringUtils.trimToEmpty(s).equals(e.getPostName())) {
postList.add(e);
list.add(e.getPostCode());
}
}
}
return postList.size() > 0 ? postList : null;
return list.size() > 0 ? list.toArray(new String[list.size()]) : null;
}
/**
@@ -50,7 +52,7 @@ public class PostListType implements FieldType {
List<Post> postList = (List<Post>) val;
return ListUtils.extractToString(postList, "postName", ", ");
}
return "";
return StringUtils.EMPTY;
}
}

View File

@@ -4,6 +4,7 @@
*/
package com.jeesite.common.utils.excel.fieldtype;
import java.util.ArrayList;
import java.util.List;
import com.jeesite.common.collect.ListUtils;
@@ -31,14 +32,15 @@ public class RoleListType implements FieldType {
* 获取对象值(导入)
*/
public Object getValue(String val) {
List<String> list = new ArrayList<String>();
for (String s : StringUtils.split(val, ",")) {
for (Role e : roleList) {
if (StringUtils.trimToEmpty(s).equals(e.getRoleName())) {
roleList.add(e);
list.add(e.getRoleCode());
}
}
}
return roleList.size() > 0 ? roleList : null;
return list.size() > 0 ? list.toArray(new String[list.size()]) : null;
}
/**
@@ -50,7 +52,7 @@ public class RoleListType implements FieldType {
List<Role> roleList = (List<Role>) val;
return ListUtils.extractToString(roleList, "roleName", ", ");
}
return "";
return StringUtils.EMPTY;
}
}