提交 d04500f3 authored 作者: taojinlong's avatar taojinlong

Merge branch 'main' of github.com:dataease/dataease into main

......@@ -8,6 +8,8 @@ import io.dataease.auth.entity.TokenInfo;
import io.dataease.auth.service.AuthUserService;
import io.dataease.auth.util.JWTUtils;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.commons.utils.LogUtil;
import io.dataease.listener.util.CacheUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
......@@ -54,6 +56,11 @@ public class F2CRealm extends AuthorizingRealm {
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
try {
CacheUtils.get("lic_info", "lic");
}catch (Exception e) {
LogUtil.error(e);
}
String token = (String) auth.getCredentials();
// 解密获得username,用于和数据库进行对比
TokenInfo tokenInfo = JWTUtils.tokenInfoByToken(token);
......
......@@ -6,12 +6,9 @@ import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.interfaces.DecodedJWT;
import io.dataease.auth.entity.TokenInfo;
import io.dataease.auth.filter.JWTFilter;
import io.dataease.commons.utils.CommonBeanFactory;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.springframework.core.env.Environment;
import java.util.Date;
......
......@@ -25,12 +25,12 @@ public class DataSetTableController {
private DataSetTableService dataSetTableService;
@PostMapping("batchAdd")
public void batchAdd(@RequestBody List<DatasetTable> datasetTable) throws Exception {
public void batchAdd(@RequestBody List<DataSetTableRequest> datasetTable) throws Exception {
dataSetTableService.batchInsert(datasetTable);
}
@PostMapping("update")
public DatasetTable save(@RequestBody DatasetTable datasetTable) throws Exception {
public DatasetTable save(@RequestBody DataSetTableRequest datasetTable) throws Exception {
return dataSetTableService.save(datasetTable);
}
......
......@@ -18,4 +18,6 @@ public class DataSetTableRequest extends DatasetTable {
private String row = "1000";
private String userId;
private Integer editType;
}
package io.dataease.listener;
import io.dataease.commons.constants.AuthConstants;
import io.dataease.listener.util.CacheUtils;
import net.sf.ehcache.CacheException;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import net.sf.ehcache.event.CacheEventListener;
import net.sf.ehcache.event.CacheEventListenerFactory;
import org.springframework.stereotype.Component;
import java.util.Properties;
@Component
public class LicCacheEventListener extends CacheEventListenerFactory implements CacheEventListener {
private static CacheEventListener cacheEventListener;
public LicCacheEventListener() {
cacheEventListener = cacheEventListener == null ? this : cacheEventListener;
}
@Override
public void notifyElementRemoved(Ehcache ehcache, Element element) throws CacheException {
/*System.out.println("notifyElementRemoved");*/
}
@Override
public void notifyElementPut(Ehcache ehcache, Element element) throws CacheException {
/*long expirationTime = element.getExpirationTime();
System.out.println(expirationTime);
System.out.println("notifyElementPut");*/
}
@Override
public void notifyElementUpdated(Ehcache ehcache, Element element) throws CacheException {
/*System.out.println("notifyElementUpdated");*/
}
/**
* lic过期触发: 清除用户、角色、权限缓存
* @param ehcache
* @param element
*/
@Override
public void notifyElementExpired(Ehcache ehcache, Element element) {
// System.out.println("notifyElementExpired");
/*String token = ServletUtils.getToken();
Long userId = JWTUtils.tokenInfoByToken(token).getUserId();
authUserService.clearCache(userId);*/
CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME);
CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME);
CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME);
}
@Override
public void notifyElementEvicted(Ehcache ehcache, Element element) {
/*System.out.println("notifyElementEvicted");*/
}
@Override
public void notifyRemoveAll(Ehcache ehcache) {
/*System.out.println("notifyRemoveAll");*/
}
@Override
public void dispose() {
}
@Override
public CacheEventListener createCacheEventListener(Properties properties) {
return cacheEventListener;
}
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
package io.dataease.listener.util;
import net.sf.ehcache.Cache;
import net.sf.ehcache.Element;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.context.annotation.Configuration;
import java.util.Date;
@Configuration
public class CacheUtils {
private static CacheManager manager;
@Autowired
public void setManager(CacheManager manager) {
CacheUtils.manager = manager;
}
public static Object get(String cacheName, Object key) {
Element element = cache(cacheName).get(key);
if (null == element) return null;
return element.getObjectValue();
}
private static void put(String cacheName, Object key, Object value, Integer ttl, Integer tti) {
Element e = new Element(key, value);
//不设置则使用xml配置
if (ttl != null)
e.setEternal(false);
e.setTimeToLive(ttl);
if (tti != null)
e.setTimeToIdle(tti);
cache(cacheName).put(e);
}
private static boolean remove(String cacheName, Object key) {
return cache(cacheName).remove(key);
}
public static void removeAll(String cacheName) {
cache(cacheName).removeAll();
}
private static Cache cache(String cacheName) {
net.sf.ehcache.CacheManager cacheManager = ((EhCacheCacheManager) manager).getCacheManager();
if (!cacheManager.cacheExists(cacheName))
cacheManager.addCache(cacheName);
Cache cacheManagerCache = cacheManager.getCache(cacheName);
return cacheManagerCache;
}
public static void updateLicCache(Date expDate){
long time = expDate.getTime();
long exp = (time - System.currentTimeMillis()) / 1000;
int intExp = (int)exp;
removeAll("lic_info");
put("lic_info", "lic", "lic", intExp, intExp);
}
}
......@@ -2,18 +2,22 @@ package io.dataease.plugins.server;
import io.dataease.auth.api.dto.CurrentUserDto;
import io.dataease.commons.constants.AuthConstants;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.controller.handler.annotation.I18n;
import io.dataease.listener.util.CacheUtils;
import io.dataease.plugins.config.SpringContextUtil;
import io.dataease.plugins.xpack.auth.dto.request.XpackBaseTreeRequest;
import io.dataease.plugins.xpack.auth.dto.request.XpackSysAuthRequest;
import io.dataease.plugins.xpack.auth.dto.response.XpackSysAuthDetail;
import io.dataease.plugins.xpack.auth.dto.response.XpackSysAuthDetailDTO;
import io.dataease.plugins.xpack.auth.dto.response.XpackVAuthModelDTO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import io.dataease.plugins.xpack.auth.service.AuthXpackService;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@RequestMapping("/plugin/auth")
@RestController
......@@ -45,5 +49,13 @@ public class XAuthServer {
AuthXpackService sysAuthService = SpringContextUtil.getBean(AuthXpackService.class);
CurrentUserDto user = AuthUtils.getUser();
sysAuthService.authChange(request, user.getUserId(), user.getUsername(), user.getIsAdmin());
// 当权限发生变化 前端实时刷新对应菜单
Optional.ofNullable(request.getAuthSourceType()).ifPresent(type -> {
if (StringUtils.equals("menu", type)) {
CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME);
CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME);
CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME);
}
});
}
}
package io.dataease.service;
import io.dataease.commons.constants.AuthConstants;
import io.dataease.commons.license.DefaultLicenseService;
import io.dataease.commons.license.F2CLicenseResponse;
import io.dataease.commons.utils.CommonBeanFactory;
import io.dataease.commons.utils.LogUtil;
import io.dataease.listener.util.CacheUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.util.Date;
import java.util.Optional;
@Service
......@@ -23,6 +25,15 @@ public class AboutService {
public F2CLicenseResponse updateLicense(String licenseKey) {
F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.updateLicense(product, licenseKey);
Optional.ofNullable(f2CLicenseResponse).ifPresent(resp -> {
if (resp.getStatus() == F2CLicenseResponse.Status.valid){
CacheUtils.updateLicCache(new Date(f2CLicenseResponse.getLicense().getExpired()));
CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME);
CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME);
CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME);
}
});
return f2CLicenseResponse;
}
......
......@@ -84,13 +84,13 @@ public class DataSetTableService {
@Value("${upload.file.path}")
private String path;
public void batchInsert(List<DatasetTable> datasetTable) throws Exception {
for (DatasetTable table : datasetTable) {
public void batchInsert(List<DataSetTableRequest> datasetTable) throws Exception {
for (DataSetTableRequest table : datasetTable) {
save(table);
}
}
public DatasetTable save(DatasetTable datasetTable) throws Exception {
public DatasetTable save(DataSetTableRequest datasetTable) throws Exception {
checkName(datasetTable);
if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql")) {
DataSetTableRequest dataSetTableRequest = new DataSetTableRequest();
......
......@@ -5,9 +5,11 @@ import io.dataease.base.domain.MyPlugin;
import io.dataease.base.mapper.MyPluginMapper;
import io.dataease.base.mapper.ext.ExtSysPluginMapper;
import io.dataease.base.mapper.ext.query.GridExample;
import io.dataease.commons.constants.AuthConstants;
import io.dataease.commons.utils.DeFileUtils;
import io.dataease.commons.utils.ZipUtils;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.listener.util.CacheUtils;
import io.dataease.plugins.config.LoadjarUtil;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -89,6 +91,10 @@ public class PluginService {
jarPath = DeFileUtils.copy(jarFile, targetDir);
loadJar(jarPath, myPlugin);
myPluginMapper.insert(myPlugin);
CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME);
CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME);
CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME);
} catch (Exception e) {
if (StringUtils.isNotEmpty(targetDir)) {
DeFileUtils.deleteFile(targetDir);
......@@ -137,6 +143,9 @@ public class PluginService {
* @return
*/
public Boolean uninstall(Long pluginId) {
CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME);
CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME);
CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME);
myPluginMapper.deleteByPrimaryKey(pluginId);
return true;
}
......@@ -148,6 +157,9 @@ public class PluginService {
* @return
*/
public Boolean changeStatus(Long pluginId, Boolean status) {
CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME);
CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME);
CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME);
return false;
}
......
......@@ -69,5 +69,18 @@
memoryStoreEvictionPolicy="LRU"
/>
<cache
name="lic_info"
eternal="false"
maxElementsInMemory="10"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="60"
timeToLiveSeconds="60"
memoryStoreEvictionPolicy="FIFO"
>
<cacheEventListenerFactory class="io.dataease.listener.LicCacheEventListener" />
</cache>
</ehcache>
\ No newline at end of file
......@@ -36,15 +36,18 @@ export default {
},
element: {
require: true,
type: Object
type: Object,
default: null
},
defaultStyle: {
require: true,
type: Object
type: Object,
default: null
},
index: {
require: true,
type: [Number, String]
type: [Number, String],
default: null
}
},
data() {
......@@ -200,6 +203,7 @@ export default {
pointList.forEach(point => {
const angle = mod360(initialAngle[point] + rotate)
const len = angleToCursor.length
// eslint-disable-next-line no-constant-condition
while (true) {
lastMatchIndex = (lastMatchIndex + 1) % len
const angleLimit = angleToCursor[lastMatchIndex]
......
......@@ -40,7 +40,8 @@ export default {
components: { ChartComponent, TableNormal, LabelNormal },
props: {
element: {
type: Object
type: Object,
default: null
},
filter: {
type: Object,
......@@ -59,38 +60,6 @@ export default {
}
}
},
watch: {
'$store.getters.conditions': function(newVal, oldVal) {
this.filter.filter = newVal
this.getData(this.element.propValue.viewId)
},
filter(val) {
this.getData(this.element.propValue.viewId)
},
// deep监听panel 如果改变 提交到 store
canvasStyleData: {
handler(newVal, oldVla) {
// this.chart.stylePriority == panel 优先使用仪表板样式
this.mergeStyle()
},
deep: true
},
// 监听外部的样式变化
outStyle: {
handler(newVal, oldVla) {
if (this.$refs[this.element.propValue.id]) {
this.$refs[this.element.propValue.id].chartResize()
}
},
deep: true
}
},
created() {
this.refId = uuid.v1
},
computed: mapState([
'canvasStyleData'
]),
data() {
return {
refId: null,
......@@ -120,8 +89,35 @@ export default {
message: null
}
},
computed: mapState([
'canvasStyleData'
]),
watch: {
filter(val) {
this.getData(this.element.propValue.viewId)
},
// deep监听panel 如果改变 提交到 store
canvasStyleData: {
handler(newVal, oldVla) {
// this.chart.stylePriority == panel 优先使用仪表板样式
this.mergeStyle()
},
deep: true
},
// 监听外部的样式变化
outStyle: {
handler(newVal, oldVla) {
if (this.$refs[this.element.propValue.id]) {
this.$refs[this.element.propValue.id].chartResize()
}
},
deep: true
}
},
created() {
this.filter.filter = this.$store.getters.conditions
this.refId = uuid.v1
// this.filter.filter = this.$store.getters.conditions
this.getData(this.element.propValue.viewId)
},
mounted() {
......
......@@ -830,7 +830,11 @@ export default {
preview_100_data: 'Show 100 lines data',
invalid_table_check: 'Please sync data first.',
parse_error: 'Parse Error',
origin_field_type: 'Origin Type'
origin_field_type: 'Origin Type',
edit_excel_table: 'Edit Excel Dataset',
edit_excel: 'Edit Excel',
excel_replace: 'Replace',
excel_add: 'Add'
},
datasource: {
datasource: 'Data Source',
......
......@@ -797,7 +797,7 @@ export default {
param: '參數',
edit_sql: '編輯 SQL',
showRow: '顯示行',
add_excel_table: ' 添加 Excel 數據集',
add_excel_table: ' 添加Excel數據集',
add_custom_table: '添加自助數據集',
upload_file: '上傳文件',
detail: '詳情',
......@@ -830,7 +830,11 @@ export default {
preview_100_data: '顯示前100行數據',
invalid_table_check: '非直連數據集請先完成數據同步',
parse_error: '解析錯誤',
origin_field_type: '原始類型'
origin_field_type: '原始類型',
edit_excel_table: '編輯Excel數據集',
edit_excel: '編輯Excel',
excel_replace: '替換',
excel_add: '追加'
},
datasource: {
datasource: '數據源',
......
......@@ -830,7 +830,11 @@ export default {
preview_100_data: '显示前100行数据',
invalid_table_check: '非直连数据集请先完成数据同步',
parse_error: '解析错误',
origin_field_type: '原始类型'
origin_field_type: '原始类型',
edit_excel_table: '编辑Excel数据集',
edit_excel: '编辑Excel',
excel_replace: '替换',
excel_add: '追加'
},
datasource: {
datasource: '数据源',
......
......@@ -83,6 +83,10 @@ const checkAuth = response => {
const linkToken = response.headers[LinkTokenKey.toLocaleLowerCase()]
setLinkToken(linkToken)
}
// 许可状态改变 刷新页面
// if (response.headers['lic-status']) {
// location.reload()
// }
}
// 请根据实际需求修改
......
......@@ -2,6 +2,7 @@
<div ref="tableContainer" :style="bg_class">
<p v-show="title_show" ref="title" :style="title_class">{{ chart.title }}</p>
<ux-grid
:id="chart.id"
ref="plxTable"
size="mini"
style="width: 100%;"
......@@ -109,7 +110,9 @@ export default {
datas = []
}
this.$refs.plxTable.reloadData(datas)
this.initStyle()
this.$nextTick(() => {
this.initStyle()
})
window.onresize = function() {
that.calcHeight()
}
......@@ -165,15 +168,18 @@ export default {
this.bg_class.background = hexColorToRGBA(customStyle.background.color, customStyle.background.alpha)
}
}
// 修改footer合计样式
const s_table = document.getElementsByClassName('elx-table--footer')[0]
const table = document.getElementById(this.chart.id)
const s_table = table.getElementsByClassName('elx-table--footer')
// console.log(s_table)
let s = ''
for (const i in this.table_header_class) {
s += (i === 'fontSize' ? 'font-size' : i) + ':' + this.table_header_class[i] + ';'
}
s_table.setAttribute('style', s)
console.log(s_table)
for (let i = 0; i < s_table.length; i++) {
s_table[i].setAttribute('style', s)
}
},
getRowStyle({ row, rowIndex }) {
if (rowIndex % 2 === 0) {
......
......@@ -3,7 +3,7 @@
<el-row>
<el-row style="height: 26px;">
<span style="line-height: 26px;">
{{ $t('dataset.add_excel_table') }}
{{ param.tableId?$t('dataset.edit_excel_table'):$t('dataset.add_excel_table') }}
</span>
<el-row style="float: right">
<el-button size="mini" @click="cancel">
......@@ -20,7 +20,7 @@
<el-col style="width: 500px;">
<el-form :inline="true" size="mini" class="row-style">
<el-form-item class="form-item">
<el-input v-model="name" :placeholder="$t('commons.name')" />
<el-input v-show="!param.tableId" v-model="name" :placeholder="$t('commons.name')" />
</el-form-item>
<el-form-item class="form-item">
<el-upload
......@@ -176,14 +176,28 @@ export default {
})
return
}
const table = {
id: this.param.tableId,
name: this.name,
sceneId: this.param.id,
dataSourceId: null,
type: 'excel',
mode: parseInt(this.mode),
info: '{"data":"' + this.path + '"}'
let table = {}
if (!this.param.tableId) {
table = {
id: this.param.tableId,
name: this.name,
sceneId: this.param.id,
dataSourceId: null,
type: 'excel',
mode: parseInt(this.mode),
info: '{"data":"' + this.path + '"}'
}
} else {
table = {
id: this.param.tableId,
name: this.param.table.name,
sceneId: this.param.id,
dataSourceId: null,
type: 'excel',
mode: parseInt(this.mode),
info: '{"data":"' + this.path + '"}',
editType: this.param.editType ? this.param.editType : 0
}
}
post('/dataset/table/update', table).then(response => {
this.$store.dispatch('dataset/setSceneData', new Date().getTime())
......
......@@ -14,6 +14,19 @@
</span>
</el-popover>
<el-row style="float: right">
<el-dropdown style="margin-right: 10px;" size="small" trigger="click" @command="clickEditExcel">
<el-button type="primary" size="mini" plain>
{{ $t('dataset.edit_excel') }}
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeEditExcel('0')">
{{ $t('dataset.excel_replace') }}
</el-dropdown-item>
<el-dropdown-item :command="beforeEditExcel('1')">
{{ $t('dataset.excel_add') }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-button v-if="table.type ==='custom'" size="mini" @click="editCustom">
{{ $t('dataset.edit_custom_table') }}
</el-button>
......@@ -108,10 +121,10 @@ export default {
this.fields = response.data.fields
this.data = response.data.data
this.page = response.data.page
if(response.data.status === 'warnning'){
if (response.data.status === 'warnning') {
this.$warning(response.data.msg, 3000)
}
if(response.data.status === 'error') {
if (response.data.status === 'error') {
this.$error(response.data.msg, 3000)
}
}).catch(response => {
......@@ -147,6 +160,24 @@ export default {
},
hideTab() {
this.tabStatus = false
},
clickEditExcel(param) {
// console.log(param);
switch (param.type) {
case '0':
this.$emit('switchComponent', { name: 'AddExcel', param: { id: this.table.sceneId, tableId: this.table.id, editType: 0, table: this.table }})
break
case '1':
this.$emit('switchComponent', { name: 'AddExcel', param: { id: this.table.sceneId, tableId: this.table.id, editType: 1, table: this.table }})
break
}
},
beforeEditExcel(type) {
return {
'type': type
}
}
}
}
......
......@@ -57,7 +57,8 @@ export default {
},
authCondition: {
type: Object,
required: false
required: false,
default: null
},
dataInfo: {
type: Object,
......@@ -67,7 +68,10 @@ export default {
type: String,
required: true
},
attachActiveName: String,
attachActiveName: {
type: String,
default: null
},
defaultProps: {
type: Object,
required: false,
......
......@@ -92,7 +92,7 @@
import LayoutContent from '@/components/business/LayoutContent'
import ComplexTable from '@/components/business/complex-table'
import { checkPermission, hasDataPermission } from '@/utils/permission'
import { hasDataPermission } from '@/utils/permission'
import { formatCondition } from '@/utils/index'
import { dsGrid, addDs, editDs, delDs, validateDs } from '@/api/system/datasource'
......
......@@ -146,7 +146,7 @@ export default {
},
methods: {
handleClick(tab, event) {
console.log(tab, event)
// console.log(tab, event)
},
create() {
this.$router.push({ name: 'system-role-form' })
......
......@@ -152,7 +152,7 @@ export default {
this.formInline = response.data
this.formInline.ssl = this.formInline.ssl === 'true'
this.formInline.tls = this.formInline.tls === 'true'
console.log(this.formInline)
// console.log(this.formInline)
this.$nextTick(() => {
this.$refs.formInline.clearValidate()
})
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论