提交 77421f1c authored 作者: songchuancai's avatar songchuancai

优化代码

上级 b4c406aa
...@@ -60,6 +60,7 @@ public class DataServiceManagementController extends BaseController { ...@@ -60,6 +60,7 @@ public class DataServiceManagementController extends BaseController {
@ApiOperation(value = "数据服务管理-数据服务列表") @ApiOperation(value = "数据服务管理-数据服务列表")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "environment", value = "环境", required = true), @ApiImplicitParam(name = "environment", value = "环境", required = true),
@ApiImplicitParam(name = "publishSystemId", value = "发布系统ID", required = true),
@ApiImplicitParam(name = "status", value = "类型(1:已发布/0:草稿)", required = true), @ApiImplicitParam(name = "status", value = "类型(1:已发布/0:草稿)", required = true),
@ApiImplicitParam(name = "pageSize", value = "指定返回结果中每页显示的记录数量", defaultValue = "10", required = false), @ApiImplicitParam(name = "pageSize", value = "指定返回结果中每页显示的记录数量", defaultValue = "10", required = false),
@ApiImplicitParam(name = "page", value = "指定显示返回结果中的第几页", defaultValue = "1", required = false), @ApiImplicitParam(name = "page", value = "指定显示返回结果中的第几页", defaultValue = "1", required = false),
...@@ -68,15 +69,16 @@ public class DataServiceManagementController extends BaseController { ...@@ -68,15 +69,16 @@ public class DataServiceManagementController extends BaseController {
}) })
@GetMapping("/{environment}") @GetMapping("/{environment}")
public Result<PageData<DataApiModelItemVo>> getPublishDataApiList(@PathVariable String environment, public Result<PageData<DataApiModelItemVo>> getPublishDataApiList(@PathVariable String environment,
@RequestParam(value = "status") Integer status, @RequestParam(value = "status", defaultValue = "1") Integer status,
@RequestParam(value = "publishSystemId") Long publishSystemId,
@RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize, @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
@RequestParam(value = "page", required = false, defaultValue = "1") Integer page, @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
@RequestParam(value = "sortProperty", required = false) String sortProperty, @RequestParam(value = "sortProperty", required = false, defaultValue = "id") String sortProperty,
@RequestParam(value = "sortOrder", required = false) String sortOrder) { @RequestParam(value = "sortOrder", required = false, defaultValue = "ASC") String sortOrder) {
PageLink pageLink = createPageLink(pageSize, page, "", sortProperty, sortOrder); PageLink pageLink = createPageLink(pageSize, page, "", sortProperty, sortOrder);
return dataApiServiceManagementService.queryDataApiList(environment, status, pageLink); return dataApiServiceManagementService.queryDataApiList(environment, status, publishSystemId, pageLink);
} }
@ApiOperation(value = "数据服务管理-服务详情") @ApiOperation(value = "数据服务管理-服务详情")
...@@ -100,7 +102,7 @@ public class DataServiceManagementController extends BaseController { ...@@ -100,7 +102,7 @@ public class DataServiceManagementController extends BaseController {
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "environment", value = "环境", required = true), @ApiImplicitParam(name = "environment", value = "环境", required = true),
@ApiImplicitParam(name = "dataModelId", value = "数据服务ID", required = true), @ApiImplicitParam(name = "dataModelId", value = "数据服务ID", required = true),
@ApiImplicitParam(name = "type", value = "调试类型(发布/订阅)", required = true, allowableValues = "PUBLISH/SUBSCRIBE") @ApiImplicitParam(name = "type", value = "调试类型(发布/订阅)", required = true, allowableValues = "PUBLISH,SUBSCRIBE")
}) })
@GetMapping("/debugService/{environment}/{dataModelId}/{type}") @GetMapping("/debugService/{environment}/{dataModelId}/{type}")
public Result<JSONObject> debugService(@PathVariable String environment, public Result<JSONObject> debugService(@PathVariable String environment,
......
...@@ -34,10 +34,6 @@ public class DataApiModel extends BaseEntity{ ...@@ -34,10 +34,6 @@ public class DataApiModel extends BaseEntity{
// 数据源ID // 数据源ID
private Long dataSourceId; private Long dataSourceId;
// 数据表和对应列集合 Map<数据表ID,列ID列表> 提供订阅时使用
// @Type( type = "json" )
// private List<TableWithColumnRelationConfig> dataTableIdWithColumnIds;
// 数据表关系配置 Map<数据表ID,列名ID> // 数据表关系配置 Map<数据表ID,列名ID>
@Type( type = "json" ) @Type( type = "json" )
private List<TableJoinRelationConfig> tableJoinRelationConfig; private List<TableJoinRelationConfig> tableJoinRelationConfig;
......
...@@ -11,6 +11,7 @@ import org.springframework.data.jpa.repository.Query; ...@@ -11,6 +11,7 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* @author : scc * @author : scc
...@@ -29,4 +30,7 @@ public interface DataApiDataSourceRepository extends JpaRepository<DataApiDataSo ...@@ -29,4 +30,7 @@ public interface DataApiDataSourceRepository extends JpaRepository<DataApiDataSo
"FROM data_api_datasource ds " + "FROM data_api_datasource ds " +
"WHERE ds.deleted = false", nativeQuery = true) "WHERE ds.deleted = false", nativeQuery = true)
List<String> findAllSourceType(); List<String> findAllSourceType();
Optional<DataApiDataSource> findByIdAndEnvironmentAndDeletedIsFalse(Long id, Integer environment);
} }
...@@ -7,6 +7,7 @@ import org.springframework.data.domain.Pageable; ...@@ -7,6 +7,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Optional; import java.util.Optional;
...@@ -27,5 +28,5 @@ public interface DataApiModelRepository extends JpaRepository<DataApiModel,Long> ...@@ -27,5 +28,5 @@ public interface DataApiModelRepository extends JpaRepository<DataApiModel,Long>
boolean existsByNameAndSystemEnv(String name, SystemEnv env); boolean existsByNameAndSystemEnv(String name, SystemEnv env);
@Query(value = "select name from system_info where id = :systemId", nativeQuery = true) @Query(value = "select name from system_info where id = :systemId", nativeQuery = true)
String findSystemNameBySystemId(Long systemId); String findSystemNameBySystemId(@Param("systemId") Long systemId);
} }
...@@ -25,7 +25,7 @@ public interface DataApiServiceManagementService extends BaseService { ...@@ -25,7 +25,7 @@ public interface DataApiServiceManagementService extends BaseService {
Result<JSONObject> debugDataApiService(String environment, Long dataModelId, ModelConfigType type); Result<JSONObject> debugDataApiService(String environment, Long dataModelId, ModelConfigType type);
Result<PageData<DataApiModelItemVo>> queryDataApiList(String environment, Integer status, PageLink pageLink); Result<PageData<DataApiModelItemVo>> queryDataApiList(String environment, Integer status, Long publishSystemId, PageLink pageLink);
Result<DataApiModelDetailVo> queryApiModelDetail(String environment, Long modelId); Result<DataApiModelDetailVo> queryApiModelDetail(String environment, Long modelId);
} }
...@@ -459,7 +459,7 @@ public class DataApiServiceManagementServiceImpl implements DataApiServiceManage ...@@ -459,7 +459,7 @@ public class DataApiServiceManagementServiceImpl implements DataApiServiceManage
public Result<JSONObject> debugDataApiService(String environment, Long dataModelId, ModelConfigType type){ public Result<JSONObject> debugDataApiService(String environment, Long dataModelId, ModelConfigType type){
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
Optional<DataApiModel> dataApiModelOptional = dataApiModelRepository.findById(dataModelId); Optional<DataApiModel> dataApiModelOptional = dataApiModelRepository.findByIdAndSystemEnv(dataModelId, SystemEnv.valueOf(environment));
if (!dataApiModelOptional.isPresent()) { if (!dataApiModelOptional.isPresent()) {
return failure("调试数据api服务失败--数据api服务不存在", null); return failure("调试数据api服务失败--数据api服务不存在", null);
} }
...@@ -517,11 +517,12 @@ public class DataApiServiceManagementServiceImpl implements DataApiServiceManage ...@@ -517,11 +517,12 @@ public class DataApiServiceManagementServiceImpl implements DataApiServiceManage
} }
@Override @Override
public Result<PageData<DataApiModelItemVo>> queryDataApiList(String environment, Integer status, PageLink pageLink) { public Result<PageData<DataApiModelItemVo>> queryDataApiList(String environment, Integer status, Long publishSystemId, PageLink pageLink) {
Specification<DataApiModel> spec = (root, query, builder) -> { Specification<DataApiModel> spec = (root, query, builder) -> {
List<Predicate> andList = new LinkedList<>(); List<Predicate> andList = new LinkedList<>();
andList.add(builder.equal((root.get("status").as(Integer.class)), status)); andList.add(builder.equal((root.get("status").as(Integer.class)), status));
andList.add(builder.equal((root.get("publishSystemId").as(Long.class)), publishSystemId));
andList.add(builder.equal((root.get("deleted").as(Boolean.class)), Boolean.FALSE)); andList.add(builder.equal((root.get("deleted").as(Boolean.class)), Boolean.FALSE));
andList.add(builder.equal((root.get("systemEnv").as(SystemEnv.class)), SystemEnv.valueOf(environment.toUpperCase()))); andList.add(builder.equal((root.get("systemEnv").as(SystemEnv.class)), SystemEnv.valueOf(environment.toUpperCase())));
......
...@@ -4,7 +4,6 @@ import com.hisense.dataservice.bo.ColumnDataRangeFilter; ...@@ -4,7 +4,6 @@ import com.hisense.dataservice.bo.ColumnDataRangeFilter;
import com.hisense.dataservice.bo.LineDataRangeFilter; import com.hisense.dataservice.bo.LineDataRangeFilter;
import com.hisense.dataservice.bo.TableJoinRelationConfig; import com.hisense.dataservice.bo.TableJoinRelationConfig;
import com.hisense.dataservice.enums.NetworkEnv; import com.hisense.dataservice.enums.NetworkEnv;
import com.hisense.dataservice.enums.SystemEnv;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
......
...@@ -32,6 +32,6 @@ public class DataApiModelItemVo { ...@@ -32,6 +32,6 @@ public class DataApiModelItemVo {
private String creator; private String creator;
@ApiModelProperty(name = "发布系统名") @ApiModelProperty(name = "发布系统名")
private String systemName; private String publishSystemName;
} }
...@@ -480,7 +480,7 @@ public class DataApiCommonServiceTest { ...@@ -480,7 +480,7 @@ public class DataApiCommonServiceTest {
try { try {
dataApiModelService.unsubscribeDataApi(432L); dataApiModelService.unsubscribeDataApi(432L);
Boolean result = dataApiModelService.subscribeDataApi(dataApiModelDto); // Boolean result = dataApiModelService.subscribeDataApi(dataApiModelDto);
} catch (Exception e) { } catch (Exception e) {
log.error("创建或更新数据服务api失败:" , e); log.error("创建或更新数据服务api失败:" , e);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论