|
@@ -13,6 +13,7 @@ import com.boman.gen.controller.MyController;
|
|
|
import com.boman.gen.domain.GenTable;
|
|
|
import com.boman.gen.domain.GenTableColumn;
|
|
|
import com.boman.gen.domain.GenTableRelation;
|
|
|
+import com.boman.gen.service.IGenTableService;
|
|
|
import com.boman.system.domain.SysDictData;
|
|
|
import com.boman.system.service.*;
|
|
|
import com.boman.system.utils.IdUtils;
|
|
@@ -26,6 +27,7 @@ import org.springframework.web.client.RestTemplate;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.*;
|
|
@@ -56,6 +58,8 @@ public class TableServiceCmdService {
|
|
|
private RestTemplate restTemplate;
|
|
|
@Resource
|
|
|
private ISysDictTypeService dictTypeService;
|
|
|
+ @Resource
|
|
|
+ private IGenTableService genTableService;
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(TableServiceCmdService.class);
|
|
|
|
|
@@ -490,10 +494,25 @@ public class TableServiceCmdService {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
- // todo redis中未找到,要去查数据库,然后再塞进去
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 功能描述: 查询表从redis中
|
|
|
+ *
|
|
|
+ * @param redisKeyPrefix 前缀
|
|
|
+ * @param tableName 表名
|
|
|
+ * @return com.boman.gen.domain.GenTable
|
|
|
+ */
|
|
|
private GenTable getTableFromRedisByTableName(String redisKeyPrefix, String tableName) {
|
|
|
- GenTable genTable = redisService.getCacheObject(redisKeyPrefix + requireNonNull(tableName));
|
|
|
- return requireNonNull(genTable, "未找到表对应的信息");
|
|
|
+ String key = requireNonNull(redisKeyPrefix) + requireNonNull(tableName);
|
|
|
+ GenTable genTable = redisService.getCacheObject(key);
|
|
|
+ if (ObjectUtils.isEmpty(genTable)) {
|
|
|
+ genTable = genTableService.selectGenTableByName(tableName);
|
|
|
+ requireNonNull(genTable, "未找到表对应的信息");
|
|
|
+ // {@link com.boman.gen.controller.MyController.packTableAndInsertToRedis} 失效时间
|
|
|
+ redisService.setCacheObject(key, genTable, 12L, TimeUnit.DAYS);
|
|
|
+ }
|
|
|
+
|
|
|
+ return genTable;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -507,7 +526,7 @@ public class TableServiceCmdService {
|
|
|
* @return com.boman.common.core.web.domain.AjaxResult
|
|
|
*/
|
|
|
public AjaxResult getByTableName(BaseTableSaveDTO condition) {
|
|
|
-// requiredNonNull(condition.getTable(), "表名为空");
|
|
|
+ requireNonNull(condition.getTable(), "表名为空");
|
|
|
GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, condition.getTable());
|
|
|
List<GenTableColumn> columns = genTable.getColumns();
|
|
|
for (GenTableColumn column : columns) {
|