fix(system): 调整小程序配置读取顺序
- 修改 getMpWxSetting 方法,优先读取 sys_setting(mp-weixin) - 读取失败时回退到 db_websopy.app_config(category=wechat) - 更新异常日志内容,明确读取失败顺序 - 适配业务需求调整配置优先级 - 影响所有调用 getMpWxSetting 的相关方法调用流程
This commit is contained in:
27
.workbuddy/memory/2026-06-21.md
Normal file
27
.workbuddy/memory/2026-06-21.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# 2026-06-21 工作日志
|
||||||
|
|
||||||
|
## WxLoginController 配置读取顺序调整
|
||||||
|
|
||||||
|
### 修改内容
|
||||||
|
修改了 `WxLoginController.java` 中的 `getMpWxSetting` 方法,调整小程序配置读取顺序:
|
||||||
|
|
||||||
|
**修改前:**
|
||||||
|
- 优先:`db_websopy.app_config`(category=wechat)
|
||||||
|
- 兜底:`sys_setting.mp-weixin`
|
||||||
|
|
||||||
|
**修改后:**
|
||||||
|
- 优先:`sys_setting.mp-weixin`
|
||||||
|
- 兜底:`db_websopy.app_config`(category=wechat)
|
||||||
|
|
||||||
|
### 修改原因
|
||||||
|
业务需求变更,需要优先从系统设置(sys_setting)读取小程序配置,数据库配置(app_config)作为兜底方案。
|
||||||
|
|
||||||
|
### 影响范围
|
||||||
|
影响所有调用 `getMpWxSetting` 方法的地方:
|
||||||
|
- `getOpenIdByCode` - 获取 openid
|
||||||
|
- `getAccessToken` - 获取 access_token
|
||||||
|
- `loginByOpenId` - openid 无感登录
|
||||||
|
- `getWxOpenId` / `getWxOpenIdOnly` - 获取微信 openId
|
||||||
|
|
||||||
|
### 文件位置
|
||||||
|
`/Users/gxwebsoft/JAVA/com.gxwebsoft.core/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java`
|
||||||
@@ -437,7 +437,7 @@ public class WxLoginController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优先读取 db_websopy.app_config(category=wechat),不存在或异常时回退到 sys_setting (mp-weixin)
|
* 优先读取 sys_setting (mp-weixin),不存在或异常时回退到 db_websopy.app_config(category=wechat)
|
||||||
*
|
*
|
||||||
* @param tenantId 租户ID(传 null 时使用当前请求租户)
|
* @param tenantId 租户ID(传 null 时使用当前请求租户)
|
||||||
* @return JSONObject 配置内容(含 appId / appSecret 等字段)
|
* @return JSONObject 配置内容(含 appId / appSecret 等字段)
|
||||||
@@ -445,15 +445,16 @@ public class WxLoginController extends BaseController {
|
|||||||
private JSONObject getMpWxSetting(Integer tenantId) {
|
private JSONObject getMpWxSetting(Integer tenantId) {
|
||||||
Integer tid = tenantId != null ? tenantId : getTenantId();
|
Integer tid = tenantId != null ? tenantId : getTenantId();
|
||||||
try {
|
try {
|
||||||
JSONObject wechat = appConfigService.getByCategory("wechat", tid);
|
// 优先:sys_setting.mp-weixin
|
||||||
if (wechat != null && !wechat.isEmpty()) {
|
JSONObject setting = settingService.getBySettingKey("mp-weixin");
|
||||||
return wechat;
|
if (setting != null && !setting.isEmpty()) {
|
||||||
|
return setting;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("[WxLoginController] 读取 app_config 失败,回退 sys_setting: " + e.getMessage());
|
System.err.println("[WxLoginController] 读取 sys_setting 失败,回退 app_config: " + e.getMessage());
|
||||||
}
|
}
|
||||||
// 兜底:原 sys_setting.mp-weixin
|
// 兜底:db_websopy.app_config(category=wechat)
|
||||||
return settingService.getBySettingKey("mp-weixin");
|
return appConfigService.getByCategory("wechat", tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user