From f4ba70ec5aa122bd1a431b4ceef8f1e4dde9d3fe Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 29 Nov 2025 10:10:31 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90SocialClient=E3=80=91=20?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/dm/ruoyi-vue-pro-dm8.sql | 5 ++++- sql/kingbase/ruoyi-vue-pro.sql | 5 ++++- sql/mysql/ruoyi-vue-pro.sql | 4 +++- sql/opengauss/ruoyi-vue-pro.sql | 5 ++++- sql/oracle/ruoyi-vue-pro.sql | 5 ++++- sql/postgresql/ruoyi-vue-pro.sql | 5 ++++- sql/sqlserver/ruoyi-vue-pro.sql | 12 +++++++++++- .../module/system/enums/social/SocialTypeEnum.java | 6 ++++++ .../admin/socail/vo/client/SocialClientRespVO.java | 5 ++++- .../socail/vo/client/SocialClientSaveReqVO.java | 11 +++++++++++ .../system/dal/dataobject/social/SocialClientDO.java | 8 ++++++++ .../service/social/SocialClientServiceImpl.java | 8 ++++++-- .../src/main/resources/application-dev.yaml | 6 ++++++ .../src/main/resources/application-local.yaml | 6 ++++++ yudao-server/src/main/resources/application-dev.yaml | 6 ++++++ .../src/main/resources/application-local.yaml | 6 ++++++ 16 files changed, 93 insertions(+), 10 deletions(-) diff --git a/sql/dm/ruoyi-vue-pro-dm8.sql b/sql/dm/ruoyi-vue-pro-dm8.sql index f97d09de4..e16c85ea7 100644 --- a/sql/dm/ruoyi-vue-pro-dm8.sql +++ b/sql/dm/ruoyi-vue-pro-dm8.sql @@ -1240,6 +1240,7 @@ INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_t INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3000, 16, '百川智能', 'BaiChuan', 'ai_platform', 0, '', '', '', '1', '2025-03-23 12:15:46', '1', '2025-03-23 12:15:46', '0'); INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3001, 50, 'Vben5.0 Ant Design Schema 模版', '40', 'infra_codegen_front_type', 0, '', '', NULL, '1', '2025-04-23 21:47:47', '1', '2025-05-02 12:01:15', '0'); INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3002, 6, '支付宝余额', '6', 'brokerage_withdraw_type', 0, '', '', 'API 打款', '1', '2025-05-10 08:24:49', '1', '2025-05-10 08:24:49', '0'); +INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3035, 40, '支付宝小程序', '40', 'system_social_type', 0, '', '', '', '1', '2023-11-04 13:05:38', '1', '2023-11-04 13:07:16', '0'); COMMIT; SET IDENTITY_INSERT system_dict_data OFF; -- @formatter:on @@ -4179,7 +4180,8 @@ CREATE TABLE system_social_client social_type smallint NOT NULL, user_type smallint NOT NULL, client_id varchar(255) NOT NULL, - client_secret varchar(255) NOT NULL, + client_secret varchar(2048) NOT NULL, + public_key varchar(2048) DEFAULT NULL NULL, agent_id varchar(255) DEFAULT NULL NULL, status smallint NOT NULL, creator varchar(64) DEFAULT '' NULL, @@ -4195,6 +4197,7 @@ COMMENT ON COLUMN system_social_client.name IS '应用名'; COMMENT ON COLUMN system_social_client.social_type IS '社交平台的类型'; COMMENT ON COLUMN system_social_client.user_type IS '用户类型'; COMMENT ON COLUMN system_social_client.client_id IS '客户端编号'; +COMMENT ON COLUMN system_social_client.public_key IS 'publicKey公钥'; COMMENT ON COLUMN system_social_client.client_secret IS '客户端密钥'; COMMENT ON COLUMN system_social_client.agent_id IS '代理编号'; COMMENT ON COLUMN system_social_client.status IS '状态'; diff --git a/sql/kingbase/ruoyi-vue-pro.sql b/sql/kingbase/ruoyi-vue-pro.sql index c1f8e7666..63ea981d0 100644 --- a/sql/kingbase/ruoyi-vue-pro.sql +++ b/sql/kingbase/ruoyi-vue-pro.sql @@ -1354,6 +1354,7 @@ INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_t INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3000, 16, '百川智能', 'BaiChuan', 'ai_platform', 0, '', '', '', '1', '2025-03-23 12:15:46', '1', '2025-03-23 12:15:46', '0'); INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3001, 50, 'Vben5.0 Ant Design Schema 模版', '40', 'infra_codegen_front_type', 0, '', '', NULL, '1', '2025-04-23 21:47:47', '1', '2025-05-02 12:01:15', '0'); INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3002, 6, '支付宝余额', '6', 'brokerage_withdraw_type', 0, '', '', 'API 打款', '1', '2025-05-10 08:24:49', '1', '2025-05-10 08:24:49', '0'); +INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3035, 40, '支付宝小程序', 40, '', '', '', '1', '2023-11-04 13:05:38', '1', '2023-11-04 13:07:16', '0'); COMMIT; -- @formatter:on @@ -4461,7 +4462,8 @@ CREATE TABLE system_social_client social_type int2 NOT NULL, user_type int2 NOT NULL, client_id varchar(255) NOT NULL, - client_secret varchar(255) NOT NULL, + client_secret varchar(2048) NOT NULL, + public_key varchar(2048) NULL DEFAULT NULL, agent_id varchar(255) NULL DEFAULT NULL, status int2 NOT NULL, creator varchar(64) NULL DEFAULT '', @@ -4481,6 +4483,7 @@ COMMENT ON COLUMN system_social_client.social_type IS '社交平台的类型'; COMMENT ON COLUMN system_social_client.user_type IS '用户类型'; COMMENT ON COLUMN system_social_client.client_id IS '客户端编号'; COMMENT ON COLUMN system_social_client.client_secret IS '客户端密钥'; +COMMENT ON COLUMN system_social_client.public_key IS 'publicKey公钥'; COMMENT ON COLUMN system_social_client.agent_id IS '代理编号'; COMMENT ON COLUMN system_social_client.status IS '状态'; COMMENT ON COLUMN system_social_client.creator IS '创建者'; diff --git a/sql/mysql/ruoyi-vue-pro.sql b/sql/mysql/ruoyi-vue-pro.sql index 74a8c2cc8..526f2c17a 100644 --- a/sql/mysql/ruoyi-vue-pro.sql +++ b/sql/mysql/ruoyi-vue-pro.sql @@ -1092,6 +1092,7 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (3032, 50, 'Vben5.0 Element Plus Schema 模版', '50', 'infra_codegen_front_type', 0, '', '', '', '1', '2025-09-04 23:26:38', '1', '2025-09-04 23:26:38', b'0'); INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (3033, 51, 'Vben5.0 Element Plus 标准模版', '51', 'infra_codegen_front_type', 0, '', '', '', '1', '2025-09-04 23:26:49', '1', '2025-09-04 23:26:49', b'0'); INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (3034, 1, 'ttt', 'tt', 'iot_ota_task_record_status', 0, 'success', '', NULL, '1', '2025-09-06 00:02:21', '1', '2025-09-06 00:02:31', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (3035, 40, '支付宝小程序', '40', 'system_social_type', 0, '', '', '', '1', '2023-11-04 13:05:38', '1', '2023-11-04 13:07:16', b'0'); COMMIT; -- ---------------------------- @@ -3669,7 +3670,8 @@ CREATE TABLE `system_social_client` ( `social_type` tinyint NOT NULL COMMENT '社交平台的类型', `user_type` tinyint NOT NULL COMMENT '用户类型', `client_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '客户端编号', - `client_secret` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '客户端密钥', + `client_secret` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '客户端密钥', + `public_key` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT 'publicKey公钥', `agent_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '代理编号', `status` tinyint NOT NULL COMMENT '状态', `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', diff --git a/sql/opengauss/ruoyi-vue-pro.sql b/sql/opengauss/ruoyi-vue-pro.sql index c0408f34c..6a83ec182 100644 --- a/sql/opengauss/ruoyi-vue-pro.sql +++ b/sql/opengauss/ruoyi-vue-pro.sql @@ -1354,6 +1354,7 @@ INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_t INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3000, 16, '百川智能', 'BaiChuan', 'ai_platform', 0, '', '', '', '1', '2025-03-23 12:15:46', '1', '2025-03-23 12:15:46', '0'); INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3001, 50, 'Vben5.0 Ant Design Schema 模版', '40', 'infra_codegen_front_type', 0, '', '', NULL, '1', '2025-04-23 21:47:47', '1', '2025-05-02 12:01:15', '0'); INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3002, 6, '支付宝余额', '6', 'brokerage_withdraw_type', 0, '', '', 'API 打款', '1', '2025-05-10 08:24:49', '1', '2025-05-10 08:24:49', '0'); +INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3035, 40, '支付宝小程序', '40', 'system_social_type', 0, '', '', '', '1', '2023-11-04 13:05:38', '1', '2023-11-04 13:07:16', '0'); COMMIT; -- @formatter:on @@ -4461,7 +4462,8 @@ CREATE TABLE system_social_client social_type int2 NOT NULL, user_type int2 NOT NULL, client_id varchar(255) NOT NULL, - client_secret varchar(255) NOT NULL, + client_secret varchar(2048) NOT NULL, + public_key varchar(2048) NULL DEFAULT NULL, agent_id varchar(255) NULL DEFAULT NULL, status int2 NOT NULL, creator varchar(64) NULL DEFAULT '', @@ -4481,6 +4483,7 @@ COMMENT ON COLUMN system_social_client.social_type IS '社交平台的类型'; COMMENT ON COLUMN system_social_client.user_type IS '用户类型'; COMMENT ON COLUMN system_social_client.client_id IS '客户端编号'; COMMENT ON COLUMN system_social_client.client_secret IS '客户端密钥'; +COMMENT ON COLUMN system_social_client.public_key IS 'publicKey公钥'; COMMENT ON COLUMN system_social_client.agent_id IS '代理编号'; COMMENT ON COLUMN system_social_client.status IS '状态'; COMMENT ON COLUMN system_social_client.creator IS '创建者'; diff --git a/sql/oracle/ruoyi-vue-pro.sql b/sql/oracle/ruoyi-vue-pro.sql index 0af291458..01e1de0b9 100644 --- a/sql/oracle/ruoyi-vue-pro.sql +++ b/sql/oracle/ruoyi-vue-pro.sql @@ -1306,6 +1306,7 @@ INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_t INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3000, 16, '百川智能', 'BaiChuan', 'ai_platform', 0, '', '', '', '1', to_date('2025-03-23 12:15:46', 'SYYYY-MM-DD HH24:MI:SS'), '1', to_date('2025-03-23 12:15:46', 'SYYYY-MM-DD HH24:MI:SS'), '0'); INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3001, 50, 'Vben5.0 Ant Design Schema 模版', '40', 'infra_codegen_front_type', 0, '', '', NULL, '1', to_date('2025-04-23 21:47:47', 'SYYYY-MM-DD HH24:MI:SS'), '1', to_date('2025-05-02 12:01:15', 'SYYYY-MM-DD HH24:MI:SS'), '0'); INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3002, 6, '支付宝余额', '6', 'brokerage_withdraw_type', 0, '', '', 'API 打款', '1', to_date('2025-05-10 08:24:49', 'SYYYY-MM-DD HH24:MI:SS'), '1', to_date('2025-05-10 08:24:49', 'SYYYY-MM-DD HH24:MI:SS'), '0'); +INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3035, 40, '支付宝小程序', '40', 'system_social_type', 0, '', '', '', '1', to_date('2023-11-04 13:05:38', 'SYYYY-MM-DD HH24:MI:SS'), '1', to_date('2023-11-04 13:07:16', 'SYYYY-MM-DD HH24:MI:SS'), '0'); COMMIT; -- @formatter:on @@ -4355,7 +4356,8 @@ CREATE TABLE system_social_client social_type smallint NOT NULL, user_type smallint NOT NULL, client_id varchar2(255) NULL, - client_secret varchar2(255) NULL, + client_secret varchar2(2048) NULL, + public_key varchar2(2048) DEFAULT NULL NULL, agent_id varchar2(255) DEFAULT NULL NULL, status smallint NOT NULL, creator varchar2(64) DEFAULT '' NULL, @@ -4375,6 +4377,7 @@ COMMENT ON COLUMN system_social_client.social_type IS '社交平台的类型'; COMMENT ON COLUMN system_social_client.user_type IS '用户类型'; COMMENT ON COLUMN system_social_client.client_id IS '客户端编号'; COMMENT ON COLUMN system_social_client.client_secret IS '客户端密钥'; +COMMENT ON COLUMN system_social_client.public_key IS 'publicKey公钥'; COMMENT ON COLUMN system_social_client.agent_id IS '代理编号'; COMMENT ON COLUMN system_social_client.status IS '状态'; COMMENT ON COLUMN system_social_client.creator IS '创建者'; diff --git a/sql/postgresql/ruoyi-vue-pro.sql b/sql/postgresql/ruoyi-vue-pro.sql index 85eafefc4..d41080d65 100644 --- a/sql/postgresql/ruoyi-vue-pro.sql +++ b/sql/postgresql/ruoyi-vue-pro.sql @@ -1354,6 +1354,7 @@ INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_t INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3000, 16, '百川智能', 'BaiChuan', 'ai_platform', 0, '', '', '', '1', '2025-03-23 12:15:46', '1', '2025-03-23 12:15:46', '0'); INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3001, 50, 'Vben5.0 Ant Design Schema 模版', '40', 'infra_codegen_front_type', 0, '', '', NULL, '1', '2025-04-23 21:47:47', '1', '2025-05-02 12:01:15', '0'); INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3002, 6, '支付宝余额', '6', 'brokerage_withdraw_type', 0, '', '', 'API 打款', '1', '2025-05-10 08:24:49', '1', '2025-05-10 08:24:49', '0'); +INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3035, 40, '支付宝小程序', '40', 'system_social_type', 0, '', '', '', '1', '2023-11-04 13:05:38', '1', '2023-11-04 13:07:16', '0'); COMMIT; -- @formatter:on @@ -4461,7 +4462,8 @@ CREATE TABLE system_social_client social_type int2 NOT NULL, user_type int2 NOT NULL, client_id varchar(255) NOT NULL, - client_secret varchar(255) NOT NULL, + client_secret varchar(2048) NOT NULL, + public_key varchar(2048) NULL DEFAULT NULL, agent_id varchar(255) NULL DEFAULT NULL, status int2 NOT NULL, creator varchar(64) NULL DEFAULT '', @@ -4481,6 +4483,7 @@ COMMENT ON COLUMN system_social_client.social_type IS '社交平台的类型'; COMMENT ON COLUMN system_social_client.user_type IS '用户类型'; COMMENT ON COLUMN system_social_client.client_id IS '客户端编号'; COMMENT ON COLUMN system_social_client.client_secret IS '客户端密钥'; +COMMENT ON COLUMN system_social_client.public_key IS 'publicKey公钥'; COMMENT ON COLUMN system_social_client.agent_id IS '代理编号'; COMMENT ON COLUMN system_social_client.status IS '状态'; COMMENT ON COLUMN system_social_client.creator IS '创建者'; diff --git a/sql/sqlserver/ruoyi-vue-pro.sql b/sql/sqlserver/ruoyi-vue-pro.sql index fc4c81bba..a217dac83 100644 --- a/sql/sqlserver/ruoyi-vue-pro.sql +++ b/sql/sqlserver/ruoyi-vue-pro.sql @@ -3299,6 +3299,8 @@ INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_t GO INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3002, 6, N'支付宝余额', N'6', N'brokerage_withdraw_type', 0, N'', N'', N'API 打款', N'1', N'2025-05-10 08:24:49', N'1', N'2025-05-10 08:24:49', N'0') GO +INSERT INTO system_dict_data (id, sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted) VALUES (3035, 40, N'支付宝小程序', N'40', N'system_social_type', 0, N'', N'', N'', N'1', N'2023-11-04 13:05:38', N'1', N'2023-11-04 13:07:16', N'0') +GO SET IDENTITY_INSERT system_dict_data OFF GO COMMIT @@ -10433,7 +10435,8 @@ CREATE TABLE system_social_client social_type tinyint NOT NULL, user_type tinyint NOT NULL, client_id nvarchar(255) NOT NULL, - client_secret nvarchar(255) NOT NULL, + client_secret nvarchar(2048) NOT NULL, + public_key nvarchar(2048) DEFAULT NULL NULL, agent_id nvarchar(255) DEFAULT NULL NULL, status tinyint NOT NULL, creator nvarchar(64) DEFAULT '' NULL, @@ -10487,6 +10490,13 @@ EXEC sp_addextendedproperty 'COLUMN', N'client_secret' GO +EXEC sp_addextendedproperty + 'MS_Description', N'publicKey公钥', + 'SCHEMA', N'dbo', + 'TABLE', N'system_social_client', + 'COLUMN', N'public_key' +GO + EXEC sp_addextendedproperty 'MS_Description', N'代理编号', 'SCHEMA', N'dbo', diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/social/SocialTypeEnum.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/social/SocialTypeEnum.java index e6c4dc32b..f84ce535d 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/social/SocialTypeEnum.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/social/SocialTypeEnum.java @@ -53,6 +53,12 @@ public enum SocialTypeEnum implements ArrayValuable { * @see 接入文档 */ WECHAT_MINI_PROGRAM(34, "WECHAT_MINI_PROGRAM"), + /** + * 支付宝小程序 + * + * @see 接入文档 + */ + ALIPAY_MINI_PROGRAM(40, "ALIPAY"), ; public static final Integer[] ARRAYS = Arrays.stream(values()).map(SocialTypeEnum::getType).toArray(Integer[]::new); diff --git a/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/client/SocialClientRespVO.java b/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/client/SocialClientRespVO.java index 900f363d1..fee606123 100644 --- a/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/client/SocialClientRespVO.java +++ b/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/client/SocialClientRespVO.java @@ -27,9 +27,12 @@ public class SocialClientRespVO { @Schema(description = "客户端密钥", requiredMode = Schema.RequiredMode.REQUIRED, example = "peter") private String clientSecret; - @Schema(description = "授权方的网页应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000045") + @Schema(description = "授权方的网页应用编号", example = "2000045") private String agentId; + @Schema(description = "publicKey 公钥", example = "2000045") + private String publicKey; + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") private Integer status; diff --git a/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/client/SocialClientSaveReqVO.java b/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/client/SocialClientSaveReqVO.java index 9549b826c..deeb1ebb9 100644 --- a/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/client/SocialClientSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/client/SocialClientSaveReqVO.java @@ -45,6 +45,9 @@ public class SocialClientSaveReqVO { @Schema(description = "授权方的网页应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000045") private String agentId; + @Schema(description = "publicKey 公钥", example = "2000045") + private String publicKey; + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @NotNull(message = "状态不能为空") @InEnum(CommonStatusEnum.class) @@ -58,4 +61,12 @@ public class SocialClientSaveReqVO { || !StrUtil.isEmpty(agentId); } + @AssertTrue(message = "publicKey 不能为空") + @JsonIgnore + public boolean isPublicKeyValid() { + // 如果是支付宝,必须填写 publicKey 属性 + return !Objects.equals(socialType, SocialTypeEnum.ALIPAY_MINI_PROGRAM.getType()) + || !StrUtil.isEmpty(publicKey); + } + } diff --git a/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/social/SocialClientDO.java b/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/social/SocialClientDO.java index 544910610..bc420ced6 100644 --- a/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/social/SocialClientDO.java +++ b/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/social/SocialClientDO.java @@ -73,4 +73,12 @@ public class SocialClientDO extends TenantBaseDO { */ private String agentId; + /** + * publicKey 公钥 + * + * 目前只有部分“社交类型”在使用: + * 1. 支付宝:支付宝公钥 + */ + private String publicKey; + } diff --git a/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java b/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java index 97c65205d..fc81be23b 100644 --- a/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java +++ b/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java @@ -11,7 +11,6 @@ import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl; import cn.binarywang.wx.miniapp.constant.WxMaConstants; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.DesensitizedUtil; import cn.hutool.core.util.ObjUtil; @@ -52,6 +51,7 @@ import me.zhyd.oauth.config.AuthConfig; import me.zhyd.oauth.model.AuthCallback; import me.zhyd.oauth.model.AuthResponse; import me.zhyd.oauth.model.AuthUser; +import me.zhyd.oauth.request.AuthAlipayRequest; import me.zhyd.oauth.request.AuthRequest; import me.zhyd.oauth.utils.AuthStateUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -169,7 +169,7 @@ public class SocialClientServiceImpl implements SocialClientService { public AuthUser getAuthUser(Integer socialType, Integer userType, String code, String state) { // 构建请求 AuthRequest authRequest = buildAuthRequest(socialType, userType); - AuthCallback authCallback = AuthCallback.builder().code(code).state(state).build(); + AuthCallback authCallback = AuthCallback.builder().code(code).auth_code(code).state(state).build(); // 执行请求 AuthResponse authResponse = authRequest.login(authCallback); log.info("[getAuthUser][请求社交平台 type({}) request({}) response({})]", socialType, @@ -206,6 +206,10 @@ public class SocialClientServiceImpl implements SocialClientService { newAuthConfig.setAgentId(client.getAgentId()); } // 2.3 设置会 request 里,进行后续使用 + if (SocialTypeEnum.ALIPAY_MINI_PROGRAM.getType().equals(socialType)) { + // 特殊:如果是支付宝的小程序,多了 publicKey 属性,可见 AuthConfig 里的 alipayPublicKey 字段说明 + return new AuthAlipayRequest(newAuthConfig, client.getPublicKey()); + } ReflectUtil.setFieldValue(request, "config", newAuthConfig); } return request; diff --git a/yudao-module-system/yudao-module-system-server/src/main/resources/application-dev.yaml b/yudao-module-system/yudao-module-system-server/src/main/resources/application-dev.yaml index d455334d6..3c2180b0e 100644 --- a/yudao-module-system/yudao-module-system-server/src/main/resources/application-dev.yaml +++ b/yudao-module-system/yudao-module-system-server/src/main/resources/application-dev.yaml @@ -180,6 +180,12 @@ justauth: client-id: ${wx.mp.app-id} client-secret: ${wx.mp.secret} ignore-check-redirect-uri: true + ALIPAY: # 支付宝小程序 + client-id: xx + client-secret: xx + alipay-public-key: xx + ignore-check-redirect-uri: true + ignore-check-state: true cache: type: REDIS prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: diff --git a/yudao-module-system/yudao-module-system-server/src/main/resources/application-local.yaml b/yudao-module-system/yudao-module-system-server/src/main/resources/application-local.yaml index 40d04f72f..cc2eec810 100644 --- a/yudao-module-system/yudao-module-system-server/src/main/resources/application-local.yaml +++ b/yudao-module-system/yudao-module-system-server/src/main/resources/application-local.yaml @@ -209,6 +209,12 @@ justauth: client-id: ${wx.mp.app-id} client-secret: ${wx.mp.secret} ignore-check-redirect-uri: true + ALIPAY: # 支付宝小程序 + client-id: xx + client-secret: xx + alipay-public-key: xx + ignore-check-redirect-uri: true + ignore-check-state: true cache: type: REDIS prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: diff --git a/yudao-server/src/main/resources/application-dev.yaml b/yudao-server/src/main/resources/application-dev.yaml index 7a21ae452..29a58e821 100644 --- a/yudao-server/src/main/resources/application-dev.yaml +++ b/yudao-server/src/main/resources/application-dev.yaml @@ -175,6 +175,12 @@ justauth: client-id: ${wx.mp.app-id} client-secret: ${wx.mp.secret} ignore-check-redirect-uri: true + ALIPAY: # 支付宝小程序 + client-id: xx + client-secret: xx + alipay-public-key: xx + ignore-check-redirect-uri: true + ignore-check-state: true cache: type: REDIS prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 4bb280516..292f740a5 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -237,6 +237,12 @@ justauth: client-id: ${wx.mp.app-id} client-secret: ${wx.mp.secret} ignore-check-redirect-uri: true + ALIPAY: # 支付宝小程序 + client-id: xx + client-secret: xx + alipay-public-key: xx + ignore-check-redirect-uri: true + ignore-check-state: true cache: type: REDIS prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE::