shiqian 4 gadi atpakaļ
vecāks
revīzija
f3b7949761

+ 15 - 9
boman-web-core/src/main/java/com/boman/web/core/service/TableServiceCmdService.java

@@ -3,26 +3,25 @@ package com.boman.web.core.service;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.boman.common.core.utils.number.NumberUtils;
-import com.boman.domain.constant.CacheConstants;
 import com.boman.common.core.utils.SecurityUtils;
 import com.boman.common.core.utils.StringUtils;
 import com.boman.common.core.utils.collection.CollectionUtils;
+import com.boman.common.core.utils.number.NumberUtils;
 import com.boman.common.core.utils.obj.ObjectUtils;
-import com.boman.domain.dto.*;
 import com.boman.common.redis.RedisKey;
 import com.boman.common.redis.service.RedisService;
 import com.boman.common.security.service.TokenService;
 import com.boman.domain.GenTable;
 import com.boman.domain.GenTableColumn;
 import com.boman.domain.SysDictData;
+import com.boman.domain.SysMenu;
 import com.boman.domain.constant.*;
+import com.boman.domain.dto.*;
 import com.boman.domain.exception.NoSuchFunctionException;
 import com.boman.gen.api.RemoteGenTableColumnService;
 import com.boman.gen.api.RemoteGenTableService;
 import com.boman.jflow.api.RemoteJflowProcessService;
 import com.boman.system.api.RemoteMenuService;
-import com.boman.domain.SysMenu;
 import com.boman.system.api.model.LoginUser;
 import com.boman.web.core.domain.ActionType;
 import com.boman.web.core.domain.RowResult;
@@ -51,10 +50,10 @@ import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Predicate;
 
-import static com.boman.domain.constant.GenConstants.HTML_FILE_UPLOAD;
-import static com.boman.domain.constant.GenConstants.HTML_IMAGE_UPLOAD;
 import static com.boman.common.core.utils.obj.ObjectUtils.*;
 import static com.boman.domain.constant.FormDataConstant.*;
+import static com.boman.domain.constant.GenConstants.HTML_FILE_UPLOAD;
+import static com.boman.domain.constant.GenConstants.HTML_IMAGE_UPLOAD;
 import static com.boman.domain.constant.MaskConstant.*;
 import static com.boman.web.core.utils.AuthUtils.*;
 import static com.boman.web.core.utils.ColumnUtils.*;
@@ -215,7 +214,8 @@ public class TableServiceCmdService {
             }
 
             rowResult = deleteService.deleteById(dto.getTable(), pkName, id);
-            LOGGER.info("删除" + (rowResult.isOk() ? "成功" : "失败") + ", tableName: {}, id: {}, 操作人: {}", tableContext.getTableName(), id, getLoginUser().getUsername());
+            LOGGER.info("删除" + (rowResult.isOk() ? "成功" : "失败") + ", tableName: {}, id: {}, 操作人: {}"
+                    , tableContext.getTableName(), id, getCurrentUsername());
             result.add(rowResult);
         }
 
@@ -252,12 +252,12 @@ public class TableServiceCmdService {
 
             rowResult = deleteService.objectLogicDelete(new Long[]{id}, dto.getTable(), pkName, jsonObject);
             if (!rowResult.isOk()) {
-                LOGGER.info("逻辑删除失败, tableName: {}, id: {}, 操作人: {}", tableContext.getTableName(), id, getLoginUser().getUsername());
+                LOGGER.info("逻辑删除失败, tableName: {}, id: {}, 操作人: {}", tableContext.getTableName(), id, getCurrentUsername());
                 result.add(rowResult);
                 continue;
             }
 
-            LOGGER.info("逻辑删除成功, tableName: {}, id: {}, 操作人: {}", tableContext.getTableName(), id, getLoginUser().getUsername());
+            LOGGER.info("逻辑删除成功, tableName: {}, id: {}, 操作人: {}", tableContext.getTableName(), id, getCurrentUsername());
             Boolean stopProcess = dto.getStopProcess();
             if (BooleanUtils.isTrue(stopProcess)) {
                 ProcessDto processDto = new ProcessDto();
@@ -1139,6 +1139,12 @@ public class TableServiceCmdService {
         }
     }
 
+    /**
+     * 功能描述: 复杂对象保存的时候,从dto中拿到所有需要保存的数据,存到result中
+     *
+     * @param dto    前台传过来需要保存的数据
+     * @param result 所有需要保存的数据
+     */
     private void recursionAllChildrenFromDto(FormDataDto dto, List<FormDataDto> result) {
         List<FormDataDto> children = dto.getChildren();
         if (isEmpty(children)) {

+ 8 - 0
boman-web-core/src/main/java/com/boman/web/core/utils/AuthUtils.java

@@ -116,6 +116,14 @@ public class AuthUtils {
         return redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + SecurityUtils.getToken());
     }
 
+    /**
+     * 功能描述: 拿到当前登陆人username
+     */
+    public static String getCurrentUsername() {
+        LoginUser loginUser = getLoginUser();
+        return loginUser.getUsername();
+    }
+
     /**
      * 功能描述: 封装表的perms   eg: sys_user:A sys_user:M sys_user:D
      *

+ 1 - 0
boman-web-core/src/main/java/com/boman/web/core/utils/ColumnUtils.java

@@ -516,6 +516,7 @@ public class ColumnUtils {
                     continue;
                 }
                 String[] split = strValue.split(POINT);
+                // 默认关联的都是主表的id,fk.primaryTableName
                 String lastTableName = split[split.length - 1];
                 Long maxId = tableNameIdMap.get(lastTableName);
                 if (maxId == null) {