提交 b3352c07 authored 作者: junjie's avatar junjie

feat: 数据集入口适配

上级 0eca3858
...@@ -5,6 +5,8 @@ import io.dataease.commons.constants.ParamConstants; ...@@ -5,6 +5,8 @@ import io.dataease.commons.constants.ParamConstants;
import io.dataease.controller.sys.response.BasicInfo; import io.dataease.controller.sys.response.BasicInfo;
import io.dataease.controller.sys.response.MailInfo; import io.dataease.controller.sys.response.MailInfo;
import io.dataease.dto.SystemParameterDTO; 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.FileService;
import io.dataease.service.system.EmailService; import io.dataease.service.system.EmailService;
import io.dataease.service.system.SystemParameterService; import io.dataease.service.system.SystemParameterService;
...@@ -16,6 +18,7 @@ import org.springframework.http.ResponseEntity; ...@@ -16,6 +18,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
...@@ -45,7 +48,7 @@ public class SystemParameterController { ...@@ -45,7 +48,7 @@ public class SystemParameterController {
public BasicInfo basicInfo() { public BasicInfo basicInfo() {
return systemParameterService.basicInfo(); return systemParameterService.basicInfo();
} }
@GetMapping("/requestTimeOut") @GetMapping("/requestTimeOut")
public Integer RequestTimeOut() { public Integer RequestTimeOut() {
BasicInfo basicInfo = systemParameterService.basicInfo(); BasicInfo basicInfo = systemParameterService.basicInfo();
...@@ -73,19 +76,17 @@ public class SystemParameterController { ...@@ -73,19 +76,17 @@ public class SystemParameterController {
} }
@GetMapping("/base/info") @GetMapping("/base/info")
public List<SystemParameterDTO> getBaseInfo () { public List<SystemParameterDTO> getBaseInfo() {
return systemParameterService.getSystemParameterInfo(ParamConstants.Classify.BASE.getValue()); return systemParameterService.getSystemParameterInfo(ParamConstants.Classify.BASE.getValue());
} }
@GetMapping("/ui/info") @GetMapping("/ui/info")
public List<SystemParameterDTO> getDisplayInfo () { public List<SystemParameterDTO> getDisplayInfo() {
return systemParameterService.getSystemParameterInfo(ParamConstants.Classify.UI.getValue()); 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) { public ResponseEntity<byte[]> image(@PathVariable("imageId") String imageId) {
byte[] bytes = fileService.loadFileAsBytes(imageId); byte[] bytes = fileService.loadFileAsBytes(imageId);
final HttpHeaders headers = new HttpHeaders(); final HttpHeaders headers = new HttpHeaders();
...@@ -93,12 +94,19 @@ public class SystemParameterController { ...@@ -93,12 +94,19 @@ public class SystemParameterController {
return new ResponseEntity<>(bytes, headers, HttpStatus.OK); return new ResponseEntity<>(bytes, headers, HttpStatus.OK);
} }
@PostMapping(value="/save/ui", consumes = {"multipart/form-data"}) @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 { public void saveUIInfo(@RequestPart("request") Map<String, List<SystemParameterDTO>> systemParameterMap, @RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles) throws IOException {
systemParameterService.saveUIInfo(systemParameterMap,bodyFiles); 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;
}
}
} }
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) ...@@ -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 = { ...@@ -16,6 +16,7 @@ const getters = {
errorLogs: state => state.errorLog.logs, errorLogs: state => state.errorLog.logs,
sceneData: state => state.dataset.sceneData, sceneData: state => state.dataset.sceneData,
table: state => state.dataset.table, table: state => state.dataset.table,
hideCustomDs: state => state.dataset.hideCustomDs,
loadingMap: state => state.request.loadingMap, loadingMap: state => state.request.loadingMap,
currentPath: state => state.permission.currentPath, currentPath: state => state.permission.currentPath,
permissions: state => state.user.permissions, permissions: state => state.user.permissions,
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
const getDefaultState = () => { const getDefaultState = () => {
return { return {
sceneData: {}, sceneData: {},
table: {} table: {},
hideCustomDs: false
} }
} }
...@@ -14,6 +15,9 @@ const mutations = { ...@@ -14,6 +15,9 @@ const mutations = {
}, },
setTable: (state, table) => { setTable: (state, table) => {
state.table = table state.table = table
},
setHideCustomDs: (state, hideCustomDs) => {
state.hideCustomDs = hideCustomDs
} }
} }
...@@ -23,6 +27,9 @@ const actions = { ...@@ -23,6 +27,9 @@ const actions = {
}, },
setTable({ commit }, table) { setTable({ commit }, table) {
commit('setTable', table) commit('setTable', table)
},
setHideCustomDs({ commit }, hideCustomDs) {
commit('setHideCustomDs', hideCustomDs)
} }
} }
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<el-tab-pane :label="$t('dataset.field_manage')" name="fieldEdit"> <el-tab-pane :label="$t('dataset.field_manage')" name="fieldEdit">
<field-edit :param="param" :table="table" /> <field-edit :param="param" :table="table" />
</el-tab-pane> </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" /> <union-view :param="param" :table="table" />
</el-tab-pane> </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"> <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' ...@@ -76,7 +76,7 @@ import FieldEdit from './FieldEdit'
export default { export default {
name: 'ViewTable', name: 'ViewTable',
components: {FieldEdit, UnionView, DatasetChartDetail, UpdateInfo, TabDataPreview }, components: { FieldEdit, UnionView, DatasetChartDetail, UpdateInfo, TabDataPreview },
props: { props: {
param: { param: {
type: Object, type: Object,
...@@ -103,10 +103,9 @@ export default { ...@@ -103,10 +103,9 @@ export default {
} }
}, },
computed: { computed: {
// tableRefresh() { hideCustomDs: function() {
// this.initTable(this.param) return this.$store.getters.hideCustomDs
// return this.$store.state.dataset.table }
// }
}, },
watch: { watch: {
'param': function() { 'param': function() {
......
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<svg-icon icon-class="ds-excel" class="ds-icon-excel" /> <svg-icon icon-class="ds-excel" class="ds-icon-excel" />
{{ $t('dataset.excel_data') }} {{ $t('dataset.excel_data') }}
</el-dropdown-item> </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" /> <svg-icon icon-class="ds-custom" class="ds-icon-custom" />
{{ $t('dataset.custom_data') }} {{ $t('dataset.custom_data') }}
</el-dropdown-item> </el-dropdown-item>
...@@ -309,6 +309,9 @@ export default { ...@@ -309,6 +309,9 @@ export default {
} }
}, },
computed: { computed: {
hideCustomDs: function() {
return this.$store.getters.hideCustomDs
}
}, },
watch: { watch: {
saveStatus() { saveStatus() {
......
...@@ -26,6 +26,7 @@ import AddCustom from './add/AddCustom' ...@@ -26,6 +26,7 @@ import AddCustom from './add/AddCustom'
import AddUnion from '@/views/dataset/add/AddUnion' import AddUnion from '@/views/dataset/add/AddUnion'
import FieldEdit from './data/FieldEdit' import FieldEdit from './data/FieldEdit'
import { removeClass } from '@/utils' import { removeClass } from '@/utils'
import { checkCustomDs } from '@/api/dataset/dataset'
export default { export default {
name: 'DataSet', name: 'DataSet',
components: { DeMainContainer, DeContainer, DeAsideContainer, Group, DataHome, ViewTable, AddDB, AddSQL, AddExcel, AddCustom }, components: { DeMainContainer, DeContainer, DeAsideContainer, Group, DataHome, ViewTable, AddDB, AddSQL, AddExcel, AddCustom },
...@@ -40,11 +41,17 @@ export default { ...@@ -40,11 +41,17 @@ export default {
removeClass(document.body, 'showRightPanel') removeClass(document.body, 'showRightPanel')
}, },
created() { created() {
this.initDs()
this.$store.dispatch('app/toggleSideBarHide', true) this.$store.dispatch('app/toggleSideBarHide', true)
const routerParam = this.$router.currentRoute.params const routerParam = this.$router.currentRoute.params
this.toMsgShare(routerParam) this.toMsgShare(routerParam)
}, },
methods: { methods: {
initDs() {
checkCustomDs().then(res => {
this.$store.dispatch('dataset/setHideCustomDs', res.data)
})
},
switchComponent(c) { switchComponent(c) {
this.param = c.param this.param = c.param
switch (c.name) { switch (c.name) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论