Unverified Commit 13ea40c7 authored by Zzm0809's avatar Zzm0809 Committed by GitHub

[Fix] fix savepoint interface 404 (#2928)

* fix-savepoint-interface-404 * Spotless Apply * delete unuse code * Spotless Apply --------- Co-authored-by: 's avatarZzm0809 <Zzm0809@users.noreply.github.com>
parent 89c14b30
...@@ -20,16 +20,21 @@ ...@@ -20,16 +20,21 @@
package org.dinky.controller; package org.dinky.controller;
import org.dinky.data.model.Savepoints; import org.dinky.data.model.Savepoints;
import org.dinky.data.result.ProTableResult;
import org.dinky.data.result.Result; import org.dinky.data.result.Result;
import org.dinky.service.SavepointsService; import org.dinky.service.SavepointsService;
import java.util.List; import java.util.List;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -50,10 +55,28 @@ public class SavePointsController { ...@@ -50,10 +55,28 @@ public class SavePointsController {
private final SavepointsService savepointsService; private final SavepointsService savepointsService;
/**
* query all savepoint list
*
* @param para {@link JsonNode} params
* @return {@link ProTableResult}<{@link Savepoints}>
*/
@PostMapping
@ApiOperation("Query SavePoint List")
@ApiImplicitParam(
name = "para",
value = "Query Params",
dataType = "JsonNode",
paramType = "body",
required = true,
dataTypeClass = JsonNode.class)
public ProTableResult<Savepoints> listSavePoints(@RequestBody JsonNode para) {
return savepointsService.selectForProTable(para);
}
/** /**
* query savepoint list by task id * query savepoint list by task id
* *
* @param taskID {@link Integer} * @param taskId {@link Integer}
* @return {@link Result}<{@link List}<{@link Savepoints}>> * @return {@link Result}<{@link List}<{@link Savepoints}>>
*/ */
@GetMapping("/listSavepointsByTaskId") @GetMapping("/listSavepointsByTaskId")
......
...@@ -35,6 +35,7 @@ import javax.servlet.http.Cookie; ...@@ -35,6 +35,7 @@ import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.jetbrains.annotations.NotNull;
import org.springframework.web.servlet.AsyncHandlerInterceptor; import org.springframework.web.servlet.AsyncHandlerInterceptor;
import cn.dev33.satoken.SaManager; import cn.dev33.satoken.SaManager;
...@@ -47,7 +48,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -47,7 +48,7 @@ import lombok.extern.slf4j.Slf4j;
public class TenantInterceptor implements AsyncHandlerInterceptor { public class TenantInterceptor implements AsyncHandlerInterceptor {
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) public boolean preHandle(HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler)
throws Exception { throws Exception {
boolean isPass = false; boolean isPass = false;
Cookie[] cookies = request.getCookies(); Cookie[] cookies = request.getCookies();
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
and a.task_id = #{param.taskId} and a.task_id = #{param.taskId}
</if> </if>
<if test='param.name!=null and param.name!=""'> <if test='param.name!=null and param.name!=""'>
and a.name like "%${param.name}%" and a.name like concat("%",#{param.name},"%" )
</if> </if>
<if test='param.createTime!=null and param.createTime!=""'> <if test='param.createTime!=null and param.createTime!=""'>
and a.create_time <![CDATA[>=]]> str_to_date( #{param.createTime},'%Y-%m-%d %H:%i:%s') and a.create_time <![CDATA[>=]]> str_to_date( #{param.createTime},'%Y-%m-%d %H:%i:%s')
......
...@@ -18,28 +18,27 @@ ...@@ -18,28 +18,27 @@
*/ */
import { getCurrentData } from '@/pages/DataStudio/function'; import { getCurrentData } from '@/pages/DataStudio/function';
import { StateType } from '@/pages/DataStudio/model'; import { StateType, TaskDataType } from '@/pages/DataStudio/model';
import { postAll } from '@/services/api'; import { postAll } from '@/services/api';
import { API_CONSTANTS } from '@/services/endpoints';
import { SavePoint } from '@/types/Studio/data'; import { SavePoint } from '@/types/Studio/data';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import { ActionType, ProDescriptions, ProTable } from '@ant-design/pro-components'; import { ActionType, ProColumns, ProDescriptions, ProTable } from '@ant-design/pro-components';
import { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'; import { ProDescriptionsItemProps } from '@ant-design/pro-descriptions';
import { Drawer } from 'antd'; import { Drawer } from 'antd';
import { useRef, useState } from 'react'; import { useRef, useState } from 'react';
import { connect } from 'umi'; import { connect } from 'umi';
const url = '/api/savepoints';
const SavePoints = (props: any) => { const SavePoints = (props: any) => {
const { const {
tabs: { panes, activeKey } tabs: { panes, activeKey }
} = props; } = props;
const current = getCurrentData(panes, activeKey); const current = getCurrentData(panes, activeKey) as TaskDataType;
const [row, setRow] = useState<SavePoint>(); const [row, setRow] = useState<SavePoint>();
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
actionRef.current?.reloadAndRest?.(); actionRef.current?.reloadAndRest?.();
const columns: ProDescriptionsItemProps<SavePoint>[] = [ const columns: ProDescriptionsItemProps<SavePoint>[] | ProColumns<SavePoint>[] = [
{ {
title: l('pages.task.savePointPath'), title: l('pages.task.savePointPath'),
dataIndex: 'path', dataIndex: 'path',
...@@ -52,7 +51,7 @@ const SavePoints = (props: any) => { ...@@ -52,7 +51,7 @@ const SavePoints = (props: any) => {
valueType: 'dateTime', valueType: 'dateTime',
hideInForm: true, hideInForm: true,
hideInSearch: true, hideInSearch: true,
render: (dom, entity) => { render: (dom: any, entity: SavePoint) => {
return <a onClick={() => setRow(entity)}>{dom}</a>; return <a onClick={() => setRow(entity)}>{dom}</a>;
} }
} }
...@@ -64,9 +63,10 @@ const SavePoints = (props: any) => { ...@@ -64,9 +63,10 @@ const SavePoints = (props: any) => {
actionRef={actionRef} actionRef={actionRef}
rowKey='id' rowKey='id'
request={(params, sorter, filter) => request={(params, sorter, filter) =>
postAll(url, { taskId: current.key, ...params, sorter, filter }) postAll(API_CONSTANTS.GET_SAVEPOINT_LIST, { params, sorter, filter })
} }
columns={columns} params={{ taskId: current.id }}
columns={columns as ProColumns<SavePoint>[]}
search={false} search={false}
/> />
<Drawer <Drawer
...@@ -87,7 +87,7 @@ const SavePoints = (props: any) => { ...@@ -87,7 +87,7 @@ const SavePoints = (props: any) => {
params={{ params={{
id: row?.name id: row?.name
}} }}
columns={columns} columns={columns as ProDescriptionsItemProps<SavePoint>[]}
/> />
)} )}
</Drawer> </Drawer>
......
...@@ -20,29 +20,19 @@ ...@@ -20,29 +20,19 @@
import EllipsisMiddle from '@/components/Typography/EllipsisMiddle'; import EllipsisMiddle from '@/components/Typography/EllipsisMiddle';
import { recoveryCheckPoint } from '@/pages/DevOps/JobDetail/CheckPointsTab/components/functions'; import { recoveryCheckPoint } from '@/pages/DevOps/JobDetail/CheckPointsTab/components/functions';
import { JobProps } from '@/pages/DevOps/JobDetail/data'; import { JobProps } from '@/pages/DevOps/JobDetail/data';
import { queryDataByParams } from '@/services/BusinessCrud'; import { postAll } from '@/services/api';
import { API_CONSTANTS } from '@/services/endpoints'; import { API_CONSTANTS } from '@/services/endpoints';
import { SavePoint } from '@/types/Studio/data'; import { SavePoint } from '@/types/Studio/data';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table'; import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
import { Button } from 'antd'; import { Button } from 'antd';
import { useEffect, useRef, useState } from 'react'; import { useRef } from 'react';
const SavepointTable = (props: JobProps) => { const SavepointTable = (props: JobProps) => {
const { jobDetail } = props; const { jobDetail } = props;
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
const [savepointData, setSavepointData] = useState<SavePoint[]>([]);
useEffect(() => {
queryDataByParams<Partial<SavePoint[]>>(API_CONSTANTS.GET_SAVEPOINT_LIST_BY_TASK_ID, {
taskId: jobDetail?.instance?.taskId
}).then((res) => {
setSavepointData((res as SavePoint[]) ?? []);
});
}, [jobDetail]);
const columns: ProColumns<SavePoint>[] = [ const columns: ProColumns<SavePoint>[] = [
{ {
title: l('devops.jobinfo.ck.id'), title: l('devops.jobinfo.ck.id'),
...@@ -96,7 +86,14 @@ const SavepointTable = (props: JobProps) => { ...@@ -96,7 +86,14 @@ const SavepointTable = (props: JobProps) => {
<ProTable<SavePoint> <ProTable<SavePoint>
columns={columns} columns={columns}
style={{ width: '100%', height: 'calc(100vh - 450px)' }} style={{ width: '100%', height: 'calc(100vh - 450px)' }}
dataSource={savepointData} request={(params, sorter, filter) =>
postAll(API_CONSTANTS.GET_SAVEPOINT_LIST, {
...params,
sorter,
filter
})
}
params={{ taskId: jobDetail?.instance?.taskId }}
actionRef={actionRef} actionRef={actionRef}
toolBarRender={false} toolBarRender={false}
rowKey='id' rowKey='id'
......
...@@ -249,6 +249,7 @@ export enum API_CONSTANTS { ...@@ -249,6 +249,7 @@ export enum API_CONSTANTS {
SAVEPOINT = '/api/task/savepoint', SAVEPOINT = '/api/task/savepoint',
RESTART_TASK_FROM_CHECKPOINT = '/api/task/selectSavePointRestartTask', RESTART_TASK_FROM_CHECKPOINT = '/api/task/selectSavePointRestartTask',
GET_SAVEPOINT_LIST_BY_TASK_ID = '/api/savepoints/listSavepointsByTaskId', GET_SAVEPOINT_LIST_BY_TASK_ID = '/api/savepoints/listSavepointsByTaskId',
GET_SAVEPOINT_LIST = '/api/savepoints',
ALERT_HISTORY_LIST = '/api/alertHistory/list', ALERT_HISTORY_LIST = '/api/alertHistory/list',
ALERT_HISTORY_DELETE = '/api/alertHistory/delete', ALERT_HISTORY_DELETE = '/api/alertHistory/delete',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment