commit
2e72f48877
@ -17,4 +17,9 @@ public class CurrentUserDto extends SysUserEntity implements Serializable {
|
||||
|
||||
@ApiModelProperty("权限集合")
|
||||
private List<String> permissions;
|
||||
|
||||
public CurrentUserDto(String username, String nickName) {
|
||||
super.setUsername(username);
|
||||
super.setNickName(nickName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ public class ShiroServiceImpl implements ShiroService {
|
||||
filterChainDefinitionMap.put("/panel/group/exportDetails", ANON);
|
||||
filterChainDefinitionMap.put("/dataset/field/linkMultFieldValues", "link");
|
||||
filterChainDefinitionMap.put("/dataset/field/linkMappingFieldValues", "link");
|
||||
filterChainDefinitionMap.put("/systemInfo/proxyUserLoginInfo/**", ANON);
|
||||
filterChainDefinitionMap.put("/systemInfo/proxyUserLoginInfo", ANON);
|
||||
|
||||
filterChainDefinitionMap.put("/**", "authc");
|
||||
|
||||
|
||||
@ -1,14 +1,20 @@
|
||||
package io.dataease.controller.sys;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import io.dataease.auth.filter.F2CLinkFilter;
|
||||
import io.dataease.dto.UserLoginInfoDTO;
|
||||
import io.dataease.service.SystemInfoService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
@ApiIgnore
|
||||
@ -23,8 +29,17 @@ public class SystemInfoController {
|
||||
return systemInfoService.getUserLoginInfo(null);
|
||||
}
|
||||
|
||||
@GetMapping("proxyUserLoginInfo/{userId}")
|
||||
public UserLoginInfoDTO proxyUserLoginInfo(@PathVariable String userId) throws IOException {
|
||||
return systemInfoService.getUserLoginInfo(userId);
|
||||
@GetMapping("proxyUserLoginInfo")
|
||||
public UserLoginInfoDTO proxyUserLoginInfo() throws IOException {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
|
||||
.getRequest();
|
||||
String linkToken = request.getHeader(F2CLinkFilter.LINK_TOKEN_KEY);
|
||||
if (StringUtils.isNotEmpty(linkToken)) {
|
||||
DecodedJWT jwt = JWT.decode(linkToken);
|
||||
return systemInfoService.getUserLoginInfo(jwt.getClaim("userId").asLong());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,4 +22,9 @@ public class UserLoginInfoDTO {
|
||||
this.userInfo = userInfo;
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public UserLoginInfoDTO(String username, String nickname, String ip) {
|
||||
this.userInfo = new CurrentUserDto(username, nickname);
|
||||
this.ip = ip;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,12 +2,10 @@ package io.dataease.service;
|
||||
|
||||
import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.IPUtils;
|
||||
import io.dataease.dto.UserLoginInfoDTO;
|
||||
import io.dataease.plugins.common.base.domain.SysUser;
|
||||
import io.dataease.plugins.common.base.mapper.SysUserMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -18,14 +16,18 @@ public class SystemInfoService {
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
public UserLoginInfoDTO getUserLoginInfo(String userId) {
|
||||
if (StringUtils.isNotEmpty(userId)) {
|
||||
SysUser userInfo = sysUserMapper.selectByPrimaryKey(Long.parseLong(userId));
|
||||
CurrentUserDto userDto = new CurrentUserDto();
|
||||
BeanUtils.copyBean(userDto, userInfo);
|
||||
return new UserLoginInfoDTO(userDto, IPUtils.get());
|
||||
public UserLoginInfoDTO getUserLoginInfo(Long userId) {
|
||||
if (userId != null) {
|
||||
SysUser userInfo = sysUserMapper.selectByPrimaryKey(userId);
|
||||
return new UserLoginInfoDTO(userInfo.getUsername(), userInfo.getNickName(), IPUtils.get());
|
||||
}
|
||||
CurrentUserDto userDto = AuthUtils.getUser();
|
||||
if (userDto != null) {
|
||||
return new UserLoginInfoDTO(userDto.getUsername(), userDto.getNickName(), IPUtils.get());
|
||||
} else {
|
||||
return new UserLoginInfoDTO(null, null, IPUtils.get());
|
||||
}
|
||||
return new UserLoginInfoDTO(AuthUtils.getUser(), IPUtils.get());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1846,7 +1846,7 @@ public class ChartViewService {
|
||||
}
|
||||
}
|
||||
}
|
||||
sql = dataSetTableService.handleVariableDefaultValue(sql, null, ds.getType());
|
||||
sql = dataSetTableService.handleVariableDefaultValue(sql, null, ds.getType(), false);
|
||||
return sql;
|
||||
}
|
||||
|
||||
|
||||
@ -122,7 +122,7 @@ public class ViewPluginBaseServiceImpl implements ViewPluginBaseService {
|
||||
break;
|
||||
case SQL:
|
||||
String sql = dataTableInfoDTO.isBase64Encryption() ? new String(java.util.Base64.getDecoder().decode(dataTableInfoDTO.getSql())) : dataTableInfoDTO.getSql();
|
||||
tableName = dataSetTableService.handleVariableDefaultValue(sql, null, pluginViewSet.getDsType());
|
||||
tableName = dataSetTableService.handleVariableDefaultValue(sql, null, pluginViewSet.getDsType(), false);
|
||||
tableName = "(" + sqlFix(tableName) + ")";
|
||||
break;
|
||||
case CUSTOM:
|
||||
|
||||
@ -701,7 +701,7 @@ public class DataSetTableService {
|
||||
datasourceRequest.setDatasource(ds);
|
||||
DataTableInfoDTO dataTableInfo = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class);
|
||||
String sql = dataTableInfo.isBase64Encryption() ? new String(java.util.Base64.getDecoder().decode(dataTableInfo.getSql())) : dataTableInfo.getSql();
|
||||
sql = handleVariableDefaultValue(sql, datasetTable.getSqlVariableDetails(), ds.getType());
|
||||
sql = handleVariableDefaultValue(sql, datasetTable.getSqlVariableDetails(), ds.getType(), false);
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(
|
||||
qp.createQuerySQLWithPage(sql, fields, page, pageSize, realSize, false, null, rowPermissionsTree));
|
||||
@ -1049,7 +1049,7 @@ public class DataSetTableService {
|
||||
}
|
||||
}
|
||||
|
||||
public String handleVariableDefaultValue(String sql, String sqlVariableDetails, String dsType) {
|
||||
public String handleVariableDefaultValue(String sql, String sqlVariableDetails, String dsType, boolean isEdit) {
|
||||
if (StringUtils.isEmpty(sql)) {
|
||||
DataEaseException.throwException(Translator.get("i18n_sql_not_empty"));
|
||||
}
|
||||
@ -1065,10 +1065,14 @@ public class DataSetTableService {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (defaultsSqlVariableDetail != null && defaultsSqlVariableDetail.getDefaultValueScope() != null &&
|
||||
if (!isEdit && defaultsSqlVariableDetail != null && defaultsSqlVariableDetail.getDefaultValueScope() != null &&
|
||||
defaultsSqlVariableDetail.getDefaultValueScope().equals(SqlVariableDetails.DefaultValueScope.ALLSCOPE) && StringUtils.isNotEmpty(defaultsSqlVariableDetail.getDefaultValue())) {
|
||||
sql = sql.replace(matcher.group(), defaultsSqlVariableDetail.getDefaultValue());
|
||||
}
|
||||
if (isEdit && defaultsSqlVariableDetail != null && defaultsSqlVariableDetail.getDefaultValueScope() != null &&
|
||||
defaultsSqlVariableDetail.getDefaultValueScope().equals(SqlVariableDetails.DefaultValueScope.EDIT) && StringUtils.isNotEmpty(defaultsSqlVariableDetail.getDefaultValue())) {
|
||||
sql = sql.replace(matcher.group(), defaultsSqlVariableDetail.getDefaultValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1261,7 +1265,7 @@ public class DataSetTableService {
|
||||
datasourceRequest.setDatasource(ds);
|
||||
|
||||
|
||||
sql = handleVariableDefaultValue(sql, dataSetTableRequest.getSqlVariableDetails(), ds.getType());
|
||||
sql = handleVariableDefaultValue(sql, dataSetTableRequest.getSqlVariableDetails(), ds.getType(), true);
|
||||
if (StringUtils.isEmpty(sql)) {
|
||||
DataEaseException.throwException(Translator.get("i18n_sql_not_empty"));
|
||||
}
|
||||
@ -1927,7 +1931,7 @@ public class DataSetTableService {
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
DataTableInfoDTO dataTableInfo = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class);
|
||||
String sql = dataTableInfo.isBase64Encryption() ? new String(java.util.Base64.getDecoder().decode(dataTableInfo.getSql())) : dataTableInfo.getSql();
|
||||
sql = handleVariableDefaultValue(sql, null, ds.getType());
|
||||
sql = handleVariableDefaultValue(sql, null, ds.getType(), false);
|
||||
String sqlAsTable = qp.createSQLPreview(sql, null);
|
||||
datasourceRequest.setQuery(sqlAsTable);
|
||||
fields = datasourceProvider.fetchResultField(datasourceRequest);
|
||||
|
||||
@ -80,7 +80,7 @@ public class DataSetTableTaskLogService {
|
||||
row[0] = item.getName();
|
||||
row[1] = item.getDatasetName();
|
||||
row[2] = DateUtil.formatDateTime(new Date(item.getStartTime()));
|
||||
row[3] = DateUtil.formatDateTime(new Date(item.getEndTime()));
|
||||
row[3] = item.getEndTime() != null ? DateUtil.formatDateTime(new Date(item.getEndTime())) : "";
|
||||
row[4] = Translator.get("I18N_TASK_LOG_" + item.getStatus().toUpperCase()) ;
|
||||
return row;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
@ -171,7 +171,7 @@ public class DirectFieldService implements DataSetFieldService {
|
||||
if (dataTableInfoDTO.isBase64Encryption()) {
|
||||
sql = new String(java.util.Base64.getDecoder().decode(sql));
|
||||
}
|
||||
sql = dataSetTableService.handleVariableDefaultValue(sql, datasetTable.getSqlVariableDetails(), ds.getType());
|
||||
sql = dataSetTableService.handleVariableDefaultValue(sql, null, ds.getType(), false);
|
||||
datasourceRequest.setQuery(qp.createQuerySQLAsTmp(sql, permissionFields, !needSort, customFilter, rowPermissionsTree, deSortFields));
|
||||
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), DatasetType.CUSTOM.toString())) {
|
||||
DataTableInfoDTO dt = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class);
|
||||
|
||||
4
backend/src/main/resources/db/migration/V52__1.18.5.sql
Normal file
4
backend/src/main/resources/db/migration/V52__1.18.5.sql
Normal file
@ -0,0 +1,4 @@
|
||||
UPDATE `my_plugin`
|
||||
SET `version` = '1.18.5'
|
||||
where `plugin_id` > 0
|
||||
and `version` = '1.18.4';
|
||||
@ -8,9 +8,9 @@ export function userLoginInfo() {
|
||||
})
|
||||
}
|
||||
|
||||
export function proxyUserLoginInfo(userId) {
|
||||
export function proxyUserLoginInfo() {
|
||||
return request({
|
||||
url: '/systemInfo/proxyUserLoginInfo/' + userId,
|
||||
url: '/systemInfo/proxyUserLoginInfo',
|
||||
method: 'get',
|
||||
loading: false
|
||||
})
|
||||
|
||||
@ -485,7 +485,7 @@ export default {
|
||||
activeWatermark(this.panelInfo.watermarkInfo.settingContent, this.userInfo, waterDomId, this.canvasId, this.panelInfo.watermarkOpen)
|
||||
} else {
|
||||
const method = this.userId ? proxyUserLoginInfo : userLoginInfo
|
||||
method(this.userId).then(res => {
|
||||
method().then(res => {
|
||||
this.userInfo = res.data
|
||||
activeWatermark(this.panelInfo.watermarkInfo.settingContent, this.userInfo, waterDomId, this.canvasId, this.panelInfo.watermarkOpen)
|
||||
})
|
||||
|
||||
@ -911,8 +911,9 @@ export default {
|
||||
},
|
||||
|
||||
initTableInfo() {
|
||||
if (this.param.tableId) {
|
||||
getTable(this.param.tableId).then((response) => {
|
||||
const tableId = this.param.tableId || this.$route.query.id
|
||||
if (tableId) {
|
||||
getTable(tableId).then((response) => {
|
||||
const table = response.data
|
||||
this.dataSource = table.dataSourceId
|
||||
this.changeDatasource()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user