代码拉取完成,页面将自动刷新
同步操作将从 all the way/ibsm-common 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#常用工具类合集:
package com.hm.car.util;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import com.hm.common.ServerResponse;
/**
* @author shishun.wang
* @date 2016年12月15日 下午12:00:07
* @version 1.0
* @describe
*/
public class ControllerResult<T> {
public static <T> ResponseEntity<ServerResponse<T>> success(T result) {
return new ResponseEntity<ServerResponse<T>>(new ServerResponse<T>().success(result), HttpStatus.OK);
}
public static <T> ResponseEntity<ServerResponse<T>> failed(String message) {
return new ResponseEntity<ServerResponse<T>>(new ServerResponse<T>().failure(message), HttpStatus.BAD_REQUEST);
}
public static <T> ResponseEntity<ServerResponse<T>> failed(Exception e) {
return new ResponseEntity<ServerResponse<T>>(new ServerResponse<T>().failure(e.getMessage()),
HttpStatus.BAD_REQUEST);
}
}
package com.hm.car.util;
import java.lang.reflect.Field;
import java.util.Arrays;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.util.ReflectionUtils;
import com.hm.common.util.CommonUtil;
/**
* @author shishun.wang
* @date 2016年12月14日 上午10:11:15
* @version 1.0
* @describe
*/
public class BeanUtil {
private static final String MODEL_ID_FIELD = "id";
public static final void copyProperties(Object source, Object target, String... ignoreProperties) {
if (com.hm.common.util.CommonUtil.isAnyEmpty(source, target)) {
return;
}
BeanUtils.copyProperties(source, target, ignoreProperties);
// Trying copy id field
if (com.hm.common.util.CommonUtil.isNotEmpty(ignoreProperties) && Arrays.asList(ignoreProperties).contains(MODEL_ID_FIELD)) {
return;
}
Field targetFiled = ReflectionUtils.findField(target.getClass(), MODEL_ID_FIELD, String.class);
if (targetFiled == null) {
return;
}
Field sourceFiled = ReflectionUtils.findField(source.getClass(), MODEL_ID_FIELD);
if (sourceFiled == null) {
return;
}
try {
sourceFiled.setAccessible(true);
Object sourceId = sourceFiled.get(source);
if (sourceId == null) {
return;
}
targetFiled.setAccessible(true);
if (sourceId instanceof String) {
ReflectionUtils.setField(targetFiled, target, sourceId);
} else {
ReflectionUtils.setField(targetFiled, target, sourceId.toString());
}
} catch (IllegalArgumentException | IllegalAccessException e) {
LoggerFactory.getLogger(CommonUtil.class).error("Failed to reflect set id properties", e);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。