QuickBi 前后端实现动态接收参数展示页面

        前端页面代码,其中关键参数为pageId和ticket; pageId可以前端菜单配置传输,而ticket则需要后端代码生成;

前端代码

代码运行环境是vue3,visual studio code编辑器;



  
   
  
  

 前端调用后端api,生成ticket返回页面;

import request from '@/axios';

export const getQuickbiticket = (pageId) => {
  return request({
    url: '/system/dataQBi/getTicket',
    method: 'get',
    params: {
        pageId
      }
  })
}

后端代码

idea软件,java8环境;

@RestController
@AllArgsConstructor
@RequestMapping("/dataQBi")
public class DataQBiController extends BladeController {

	@GetMapping("/getTicket")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "报表id", notes = "传入pageId")
	public String getTicket (@RequestParam(value = "pageId", defaultValue = "") String pageId)  {
		String ticket = "";
		String account =  String.valueOf(getUser().getAccount());

		try{
			ticket = QuickBiUtils.generateTicket(pageId,account);
		}catch (SDKException e){
			e.printStackTrace();
		}
		return ticket;
	}

}

 具体参数api 自己套用自己公司的;

public class QuickBiUtils {

	private static IOpenAPIClient openAPIClient = HttpClientFactory.buildDefaultClient(
		"https://xxx.com.cn", "asf-123asf", "as-123-safweq", true);

	public static String generateTicket(String worksId ,String accountName)throws SDKException {
		HttpRequest request = null;
		String result = "";
		request = HttpRequest.build()
			.setUri("/openapi/v2/embed/ticket/create")
			.setMethod(HttpMethod.POST);
		request.addParameter("worksId", worksId);
		if (!StringUtils.equals(accountName,"admin")) {
			request.addParameter("accountName", accountName);
		}

		request.addParameter("accountType", "3");
		request.addParameter("ticketNum", 1);//ticket 的票据数量,默认为 1。建议为 1。
		request.setHttpContentType(FormatType.FORM);
		result = openAPIClient.syncExecute(request);
		return result;
	}
}

实现效果

QuickBi 前后端实现动态接收参数展示页面_第1张图片

 如果有帮到你,真的是太好了!

你可能感兴趣的:(必备技术,servlet)