Merge pull request #4912 from dataease/pr@dev@fix_public-link

fix(公共链接): 修复公共链接部分明细表导出失败问题
This commit is contained in:
王嘉豪 2023-03-29 12:47:39 +08:00 committed by GitHub
commit bc71cd0828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View File

@ -1,9 +1,12 @@
package io.dataease.controller.panel;
import com.auth0.jwt.JWT;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.dataease.auth.annotation.DePermission;
import io.dataease.auth.annotation.DePermissionProxy;
import io.dataease.auth.annotation.DePermissions;
import io.dataease.auth.filter.F2CLinkFilter;
import io.dataease.auth.service.impl.ExtAuthServiceImpl;
import io.dataease.commons.constants.DePermissionType;
import io.dataease.commons.constants.PanelConstants;
@ -21,9 +24,12 @@ import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.Logical;
import org.pentaho.di.core.util.UUIDUtil;
import org.springframework.web.bind.annotation.*;
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 javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@ -141,6 +147,12 @@ public class PanelGroupController {
@PostMapping("/exportDetails")
@I18n
public void exportDetails(@RequestBody PanelViewDetailsRequest request, HttpServletResponse response) throws IOException {
HttpServletRequest httpServletRequest = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
.getRequest();
String linkToken = httpServletRequest.getHeader(F2CLinkFilter.LINK_TOKEN_KEY);
DecodedJWT jwt = JWT.decode(linkToken);
Long userId = jwt.getClaim("userId").asLong();
request.setUserId(userId);
panelGroupService.exportPanelViewDetails(request, response);
}

View File

@ -40,4 +40,6 @@ public class PanelViewDetailsRequest {
@ApiModelProperty(hidden = true)
private PermissionProxy proxy;
private Long userId;
}

View File

@ -1161,6 +1161,8 @@ public class PanelGroupService {
componentFilterInfo.setGoPage(1l);
componentFilterInfo.setPageSize(1000000l);
componentFilterInfo.setExcelExportFlag(true);
componentFilterInfo.setProxy(request.getProxy());
componentFilterInfo.setUser(request.getUserId());
ChartViewDTO chartViewInfo = chartViewService.getData(request.getViewId(), componentFilterInfo);
List<Map> tableRow = (List) chartViewInfo.getData().get("tableRow");
List<Object[]> result = new ArrayList<>();