| | |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.vci.ubcs.com.vci.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.com.vci.starter.web.pagemodel.SessionInfo; |
| | | import com.vci.ubcs.com.vci.starter.web.toolmodel.DateConverter; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | return listHasList; |
| | | } |
| | | } |
| | | public static short getShort(String s) { |
| | | // short i = false; |
| | | if (s == null) { |
| | | return 0; |
| | | } else { |
| | | try { |
| | | short i = Short.parseShort(s); |
| | | return i; |
| | | } catch (Exception var3) { |
| | | return 0; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public static void setValueForField(Field field, Object obj, String value) { |
| | | try { |
| | | if (field != null && StringUtils.isNotBlank(value)) { |
| | | field.setAccessible(true); |
| | | Method setMethod = getSetmethod(field.getDeclaringClass(), field.getName()); |
| | | Class type = field.getType(); |
| | | Object valueObj = null; |
| | | if (!type.equals(Integer.TYPE) && !type.equals(Integer.class)) { |
| | | if (!type.equals(Float.TYPE) && !type.equals(Float.class)) { |
| | | if (!type.equals(Long.TYPE) && !type.equals(Long.class)) { |
| | | if (!type.equals(Double.class) && !type.equals(Double.TYPE)) { |
| | | if (type.equals(Date.class)) { |
| | | DateConverter dateConverter = new DateConverter(); |
| | | dateConverter.setAsText(value); |
| | | valueObj = dateConverter.getValue(); |
| | | } else if (type.equals(String.class)) { |
| | | valueObj = value; |
| | | } else { |
| | | valueObj = value; |
| | | if (log.isErrorEnabled()) { |
| | | log.error("不支持的类型" + type.toString()); |
| | | } |
| | | } |
| | | } else { |
| | | valueObj = getDouble(value); |
| | | } |
| | | } else { |
| | | valueObj = getLong(value); |
| | | } |
| | | } else { |
| | | valueObj = getFloat(value); |
| | | } |
| | | } else { |
| | | valueObj = getInt(value); |
| | | } |
| | | |
| | | if (setMethod != null) { |
| | | setMethod.invoke(obj, valueObj); |
| | | } else { |
| | | field.set(obj, valueObj); |
| | | } |
| | | } |
| | | } catch (Throwable var7) { |
| | | if (log.isErrorEnabled()) { |
| | | log.error("设置属性的值出错了错误", var7); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |