增加api日志管理,TabbedPane右键关闭菜单
This commit is contained in:
parent
fd3caf7a0e
commit
55db993b22
BIN
dillon-server/src/main/resources/keystore.p12
Normal file
BIN
dillon-server/src/main/resources/keystore.p12
Normal file
Binary file not shown.
@ -0,0 +1,20 @@
|
||||
package com.lw.ui.request.api.apilog;
|
||||
|
||||
import com.lw.dillon.admin.framework.common.pojo.CommonResult;
|
||||
import com.lw.dillon.admin.framework.common.pojo.PageResult;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogRespVO;
|
||||
import com.lw.ui.request.api.BaseFeignApi;
|
||||
import feign.QueryMap;
|
||||
import feign.RequestLine;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ApiAccessLogFeign extends BaseFeignApi {
|
||||
|
||||
|
||||
// "获得API 访问日志分页")
|
||||
@RequestLine("GET /admin-api/infra/api-access-log/page")
|
||||
CommonResult<PageResult<ApiAccessLogRespVO>> getApiAccessLogPage(@QueryMap Map<String,Object> pageReqVO);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.lw.ui.request.api.apilog;
|
||||
|
||||
import com.lw.dillon.admin.framework.common.pojo.CommonResult;
|
||||
import com.lw.dillon.admin.framework.common.pojo.PageResult;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogRespVO;
|
||||
import com.lw.ui.request.api.BaseFeignApi;
|
||||
import feign.Param;
|
||||
import feign.QueryMap;
|
||||
import feign.RequestLine;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ApiErrorLogFeign extends BaseFeignApi {
|
||||
|
||||
|
||||
// "更新 API 错误日志的状态")
|
||||
|
||||
@RequestLine("PUT /admin-api/infra/api-error-log/update-status?id={id}&processStatus={processStatus}")
|
||||
CommonResult<Boolean> updateApiErrorLogProcess(@Param("id") Long id,
|
||||
@Param("processStatus") Integer processStatus);
|
||||
|
||||
// "获得 API 错误日志分页")
|
||||
@RequestLine("GET /admin-api/infra/api-error-log/page")
|
||||
CommonResult<PageResult<ApiErrorLogRespVO>> getApiErrorLogPage(@QueryMap Map<String,Object> pageReqVO);
|
||||
|
||||
|
||||
}
|
@ -201,7 +201,7 @@ public class MainView implements FxmlView<MainViewModel>, Initializable {
|
||||
fadeTransition.play();
|
||||
|
||||
ViewTuple<DashboardView, DashboardViewModel> viewTuple = FluentViewLoader.fxmlView(DashboardView.class).load();
|
||||
loddTab("主页", Material2AL.HOME, false, viewTuple.getView());
|
||||
// loddTab("主页", Material2AL.HOME,true, viewTuple.getView());
|
||||
MvvmFX.getNotificationCenter().subscribe("showThemePage", (key, payload) -> {
|
||||
// trigger some actions
|
||||
Platform.runLater(() -> {
|
||||
|
@ -5,6 +5,7 @@ import com.lw.dillon.admin.module.system.controller.admin.auth.vo.AuthLoginRespV
|
||||
import com.lw.dillon.admin.module.system.controller.admin.auth.vo.AuthPermissionInfoRespVO;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.dict.vo.data.DictDataSimpleRespVO;
|
||||
import com.lw.swing.request.Request;
|
||||
import com.lw.swing.subject.MenuRefrestObservable;
|
||||
import com.lw.ui.request.api.system.DictDataFeign;
|
||||
import com.lw.ui.utils.DictTypeEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -14,6 +15,7 @@ import java.awt.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Observable;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
@ -23,6 +25,7 @@ public class AppStore {
|
||||
|
||||
private static AuthLoginRespVO authLoginRespVO;
|
||||
private static AuthPermissionInfoRespVO authPermissionInfoRespVO;
|
||||
private static final MenuRefrestObservable menuRefreshObservable = new MenuRefrestObservable();
|
||||
|
||||
private static Map<String, List<DictDataSimpleRespVO>> dictDataListMap;
|
||||
|
||||
@ -208,5 +211,7 @@ public class AppStore {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static MenuRefrestObservable getMenuRefreshObservable() {
|
||||
return menuRefreshObservable;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.lw.swing.subject;
|
||||
|
||||
import java.util.Observable;
|
||||
|
||||
/**
|
||||
* 自动刷新主题
|
||||
*/
|
||||
public class AppRefreshObservable extends Observable {
|
||||
|
||||
/**
|
||||
* 界面刷新
|
||||
*/
|
||||
public void refresh() {
|
||||
setChanged();
|
||||
notifyObservers();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.lw.swing.subject;
|
||||
|
||||
import java.util.Observable;
|
||||
|
||||
/**
|
||||
* r
|
||||
*/
|
||||
public class MenuRefrestObservable extends Observable {
|
||||
|
||||
|
||||
/**
|
||||
* 日期切换
|
||||
*/
|
||||
public void refresh() {
|
||||
setChanged();
|
||||
notifyObservers();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -34,4 +34,29 @@ public class BadgeLabelUtil {
|
||||
return redBadge;
|
||||
|
||||
}
|
||||
|
||||
public static JLabel getBadgeLabel(String text, String colortype) {
|
||||
JLabel redBadge = new JLabel(text);
|
||||
switch (colortype) {
|
||||
case "primary":
|
||||
redBadge.putClientProperty(FlatClientProperties.STYLE_CLASS, "primary");
|
||||
break;
|
||||
case "success":
|
||||
redBadge.putClientProperty(FlatClientProperties.STYLE_CLASS, "success");
|
||||
break;
|
||||
case "info":
|
||||
redBadge.putClientProperty(FlatClientProperties.STYLE_CLASS, "info");
|
||||
break;
|
||||
case "warning":
|
||||
redBadge.putClientProperty(FlatClientProperties.STYLE_CLASS, "warning");
|
||||
break;
|
||||
case "danger":
|
||||
redBadge.putClientProperty(FlatClientProperties.STYLE_CLASS, "danger");
|
||||
break;
|
||||
default:
|
||||
redBadge.putClientProperty(FlatClientProperties.STYLE_CLASS, "info");
|
||||
}
|
||||
return redBadge;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,10 @@ public class MainFrame extends JFrame {
|
||||
*/
|
||||
public void showLogin() {
|
||||
|
||||
sidePane = null;
|
||||
tabbedPane = null;
|
||||
statusBar = null;
|
||||
titleMenuBar = null;
|
||||
this.showMenuBar(false);
|
||||
this.setContentPane(loginPane = new LoginPane());
|
||||
this.setResizable(false);
|
||||
@ -148,6 +152,7 @@ public class MainFrame extends JFrame {
|
||||
g2.dispose();
|
||||
}
|
||||
};
|
||||
|
||||
content.add(getSidePane(), BorderLayout.WEST);
|
||||
content.add(getStatusBar(), BorderLayout.SOUTH);
|
||||
content.add(getTabbedPane(), BorderLayout.CENTER);
|
||||
@ -238,6 +243,16 @@ public class MainFrame extends JFrame {
|
||||
tabbedPane.setFont(UIManager.getFont("Label.font").deriveFont(16f));
|
||||
tabForegroundChanged();
|
||||
|
||||
tabbedPane.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
super.mouseReleased(e);
|
||||
if (SwingUtilities.isRightMouseButton(e)) {
|
||||
showPopupMenu(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
return tabbedPane;
|
||||
}
|
||||
@ -376,7 +391,6 @@ public class MainFrame extends JFrame {
|
||||
if (sidePane == null) {
|
||||
sidePane = new SidePane();
|
||||
sidePane.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, UIManager.getColor("App.borderColor")));
|
||||
|
||||
}
|
||||
return sidePane;
|
||||
}
|
||||
@ -593,4 +607,103 @@ public class MainFrame extends JFrame {
|
||||
};
|
||||
swingWorker.execute();
|
||||
}
|
||||
|
||||
private void showPopupMenu(final MouseEvent event) {
|
||||
|
||||
// 如果当前事件与右键菜单有关(单击右键),则弹出菜单
|
||||
final int index = ((JTabbedPane) event.getComponent()).getUI().tabForCoordinate(tabbedPane, event.getX(), event.getY());
|
||||
final int count = ((JTabbedPane) event.getComponent()).getTabCount();
|
||||
final String title = tabbedPane.getTitleAt(index);
|
||||
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
JPopupMenu pop = new JPopupMenu();
|
||||
JMenuItem closeCurrent = new JMenuItem("关闭当前");
|
||||
closeCurrent.setPreferredSize(new Dimension(140, 30));
|
||||
|
||||
closeCurrent.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (tabbedPane.isTabClosableAt(index)) {
|
||||
tabbedPane.removeTabAt(index);
|
||||
}
|
||||
}
|
||||
});
|
||||
pop.add(closeCurrent);
|
||||
pop.addSeparator();
|
||||
|
||||
JMenuItem closeLeft = new JMenuItem("关闭左侧标签");
|
||||
closeLeft.setPreferredSize(new Dimension(140, 30));
|
||||
|
||||
closeLeft.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
for (int j = (index - 1); j >= 0; j--) {
|
||||
if (tabbedPane.isTabClosableAt(j)) {
|
||||
tabbedPane.removeTabAt(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
pop.add(closeLeft);
|
||||
|
||||
JMenuItem closeRight = new JMenuItem("关闭右侧标签");
|
||||
closeRight.setPreferredSize(new Dimension(140, 30));
|
||||
|
||||
closeRight.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
for (int j = (count - 1); j > index; j--) {
|
||||
if (tabbedPane.isTabClosableAt(j)) {
|
||||
tabbedPane.removeTabAt(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
closeRight.setPreferredSize(new Dimension(140, 30));
|
||||
pop.add(closeRight);
|
||||
|
||||
JMenuItem other = new JMenuItem("关闭其它标签");
|
||||
other.setPreferredSize(new Dimension(140, 30));
|
||||
|
||||
other.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
int tabCount = count;
|
||||
while (tabCount-- > 0) {
|
||||
if (title.equals(tabbedPane.getTitleAt(tabCount))) {
|
||||
continue;
|
||||
}
|
||||
if (tabbedPane.isTabClosableAt(tabCount)) {
|
||||
tabbedPane.removeTabAt(tabCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
pop.add(other);
|
||||
pop.addSeparator();
|
||||
|
||||
JMenuItem all = new JMenuItem("关闭所有标签");
|
||||
all.setPreferredSize(new Dimension(140, 30));
|
||||
|
||||
all.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
int tabCount = count;
|
||||
// We invoke removeTabAt for each tab, otherwise we may end up
|
||||
// removing Components added by the UI.
|
||||
while (tabCount-- > 0) {
|
||||
|
||||
if (tabbedPane.isTabClosableAt(tabCount)) {
|
||||
tabbedPane.removeTabAt(tabCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
pop.add(all);
|
||||
|
||||
pop.show(event.getComponent(), event.getX(), event.getY());
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,14 @@ package com.lw.swing.view;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.formdev.flatlaf.extras.FlatSVGIcon;
|
||||
import com.lw.dillon.admin.framework.common.pojo.CommonResult;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.auth.vo.AuthPermissionInfoRespVO;
|
||||
import com.lw.swing.components.WPanel;
|
||||
import com.lw.swing.components.WScrollPane;
|
||||
import com.lw.swing.request.Request;
|
||||
import com.lw.swing.store.AppStore;
|
||||
import com.lw.swing.utils.IconLoader;
|
||||
import com.lw.ui.request.api.system.AuthFeign;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jdesktop.swingx.JXTreeTable;
|
||||
import org.jdesktop.swingx.decorator.ColorHighlighter;
|
||||
@ -20,6 +23,8 @@ import javax.swing.table.JTableHeader;
|
||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
@ -27,7 +32,7 @@ import java.util.concurrent.ExecutionException;
|
||||
* @date 2024/05/09
|
||||
*/
|
||||
@Slf4j
|
||||
public class SidePane extends WPanel {
|
||||
public class SidePane extends WPanel implements Observer {
|
||||
|
||||
|
||||
private JXTreeTable treeTable;
|
||||
@ -36,7 +41,7 @@ public class SidePane extends WPanel {
|
||||
initComponents();
|
||||
initListeners();
|
||||
initData();
|
||||
|
||||
AppStore.getMenuRefreshObservable().addObserver(this);
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
@ -64,15 +69,15 @@ public class SidePane extends WPanel {
|
||||
Component component = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
|
||||
if (component instanceof JLabel) {
|
||||
if (value instanceof AuthPermissionInfoRespVO.MenuVO) {
|
||||
AuthPermissionInfoRespVO.MenuVO menuVO= (AuthPermissionInfoRespVO.MenuVO) value;
|
||||
AuthPermissionInfoRespVO.MenuVO menuVO = (AuthPermissionInfoRespVO.MenuVO) value;
|
||||
((JLabel) component).setText(menuVO.getName());
|
||||
String icon = menuVO.getIcon();
|
||||
if (StrUtil.isBlank(menuVO.getIcon())) {
|
||||
icon="icons/item.svg";
|
||||
}else if (StrUtil.contains(icon,":")){
|
||||
icon="icons/menu/"+icon.split(":")[1]+".svg";
|
||||
icon = "icons/item.svg";
|
||||
} else if (StrUtil.contains(icon, ":")) {
|
||||
icon = "icons/menu/" + icon.split(":")[1] + ".svg";
|
||||
}
|
||||
FlatSVGIcon svgIcon = IconLoader.getSvgIcon(icon,25,25);
|
||||
FlatSVGIcon svgIcon = IconLoader.getSvgIcon(icon, 25, 25);
|
||||
|
||||
|
||||
((JLabel) component).setIcon(svgIcon);
|
||||
@ -106,6 +111,9 @@ public class SidePane extends WPanel {
|
||||
|
||||
private void initListeners() {
|
||||
treeTable.addTreeSelectionListener(e -> {
|
||||
if (e.getNewLeadSelectionPath() == null) {
|
||||
return;
|
||||
}
|
||||
Object object = e.getNewLeadSelectionPath().getLastPathComponent();
|
||||
|
||||
if (object instanceof AuthPermissionInfoRespVO.MenuVO) {
|
||||
@ -193,6 +201,45 @@ public class SidePane extends WPanel {
|
||||
return container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Observable o, Object arg) {
|
||||
if (this.isDisplayable()) {
|
||||
updateData();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateData() {
|
||||
SwingWorker<AuthPermissionInfoRespVO.MenuVO, Object> swingWorker = new SwingWorker<AuthPermissionInfoRespVO.MenuVO, Object>() {
|
||||
@Override
|
||||
protected AuthPermissionInfoRespVO.MenuVO doInBackground() throws Exception {
|
||||
|
||||
|
||||
CommonResult<AuthPermissionInfoRespVO> permissionInfoRespVOCommonResult = Request.connector(AuthFeign.class).getPermissionInfo();
|
||||
AuthPermissionInfoRespVO.MenuVO rootNode = new AuthPermissionInfoRespVO.MenuVO();
|
||||
rootNode.setName("root");
|
||||
if (permissionInfoRespVOCommonResult.isSuccess()) {
|
||||
AppStore.setAuthPermissionInfoRespVO(permissionInfoRespVOCommonResult.getData());
|
||||
|
||||
rootNode.setChildren(AppStore.getMenus());
|
||||
}
|
||||
|
||||
|
||||
return rootNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
updateTreeTableRoot(get());
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
}
|
||||
|
||||
class MenuModel extends AbstractTreeTableModel {
|
||||
|
||||
|
@ -0,0 +1,463 @@
|
||||
/*
|
||||
* Created by JFormDesigner on Thu Jun 13 19:52:21 CST 2024
|
||||
*/
|
||||
|
||||
package com.lw.swing.view.intra.apilog;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.formdev.flatlaf.extras.FlatSVGIcon;
|
||||
import com.lw.dillon.admin.framework.common.pojo.CommonResult;
|
||||
import com.lw.dillon.admin.framework.common.pojo.PageResult;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogRespVO;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.dict.vo.data.DictDataSimpleRespVO;
|
||||
import com.lw.swing.components.*;
|
||||
import com.lw.swing.components.table.renderer.OptButtonTableCellEditor;
|
||||
import com.lw.swing.components.table.renderer.OptButtonTableCellRenderer;
|
||||
import com.lw.swing.request.Request;
|
||||
import com.lw.swing.store.AppStore;
|
||||
import com.lw.swing.utils.BadgeLabelUtil;
|
||||
import com.lw.ui.request.api.apilog.ApiAccessLogFeign;
|
||||
import com.lw.ui.utils.DictTypeEnum;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.jdesktop.swingx.JXTable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static com.lw.ui.utils.DictTypeEnum.INFRA_OPERATE_TYPE;
|
||||
import static com.lw.ui.utils.DictTypeEnum.USER_TYPE;
|
||||
import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
|
||||
import static javax.swing.JOptionPane.PLAIN_MESSAGE;
|
||||
|
||||
/**
|
||||
* @author wenli
|
||||
*/
|
||||
public class ApiAccessLogPane extends JPanel {
|
||||
private String[] COLUMN_ID = {"日志编号", "用户编号", "用户类型", "应用名", "请求方法", "请求地址", "请求时间", "执行时长", "操作结果", "操作模块", "操作名", "操作类型", "操作"};
|
||||
|
||||
private DefaultTableModel tableModel;
|
||||
|
||||
private WPaginationPane paginationPane;
|
||||
|
||||
public ApiAccessLogPane() {
|
||||
initComponents();
|
||||
initListeners();
|
||||
updateData();
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
textField = new JTextField();
|
||||
scrollPane1 = new WScrollPane();
|
||||
centerPane = new JPanel();
|
||||
scrollPane2 = new WScrollPane();
|
||||
table = new JXTable(tableModel = new DefaultTableModel());
|
||||
toolPane = new WPanel();
|
||||
label7 = new JLabel();
|
||||
userIdField = new JTextField();
|
||||
label8 = new JLabel();
|
||||
applicationNameFiele = new JTextField();
|
||||
label9 = new JLabel();
|
||||
durationField = new JTextField();
|
||||
resultCodeField = new JTextField();
|
||||
userTypeComboBox = new JComboBox();
|
||||
label10 = new JLabel();
|
||||
startDateTextField = new WLocalDateCombo();
|
||||
label11 = new JLabel();
|
||||
endDateTextField = new WLocalDateCombo();
|
||||
searchBut = new JButton();
|
||||
reseBut = new JButton();
|
||||
|
||||
//======== this ========
|
||||
setOpaque(false);
|
||||
setLayout(new BorderLayout(10, 10));
|
||||
|
||||
|
||||
//======== centerPane ========
|
||||
{
|
||||
centerPane.setOpaque(false);
|
||||
centerPane.setLayout(new BorderLayout(10, 10));
|
||||
|
||||
//======== scrollPane2 ========
|
||||
{
|
||||
tableModel.setColumnIdentifiers(COLUMN_ID);
|
||||
scrollPane2.setViewportView(table);
|
||||
}
|
||||
|
||||
JPanel panel = new WPanel();
|
||||
panel.setLayout(new BorderLayout());
|
||||
panel.add(scrollPane2);
|
||||
paginationPane = new WPaginationPane() {
|
||||
@Override
|
||||
public void setPageIndex(long pageIndex) {
|
||||
super.setPageIndex(pageIndex);
|
||||
updateData();
|
||||
}
|
||||
};
|
||||
paginationPane.setOpaque(false);
|
||||
panel.add(paginationPane, BorderLayout.SOUTH);
|
||||
centerPane.add(panel, BorderLayout.CENTER);
|
||||
|
||||
//======== toolPane ========
|
||||
{
|
||||
toolPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[left]",
|
||||
// rows
|
||||
"[]"));
|
||||
toolPane.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||
//---- label7 ----
|
||||
label7.setText("用户编号");
|
||||
toolPane.add(label7, "cell 0 0");
|
||||
|
||||
//---- userNameTextField ----
|
||||
userIdField.setColumns(15);
|
||||
toolPane.add(userIdField, "cell 0 0");
|
||||
|
||||
toolPane.add(new JLabel("用户类型"), "cell 0 0");
|
||||
toolPane.add(userTypeComboBox, "cell 0 0");
|
||||
|
||||
//---- label8 ----
|
||||
label8.setText("应用名");
|
||||
toolPane.add(label8, "cell 0 0");
|
||||
|
||||
//---- phoneTextField ----
|
||||
applicationNameFiele.setColumns(15);
|
||||
toolPane.add(applicationNameFiele, "cell 0 0");
|
||||
|
||||
|
||||
//---- label9 ----
|
||||
label9.setText("执行时长");
|
||||
toolPane.add(label9, "cell 0 0");
|
||||
toolPane.add(durationField, "cell 0 0");
|
||||
toolPane.add(new JLabel("结果码"), "cell 0 0");
|
||||
resultCodeField.setColumns(15);
|
||||
toolPane.add(resultCodeField, "cell 0 0");
|
||||
|
||||
|
||||
//---- label10 ----
|
||||
label10.setText("请求时间");
|
||||
toolPane.add(label10, "cell 0 0");
|
||||
|
||||
//---- startDateTextField ----
|
||||
toolPane.add(startDateTextField, "cell 0 0");
|
||||
|
||||
//---- label11 ----
|
||||
label11.setText("-");
|
||||
toolPane.add(label11, "cell 0 0");
|
||||
|
||||
//---- endDateTextField ----
|
||||
toolPane.add(endDateTextField, "cell 0 0");
|
||||
|
||||
//---- button1 ----
|
||||
searchBut.setText("搜索");
|
||||
toolPane.add(searchBut, "cell 0 0");
|
||||
|
||||
//---- reseBut ----
|
||||
reseBut.setText("重置");
|
||||
toolPane.add(reseBut, "cell 0 0");
|
||||
|
||||
|
||||
}
|
||||
centerPane.add(toolPane, BorderLayout.NORTH);
|
||||
}
|
||||
add(centerPane, BorderLayout.CENTER);
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents @formatter:on
|
||||
|
||||
table.setRowHeight(40);
|
||||
|
||||
|
||||
startDateTextField.setValue(null);
|
||||
endDateTextField.setValue(null);
|
||||
table.setDefaultRenderer(Object.class, new CenterTableCellRenderer());
|
||||
|
||||
AppStore.getDictDataList(USER_TYPE).forEach(dictDataSimpleRespVO -> {
|
||||
userTypeComboBox.addItem(dictDataSimpleRespVO);
|
||||
});
|
||||
|
||||
userTypeComboBox.setSelectedItem(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
if (table != null) {
|
||||
table.setDefaultRenderer(Object.class, new CenterTableCellRenderer());
|
||||
}
|
||||
}
|
||||
|
||||
private JToolBar creatBar() {
|
||||
JToolBar optBar = new JToolBar();
|
||||
optBar.setOpaque(false);
|
||||
JButton viewBut = new JButton("详情");
|
||||
viewBut.setForeground(UIManager.getColor("App.accentColor"));
|
||||
viewBut.setIcon(new FlatSVGIcon("icons/chakan.svg", 15, 15));
|
||||
viewBut.addActionListener(e -> showDetailsDialog());
|
||||
|
||||
|
||||
optBar.add(Box.createGlue());
|
||||
optBar.add(viewBut);
|
||||
optBar.add(Box.createGlue());
|
||||
return optBar;
|
||||
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
|
||||
reseBut.addActionListener(e -> reset());
|
||||
searchBut.addActionListener(e -> updateData());
|
||||
}
|
||||
|
||||
private void showDetailsDialog() {
|
||||
|
||||
|
||||
int selRow = table.getSelectedRow();
|
||||
ApiAccessLogRespVO respVO = null;
|
||||
if (selRow != -1) {
|
||||
respVO = (ApiAccessLogRespVO) table.getValueAt(selRow, COLUMN_ID.length - 1);
|
||||
}
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill][grow,fill]",
|
||||
// rows
|
||||
"[][][][][][][][][][][][][][][]"));
|
||||
panel.setPreferredSize(new Dimension(450, 600));
|
||||
addMessageInfo("日志主键", respVO.getId(), panel, 0);
|
||||
addMessageInfo("链路追踪", respVO.getTraceId(), panel, 1);
|
||||
addMessageInfo("应用名", respVO.getApplicationName(), panel, 2);
|
||||
addMessageInfo("用户信息", USER_TYPE, respVO.getUserType(), panel, 3);
|
||||
addMessageInfo("用户 IP", respVO.getUserIp(), panel, 4);
|
||||
addMessageInfo("用户 UA", respVO.getUserAgent(), panel, 5);
|
||||
addMessageInfo("请求信息", respVO.getRequestMethod() + " " + respVO.getRequestUrl(), panel, 6);
|
||||
addMessageInfo("请求参数", respVO.getRequestParams(), panel, 7);
|
||||
addMessageInfo("请求结果", respVO.getResponseBody(), panel, 8);
|
||||
addMessageInfo("请求时间", DateUtil.format(respVO.getBeginTime(), "yyyy-MM-dd HH:mm:ss") + " ~ " + DateUtil.format(respVO.getEndTime(), "yyyy-MM-dd HH:mm:ss"), panel, 9);
|
||||
addMessageInfo("请求耗时", respVO.getDuration() + " ms", panel, 10);
|
||||
addMessageInfoArea("操作结果", respVO.getResultCode() == 0 ? "正常" : "失败 | " + respVO.getResultCode() + " | " + respVO.getResultMsg(), panel, 11);
|
||||
addMessageInfo("操作模块", respVO.getOperateModule(), panel, 12);
|
||||
addMessageInfo("操作名", respVO.getOperateName(), panel, 13);
|
||||
addMessageInfo("操作名类型", INFRA_OPERATE_TYPE, respVO.getOperateType(), panel, 14);
|
||||
|
||||
|
||||
WOptionPane.showOptionDialog(null, panel, "详情", OK_CANCEL_OPTION, PLAIN_MESSAGE, null, new Object[]{"确定", "取消"}, "确定");
|
||||
|
||||
}
|
||||
|
||||
private void addMessageInfoArea(String text, Object value, JPanel panel, int row) {
|
||||
|
||||
|
||||
JLabel label = new JLabel(text);
|
||||
JTextArea textField = new JTextArea(value + "");
|
||||
textField.setEditable(false);
|
||||
textField.setLineWrap(true);
|
||||
|
||||
panel.add(label, "cell 0 " + row);
|
||||
panel.add(new JScrollPane(textField), "cell 1 " + row + ",grow");
|
||||
}
|
||||
|
||||
private void addMessageInfo(String text, Object value, JPanel panel, int row) {
|
||||
JLabel label = new JLabel(text);
|
||||
JTextField textField = new JTextField(Convert.toStr(value));
|
||||
textField.setEditable(false);
|
||||
|
||||
panel.add(label, "cell 0 " + row);
|
||||
panel.add(textField, "cell 1 " + row);
|
||||
}
|
||||
|
||||
private void addMessageInfo(String text, DictTypeEnum dictType, Object value, JPanel panel, int row) {
|
||||
|
||||
|
||||
JLabel label = new JLabel(text);
|
||||
JLabel badge = BadgeLabelUtil.getBadgeLabel(dictType, value);
|
||||
|
||||
|
||||
panel.add(label, "cell 0 " + row);
|
||||
panel.add(badge, "cell 1 " + row + ",alignx left,growx 0");
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
userIdField.setText("");
|
||||
durationField.setText("");
|
||||
resultCodeField.setText("");
|
||||
applicationNameFiele.setText("");
|
||||
userTypeComboBox.setSelectedItem(null);
|
||||
startDateTextField.setValue(null);
|
||||
endDateTextField.setValue(null);
|
||||
updateData();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void updateData() {
|
||||
|
||||
Map<String, Object> queryMap = new HashMap<>();
|
||||
queryMap.put("pageNo", paginationPane.getPageIndex());
|
||||
queryMap.put("pageSize", paginationPane.getPageSize());
|
||||
|
||||
if (StrUtil.isNotBlank(userIdField.getText())) {
|
||||
queryMap.put("userId", userIdField.getText());
|
||||
}
|
||||
if (StrUtil.isNotBlank(applicationNameFiele.getText())) {
|
||||
queryMap.put("applicationName", applicationNameFiele.getText());
|
||||
}
|
||||
if (StrUtil.isNotBlank(durationField.getText())) {
|
||||
queryMap.put("duration", durationField.getText());
|
||||
}
|
||||
if (StrUtil.isNotBlank(resultCodeField.getText())) {
|
||||
queryMap.put("resultCode", resultCodeField.getText());
|
||||
}
|
||||
|
||||
if (userTypeComboBox.getSelectedItem() != null) {
|
||||
DictDataSimpleRespVO selectedItem = (DictDataSimpleRespVO) userTypeComboBox.getSelectedItem();
|
||||
queryMap.put("userType", selectedItem.getValue());
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isAllNotEmpty(startDateTextField.getValue(), endDateTextField.getValue())) {
|
||||
String[] dateTimes = new String[2];
|
||||
dateTimes[0] = DateUtil.format(startDateTextField.getValue().atTime(0, 0, 0), "yyyy-MM-dd HH:mm:ss");
|
||||
dateTimes[1] = DateUtil.format(endDateTextField.getValue().atTime(23, 59, 59), "yyyy-MM-dd HH:mm:ss");
|
||||
queryMap.put("beginTime", dateTimes);
|
||||
}
|
||||
|
||||
SwingWorker<Vector<Vector>, Long> swingWorker = new SwingWorker<Vector<Vector>, Long>() {
|
||||
@Override
|
||||
protected Vector<Vector> doInBackground() throws Exception {
|
||||
CommonResult<PageResult<ApiAccessLogRespVO>> result = Request.connector(ApiAccessLogFeign.class).getApiAccessLogPage(queryMap);
|
||||
|
||||
Vector<Vector> tableData = new Vector<>();
|
||||
|
||||
|
||||
if (result.isSuccess()) {
|
||||
|
||||
result.getData().getList().forEach(respVO -> {
|
||||
Vector rowV = new Vector();
|
||||
rowV.add(respVO.getId());
|
||||
rowV.add(respVO.getUserId());
|
||||
rowV.add(respVO.getUserType());
|
||||
rowV.add(respVO.getApplicationName());
|
||||
rowV.add(respVO.getRequestMethod());
|
||||
rowV.add(respVO.getRequestUrl());
|
||||
rowV.add(DateUtil.format(respVO.getBeginTime(), "yyyy-MM-dd HH:mm:ss"));
|
||||
rowV.add(respVO.getDuration() + " ms");
|
||||
rowV.add(respVO.getResultCode());
|
||||
rowV.add(respVO.getOperateModule());
|
||||
rowV.add(respVO.getOperateName());
|
||||
rowV.add(respVO.getOperateType());
|
||||
rowV.add(respVO);
|
||||
tableData.add(rowV);
|
||||
});
|
||||
|
||||
publish(result.getData().getTotal());
|
||||
}
|
||||
return tableData;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void process(List<Long> chunks) {
|
||||
chunks.forEach(total -> paginationPane.setTotal(total));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
|
||||
|
||||
tableModel.setDataVector(get(), new Vector<>(Arrays.asList(COLUMN_ID)));
|
||||
table.getColumn("操作").setCellRenderer(new OptButtonTableCellRenderer(creatBar()));
|
||||
table.getColumn("操作").setCellEditor(new OptButtonTableCellEditor(creatBar()));
|
||||
|
||||
table.getColumn("用户类型").setCellRenderer(new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 10));
|
||||
JLabel label = BadgeLabelUtil.getBadgeLabel(USER_TYPE, value);
|
||||
|
||||
panel.add(label);
|
||||
panel.setBackground(component.getBackground());
|
||||
panel.setOpaque(isSelected);
|
||||
return panel;
|
||||
}
|
||||
});
|
||||
table.getColumn("操作类型").setCellRenderer(new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 10));
|
||||
JLabel label = BadgeLabelUtil.getBadgeLabel(INFRA_OPERATE_TYPE, value);
|
||||
|
||||
panel.add(label);
|
||||
panel.setBackground(component.getBackground());
|
||||
panel.setOpaque(isSelected);
|
||||
return panel;
|
||||
}
|
||||
});
|
||||
table.getColumn("操作结果").setCellRenderer(new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 10));
|
||||
JLabel label = null;
|
||||
if (Convert.toInt(value, 1) == 0) {
|
||||
label = BadgeLabelUtil.getBadgeLabel("成功", "primary");
|
||||
} else {
|
||||
label = BadgeLabelUtil.getBadgeLabel("失败", "danger");
|
||||
}
|
||||
|
||||
panel.add(label);
|
||||
panel.setBackground(component.getBackground());
|
||||
panel.setOpaque(isSelected);
|
||||
return panel;
|
||||
}
|
||||
});
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
|
||||
}
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables @formatter:off
|
||||
// Generated using JFormDesigner non-commercial license
|
||||
private JTextField textField;
|
||||
private JScrollPane scrollPane1;
|
||||
private JPanel centerPane;
|
||||
private JScrollPane scrollPane2;
|
||||
private JTable table;
|
||||
private JPanel toolPane;
|
||||
private JLabel label7;
|
||||
private JTextField userIdField;
|
||||
private JLabel label8;
|
||||
private JTextField applicationNameFiele;
|
||||
private JLabel label9;
|
||||
private JTextField durationField;
|
||||
private JTextField resultCodeField;
|
||||
private JComboBox userTypeComboBox;
|
||||
private JLabel label10;
|
||||
private WLocalDateCombo startDateTextField;
|
||||
private JLabel label11;
|
||||
private WLocalDateCombo endDateTextField;
|
||||
private JButton searchBut;
|
||||
private JButton reseBut;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables @formatter:on
|
||||
}
|
@ -0,0 +1,475 @@
|
||||
/*
|
||||
* Created by JFormDesigner on Thu Jun 13 19:52:21 CST 2024
|
||||
*/
|
||||
|
||||
package com.lw.swing.view.intra.apilog;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.formdev.flatlaf.extras.FlatSVGIcon;
|
||||
import com.lw.dillon.admin.framework.common.pojo.CommonResult;
|
||||
import com.lw.dillon.admin.framework.common.pojo.PageResult;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogRespVO;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.dict.vo.data.DictDataSimpleRespVO;
|
||||
import com.lw.swing.components.*;
|
||||
import com.lw.swing.components.table.renderer.OptButtonTableCellEditor;
|
||||
import com.lw.swing.components.table.renderer.OptButtonTableCellRenderer;
|
||||
import com.lw.swing.request.Request;
|
||||
import com.lw.swing.store.AppStore;
|
||||
import com.lw.swing.utils.BadgeLabelUtil;
|
||||
import com.lw.ui.request.api.apilog.ApiErrorLogFeign;
|
||||
import com.lw.ui.utils.DictTypeEnum;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.jdesktop.swingx.JXTable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static com.lw.ui.utils.DictTypeEnum.*;
|
||||
import static javax.swing.JOptionPane.*;
|
||||
|
||||
/**
|
||||
* @author wenli
|
||||
*/
|
||||
public class ApiErrorLogPane extends JPanel {
|
||||
private String[] COLUMN_ID = {"日志编号", "用户编号", "用户类型", "应用名", "请求方法", "请求地址", "异常发生时间", "异常名", "处理状态", "操作"};
|
||||
|
||||
private DefaultTableModel tableModel;
|
||||
|
||||
private WPaginationPane paginationPane;
|
||||
|
||||
public ApiErrorLogPane() {
|
||||
initComponents();
|
||||
initListeners();
|
||||
updateData();
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
textField = new JTextField();
|
||||
scrollPane1 = new WScrollPane();
|
||||
centerPane = new JPanel();
|
||||
scrollPane2 = new WScrollPane();
|
||||
table = new JXTable(tableModel = new DefaultTableModel());
|
||||
toolPane = new WPanel();
|
||||
label7 = new JLabel();
|
||||
userIdField = new JTextField();
|
||||
label8 = new JLabel();
|
||||
applicationNameFiele = new JTextField();
|
||||
label9 = new JLabel();
|
||||
processStatusComboBox = new JComboBox();
|
||||
userTypeComboBox = new JComboBox();
|
||||
label10 = new JLabel();
|
||||
startDateTextField = new WLocalDateCombo();
|
||||
label11 = new JLabel();
|
||||
endDateTextField = new WLocalDateCombo();
|
||||
searchBut = new JButton();
|
||||
reseBut = new JButton();
|
||||
|
||||
//======== this ========
|
||||
setOpaque(false);
|
||||
setLayout(new BorderLayout(10, 10));
|
||||
|
||||
|
||||
//======== centerPane ========
|
||||
{
|
||||
centerPane.setOpaque(false);
|
||||
centerPane.setLayout(new BorderLayout(10, 10));
|
||||
|
||||
//======== scrollPane2 ========
|
||||
{
|
||||
tableModel.setColumnIdentifiers(COLUMN_ID);
|
||||
scrollPane2.setViewportView(table);
|
||||
}
|
||||
|
||||
JPanel panel = new WPanel();
|
||||
panel.setLayout(new BorderLayout());
|
||||
panel.add(scrollPane2);
|
||||
paginationPane = new WPaginationPane() {
|
||||
@Override
|
||||
public void setPageIndex(long pageIndex) {
|
||||
super.setPageIndex(pageIndex);
|
||||
updateData();
|
||||
}
|
||||
};
|
||||
paginationPane.setOpaque(false);
|
||||
panel.add(paginationPane, BorderLayout.SOUTH);
|
||||
centerPane.add(panel, BorderLayout.CENTER);
|
||||
|
||||
//======== toolPane ========
|
||||
{
|
||||
toolPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[left]",
|
||||
// rows
|
||||
"[]"));
|
||||
toolPane.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||
//---- label7 ----
|
||||
label7.setText("用户编号");
|
||||
toolPane.add(label7, "cell 0 0");
|
||||
|
||||
//---- userNameTextField ----
|
||||
userIdField.setColumns(15);
|
||||
toolPane.add(userIdField, "cell 0 0");
|
||||
|
||||
toolPane.add(new JLabel("用户类型"), "cell 0 0");
|
||||
toolPane.add(userTypeComboBox, "cell 0 0");
|
||||
|
||||
//---- label8 ----
|
||||
label8.setText("应用名");
|
||||
toolPane.add(label8, "cell 0 0");
|
||||
|
||||
//---- phoneTextField ----
|
||||
applicationNameFiele.setColumns(15);
|
||||
toolPane.add(applicationNameFiele, "cell 0 0");
|
||||
|
||||
|
||||
//---- label9 ----
|
||||
label9.setText("处理状态");
|
||||
toolPane.add(label9, "cell 0 0");
|
||||
toolPane.add(processStatusComboBox, "cell 0 0");
|
||||
|
||||
//---- label10 ----
|
||||
label10.setText("异常时间");
|
||||
toolPane.add(label10, "cell 0 0");
|
||||
|
||||
//---- startDateTextField ----
|
||||
toolPane.add(startDateTextField, "cell 0 0");
|
||||
|
||||
//---- label11 ----
|
||||
label11.setText("-");
|
||||
toolPane.add(label11, "cell 0 0");
|
||||
|
||||
//---- endDateTextField ----
|
||||
toolPane.add(endDateTextField, "cell 0 0");
|
||||
|
||||
//---- button1 ----
|
||||
searchBut.setText("搜索");
|
||||
toolPane.add(searchBut, "cell 0 0");
|
||||
|
||||
//---- reseBut ----
|
||||
reseBut.setText("重置");
|
||||
toolPane.add(reseBut, "cell 0 0");
|
||||
|
||||
|
||||
}
|
||||
centerPane.add(toolPane, BorderLayout.NORTH);
|
||||
}
|
||||
add(centerPane, BorderLayout.CENTER);
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents @formatter:on
|
||||
|
||||
table.setRowHeight(40);
|
||||
|
||||
|
||||
startDateTextField.setValue(null);
|
||||
endDateTextField.setValue(null);
|
||||
table.setDefaultRenderer(Object.class, new CenterTableCellRenderer());
|
||||
|
||||
AppStore.getDictDataList(USER_TYPE).forEach(dictDataSimpleRespVO -> {
|
||||
userTypeComboBox.addItem(dictDataSimpleRespVO);
|
||||
});
|
||||
AppStore.getDictDataList(INFRA_API_ERROR_LOG_PROCESS_STATUS).forEach(dictDataSimpleRespVO -> {
|
||||
processStatusComboBox.addItem(dictDataSimpleRespVO);
|
||||
});
|
||||
userTypeComboBox.setSelectedItem(null);
|
||||
processStatusComboBox.setSelectedItem(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
if (table != null) {
|
||||
table.setDefaultRenderer(Object.class, new CenterTableCellRenderer());
|
||||
}
|
||||
}
|
||||
|
||||
private JToolBar creatBar() {
|
||||
JToolBar optBar = new JToolBar();
|
||||
optBar.setOpaque(false);
|
||||
JButton viewBut = new JButton("详情");
|
||||
viewBut.setForeground(UIManager.getColor("App.accentColor"));
|
||||
viewBut.setIcon(new FlatSVGIcon("icons/chakan.svg", 15, 15));
|
||||
viewBut.addActionListener(e -> showDetailsDialog());
|
||||
|
||||
JButton processedBut = new JButton("已处理");
|
||||
processedBut.addActionListener(e -> processed(1));
|
||||
processedBut.setForeground(UIManager.getColor("App.accentColor"));
|
||||
|
||||
JButton ignoredBut = new JButton("已忽略");
|
||||
ignoredBut.addActionListener(e -> processed(2));
|
||||
ignoredBut.setForeground(UIManager.getColor("App.accentColor"));
|
||||
|
||||
optBar.add(Box.createGlue());
|
||||
optBar.add(viewBut);
|
||||
optBar.add(processedBut);
|
||||
optBar.add(ignoredBut);
|
||||
optBar.add(Box.createGlue());
|
||||
return optBar;
|
||||
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
|
||||
reseBut.addActionListener(e -> reset());
|
||||
searchBut.addActionListener(e -> updateData());
|
||||
}
|
||||
|
||||
private void showDetailsDialog() {
|
||||
|
||||
|
||||
int selRow = table.getSelectedRow();
|
||||
ApiErrorLogRespVO respVO = null;
|
||||
if (selRow != -1) {
|
||||
respVO = (ApiErrorLogRespVO) table.getValueAt(selRow, COLUMN_ID.length - 1);
|
||||
}
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill][grow,fill]",
|
||||
// rows
|
||||
"[][][][][][][]"));
|
||||
panel.setPreferredSize(new Dimension(450, 600));
|
||||
addMessageInfo("日志主键", respVO.getId(), panel, 0);
|
||||
addMessageInfo("链路追踪", respVO.getTraceId(), panel, 1);
|
||||
addMessageInfo("应用名", respVO.getApplicationName(), panel, 2);
|
||||
addMessageInfo("用户编号", respVO.getUserId(), panel, 3);
|
||||
addMessageInfo("用户 IP", respVO.getUserIp(), panel, 4);
|
||||
addMessageInfo("用户 UA", respVO.getUserAgent(), panel, 5);
|
||||
addMessageInfo("请求信息", respVO.getRequestMethod()+" "+respVO.getRequestUrl(), panel, 6);
|
||||
addMessageInfo("请求参数", respVO.getRequestParams(), panel, 7);
|
||||
addMessageInfo("异常时间", DateUtil.format(respVO.getExceptionTime(), "yyyy-MM-dd HH:mm:ss"), panel, 8);
|
||||
addMessageInfo("异常名", respVO.getExceptionName(), panel, 9);
|
||||
addMessageInfoArea("异常堆栈", respVO.getExceptionStackTrace(), panel, 10);
|
||||
addMessageInfo("处理状态", INFRA_API_ERROR_LOG_PROCESS_STATUS, respVO.getProcessStatus(), panel, 11);
|
||||
addMessageInfo("处理人", respVO.getProcessUserId(), panel, 12);
|
||||
addMessageInfo("处理时间", DateUtil.format(respVO.getProcessTime(), "yyyy-MM-dd HH:mm:ss"), panel, 13);
|
||||
|
||||
|
||||
WOptionPane.showOptionDialog(null, panel, "详情", OK_CANCEL_OPTION, PLAIN_MESSAGE, null, new Object[]{"确定", "取消"}, "确定");
|
||||
|
||||
}
|
||||
private void addMessageInfoArea(String text, Object value, JPanel panel, int row) {
|
||||
|
||||
|
||||
JLabel label = new JLabel(text);
|
||||
JTextArea textField = new JTextArea(value+"");
|
||||
textField.setEditable(false);
|
||||
textField.setLineWrap(true);
|
||||
|
||||
panel.add(label, "cell 0 " + row);
|
||||
panel.add(new JScrollPane(textField), "cell 1 " + row+",grow");
|
||||
}
|
||||
private void addMessageInfo(String text, Object value, JPanel panel, int row) {
|
||||
JLabel label = new JLabel(text);
|
||||
JTextField textField = new JTextField(Convert.toStr(value));
|
||||
textField.setEditable(false);
|
||||
|
||||
panel.add(label, "cell 0 " + row);
|
||||
panel.add(textField, "cell 1 " + row);
|
||||
}
|
||||
|
||||
private void addMessageInfo(String text, DictTypeEnum dictType, Object value, JPanel panel, int row) {
|
||||
|
||||
|
||||
JLabel label = new JLabel(text);
|
||||
JLabel badge = BadgeLabelUtil.getBadgeLabel(dictType, value);
|
||||
|
||||
|
||||
panel.add(label, "cell 0 " + row);
|
||||
panel.add(badge, "cell 1 " + row + ",alignx left,growx 0");
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
userIdField.setText("");
|
||||
applicationNameFiele.setText("");
|
||||
processStatusComboBox.setSelectedItem(null);
|
||||
userTypeComboBox.setSelectedItem(null);
|
||||
startDateTextField.setValue(null);
|
||||
endDateTextField.setValue(null);
|
||||
updateData();
|
||||
}
|
||||
|
||||
|
||||
private void processed(int processStatus) {
|
||||
Long userId = null;
|
||||
|
||||
int selRow = table.getSelectedRow();
|
||||
if (selRow != -1) {
|
||||
userId = Convert.toLong(table.getValueAt(selRow, 0));
|
||||
}
|
||||
|
||||
int opt = WOptionPane.showOptionDialog(this, "确认标记为" + (processStatus == 1 ? "已处理" : "已忽略") + "?", "提示", OK_CANCEL_OPTION, WARNING_MESSAGE, null, null, null);
|
||||
|
||||
if (opt != 0) {
|
||||
return;
|
||||
}
|
||||
Long finalUserId = userId;
|
||||
SwingWorker<CommonResult<Boolean>, Object> swingWorker = new SwingWorker<CommonResult<Boolean>, Object>() {
|
||||
@Override
|
||||
protected CommonResult<Boolean> doInBackground() throws Exception {
|
||||
return Request.connector(ApiErrorLogFeign.class).updateApiErrorLogProcess(finalUserId, processStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
if (get().isSuccess()) {
|
||||
updateData();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void updateData() {
|
||||
|
||||
Map<String, Object> queryMap = new HashMap<>();
|
||||
queryMap.put("pageNo", paginationPane.getPageIndex());
|
||||
queryMap.put("pageSize", paginationPane.getPageSize());
|
||||
|
||||
if (StrUtil.isNotBlank(userIdField.getText())) {
|
||||
queryMap.put("userId", userIdField.getText());
|
||||
}
|
||||
if (StrUtil.isNotBlank(applicationNameFiele.getText())) {
|
||||
queryMap.put("applicationName", applicationNameFiele.getText());
|
||||
}
|
||||
|
||||
if (userTypeComboBox.getSelectedItem() != null) {
|
||||
DictDataSimpleRespVO selectedItem = (DictDataSimpleRespVO) userTypeComboBox.getSelectedItem();
|
||||
queryMap.put("userType", selectedItem.getValue());
|
||||
}
|
||||
if (processStatusComboBox.getSelectedItem() != null) {
|
||||
DictDataSimpleRespVO selectedItem = (DictDataSimpleRespVO) processStatusComboBox.getSelectedItem();
|
||||
queryMap.put("processStatus", selectedItem.getValue());
|
||||
}
|
||||
|
||||
if (ObjectUtil.isAllNotEmpty(startDateTextField.getValue(), endDateTextField.getValue())) {
|
||||
String[] dateTimes = new String[2];
|
||||
dateTimes[0] = DateUtil.format(startDateTextField.getValue().atTime(0, 0, 0), "yyyy-MM-dd HH:mm:ss");
|
||||
dateTimes[1] = DateUtil.format(endDateTextField.getValue().atTime(23, 59, 59), "yyyy-MM-dd HH:mm:ss");
|
||||
queryMap.put("createTime", dateTimes);
|
||||
}
|
||||
|
||||
SwingWorker<Vector<Vector>, Long> swingWorker = new SwingWorker<Vector<Vector>, Long>() {
|
||||
@Override
|
||||
protected Vector<Vector> doInBackground() throws Exception {
|
||||
CommonResult<PageResult<ApiErrorLogRespVO>> result = Request.connector(ApiErrorLogFeign.class).getApiErrorLogPage(queryMap);
|
||||
|
||||
Vector<Vector> tableData = new Vector<>();
|
||||
|
||||
|
||||
if (result.isSuccess()) {
|
||||
|
||||
result.getData().getList().forEach(respVO -> {
|
||||
Vector rowV = new Vector();
|
||||
rowV.add(respVO.getId());
|
||||
rowV.add(respVO.getUserId());
|
||||
rowV.add(respVO.getUserType());
|
||||
rowV.add(respVO.getApplicationName());
|
||||
rowV.add(respVO.getRequestMethod());
|
||||
rowV.add(respVO.getRequestUrl());
|
||||
rowV.add(DateUtil.format(respVO.getExceptionTime(), "yyyy-MM-dd HH:mm:ss"));
|
||||
rowV.add(respVO.getExceptionName());
|
||||
rowV.add(respVO.getProcessStatus());
|
||||
rowV.add(respVO);
|
||||
tableData.add(rowV);
|
||||
});
|
||||
|
||||
publish(result.getData().getTotal());
|
||||
}
|
||||
return tableData;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void process(List<Long> chunks) {
|
||||
chunks.forEach(total -> paginationPane.setTotal(total));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
|
||||
|
||||
tableModel.setDataVector(get(), new Vector<>(Arrays.asList(COLUMN_ID)));
|
||||
table.getColumn("操作").setCellRenderer(new OptButtonTableCellRenderer(creatBar()));
|
||||
table.getColumn("操作").setCellEditor(new OptButtonTableCellEditor(creatBar()));
|
||||
|
||||
table.getColumn("用户类型").setCellRenderer(new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 10));
|
||||
JLabel label = BadgeLabelUtil.getBadgeLabel(USER_TYPE, value);
|
||||
|
||||
panel.add(label);
|
||||
panel.setBackground(component.getBackground());
|
||||
panel.setOpaque(isSelected);
|
||||
return panel;
|
||||
}
|
||||
});
|
||||
table.getColumn("处理状态").setCellRenderer(new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 10));
|
||||
JLabel label = BadgeLabelUtil.getBadgeLabel(INFRA_API_ERROR_LOG_PROCESS_STATUS, value);
|
||||
|
||||
panel.add(label);
|
||||
panel.setBackground(component.getBackground());
|
||||
panel.setOpaque(isSelected);
|
||||
return panel;
|
||||
}
|
||||
});
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
|
||||
}
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables @formatter:off
|
||||
// Generated using JFormDesigner non-commercial license
|
||||
private JTextField textField;
|
||||
private JScrollPane scrollPane1;
|
||||
private JPanel centerPane;
|
||||
private JScrollPane scrollPane2;
|
||||
private JTable table;
|
||||
private JPanel toolPane;
|
||||
private JLabel label7;
|
||||
private JTextField userIdField;
|
||||
private JLabel label8;
|
||||
private JTextField applicationNameFiele;
|
||||
private JLabel label9;
|
||||
private JComboBox processStatusComboBox;
|
||||
private JComboBox userTypeComboBox;
|
||||
private JLabel label10;
|
||||
private WLocalDateCombo startDateTextField;
|
||||
private JLabel label11;
|
||||
private WLocalDateCombo endDateTextField;
|
||||
private JButton searchBut;
|
||||
private JButton reseBut;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables @formatter:on
|
||||
}
|
@ -17,6 +17,7 @@ import com.lw.swing.components.notice.WMessage;
|
||||
import com.lw.swing.components.table.renderer.OptButtonTableCellEditor;
|
||||
import com.lw.swing.components.table.renderer.OptButtonTableCellRenderer;
|
||||
import com.lw.swing.request.Request;
|
||||
import com.lw.swing.store.AppStore;
|
||||
import com.lw.swing.view.MainFrame;
|
||||
import com.lw.ui.request.api.system.MenuFeign;
|
||||
import org.jdesktop.swingx.JXTreeTable;
|
||||
@ -50,7 +51,7 @@ public class MenuManagementPanel extends JPanel implements Observer {
|
||||
|
||||
private JTextField nameTextField;
|
||||
private JComboBox statusCombo;
|
||||
|
||||
private JToggleButton exButton;
|
||||
|
||||
private WaitPane waitPane;
|
||||
|
||||
@ -89,7 +90,7 @@ public class MenuManagementPanel extends JPanel implements Observer {
|
||||
});
|
||||
addButton.setBackground(new Color(0x1c7dfa));
|
||||
|
||||
JToggleButton exButton = new JToggleButton("展开/折叠");
|
||||
exButton= new JToggleButton("展开/折叠");
|
||||
toolBar.add(exButton);
|
||||
exButton.addActionListener(e -> {
|
||||
if (exButton.isSelected()) {
|
||||
@ -136,14 +137,7 @@ public class MenuManagementPanel extends JPanel implements Observer {
|
||||
ColorHighlighter rollover = new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, UIManager.getColor("App.hoverBackground"), null);
|
||||
treeTable.setHighlighters(rollover);
|
||||
treeTable.setIntercellSpacing(new Dimension(0, 1));
|
||||
// treeTable.setLeafIcon(null);
|
||||
// treeTable.setClosedIcon(null);
|
||||
// treeTable.setOpenIcon(null);
|
||||
|
||||
// DefaultTableCellRenderer dc = new DefaultTableCellRenderer();
|
||||
// dc.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
// dc.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
|
||||
// treeTable.getColumn("排序").setCellRenderer(dc);
|
||||
|
||||
}
|
||||
});
|
||||
@ -259,6 +253,9 @@ public class MenuManagementPanel extends JPanel implements Observer {
|
||||
try {
|
||||
if (CollUtil.isNotEmpty(get())) {
|
||||
updateTreeTableRoot(get());
|
||||
if (exButton.isSelected()) {
|
||||
treeTable.expandAll();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
@ -366,6 +363,7 @@ public class MenuManagementPanel extends JPanel implements Observer {
|
||||
if (get().isSuccess()) {
|
||||
WMessage.showMessageSuccess(MainFrame.getInstance(),"添加成功!");
|
||||
updateData();
|
||||
AppStore.getMenuRefreshObservable().refresh();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
@ -393,7 +391,7 @@ public class MenuManagementPanel extends JPanel implements Observer {
|
||||
WMessage.showMessageSuccess(MainFrame.getInstance(),"修改成功!");
|
||||
|
||||
updateData();
|
||||
|
||||
AppStore.getMenuRefreshObservable().refresh();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
@ -439,6 +437,7 @@ public class MenuManagementPanel extends JPanel implements Observer {
|
||||
WMessage.showMessageSuccess(MainFrame.getInstance(),"删除成功!");
|
||||
|
||||
updateData();
|
||||
AppStore.getMenuRefreshObservable().refresh();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
@ -0,0 +1,345 @@
|
||||
/*
|
||||
* Created by JFormDesigner on Thu Jun 13 19:52:21 CST 2024
|
||||
*/
|
||||
|
||||
package com.lw.swing.view.system.oauth2;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.formdev.flatlaf.extras.FlatSVGIcon;
|
||||
import com.lw.dillon.admin.framework.common.pojo.CommonResult;
|
||||
import com.lw.dillon.admin.framework.common.pojo.PageResult;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.dict.vo.data.DictDataSimpleRespVO;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.oauth2.vo.token.OAuth2AccessTokenRespVO;
|
||||
import com.lw.swing.components.*;
|
||||
import com.lw.swing.components.table.renderer.OptButtonTableCellEditor;
|
||||
import com.lw.swing.components.table.renderer.OptButtonTableCellRenderer;
|
||||
import com.lw.swing.request.Request;
|
||||
import com.lw.swing.store.AppStore;
|
||||
import com.lw.swing.utils.BadgeLabelUtil;
|
||||
import com.lw.ui.request.api.system.OAuth2TokenFeign;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.jdesktop.swingx.JXTable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static com.lw.ui.utils.DictTypeEnum.USER_TYPE;
|
||||
import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
|
||||
import static javax.swing.JOptionPane.WARNING_MESSAGE;
|
||||
|
||||
/**
|
||||
* @author wenli
|
||||
*/
|
||||
public class TokenPane extends JPanel {
|
||||
private String[] COLUMN_ID = {"访问令牌", "刷新令牌", "用户编号", "用户类型", "过期时间", "创建时间", "操作"};
|
||||
|
||||
private DefaultTableModel tableModel;
|
||||
|
||||
private WPaginationPane paginationPane;
|
||||
|
||||
public TokenPane() {
|
||||
initComponents();
|
||||
initListeners();
|
||||
updateData();
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
textField = new JTextField();
|
||||
scrollPane1 = new WScrollPane();
|
||||
centerPane = new JPanel();
|
||||
scrollPane2 = new WScrollPane();
|
||||
table = new JXTable(tableModel = new DefaultTableModel());
|
||||
toolPane = new WPanel();
|
||||
label7 = new JLabel();
|
||||
userIdField = new JTextField();
|
||||
label8 = new JLabel();
|
||||
clientIdFiled = new JTextField();
|
||||
label9 = new JLabel();
|
||||
userTypeComboBox = new JComboBox();
|
||||
searchBut = new JButton();
|
||||
reseBut = new JButton();
|
||||
|
||||
//======== this ========
|
||||
setOpaque(false);
|
||||
setLayout(new BorderLayout(10, 10));
|
||||
|
||||
|
||||
//======== centerPane ========
|
||||
{
|
||||
centerPane.setOpaque(false);
|
||||
centerPane.setLayout(new BorderLayout(10, 10));
|
||||
|
||||
//======== scrollPane2 ========
|
||||
{
|
||||
tableModel.setColumnIdentifiers(COLUMN_ID);
|
||||
scrollPane2.setViewportView(table);
|
||||
}
|
||||
|
||||
JPanel panel = new WPanel();
|
||||
panel.setLayout(new BorderLayout());
|
||||
panel.add(scrollPane2);
|
||||
paginationPane = new WPaginationPane() {
|
||||
@Override
|
||||
public void setPageIndex(long pageIndex) {
|
||||
super.setPageIndex(pageIndex);
|
||||
updateData();
|
||||
}
|
||||
};
|
||||
paginationPane.setOpaque(false);
|
||||
panel.add(paginationPane, BorderLayout.SOUTH);
|
||||
centerPane.add(panel, BorderLayout.CENTER);
|
||||
|
||||
//======== toolPane ========
|
||||
{
|
||||
toolPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[left]",
|
||||
// rows
|
||||
"[]"));
|
||||
toolPane.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||
//---- label7 ----
|
||||
label7.setText("用户编号");
|
||||
toolPane.add(label7, "cell 0 0");
|
||||
|
||||
//---- userNameTextField ----
|
||||
userIdField.setColumns(15);
|
||||
toolPane.add(userIdField, "cell 0 0");
|
||||
|
||||
//---- label8 ----
|
||||
label8.setText("客户端编号");
|
||||
toolPane.add(label8, "cell 0 0");
|
||||
|
||||
//---- phoneTextField ----
|
||||
clientIdFiled.setColumns(15);
|
||||
toolPane.add(clientIdFiled, "cell 0 0");
|
||||
|
||||
//---- label9 ----
|
||||
label9.setText("用户类型");
|
||||
toolPane.add(label9, "cell 0 0");
|
||||
toolPane.add(userTypeComboBox, "cell 0 0");
|
||||
|
||||
|
||||
//---- button1 ----
|
||||
searchBut.setText("搜索");
|
||||
toolPane.add(searchBut, "cell 0 0");
|
||||
|
||||
//---- reseBut ----
|
||||
reseBut.setText("重置");
|
||||
toolPane.add(reseBut, "cell 0 0");
|
||||
|
||||
|
||||
|
||||
}
|
||||
centerPane.add(toolPane, BorderLayout.NORTH);
|
||||
}
|
||||
add(centerPane, BorderLayout.CENTER);
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents @formatter:on
|
||||
|
||||
table.setRowHeight(40);
|
||||
|
||||
table.setDefaultRenderer(Object.class, new CenterTableCellRenderer());
|
||||
|
||||
|
||||
AppStore.getDictDataList(USER_TYPE).forEach(dictDataSimpleRespVO -> {
|
||||
userTypeComboBox.addItem(dictDataSimpleRespVO);
|
||||
});
|
||||
userTypeComboBox.setSelectedItem(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
if (table != null) {
|
||||
table.setDefaultRenderer(Object.class, new CenterTableCellRenderer());
|
||||
}
|
||||
}
|
||||
|
||||
private JToolBar creatBar() {
|
||||
JToolBar optBar = new JToolBar();
|
||||
optBar.setOpaque(false);
|
||||
|
||||
|
||||
JButton del = new JButton("强退");
|
||||
del.setIcon(new FlatSVGIcon("icons/logout.svg", 15, 15));
|
||||
del.addActionListener(e -> delMenu());
|
||||
del.setForeground(UIManager.getColor("app-error-color-5"));
|
||||
optBar.add(Box.createGlue());
|
||||
optBar.add(del);
|
||||
optBar.add(Box.createGlue());
|
||||
return optBar;
|
||||
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
|
||||
reseBut.addActionListener(e -> reset());
|
||||
searchBut.addActionListener(e -> updateData());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void reset() {
|
||||
userIdField.setText("");
|
||||
clientIdFiled.setText("");
|
||||
userTypeComboBox.setSelectedItem(null);
|
||||
updateData();
|
||||
}
|
||||
|
||||
|
||||
private void delMenu() {
|
||||
String accessToken = null;
|
||||
|
||||
int selRow = table.getSelectedRow();
|
||||
if (selRow != -1) {
|
||||
accessToken = Convert.toStr(table.getValueAt(selRow, 0));
|
||||
}
|
||||
|
||||
int opt = WOptionPane.showOptionDialog(this, "是否要强制退出用户?", "提示", OK_CANCEL_OPTION, WARNING_MESSAGE, null, null, null);
|
||||
|
||||
if (opt != 0) {
|
||||
return;
|
||||
}
|
||||
String finalAccessToken = accessToken;
|
||||
SwingWorker<CommonResult<Boolean>, Object> swingWorker = new SwingWorker<CommonResult<Boolean>, Object>() {
|
||||
@Override
|
||||
protected CommonResult<Boolean> doInBackground() throws Exception {
|
||||
return Request.connector(OAuth2TokenFeign.class).deleteAccessToken(finalAccessToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
if (get().isSuccess()) {
|
||||
updateData();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void updateData() {
|
||||
|
||||
Map<String, Object> queryMap = new HashMap<>();
|
||||
queryMap.put("pageNo", paginationPane.getPageIndex());
|
||||
queryMap.put("pageSize", paginationPane.getPageSize());
|
||||
|
||||
if (StrUtil.isNotBlank(userIdField.getText())) {
|
||||
queryMap.put("userId", userIdField.getText());
|
||||
}
|
||||
if (StrUtil.isNotBlank(clientIdFiled.getText())) {
|
||||
queryMap.put("clientId", clientIdFiled.getText());
|
||||
}
|
||||
if (userTypeComboBox.getSelectedItem() != null) {
|
||||
DictDataSimpleRespVO userTypeDict= (DictDataSimpleRespVO) userTypeComboBox.getSelectedItem();
|
||||
queryMap.put("userType", userTypeDict.getValue());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
SwingWorker<Vector<Vector>, Long> swingWorker = new SwingWorker<Vector<Vector>, Long>() {
|
||||
@Override
|
||||
protected Vector<Vector> doInBackground() throws Exception {
|
||||
CommonResult<PageResult<OAuth2AccessTokenRespVO>> result = Request.connector(OAuth2TokenFeign.class).getAccessTokenPage(queryMap);
|
||||
|
||||
Vector<Vector> tableData = new Vector<>();
|
||||
|
||||
|
||||
if (result.isSuccess()) {
|
||||
|
||||
result.getData().getList().forEach(roleRespVO -> {
|
||||
Vector rowV = new Vector();
|
||||
rowV.add(roleRespVO.getAccessToken());
|
||||
rowV.add(roleRespVO.getRefreshToken());
|
||||
rowV.add(roleRespVO.getUserId());
|
||||
rowV.add(roleRespVO.getUserType());
|
||||
rowV.add(DateUtil.format(roleRespVO.getExpiresTime(), "yyyy-MM-dd HH:mm:ss"));
|
||||
rowV.add(DateUtil.format(roleRespVO.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
|
||||
rowV.add(roleRespVO);
|
||||
tableData.add(rowV);
|
||||
});
|
||||
|
||||
publish(result.getData().getTotal());
|
||||
}
|
||||
return tableData;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void process(List<Long> chunks) {
|
||||
chunks.forEach(total -> paginationPane.setTotal(total));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
|
||||
|
||||
tableModel.setDataVector(get(), new Vector<>(Arrays.asList(COLUMN_ID)));
|
||||
table.getColumn("操作").setCellRenderer(new OptButtonTableCellRenderer(creatBar()));
|
||||
table.getColumn("操作").setCellEditor(new OptButtonTableCellEditor(creatBar()));
|
||||
|
||||
table.getColumn("用户类型").setCellRenderer(new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 10));
|
||||
JLabel label = BadgeLabelUtil.getBadgeLabel(USER_TYPE, value);
|
||||
|
||||
panel.add(label);
|
||||
panel.setBackground(component.getBackground());
|
||||
panel.setOpaque(isSelected);
|
||||
return panel;
|
||||
}
|
||||
});
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
|
||||
}
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables @formatter:off
|
||||
// Generated using JFormDesigner non-commercial license
|
||||
private JTextField textField;
|
||||
private JScrollPane scrollPane1;
|
||||
private JPanel centerPane;
|
||||
private JScrollPane scrollPane2;
|
||||
private JTable table;
|
||||
private JPanel toolPane;
|
||||
private JLabel label7;
|
||||
private JTextField userIdField;
|
||||
private JLabel label8;
|
||||
private JTextField clientIdFiled;
|
||||
private JLabel label9;
|
||||
private JComboBox userTypeComboBox;
|
||||
private JButton searchBut;
|
||||
private JButton reseBut;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables @formatter:on
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user