mirror of
https://github.com/dataease/dataease.git
synced 2025-02-25 03:52:59 +08:00
Merge pull request #7829 from dataease/pr@dev-v2@fixds
refactor(数据源): 拆分接口
This commit is contained in:
commit
b64c5d04e0
@ -311,6 +311,8 @@ public class DatasourceServer implements DatasourceApi {
|
|||||||
return dataSourceDTO;
|
return dataSourceDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
public DatasourceDTO update(DatasourceDTO dataSourceDTO) throws DEException {
|
public DatasourceDTO update(DatasourceDTO dataSourceDTO) throws DEException {
|
||||||
Long pk = null;
|
Long pk = null;
|
||||||
if (ObjectUtils.isEmpty(pk = dataSourceDTO.getId())) {
|
if (ObjectUtils.isEmpty(pk = dataSourceDTO.getId())) {
|
||||||
|
@ -91,6 +91,12 @@ export const save = async (data = {}): Promise<Dataset> => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const update = async (data = {}): Promise<Dataset> => {
|
||||||
|
return request.post({ url: '/datasource/update', data }).then(res => {
|
||||||
|
return res?.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const move = async (data = {}): Promise<Dataset> => {
|
export const move = async (data = {}): Promise<Dataset> => {
|
||||||
return request.post({ url: '/datasource/move', data }).then(res => {
|
return request.post({ url: '/datasource/move', data }).then(res => {
|
||||||
return res?.data
|
return res?.data
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, reactive, computed, watch, nextTick } from 'vue'
|
import { ref, reactive, computed, watch, nextTick } from 'vue'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { checkRepeat, listDatasources, save } from '@/api/datasource'
|
import { checkRepeat, listDatasources, save, update } from '@/api/datasource'
|
||||||
import { ElMessage, ElMessageBox, ElMessageBoxOptions } from 'element-plus-secondary'
|
import { ElMessage, ElMessageBox, ElMessageBoxOptions } from 'element-plus-secondary'
|
||||||
import type { DatasetOrFolder } from '@/api/dataset'
|
import type { DatasetOrFolder } from '@/api/dataset'
|
||||||
import nothingTree from '@/assets/img/nothing-tree.png'
|
import nothingTree from '@/assets/img/nothing-tree.png'
|
||||||
@ -274,10 +274,11 @@ const saveDataset = () => {
|
|||||||
}
|
}
|
||||||
request.apiConfiguration = ''
|
request.apiConfiguration = ''
|
||||||
checkRepeat(request).then(res => {
|
checkRepeat(request).then(res => {
|
||||||
|
let method = request.id === '' ? save : update
|
||||||
if (res) {
|
if (res) {
|
||||||
ElMessageBox.confirm(t('datasource.has_same_ds'), options as ElMessageBoxOptions).then(
|
ElMessageBox.confirm(t('datasource.has_same_ds'), options as ElMessageBoxOptions).then(
|
||||||
() => {
|
() => {
|
||||||
save({ ...request, name: datasetForm.name, pid: params.pid })
|
method({ ...request, name: datasetForm.name, pid: params.pid })
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res !== undefined) {
|
if (res !== undefined) {
|
||||||
wsCache.set('ds-new-success', true)
|
wsCache.set('ds-new-success', true)
|
||||||
@ -292,7 +293,7 @@ const saveDataset = () => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
save({ ...request, name: datasetForm.name, pid: params.pid })
|
method({ ...request, name: datasetForm.name, pid: params.pid })
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res !== undefined) {
|
if (res !== undefined) {
|
||||||
wsCache.set('ds-new-success', true)
|
wsCache.set('ds-new-success', true)
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
nextTick
|
nextTick
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus-secondary'
|
import { ElMessage, ElMessageBox } from 'element-plus-secondary'
|
||||||
import { save } from '@/api/datasource'
|
import { save, update } from '@/api/datasource'
|
||||||
import type { Action } from 'element-plus-secondary'
|
import type { Action } from 'element-plus-secondary'
|
||||||
import { Base64 } from 'js-base64'
|
import { Base64 } from 'js-base64'
|
||||||
import ExcelInfo from '../ExcelInfo.vue'
|
import ExcelInfo from '../ExcelInfo.vue'
|
||||||
@ -255,9 +255,12 @@ const saveExcelData = (sheetFileMd5, table, params, successCb, finallyCb) => {
|
|||||||
table.sheets[i].jsonArray = []
|
table.sheets[i].jsonArray = []
|
||||||
}
|
}
|
||||||
table.configuration = Base64.encode(JSON.stringify(table.sheets))
|
table.configuration = Base64.encode(JSON.stringify(table.sheets))
|
||||||
|
let method = save
|
||||||
if (!table.id || table.id === '0') {
|
if (!table.id || table.id === '0') {
|
||||||
delete table.id
|
delete table.id
|
||||||
table.pid = params.pid
|
table.pid = params.pid
|
||||||
|
} else {
|
||||||
|
method = update
|
||||||
}
|
}
|
||||||
if (new Set(sheetFileMd5).size !== sheetFileMd5.length && !props.param.id) {
|
if (new Set(sheetFileMd5).size !== sheetFileMd5.length && !props.param.id) {
|
||||||
ElMessageBox.confirm(t('dataset.merge_title'), {
|
ElMessageBox.confirm(t('dataset.merge_title'), {
|
||||||
@ -272,7 +275,7 @@ const saveExcelData = (sheetFileMd5, table, params, successCb, finallyCb) => {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
table.mergeSheet = action === 'confirm'
|
table.mergeSheet = action === 'confirm'
|
||||||
if (action === 'confirm') {
|
if (action === 'confirm') {
|
||||||
save(table)
|
method(table)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
emitter.emit('showFinishPage', res)
|
emitter.emit('showFinishPage', res)
|
||||||
successCb?.()
|
successCb?.()
|
||||||
@ -288,7 +291,7 @@ const saveExcelData = (sheetFileMd5, table, params, successCb, finallyCb) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action === 'cancel') {
|
if (action === 'cancel') {
|
||||||
save(table)
|
method(table)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
emitter.emit('showFinishPage', res)
|
emitter.emit('showFinishPage', res)
|
||||||
successCb?.()
|
successCb?.()
|
||||||
@ -307,7 +310,7 @@ const saveExcelData = (sheetFileMd5, table, params, successCb, finallyCb) => {
|
|||||||
} else {
|
} else {
|
||||||
if (loading.value) return
|
if (loading.value) return
|
||||||
loading.value = true
|
loading.value = true
|
||||||
save(table)
|
method(table)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
emitter.emit('showFinishPage', res)
|
emitter.emit('showFinishPage', res)
|
||||||
successCb?.()
|
successCb?.()
|
||||||
|
@ -8,7 +8,7 @@ import DsTypeList from './DsTypeList.vue'
|
|||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import EditorDetail from './EditorDetail.vue'
|
import EditorDetail from './EditorDetail.vue'
|
||||||
import ExcelDetail from './ExcelDetail.vue'
|
import ExcelDetail from './ExcelDetail.vue'
|
||||||
import { save, validate, latestUse, isShowFinishPage, checkRepeat } from '@/api/datasource'
|
import { save, update, validate, latestUse, isShowFinishPage, checkRepeat } from '@/api/datasource'
|
||||||
import { Base64 } from 'js-base64'
|
import { Base64 } from 'js-base64'
|
||||||
import type { Param } from './ExcelDetail.vue'
|
import type { Param } from './ExcelDetail.vue'
|
||||||
import { dsTypes, typeList, nameMap } from './option'
|
import { dsTypes, typeList, nameMap } from './option'
|
||||||
@ -403,6 +403,7 @@ const saveDS = () => {
|
|||||||
tip: ''
|
tip: ''
|
||||||
}
|
}
|
||||||
checkRepeat(request).then(res => {
|
checkRepeat(request).then(res => {
|
||||||
|
let method = request.id === '' ? save : update
|
||||||
if (res) {
|
if (res) {
|
||||||
ElMessageBox.confirm(t('datasource.has_same_ds'), options as ElMessageBoxOptions).then(
|
ElMessageBox.confirm(t('datasource.has_same_ds'), options as ElMessageBoxOptions).then(
|
||||||
() => {
|
() => {
|
||||||
@ -410,7 +411,7 @@ const saveDS = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
dsLoading.value = true
|
dsLoading.value = true
|
||||||
save(request)
|
method(request)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res !== undefined) {
|
if (res !== undefined) {
|
||||||
handleShowFinishPage({ id: res.id, name: res.name })
|
handleShowFinishPage({ id: res.id, name: res.name })
|
||||||
@ -427,7 +428,7 @@ const saveDS = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
dsLoading.value = true
|
dsLoading.value = true
|
||||||
save(request)
|
method(request)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res !== undefined) {
|
if (res !== undefined) {
|
||||||
handleShowFinishPage({ id: res.id, name: res.name })
|
handleShowFinishPage({ id: res.id, name: res.name })
|
||||||
|
@ -34,6 +34,9 @@ public interface DatasourceApi {
|
|||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
DatasourceDTO save(@RequestBody DatasourceDTO dataSourceDTO) throws DEException;
|
DatasourceDTO save(@RequestBody DatasourceDTO dataSourceDTO) throws DEException;
|
||||||
|
|
||||||
|
@PostMapping("/update")
|
||||||
|
DatasourceDTO update(@RequestBody DatasourceDTO dataSourceDTO) throws DEException;
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/move")
|
@PostMapping("/move")
|
||||||
DatasourceDTO move(@RequestBody DatasourceDTO dataSourceDTO) throws DEException;
|
DatasourceDTO move(@RequestBody DatasourceDTO dataSourceDTO) throws DEException;
|
||||||
|
Loading…
Reference in New Issue
Block a user