Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #288

Merged
merged 12 commits into from
Sep 4, 2023
Prev Previous commit
Next Next commit
企业微信消息:支持私有化部署时BaseApiUrl配置
  • Loading branch information
rememberber committed Sep 3, 2023
commit 7fa7cb053eea017f1c6387cb446d450a498d889e
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ public class WxCpAccountConfig {
private String appName;
private String agentId;
private String secret;
private Boolean privateDep;
private String baseApiUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public static WxCpService getWxCpService(Integer accountId) {
// clientBuilder.setUserAgent(..)
configStorage.setApacheHttpClientBuilder(clientBuilder);

if (wxCpAccountConfig.getPrivateDep()) {
configStorage.setBaseApiUrl(wxCpAccountConfig.getBaseApiUrl());
}

WxCpService wxCpService = new WxCpServiceApacheHttpClientImpl();
wxCpService.setWxCpConfigStorage(configStorage);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<properties/>
<border type="none"/>
<children>
<grid id="cf705" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="cf705" layout-manager="GridLayoutManager" row-count="7" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
Expand All @@ -18,7 +18,7 @@
<children>
<vspacer id="a7a5f">
<constraints>
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="98a5b" class="javax.swing.JLabel">
Expand Down Expand Up @@ -85,6 +85,30 @@
</constraints>
<properties/>
</component>
<component id="4fb69" class="javax.swing.JCheckBox" binding="privateDepCheckBox">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="私有化部署"/>
</properties>
</component>
<component id="dd1e4" class="javax.swing.JTextField" binding="baseApiUrlTextField">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="3044e" class="javax.swing.JLabel" binding="baseApiUrlLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="私有BaseApiUrl"/>
</properties>
</component>
</children>
</grid>
</children>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ public class WxCpAccountForm implements IAccountForm {
private JTextField appNameTextField;
private JTextField agentIdTextField;
private JTextField secretTextField;
private JCheckBox privateDepCheckBox;
private JTextField baseApiUrlTextField;
private JLabel baseApiUrlLabel;

private static WxCpAccountForm wxMpAccountForm;
private static WxCpAccountForm wxCpAccountForm;

public volatile static WxCpDefaultConfigImpl wxCpConfigStorage;
public volatile static WxCpService wxCpService;
Expand All @@ -46,6 +49,15 @@ public void init(String accountName) {
instance.getAppNameTextField().setText(wxCpAccountConfig.getAppName());
instance.getAgentIdTextField().setText(wxCpAccountConfig.getAgentId());
instance.getSecretTextField().setText(wxCpAccountConfig.getSecret());
instance.getPrivateDepCheckBox().setSelected(wxCpAccountConfig.getPrivateDep());
instance.getBaseApiUrlTextField().setText(wxCpAccountConfig.getBaseApiUrl());
if (wxCpAccountConfig.getPrivateDep()) {
instance.getBaseApiUrlTextField().setVisible(true);
instance.getBaseApiUrlLabel().setVisible(true);
} else {
instance.getBaseApiUrlTextField().setVisible(false);
instance.getBaseApiUrlLabel().setVisible(false);
}
}
}

Expand Down Expand Up @@ -82,6 +94,8 @@ public void save(String accountName) {
wxCpAccountConfig.setAppName(instance.getAppNameTextField().getText());
wxCpAccountConfig.setAgentId(instance.getAgentIdTextField().getText());
wxCpAccountConfig.setSecret(instance.getSecretTextField().getText());
wxCpAccountConfig.setPrivateDep(instance.getPrivateDepCheckBox().isSelected());
wxCpAccountConfig.setBaseApiUrl(instance.getBaseApiUrlTextField().getText());

tAccount1.setAccountConfig(JSONUtil.toJsonStr(wxCpAccountConfig));

Expand Down Expand Up @@ -113,11 +127,20 @@ public JPanel getMainPanel() {
}

public static WxCpAccountForm getInstance() {
if (wxMpAccountForm == null) {
wxMpAccountForm = new WxCpAccountForm();
if (wxCpAccountForm == null) {
wxCpAccountForm = new WxCpAccountForm();
wxCpAccountForm.getPrivateDepCheckBox().addChangeListener(e -> {
if (wxCpAccountForm.getPrivateDepCheckBox().isSelected()) {
wxCpAccountForm.getBaseApiUrlTextField().setVisible(true);
wxCpAccountForm.getBaseApiUrlLabel().setVisible(true);
} else {
wxCpAccountForm.getBaseApiUrlTextField().setVisible(false);
wxCpAccountForm.getBaseApiUrlLabel().setVisible(false);
}
});
}
UndoUtil.register(wxMpAccountForm);
return wxMpAccountForm;
UndoUtil.register(wxCpAccountForm);
return wxCpAccountForm;
}

{
Expand All @@ -138,10 +161,10 @@ public static WxCpAccountForm getInstance() {
mainPanel = new JPanel();
mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1));
panel1.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1));
mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
panel1.add(spacer1, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
panel1.add(spacer1, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
final JLabel label1 = new JLabel();
label1.setText("应用名称");
panel1.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
Expand All @@ -162,6 +185,14 @@ public static WxCpAccountForm getInstance() {
panel1.add(label4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
corpIdTextField = new JTextField();
panel1.add(corpIdTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
privateDepCheckBox = new JCheckBox();
privateDepCheckBox.setText("私有化部署");
panel1.add(privateDepCheckBox, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
baseApiUrlTextField = new JTextField();
panel1.add(baseApiUrlTextField, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
baseApiUrlLabel = new JLabel();
baseApiUrlLabel.setText("私有BaseApiUrl");
panel1.add(baseApiUrlLabel, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}

/**
Expand Down