forked from github/dataease
feat: 数据集入口适配
This commit is contained in:
parent
0eca3858cb
commit
b3352c07c9
@ -5,6 +5,8 @@ import io.dataease.commons.constants.ParamConstants;
|
||||
import io.dataease.controller.sys.response.BasicInfo;
|
||||
import io.dataease.controller.sys.response.MailInfo;
|
||||
import io.dataease.dto.SystemParameterDTO;
|
||||
import io.dataease.listener.DatasetCheckListener;
|
||||
import io.dataease.listener.util.CacheUtils;
|
||||
import io.dataease.service.FileService;
|
||||
import io.dataease.service.system.EmailService;
|
||||
import io.dataease.service.system.SystemParameterService;
|
||||
@ -16,6 +18,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
@ -45,7 +48,7 @@ public class SystemParameterController {
|
||||
public BasicInfo basicInfo() {
|
||||
return systemParameterService.basicInfo();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/requestTimeOut")
|
||||
public Integer RequestTimeOut() {
|
||||
BasicInfo basicInfo = systemParameterService.basicInfo();
|
||||
@ -73,19 +76,17 @@ public class SystemParameterController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("/base/info")
|
||||
public List<SystemParameterDTO> getBaseInfo () {
|
||||
public List<SystemParameterDTO> getBaseInfo() {
|
||||
return systemParameterService.getSystemParameterInfo(ParamConstants.Classify.BASE.getValue());
|
||||
}
|
||||
|
||||
@GetMapping("/ui/info")
|
||||
public List<SystemParameterDTO> getDisplayInfo () {
|
||||
public List<SystemParameterDTO> getDisplayInfo() {
|
||||
return systemParameterService.getSystemParameterInfo(ParamConstants.Classify.UI.getValue());
|
||||
}
|
||||
|
||||
@GetMapping(value="/ui/image/{imageId}", produces = {MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_PNG_VALUE})
|
||||
@GetMapping(value = "/ui/image/{imageId}", produces = {MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_PNG_VALUE})
|
||||
public ResponseEntity<byte[]> image(@PathVariable("imageId") String imageId) {
|
||||
byte[] bytes = fileService.loadFileAsBytes(imageId);
|
||||
final HttpHeaders headers = new HttpHeaders();
|
||||
@ -93,12 +94,19 @@ public class SystemParameterController {
|
||||
return new ResponseEntity<>(bytes, headers, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping(value="/save/ui", consumes = {"multipart/form-data"})
|
||||
public void saveUIInfo (@RequestPart("request") Map<String,List<SystemParameterDTO>> systemParameterMap,@RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles) throws IOException {
|
||||
systemParameterService.saveUIInfo(systemParameterMap,bodyFiles);
|
||||
@PostMapping(value = "/save/ui", consumes = {"multipart/form-data"})
|
||||
public void saveUIInfo(@RequestPart("request") Map<String, List<SystemParameterDTO>> systemParameterMap, @RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles) throws IOException {
|
||||
systemParameterService.saveUIInfo(systemParameterMap, bodyFiles);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping(value = "/checkCustomDs")
|
||||
public boolean checkCustomDs() throws IOException {
|
||||
try {
|
||||
Object cache = CacheUtils.get(DatasetCheckListener.CACHE_NAME, DatasetCheckListener.CACHE_KEY);
|
||||
return cache != null && (boolean) cache;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package io.dataease.listener;
|
||||
|
||||
import io.dataease.base.domain.DatasetTable;
|
||||
import io.dataease.base.domain.DatasetTableExample;
|
||||
import io.dataease.base.mapper.DatasetTableMapper;
|
||||
import io.dataease.listener.util.CacheUtils;
|
||||
import io.dataease.plugins.loader.ClassloaderResponsity;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author gin
|
||||
* @Date 2021/12/22 10:01 上午
|
||||
*/
|
||||
@Component
|
||||
public class DatasetCheckListener implements ApplicationListener<ApplicationReadyEvent> {
|
||||
private final Logger logger = LoggerFactory.getLogger(ClassloaderResponsity.class);
|
||||
public static final String CACHE_NAME = "check_ds";
|
||||
public static final String CACHE_KEY = "hide_custom_ds";
|
||||
@Resource
|
||||
private DatasetTableMapper datasetTableMapper;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
|
||||
logger.info("Start check custom dataset");
|
||||
// 项目启动查找是否有'自定义数据集'
|
||||
DatasetTableExample datasetTableExample = new DatasetTableExample();
|
||||
datasetTableExample.createCriteria().andTypeEqualTo("custom");
|
||||
List<DatasetTable> datasetTables = datasetTableMapper.selectByExampleWithBLOBs(datasetTableExample);
|
||||
CacheUtils.put(CACHE_NAME, CACHE_KEY, CollectionUtils.isEmpty(datasetTables), null, null);
|
||||
}
|
||||
}
|
@ -182,4 +182,12 @@ export function datasetRowPermissionsList(datasetId, page, size, data, loading)
|
||||
})
|
||||
}
|
||||
|
||||
export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree }
|
||||
export function checkCustomDs() {
|
||||
return request({
|
||||
url: '/system/checkCustomDs',
|
||||
method: 'post',
|
||||
loading: true
|
||||
})
|
||||
}
|
||||
|
||||
export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree, checkCustomDs }
|
||||
|
@ -16,6 +16,7 @@ const getters = {
|
||||
errorLogs: state => state.errorLog.logs,
|
||||
sceneData: state => state.dataset.sceneData,
|
||||
table: state => state.dataset.table,
|
||||
hideCustomDs: state => state.dataset.hideCustomDs,
|
||||
loadingMap: state => state.request.loadingMap,
|
||||
currentPath: state => state.permission.currentPath,
|
||||
permissions: state => state.user.permissions,
|
||||
|
@ -2,7 +2,8 @@
|
||||
const getDefaultState = () => {
|
||||
return {
|
||||
sceneData: {},
|
||||
table: {}
|
||||
table: {},
|
||||
hideCustomDs: false
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +15,9 @@ const mutations = {
|
||||
},
|
||||
setTable: (state, table) => {
|
||||
state.table = table
|
||||
},
|
||||
setHideCustomDs: (state, hideCustomDs) => {
|
||||
state.hideCustomDs = hideCustomDs
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,6 +27,9 @@ const actions = {
|
||||
},
|
||||
setTable({ commit }, table) {
|
||||
commit('setTable', table)
|
||||
},
|
||||
setHideCustomDs({ commit }, hideCustomDs) {
|
||||
commit('setHideCustomDs', hideCustomDs)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@
|
||||
<el-tab-pane :label="$t('dataset.field_manage')" name="fieldEdit">
|
||||
<field-edit :param="param" :table="table" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="table.type !== 'union' && table.type !== 'custom' && !(table.type === 'sql' && table.mode === 0)" :label="$t('dataset.join_view')" name="joinView">
|
||||
<el-tab-pane v-if="!hideCustomDs && table.type !== 'union' && table.type !== 'custom' && !(table.type === 'sql' && table.mode === 0)" :label="$t('dataset.join_view')" name="joinView">
|
||||
<union-view :param="param" :table="table" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="table.mode === 1 && (table.type === 'excel' || table.type === 'db' || table.type === 'sql')" :label="$t('dataset.update_info')" name="updateInfo">
|
||||
@ -76,7 +76,7 @@ import FieldEdit from './FieldEdit'
|
||||
|
||||
export default {
|
||||
name: 'ViewTable',
|
||||
components: {FieldEdit, UnionView, DatasetChartDetail, UpdateInfo, TabDataPreview },
|
||||
components: { FieldEdit, UnionView, DatasetChartDetail, UpdateInfo, TabDataPreview },
|
||||
props: {
|
||||
param: {
|
||||
type: Object,
|
||||
@ -103,10 +103,9 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// tableRefresh() {
|
||||
// this.initTable(this.param)
|
||||
// return this.$store.state.dataset.table
|
||||
// }
|
||||
hideCustomDs: function() {
|
||||
return this.$store.getters.hideCustomDs
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'param': function() {
|
||||
|
@ -91,7 +91,7 @@
|
||||
<svg-icon icon-class="ds-excel" class="ds-icon-excel" />
|
||||
{{ $t('dataset.excel_data') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item :command="beforeClickAddData('custom',data)">
|
||||
<el-dropdown-item v-show="!hideCustomDs" :command="beforeClickAddData('custom',data)">
|
||||
<svg-icon icon-class="ds-custom" class="ds-icon-custom" />
|
||||
{{ $t('dataset.custom_data') }}
|
||||
</el-dropdown-item>
|
||||
@ -309,6 +309,9 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
hideCustomDs: function() {
|
||||
return this.$store.getters.hideCustomDs
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
saveStatus() {
|
||||
|
@ -26,6 +26,7 @@ import AddCustom from './add/AddCustom'
|
||||
import AddUnion from '@/views/dataset/add/AddUnion'
|
||||
import FieldEdit from './data/FieldEdit'
|
||||
import { removeClass } from '@/utils'
|
||||
import { checkCustomDs } from '@/api/dataset/dataset'
|
||||
export default {
|
||||
name: 'DataSet',
|
||||
components: { DeMainContainer, DeContainer, DeAsideContainer, Group, DataHome, ViewTable, AddDB, AddSQL, AddExcel, AddCustom },
|
||||
@ -40,11 +41,17 @@ export default {
|
||||
removeClass(document.body, 'showRightPanel')
|
||||
},
|
||||
created() {
|
||||
this.initDs()
|
||||
this.$store.dispatch('app/toggleSideBarHide', true)
|
||||
const routerParam = this.$router.currentRoute.params
|
||||
this.toMsgShare(routerParam)
|
||||
},
|
||||
methods: {
|
||||
initDs() {
|
||||
checkCustomDs().then(res => {
|
||||
this.$store.dispatch('dataset/setHideCustomDs', res.data)
|
||||
})
|
||||
},
|
||||
switchComponent(c) {
|
||||
this.param = c.param
|
||||
switch (c.name) {
|
||||
|
Loading…
Reference in New Issue
Block a user