|
@@ -11,14 +11,19 @@ import com.boman.common.core.utils.obj.ObjectUtils;
|
|
import com.boman.common.core.web.domain.AjaxResult;
|
|
import com.boman.common.core.web.domain.AjaxResult;
|
|
import com.boman.common.redis.RedisKey;
|
|
import com.boman.common.redis.RedisKey;
|
|
import com.boman.common.redis.service.RedisService;
|
|
import com.boman.common.redis.service.RedisService;
|
|
|
|
+import com.boman.domain.GenTable;
|
|
|
|
+import com.boman.domain.GenTableColumn;
|
|
import com.boman.domain.constant.*;
|
|
import com.boman.domain.constant.*;
|
|
import com.boman.gen.api.RemoteGenTableColumnService;
|
|
import com.boman.gen.api.RemoteGenTableColumnService;
|
|
import com.boman.gen.api.RemoteGenTableService;
|
|
import com.boman.gen.api.RemoteGenTableService;
|
|
-import com.boman.domain.GenTable;
|
|
|
|
-import com.boman.domain.GenTableColumn;
|
|
|
|
|
|
+import com.boman.system.api.RemoteDeptService;
|
|
import com.boman.system.api.RemoteDictDataService;
|
|
import com.boman.system.api.RemoteDictDataService;
|
|
-import com.boman.domain.SysFile;
|
|
|
|
-import com.boman.web.core.domain.*;
|
|
|
|
|
|
+import com.boman.system.api.RemoteRoleDataService;
|
|
|
|
+import com.boman.system.api.RemoteUserService;
|
|
|
|
+import com.boman.web.core.domain.ActionType;
|
|
|
|
+import com.boman.web.core.domain.FormDataDto;
|
|
|
|
+import com.boman.web.core.domain.RowResult;
|
|
|
|
+import com.boman.web.core.domain.TableContext;
|
|
import com.boman.web.core.service.delete.IBaseDeleteService;
|
|
import com.boman.web.core.service.delete.IBaseDeleteService;
|
|
import com.boman.web.core.service.save.IBaseSaveService;
|
|
import com.boman.web.core.service.save.IBaseSaveService;
|
|
import com.boman.web.core.service.select.IBaseSelectService;
|
|
import com.boman.web.core.service.select.IBaseSelectService;
|
|
@@ -36,7 +41,10 @@ import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.sql.Timestamp;
|
|
import java.sql.Timestamp;
|
|
-import java.util.*;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Collections;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.function.Predicate;
|
|
import java.util.function.Predicate;
|
|
|
|
|
|
@@ -44,6 +52,7 @@ import static com.boman.common.core.constant.GenConstants.HTML_FILE_UPLOAD;
|
|
import static com.boman.common.core.constant.GenConstants.HTML_IMAGE_UPLOAD;
|
|
import static com.boman.common.core.constant.GenConstants.HTML_IMAGE_UPLOAD;
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.*;
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.*;
|
|
import static com.boman.domain.constant.FormDataConstant.*;
|
|
import static com.boman.domain.constant.FormDataConstant.*;
|
|
|
|
+import static com.boman.web.core.utils.AuthUtils.*;
|
|
import static com.boman.web.core.utils.ColumnUtils.*;
|
|
import static com.boman.web.core.utils.ColumnUtils.*;
|
|
import static com.boman.web.core.utils.HandlerFormDataUtils.*;
|
|
import static com.boman.web.core.utils.HandlerFormDataUtils.*;
|
|
import static com.boman.web.core.utils.JSONObjectUtils.containsKeyIgnoreCase;
|
|
import static com.boman.web.core.utils.JSONObjectUtils.containsKeyIgnoreCase;
|
|
@@ -71,7 +80,7 @@ public class TableServiceCmdService {
|
|
@Resource
|
|
@Resource
|
|
private RestTemplate restTemplate;
|
|
private RestTemplate restTemplate;
|
|
@Resource
|
|
@Resource
|
|
- private RemoteDictDataService remoteDictDataService;
|
|
|
|
|
|
+ private TableContext tableContext;
|
|
@Resource
|
|
@Resource
|
|
private RemoteGenTableService remoteGenTableService;
|
|
private RemoteGenTableService remoteGenTableService;
|
|
@Resource
|
|
@Resource
|
|
@@ -82,7 +91,8 @@ public class TableServiceCmdService {
|
|
public final AjaxResult objectSave(FormDataDto dto) {
|
|
public final AjaxResult objectSave(FormDataDto dto) {
|
|
AjaxResult result = AjaxResult.success();
|
|
AjaxResult result = AjaxResult.success();
|
|
|
|
|
|
- TableContext context = TableContext.createContext(dto);
|
|
|
|
|
|
+ // 权限校验在此方法中
|
|
|
|
+ TableContext context = tableContext.createContext(dto);
|
|
// 拿到pkName和maxId
|
|
// 拿到pkName和maxId
|
|
String pkName = context.getPkName();
|
|
String pkName = context.getPkName();
|
|
JSONObject commitData = context.getCommitData();
|
|
JSONObject commitData = context.getCommitData();
|
|
@@ -155,25 +165,34 @@ public class TableServiceCmdService {
|
|
*/
|
|
*/
|
|
public AjaxResult objectDelete(FormDataDto dto) {
|
|
public AjaxResult objectDelete(FormDataDto dto) {
|
|
requireNonNull(dto.getTable(), "tableName = [" + dto.getTable() + "] 此表不存在");
|
|
requireNonNull(dto.getTable(), "tableName = [" + dto.getTable() + "] 此表不存在");
|
|
- Long[] idArr = CollectionUtils.listToArray(dto.getIdList());
|
|
|
|
- requireNonNull(idArr);
|
|
|
|
- // 拿到pkName
|
|
|
|
|
|
+
|
|
GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, dto.getTable());
|
|
GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, dto.getTable());
|
|
String pkName = IdUtils.getPkName(genTable.getColumns());
|
|
String pkName = IdUtils.getPkName(genTable.getColumns());
|
|
|
|
|
|
|
|
+ Long[] idArr = CollectionUtils.listToArray(dto.getIdList());
|
|
|
|
+ requireNonNull(idArr, "删除时,所传idList为空");
|
|
|
|
+
|
|
|
|
+ RowResult rowResult;
|
|
List<RowResult> result = Lists.newArrayListWithCapacity(idArr.length);
|
|
List<RowResult> result = Lists.newArrayListWithCapacity(idArr.length);
|
|
for (Long id : idArr) {
|
|
for (Long id : idArr) {
|
|
- RowResult rowResult = deleteService.deleteById(dto.getTable(), pkName, id);
|
|
|
|
|
|
+ // 校验权限
|
|
|
|
+ if (BooleanUtils.isTrue(checkAuthObjectDelete(genTable, id, pkName))) {
|
|
|
|
+ rowResult = deleteService.deleteById(dto.getTable(), pkName, id);
|
|
|
|
+ if (rowResult.isOk()) {
|
|
|
|
+ LOGGER.info("删除成功, tableName: {}, id: {}, 操作人: {}", tableContext.getTableName(), id, getLoginUser().getUsername());
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ LOGGER.info("删除失败, tableName: {}, id: {}, 操作人: {}", tableContext.getTableName(), id, getLoginUser().getUsername());
|
|
|
|
+ } else {
|
|
|
|
+ rowResult = RowResult.create(RowResult.FAIL, "无操作权限");
|
|
|
|
+ }
|
|
|
|
+
|
|
result.add(rowResult);
|
|
result.add(rowResult);
|
|
- LOGGER.info(rowResult.getMessage() + ", id: {}", id);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- // RowResult rowResult = deleteService.objectDelete(idArr, dto.getTable(), requireNonNull(pkName, "主键名称为空"));
|
|
|
|
-
|
|
|
|
return AjaxResult.success(result);
|
|
return AjaxResult.success(result);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 功能描述: 通用删除接口 (真的删除)
|
|
* 功能描述: 通用删除接口 (真的删除)
|
|
*
|
|
*
|
|
@@ -192,10 +211,22 @@ public class TableServiceCmdService {
|
|
List<RowResult> result = Lists.newArrayListWithCapacity(idArr.length);
|
|
List<RowResult> result = Lists.newArrayListWithCapacity(idArr.length);
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put(dto.getLogicDelName(), dto.getLogicDelValue());
|
|
jsonObject.put(dto.getLogicDelName(), dto.getLogicDelValue());
|
|
|
|
+
|
|
|
|
+ RowResult rowResult;
|
|
for (Long id : idArr) {
|
|
for (Long id : idArr) {
|
|
- RowResult rowResult = deleteService.objectLogicDelete(new Long[]{id}, dto.getTable(), pkName, jsonObject);
|
|
|
|
|
|
+ // 校验权限
|
|
|
|
+ if (BooleanUtils.isTrue(checkAuthObjectDelete(genTable, id, pkName))) {
|
|
|
|
+ rowResult = deleteService.objectLogicDelete(new Long[]{id}, dto.getTable(), pkName, jsonObject);
|
|
|
|
+ if (rowResult.isOk()) {
|
|
|
|
+ LOGGER.info("逻辑删除成功, tableName: {}, id: {}, 操作人: {}", tableContext.getTableName(), id, getLoginUser().getUsername());
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ LOGGER.info("逻辑删除失败, tableName: {}, id: {}, 操作人: {}", tableContext.getTableName(), id, getLoginUser().getUsername());
|
|
|
|
+ } else {
|
|
|
|
+ rowResult = RowResult.create(RowResult.FAIL, "无操作权限");
|
|
|
|
+ }
|
|
|
|
+
|
|
result.add(rowResult);
|
|
result.add(rowResult);
|
|
- LOGGER.info(rowResult.getMessage() + ", id: {}", id);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
return AjaxResult.success(result);
|
|
return AjaxResult.success(result);
|
|
@@ -216,10 +247,12 @@ public class TableServiceCmdService {
|
|
|
|
|
|
// 查询条件
|
|
// 查询条件
|
|
JSONObject condition = ifNullSetEmpty(fixedData.getJSONObject(CONDITION));
|
|
JSONObject condition = ifNullSetEmpty(fixedData.getJSONObject(CONDITION));
|
|
|
|
+ // 权限
|
|
|
|
+ checkAuthQueryList(genTable, condition);
|
|
// 检查列
|
|
// 检查列
|
|
checkColumn(condition, columns);
|
|
checkColumn(condition, columns);
|
|
// 封装好以后的查询条件
|
|
// 封装好以后的查询条件
|
|
- JSONObject packCondition = ifNullSetEmpty(packColCondition(columns, condition));
|
|
|
|
|
|
+ JSONObject packCondition = ifNullSetEmpty(selectService.packColCondition(columns, condition));
|
|
JSONArray showData = fixedData.getJSONArray(SHOW_DATA);
|
|
JSONArray showData = fixedData.getJSONArray(SHOW_DATA);
|
|
// 检查列
|
|
// 检查列
|
|
checkColumn(showData, genTable.getColumns());
|
|
checkColumn(showData, genTable.getColumns());
|
|
@@ -361,7 +394,7 @@ public class TableServiceCmdService {
|
|
// genTable.getMenuRole() 暂时数据库没有数据,
|
|
// genTable.getMenuRole() 暂时数据库没有数据,
|
|
jsonObject.put(FormDataConstant.BUTTON_LIST, Strings.nullToEmpty(genTable.getMenuRole()));
|
|
jsonObject.put(FormDataConstant.BUTTON_LIST, Strings.nullToEmpty(genTable.getMenuRole()));
|
|
|
|
|
|
- jsonObject.put(ViewConst.VIEW_TYPE, Strings.nullToEmpty(genTable.getTplCategory()));
|
|
|
|
|
|
+ jsonObject.put(ViewTypeConst.VIEW_TYPE, Strings.nullToEmpty(genTable.getTplCategory()));
|
|
jsonObject.put(RULES, packRequireColumn(columns));
|
|
jsonObject.put(RULES, packRequireColumn(columns));
|
|
return AjaxResult.success(jsonObject);
|
|
return AjaxResult.success(jsonObject);
|
|
}
|
|
}
|