|
@@ -14,9 +14,12 @@ import com.boman.common.redis.service.RedisService;
|
|
import com.boman.domain.GenTable;
|
|
import com.boman.domain.GenTable;
|
|
import com.boman.domain.GenTableColumn;
|
|
import com.boman.domain.GenTableColumn;
|
|
import com.boman.domain.constant.*;
|
|
import com.boman.domain.constant.*;
|
|
|
|
+import com.boman.domain.dto.RoleMenuDto;
|
|
import com.boman.domain.exception.NoSuchFunctionException;
|
|
import com.boman.domain.exception.NoSuchFunctionException;
|
|
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.system.api.RemoteMenuService;
|
|
|
|
+import com.boman.system.api.domain.SysMenu;
|
|
import com.boman.web.core.domain.ActionType;
|
|
import com.boman.web.core.domain.ActionType;
|
|
import com.boman.web.core.domain.FormDataDto;
|
|
import com.boman.web.core.domain.FormDataDto;
|
|
import com.boman.web.core.domain.RowResult;
|
|
import com.boman.web.core.domain.RowResult;
|
|
@@ -82,6 +85,8 @@ public class TableServiceCmdService {
|
|
private RemoteGenTableService remoteGenTableService;
|
|
private RemoteGenTableService remoteGenTableService;
|
|
@Resource
|
|
@Resource
|
|
private RemoteGenTableColumnService remoteGenTableColumnService;
|
|
private RemoteGenTableColumnService remoteGenTableColumnService;
|
|
|
|
+ @Resource
|
|
|
|
+ private RemoteMenuService remoteMenuService;
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(TableServiceCmdService.class);
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(TableServiceCmdService.class);
|
|
|
|
|
|
@@ -199,7 +204,7 @@ public class TableServiceCmdService {
|
|
public AjaxResult objectLogicDelete(FormDataDto dto) {
|
|
public AjaxResult objectLogicDelete(FormDataDto dto) {
|
|
requireNonNull(dto.getTable(), "tableName = [" + dto.getTable() + "] 此表不存在");
|
|
requireNonNull(dto.getTable(), "tableName = [" + dto.getTable() + "] 此表不存在");
|
|
Long[] idArr = CollectionUtils.listToArray(dto.getIdList());
|
|
Long[] idArr = CollectionUtils.listToArray(dto.getIdList());
|
|
- requireNonNull(idArr);
|
|
|
|
|
|
+ requireNonNull(idArr, "objectLogicDelete idArr is empty");
|
|
|
|
|
|
// 拿到pkName
|
|
// 拿到pkName
|
|
GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, dto.getTable());
|
|
GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, dto.getTable());
|
|
@@ -380,12 +385,7 @@ public class TableServiceCmdService {
|
|
if (GenTableColumn.IS_QUERY.equalsIgnoreCase(column.getIsQuery())) {
|
|
if (GenTableColumn.IS_QUERY.equalsIgnoreCase(column.getIsQuery())) {
|
|
String dictType = column.getDictType();
|
|
String dictType = column.getDictType();
|
|
if (ObjectUtils.isNotEmpty(dictType)) {
|
|
if (ObjectUtils.isNotEmpty(dictType)) {
|
|
- try {
|
|
|
|
- column.setSysDictData(listSysDictDataByType(dictType));
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- System.out.println("sq_dictType = " + dictType);
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
|
|
+ column.setSysDictData(listSysDictDataByType(dictType));
|
|
}
|
|
}
|
|
|
|
|
|
queryList.add(column);
|
|
queryList.add(column);
|
|
@@ -393,14 +393,37 @@ public class TableServiceCmdService {
|
|
}
|
|
}
|
|
|
|
|
|
jsonObject.put(FormDataConstant.QUERY_LIST, queryList);
|
|
jsonObject.put(FormDataConstant.QUERY_LIST, queryList);
|
|
- // genTable.getMenuRole() 暂时数据库没有数据,
|
|
|
|
- jsonObject.put(FormDataConstant.BUTTON_LIST, Strings.nullToEmpty(genTable.getMenuRole()));
|
|
|
|
|
|
|
|
|
|
+ List<String> btns = buildBtnList(genTable.getTableName());
|
|
|
|
+ jsonObject.put(FormDataConstant.BUTTON_LIST, Strings.nullToEmpty(CollectionUtils.listToString(btns)));
|
|
jsonObject.put(ViewTypeConst.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);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 功能描述: 查找当前登陆人操作的表对应的btn
|
|
|
|
+ *
|
|
|
|
+ * @param tableName tableName
|
|
|
|
+ * @return java.util.List<java.lang.String>
|
|
|
|
+ */
|
|
|
|
+ private List<String> buildBtnList(String tableName) {
|
|
|
|
+ List<SysMenu> menus = remoteMenuService.listBtnByUserId(SecurityUtils.getUserId());
|
|
|
|
+ if (isEmpty(menus)) {
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<String> permses = map(menus, SysMenu::getPerms);
|
|
|
|
+ ArrayList<String> btns = Lists.newArrayListWithCapacity(permses.size());
|
|
|
|
+ for (String perms : permses) {
|
|
|
|
+ if (perms.contains(tableName)) {
|
|
|
|
+ btns.add(RoleMenuDto.getBtnFromPerms(perms));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return btns;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 功能描述: 获取表单查询字段
|
|
* 功能描述: 获取表单查询字段
|
|
* 注意: 都是从redis中拿的,如果数据库和redis不一致,则需刷新一下redis
|
|
* 注意: 都是从redis中拿的,如果数据库和redis不一致,则需刷新一下redis
|
|
@@ -494,7 +517,7 @@ public class TableServiceCmdService {
|
|
List<Long> idList = map(commitData, jsonObject -> jsonObject.getLong(FormDataConstant.ID));
|
|
List<Long> idList = map(commitData, jsonObject -> jsonObject.getLong(FormDataConstant.ID));
|
|
|
|
|
|
List<JSONObject> beforeList = selectService.selectByIdList(tableName, pkName, idList, Lists.newArrayList(pkName, STATUS));
|
|
List<JSONObject> beforeList = selectService.selectByIdList(tableName, pkName, idList, Lists.newArrayList(pkName, STATUS));
|
|
- requireNonNull(beforeList);
|
|
|
|
|
|
+ requireNonNull(beforeList, "beforeList is empty");
|
|
|
|
|
|
for (JSONObject commitDatum : commitData) {
|
|
for (JSONObject commitDatum : commitData) {
|
|
String dbStatus = getStatusFromFormData(commitDatum, beforeList);
|
|
String dbStatus = getStatusFromFormData(commitDatum, beforeList);
|
|
@@ -558,8 +581,8 @@ public class TableServiceCmdService {
|
|
* @return 结果
|
|
* @return 结果
|
|
*/
|
|
*/
|
|
public List<JSONObject> isCustomized(String tableName, List<JSONObject> result, String action) {
|
|
public List<JSONObject> isCustomized(String tableName, List<JSONObject> result, String action) {
|
|
- requireNonNull(tableName);
|
|
|
|
- requireNonNull(action);
|
|
|
|
|
|
+ requireNonNull(tableName, "tableName is empty");
|
|
|
|
+ requireNonNull(action, "action is empty");
|
|
if (result != null && result.size() > 0) {
|
|
if (result != null && result.size() > 0) {
|
|
//获取到服务名称
|
|
//获取到服务名称
|
|
String triggerName = getTriggerName(tableName, action);
|
|
String triggerName = getTriggerName(tableName, action);
|
|
@@ -580,7 +603,7 @@ public class TableServiceCmdService {
|
|
*/
|
|
*/
|
|
private String getTriggerName(String tableName, String action) {
|
|
private String getTriggerName(String tableName, String action) {
|
|
GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, tableName);
|
|
GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, tableName);
|
|
- requireNonNull(genTable);
|
|
|
|
|
|
+ requireNonNull(genTable, "genTable empty");
|
|
if (action.equals(TriggerActionConstant.ACTION_CREATE)) {
|
|
if (action.equals(TriggerActionConstant.ACTION_CREATE)) {
|
|
return genTable.getTriggerCreate();
|
|
return genTable.getTriggerCreate();
|
|
} else if (action.equals(TriggerActionConstant.ACTION_RETRIEVE)) {
|
|
} else if (action.equals(TriggerActionConstant.ACTION_RETRIEVE)) {
|
|
@@ -604,7 +627,7 @@ public class TableServiceCmdService {
|
|
*/
|
|
*/
|
|
public GenTable getTableFromRedisByTableName(String redisKeyPrefix, String tableName) {
|
|
public GenTable getTableFromRedisByTableName(String redisKeyPrefix, String tableName) {
|
|
tableName = tableName.trim().toLowerCase();
|
|
tableName = tableName.trim().toLowerCase();
|
|
- String key = requireNonNull(redisKeyPrefix) + requireNonNull(tableName);
|
|
|
|
|
|
+ String key = requireNonNull(redisKeyPrefix, "redisKeyPrefix is empty") + requireNonNull(tableName, "tableName is empty");
|
|
GenTable genTable = redisService.getCacheObject(key);
|
|
GenTable genTable = redisService.getCacheObject(key);
|
|
if (ObjectUtils.isEmpty(genTable)) {
|
|
if (ObjectUtils.isEmpty(genTable)) {
|
|
genTable = remoteGenTableService.getByTableName(tableName);
|
|
genTable = remoteGenTableService.getByTableName(tableName);
|