优化代码
This commit is contained in:
+1
-1
@@ -103,7 +103,7 @@ public class SuperServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M,
|
|||||||
if (null != entity) {
|
if (null != entity) {
|
||||||
Class<?> cls = entity.getClass();
|
Class<?> cls = entity.getClass();
|
||||||
TableInfo tableInfo = TableInfoHelper.getTableInfo(cls);
|
TableInfo tableInfo = TableInfoHelper.getTableInfo(cls);
|
||||||
if (null != tableInfo && StringUtils.isNotEmpty(tableInfo.getKeyProperty())) {
|
if (null != tableInfo && StrUtil.isNotEmpty(tableInfo.getKeyProperty())) {
|
||||||
Object idVal = ReflectionKit.getMethodValue(cls, entity, tableInfo.getKeyProperty());
|
Object idVal = ReflectionKit.getMethodValue(cls, entity, tableInfo.getKeyProperty());
|
||||||
if (StringUtils.checkValNull(idVal) || Objects.isNull(getById((Serializable) idVal))) {
|
if (StringUtils.checkValNull(idVal) || Objects.isNull(getById((Serializable) idVal))) {
|
||||||
if (StrUtil.isEmpty(msg)) {
|
if (StrUtil.isEmpty(msg)) {
|
||||||
|
|||||||
+4
-4
@@ -9,12 +9,12 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class PointUtil {
|
public class PointUtil {
|
||||||
|
private static final String MSG_PATTERN = "{}|{}|{}";
|
||||||
|
|
||||||
private PointUtil() {
|
private PointUtil() {
|
||||||
throw new IllegalStateException("Utility class");
|
throw new IllegalStateException("Utility class");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String SPLIT = "|";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 格式为:{时间}|{来源}|{对象id}|{类型}|{对象属性(以&分割)}
|
* 格式为:{时间}|{来源}|{对象id}|{类型}|{对象属性(以&分割)}
|
||||||
* 例子1:2016-07-27 23:37:23|business-center|1|user-login|ip=xxx.xxx.xx&userName=张三&userType=后台管理员
|
* 例子1:2016-07-27 23:37:23|business-center|1|user-login|ip=xxx.xxx.xx&userName=张三&userType=后台管理员
|
||||||
@@ -25,10 +25,10 @@ public class PointUtil {
|
|||||||
* @param message 对象属性
|
* @param message 对象属性
|
||||||
*/
|
*/
|
||||||
public static void info(String id, String type, String message) {
|
public static void info(String id, String type, String message) {
|
||||||
log.info(id + SPLIT + type + SPLIT + message);
|
log.info(MSG_PATTERN, id, type, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debug(String id, String type, String message) {
|
public static void debug(String id, String type, String message) {
|
||||||
log.debug(id + SPLIT + type + SPLIT + message);
|
log.debug(MSG_PATTERN, id, type, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user