You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
4.3 KiB
137 lines
4.3 KiB
/* |
|
* Copyright (C), 2018-2021 |
|
* Project: starter |
|
* FileName: OAuthLogin |
|
* Author: Louis |
|
* Date: 2021/3/30 22:09 |
|
*/ |
|
package com.fr.plugin.higq.request; |
|
|
|
import com.fanruan.api.i18n.I18nKit; |
|
import com.fanruan.api.log.LogKit; |
|
import com.fanruan.api.net.NetworkKit; |
|
import com.fanruan.api.util.StringKit; |
|
import com.fr.decision.fun.impl.AbstractGlobalRequestFilterProvider; |
|
import com.fr.decision.webservice.bean.entry.EntryBean; |
|
import com.fr.decision.webservice.bean.entry.FileNodeBean; |
|
import com.fr.decision.webservice.v10.entry.EntryService; |
|
import com.fr.decision.webservice.v10.entry.ReportEntryService; |
|
import com.fr.decision.webservice.v10.user.UserService; |
|
import com.fr.intelli.record.Focus; |
|
import com.fr.intelli.record.Original; |
|
import com.fr.json.JSONArray; |
|
import com.fr.json.JSONObject; |
|
import com.fr.record.analyzer.EnableMetrics; |
|
import com.fr.stable.fun.Authorize; |
|
import com.fr.web.utils.WebUtils; |
|
|
|
import javax.servlet.FilterChain; |
|
import javax.servlet.FilterConfig; |
|
import javax.servlet.http.HttpServletRequest; |
|
import javax.servlet.http.HttpServletResponse; |
|
import java.util.List; |
|
|
|
/** |
|
* <Function Description><br> |
|
* <OAuthLogin> |
|
* |
|
* @author fr.open |
|
* @since 1.0.0 |
|
*/ |
|
@Authorize(callSignKey = TemplatesFilter.PLUGIN_ID) |
|
@EnableMetrics |
|
public class TemplatesFilter extends AbstractGlobalRequestFilterProvider { |
|
|
|
public static final String PLUGIN_ID = "com.fr.plugin.higq.entry"; |
|
|
|
/** |
|
* 过滤器名称 |
|
* |
|
* @return |
|
*/ |
|
@Override |
|
public String filterName() { |
|
return "higqFilter"; |
|
} |
|
|
|
/** |
|
* 过滤规则 |
|
* |
|
* @return |
|
*/ |
|
@Override |
|
public String[] urlPatterns() { |
|
return new String[]{"/decision/v10/templates/all"}; |
|
} |
|
|
|
/** |
|
* 过滤器初始化 |
|
* |
|
* @param filterConfig |
|
*/ |
|
@Override |
|
public void init(FilterConfig filterConfig) { |
|
super.init(filterConfig); |
|
} |
|
|
|
/** |
|
* 过滤器处理 |
|
* |
|
* @param request |
|
* @param response |
|
* @param filterChain |
|
*/ |
|
@Override |
|
public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) { |
|
try { |
|
operation(request, response); |
|
} catch (Exception e) { |
|
LogKit.error(e.getMessage(), e); |
|
} |
|
} |
|
|
|
/** |
|
* 数据处理操作 |
|
* |
|
* @param req |
|
* @param res |
|
* @throws Exception |
|
*/ |
|
@Focus(id = PLUGIN_ID, text = "Plugin-hrjf", source = Original.PLUGIN) |
|
private void operation(HttpServletRequest req, HttpServletResponse res) throws Exception { |
|
String keyword = NetworkKit.getHTTPRequestParameter(req, "keyword"); |
|
List<EntryBean> entryBeanList = EntryService.getInstance().getEntryTree(req); |
|
List<FileNodeBean> fileNodeBeanList = ReportEntryService.getInstance().getReportTemplateTree(UserService.getInstance().getCurrentUserId(req), keyword); |
|
FileNodeBean fileNodeBean; |
|
for (EntryBean entryBean : entryBeanList) { |
|
if (entryBean.isIsParent()) { |
|
fileNodeBean = new FileNodeBean(); |
|
fileNodeBean.setId(entryBean.getId()); |
|
if (StringKit.isBlank(entryBean.getpId())) { |
|
fileNodeBean.setpId("reportlets"); |
|
fileNodeBean.setText(I18nKit.getLocText("Dec-Entry_Management")); |
|
} else { |
|
fileNodeBean.setpId(entryBean.getpId()); |
|
fileNodeBean.setText(entryBean.getText()); |
|
} |
|
fileNodeBean.setPath(entryBean.getId()); |
|
fileNodeBean.setIsParent(entryBean.isIsParent()); |
|
fileNodeBean.setOpen(entryBean.isOpen()); |
|
fileNodeBean.setPrivilege(true); |
|
|
|
fileNodeBeanList.add(fileNodeBean); |
|
} else { |
|
for (FileNodeBean fileNode : fileNodeBeanList) { |
|
if (StringKit.equals(fileNode.getPath(), entryBean.getPath())) { |
|
fileNode.setpId(entryBean.getpId()); |
|
fileNode.setText(entryBean.getText()); |
|
} |
|
} |
|
} |
|
} |
|
|
|
JSONObject result = JSONObject.create(); |
|
result.put("data", JSONArray.create(fileNodeBeanList)); |
|
WebUtils.printAsJSON(res, result); |
|
} |
|
} |