feat(sdk+msgcenter): 对齐 SDK 重构包名(openapi.client→base)+ 消息中心代理后端(09-16/09-19 遗漏提交)
build / build-push (push) Successful in 1m34s
build / build-push (push) Successful in 1m34s
- import 全面切换 com.yunhai.platform.openapi.base.*(对齐 Nexus -57 SDK)
- MsgCenter 代理三件(Properties/Controller/ProxyService)+ 测试 11/11(09-19 消息中心二期本地完成态)
- Dockerfile 已在 563edb5 去掉写死 profile;本提交补齐源码侧遗漏
This commit is contained in:
@@ -26,10 +26,10 @@ import java.util.List;
|
||||
* 导致 OpenAPI 客户端反序列化 BoaApp.createTime 时抛 DateTimeParseException,
|
||||
* 消息中心(getMessageByUserId)等接口因此报"内部服务错误"。
|
||||
*
|
||||
* <p>yh-openapi 的 OpenApiAutoConfiguration.openApiObjectMapper() 带 @ConditionalOnMissingBean,
|
||||
* 本工程定义该 ObjectMapper bean 后即被 OpenAPI 客户端(OpenApiHttpClient / AbstractOpenApiClient)采用;
|
||||
* 同时它也是 Spring MVC 使用的全局 mapper,因此同样保留 spring.jackson.* 配置(GMT+8 时区、
|
||||
* java.util.Date 的 yyyy-MM-dd HH:mm:ss 格式)。
|
||||
* <p>yh-openapi 的装配(YschCallAutoConfiguration.yschOpenCall)经 ObjectProvider 取容器内
|
||||
* ObjectMapper,本工程定义该 bean 后即被 OpenAPI 客户端(core.YschOpenCall,2026-09-16 SDK
|
||||
* 重构后的唯一出站公共入口)采用;同时它也是 Spring MVC 使用的全局 mapper,因此同样保留
|
||||
* spring.jackson.* 配置(GMT+8 时区、java.util.Date 的 yyyy-MM-dd HH:mm:ss 格式)。
|
||||
*/
|
||||
@Configuration
|
||||
public class JacksonConfig {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.yunhai.userhome.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消息中心代理配置(§3.5 最小消息接入,修 BP-R3-1 审批人待办断头路):
|
||||
* UserHome 经签名代理调 UserMsg /oapi/msg/**(appKey=本应用 100001,UserMsg trusted-apps 已含),
|
||||
* jumpPath 是裸相对路径且各应用落地页均为 hash 路由——代理按 bizType 查基址表拼绝对 jumpUrl。
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "userhome.msgcenter")
|
||||
public class MsgCenterProperties {
|
||||
|
||||
/** UserMsg 服务基址;空 = 未接入(代理降级返回空,前端铃铛维持原表现) */
|
||||
private String usermsgBaseUrl = "";
|
||||
|
||||
/**
|
||||
* 浏览器可达的 UserMsg WS 端点(实时推送握手地址);空 = 不下发 WS 地址,
|
||||
* 前端维持"打开页面拉一次 + 操作后手动刷新"的既有表现。
|
||||
* 生产经网关暴露,如 wss://msg.yunhaixingtong.com/usermsg/ws/msg。
|
||||
*/
|
||||
private String usermsgWsUrl = "";
|
||||
|
||||
/** appKey → 应用显示名(消息行/弹层标签补全,如 100617 → 通知公告);未配置回退 msgType 文案 */
|
||||
private Map<String, String> appNames = new LinkedHashMap<>();
|
||||
|
||||
/** bizType → 应用 front 基址(jumpUrl = 基址 + "/#" + jumpPath);生产同主域用相对段如 /flow-center */
|
||||
private Map<String, String> jumpBases = new LinkedHashMap<>();
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.yunhai.userhome.controller.api;
|
||||
|
||||
import com.yunhai.platform.utils.model.BoaUser;
|
||||
import com.yunhai.userhome.config.Config;
|
||||
import com.yunhai.userhome.service.MsgCenterProxyService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消息中心代理接口(§3.5 最小消息接入,BP-R3-1):前端铃铛/消息列表改经本控制器
|
||||
* 签名代理 UserMsg /oapi/msg/**(前端不直连 UserMsg)。旧 {@code /getMessageByUserId}
|
||||
* 等本地 user_message 表链路保留不动(后续消息中心专项清理)。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = Config.API_PATH)
|
||||
@RequiredArgsConstructor
|
||||
public class MessageCenterController {
|
||||
|
||||
private final MsgCenterProxyService proxy;
|
||||
|
||||
/** schId=0 时推断:主学校 → 主归属组(bureau)→ 0(对齐 MessageController 旧口径) */
|
||||
private Integer resolveSchId(BoaUser user) {
|
||||
if (user.getSchool() != null) {
|
||||
return user.getSchool().getId();
|
||||
}
|
||||
if (user.getBureau() != null) {
|
||||
return user.getBureau().getId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** 消息分页列表:{total, list[]}(元素含改写后的绝对 jumpUrl;UserMsg 不可达降级空) */
|
||||
@GetMapping("msgCenter/list")
|
||||
public Map<String, Object> list(BoaUser authUserWithDept,
|
||||
@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "count", required = false) Integer count,
|
||||
@RequestParam(value = "onlyUnread", required = false) Boolean onlyUnread) {
|
||||
return proxy.list(authUserWithDept.getId(), page, count, onlyUnread);
|
||||
}
|
||||
|
||||
/** 铃铛摘要:未读数 + 各应用待办角标 */
|
||||
@GetMapping("msgCenter/summary")
|
||||
public Map<String, Object> summary(BoaUser authUserWithDept) {
|
||||
return proxy.summary(authUserWithDept.getId(), resolveSchId(authUserWithDept));
|
||||
}
|
||||
|
||||
/**
|
||||
* WS 实时推送握手地址(UserMsg 一次性票据 + 浏览器可达端点)。
|
||||
* 未配置 WS / UserMsg 不可达 → url=null,前端维持"手动刷新"兜底表现。
|
||||
*/
|
||||
@GetMapping("msgCenter/wsTicket")
|
||||
public Map<String, Object> wsTicket(BoaUser authUserWithDept) {
|
||||
Map<String, Object> out = new java.util.HashMap<>();
|
||||
out.put("url", proxy.createWsTicket(authUserWithDept.getId()));
|
||||
return out;
|
||||
}
|
||||
|
||||
/** 标记单条已读(按登录人代理,UserMsg 侧带归属人防伪) */
|
||||
@PostMapping("msgCenter/read")
|
||||
public void read(BoaUser authUserWithDept, @RequestParam("msgId") Long msgId) {
|
||||
proxy.read(authUserWithDept.getId(), Collections.singletonList(msgId));
|
||||
}
|
||||
|
||||
/** 全部已读 */
|
||||
@PostMapping("msgCenter/readAll")
|
||||
public void readAll(BoaUser authUserWithDept) {
|
||||
proxy.readAll(authUserWithDept.getId());
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.yunhai.userhome.controller.api;
|
||||
|
||||
import com.yunhai.platform.apistd.BizException;
|
||||
import com.yunhai.platform.openapi.client.OpenApiUserClient;
|
||||
import com.yunhai.platform.openapi.base.OpenApiUserClient;
|
||||
import com.yunhai.platform.utils.exception.ErrorCode;
|
||||
import com.yunhai.platform.utils.model.BoaUser;
|
||||
import com.yunhai.userhome.config.Config;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.yunhai.userhome.controller.api;
|
||||
|
||||
import com.yunhai.platform.apistd.BizException;
|
||||
import com.yunhai.platform.openapi.client.OpenApiUserClient;
|
||||
import com.yunhai.platform.openapi.client.YschBaseOpenApi;
|
||||
import com.yunhai.platform.openapi.base.OpenApiUserClient;
|
||||
import com.yunhai.platform.openapi.base.YschBaseOpenApi;
|
||||
import com.yunhai.platform.utils.exception.ErrorCode;
|
||||
import com.yunhai.platform.utils.model.BoaApp;
|
||||
import com.yunhai.platform.utils.model.BoaAppType;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.yunhai.userhome.controller.api;
|
||||
|
||||
import com.yunhai.platform.apistd.BizException;
|
||||
import com.yunhai.platform.openapi.client.OpenApiUserClient;
|
||||
import com.yunhai.platform.openapi.client.YschBaseOpenApi;
|
||||
import com.yunhai.platform.openapi.base.OpenApiUserClient;
|
||||
import com.yunhai.platform.openapi.base.YschBaseOpenApi;
|
||||
import com.yunhai.platform.utils.enums.ClientEnum;
|
||||
import com.yunhai.platform.utils.exception.ErrorCode;
|
||||
import com.yunhai.platform.utils.model.BoaApp;
|
||||
|
||||
@@ -47,12 +47,12 @@ public class ApiMetricsController {
|
||||
vo.setDays(d);
|
||||
vo.setTop(n);
|
||||
|
||||
Object[] in = repository.aggregateTotal(since, ApiMetricsEntity.DIRECTION_IN, 0);
|
||||
Object[] in = firstRow(repository.aggregateTotal(since, ApiMetricsEntity.DIRECTION_IN, 0));
|
||||
vo.setInCnt(asLong(in, 0));
|
||||
vo.setInAvgCostMs(avg(asLong(in, 0), asLong(in, 1)));
|
||||
vo.setInErrCnt(asLong(in, 2));
|
||||
|
||||
Object[] out = repository.aggregateTotal(since, ApiMetricsEntity.DIRECTION_OUT, 0);
|
||||
Object[] out = firstRow(repository.aggregateTotal(since, ApiMetricsEntity.DIRECTION_OUT, 0));
|
||||
vo.setOutCnt(asLong(out, 0));
|
||||
vo.setOutAvgCostMs(avg(asLong(out, 0), asLong(out, 1)));
|
||||
vo.setOutErrCnt(asLong(out, 2));
|
||||
@@ -65,8 +65,8 @@ public class ApiMetricsController {
|
||||
vo.setTopOutUris(toRows(repository.aggregateByUri(since, ApiMetricsEntity.DIRECTION_OUT, 0), n));
|
||||
|
||||
// 压测流量合计(单列口径,不与线上热度混算)
|
||||
Object[] ltIn = repository.aggregateTotal(since, ApiMetricsEntity.DIRECTION_IN, 1);
|
||||
Object[] ltOut = repository.aggregateTotal(since, ApiMetricsEntity.DIRECTION_OUT, 1);
|
||||
Object[] ltIn = firstRow(repository.aggregateTotal(since, ApiMetricsEntity.DIRECTION_IN, 1));
|
||||
Object[] ltOut = firstRow(repository.aggregateTotal(since, ApiMetricsEntity.DIRECTION_OUT, 1));
|
||||
vo.setLoadTestInCnt(asLong(ltIn, 0));
|
||||
vo.setLoadTestOutCnt(asLong(ltOut, 0));
|
||||
return vo;
|
||||
@@ -89,6 +89,17 @@ public class ApiMetricsController {
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spring Data 对「无 group by 的多列 select」返回 Object[]{行数组} 嵌套结构
|
||||
* (每个元素是一行的 Object[],不是标量),直接下标取会 ClassCastException,统一先解一层。
|
||||
*/
|
||||
private Object[] firstRow(Object[] arr) {
|
||||
if (arr != null && arr.length > 0 && arr[0] instanceof Object[]) {
|
||||
return (Object[]) arr[0];
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
private long asLong(Object[] arr, int i) {
|
||||
if (arr == null || i >= arr.length || arr[i] == null) {
|
||||
return 0L;
|
||||
|
||||
@@ -19,9 +19,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* [LOADTEST-METRICS] 出站 UserBase oapi 调用计数(direction=out,方案 §3.2)。<br>
|
||||
* 切在 yh-openapi-client 的 {@code OpenApiHttpClient}(所有出站开放接口调用的唯一公共入口,
|
||||
* Spring Bean)上:YschBaseOpenApi 静态门面、OpenApiUserClient / OpenApiAppClient 注入式调用
|
||||
* 全部经它发出,一处切面覆盖全部出站,不改动任何业务 Service 代码。<br>
|
||||
* 切在 yh-openapi-client 的 {@code YschOpenCall}(SDK 重构后所有出站开放接口调用的唯一
|
||||
* 公共入口,Spring Bean)上:YschBaseOpenApi 静态门面、OpenApiUserClient / OpenApiAppClient
|
||||
* 注入式调用全部经它发出,一处切面覆盖全部出站,不改动任何业务 Service 代码。<br>
|
||||
* 入站请求数(direction=in)与出站调用数(direction=out)相除即「放大系数」,
|
||||
* 是缓存层次决策的直接依据(方案 §5)。
|
||||
*/
|
||||
@@ -39,10 +39,10 @@ public class OutboundOapiMetricsAspect {
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截 OpenApiHttpClient 全部公开执行方法(getJson/postJson/get/post/postMultipart)。<br>
|
||||
* 各方法签名第 2 参均为 path(如 /oapi/app/list),据此归一化记 uri。
|
||||
* 拦截 YschOpenCall 全部公开调用方法(get/getList/post/postMultipart/download)。<br>
|
||||
* 按名重载第 2 参均为 path(如 /oapi/app/list),据此归一化记 uri。
|
||||
*/
|
||||
@Around("execution(* com.yunhai.platform.openapi.OpenApiHttpClient.*(..))")
|
||||
@Around("execution(* com.yunhai.platform.openapi.core.YschOpenCall.*(..))")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
String uri = resolveUri(point);
|
||||
String method = resolveHttpMethod(point.getSignature().getName());
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
package com.yunhai.userhome.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.yunhai.platform.utils.http.IDHttp;
|
||||
import com.yunhai.userhome.config.MsgCenterProperties;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* UserMsg 消息中心签名代理(§3.5 / BP-R3-1):IDHttp 出站自动签名(yh.app-auth 身份
|
||||
* appKey=100001,UserMsg trusted-apps 已含),UserHome 前端不直连 UserMsg。
|
||||
* <ul>
|
||||
* <li>列表/角标:/oapi/msg/list、/oapi/msg/unreadCount、/oapi/msg/todo/list;</li>
|
||||
* <li>已读:/oapi/msg/read、/oapi/msg/readAll(按当前登录人代理,userId 服务端取);</li>
|
||||
* <li>jumpUrl 改写:jumpType=1 且 jumpPath 非空且 bizType 配了基址 → 基址 + "/#" + jumpPath
|
||||
* (jumpPath 是裸相对路径如 /task/123,各应用落地页是 hash 路由)。</li>
|
||||
* </ul>
|
||||
* UserMsg 不可达时降级空结果(铃铛不 500),恢复后自愈。旧 user_message 本地表链路不动。
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MsgCenterProxyService {
|
||||
|
||||
private final IDHttp http;
|
||||
private final MsgCenterProperties properties;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public MsgCenterProxyService(IDHttp http, MsgCenterProperties properties, ObjectMapper objectMapper) {
|
||||
this.http = http;
|
||||
this.properties = properties;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
private boolean enabled() {
|
||||
return StringUtils.hasText(properties.getUsermsgBaseUrl());
|
||||
}
|
||||
|
||||
private String url(String pathAndQuery) {
|
||||
String base = properties.getUsermsgBaseUrl().trim();
|
||||
while (base.endsWith("/")) {
|
||||
base = base.substring(0, base.length() - 1);
|
||||
}
|
||||
return base + pathAndQuery;
|
||||
}
|
||||
|
||||
/** 消息分页列表(已过滤删除/过期):{total, list[]},元素含改写后的 jumpUrl */
|
||||
public Map<String, Object> list(Integer userId, Integer pageIndex, Integer pageSize, Boolean onlyUnread) {
|
||||
Map<String, Object> empty = emptyPage();
|
||||
if (!enabled()) {
|
||||
return empty;
|
||||
}
|
||||
try {
|
||||
JsonNode data = http.get(url("/oapi/msg/list?userId=" + userId
|
||||
+ "&pageIndex=" + (pageIndex == null || pageIndex < 1 ? 1 : pageIndex)
|
||||
+ "&pageSize=" + (pageSize == null || pageSize < 1 ? 10 : Math.min(pageSize, 100))
|
||||
+ "&onlyUnread=" + Boolean.TRUE.equals(onlyUnread)), JsonNode.class);
|
||||
List<Map<String, Object>> rows = new ArrayList<>();
|
||||
if (data != null && data.path("content").isArray()) {
|
||||
for (JsonNode row : data.get("content")) {
|
||||
rows.add(rewrite(row));
|
||||
}
|
||||
}
|
||||
Map<String, Object> out = new HashMap<>();
|
||||
out.put("total", data == null || !data.has("total") ? 0 : data.get("total").asInt());
|
||||
out.put("list", rows);
|
||||
return out;
|
||||
} catch (Exception e) {
|
||||
log.warn("[msgcenter] UserMsg 列表不可达(降级空)userId={}:{}", userId, e.toString());
|
||||
return empty;
|
||||
}
|
||||
}
|
||||
|
||||
/** 铃铛摘要:未读数 + 各应用待办角标(停机各自降级 0/空) */
|
||||
public Map<String, Object> summary(Integer userId, Integer schId) {
|
||||
Map<String, Object> out = new HashMap<>();
|
||||
out.put("unreadCount", 0L);
|
||||
out.put("todos", new ArrayList<>());
|
||||
if (!enabled()) {
|
||||
return out;
|
||||
}
|
||||
try {
|
||||
JsonNode unread = http.get(url("/oapi/msg/unreadCount?userId=" + userId), JsonNode.class);
|
||||
out.put("unreadCount", unread == null || !unread.isNumber() ? 0L : unread.asLong());
|
||||
} catch (Exception e) {
|
||||
log.warn("[msgcenter] UserMsg 未读数不可达(降级 0)userId={}:{}", userId, e.toString());
|
||||
}
|
||||
try {
|
||||
JsonNode todos = http.get(url("/oapi/msg/todo/list?userId=" + userId
|
||||
+ (schId == null ? "" : "&schId=" + schId)), JsonNode.class);
|
||||
List<Map<String, Object>> rows = new ArrayList<>();
|
||||
if (todos != null && todos.isArray()) {
|
||||
for (JsonNode t : todos) {
|
||||
Map<String, Object> row = new LinkedHashMap<>();
|
||||
row.put("appKey", text(t, "appKey"));
|
||||
row.put("count", t.has("count") ? t.get("count").asInt() : 0);
|
||||
rows.add(row);
|
||||
}
|
||||
}
|
||||
out.put("todos", rows);
|
||||
} catch (Exception e) {
|
||||
log.warn("[msgcenter] UserMsg 待办角标不可达(降级空)userId={}:{}", userId, e.toString());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** 标记已读(代理按登录人发送,UserMsg 侧 UPDATE 带归属人防伪) */
|
||||
public void read(Integer userId, List<Long> msgIds) {
|
||||
if (!enabled() || msgIds == null || msgIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("msgIds", msgIds);
|
||||
body.put("userId", userId);
|
||||
http.post(url("/oapi/msg/read"), body, JsonNode.class);
|
||||
}
|
||||
|
||||
/** 全部已读 */
|
||||
public void readAll(Integer userId) {
|
||||
if (!enabled()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("userId", userId);
|
||||
http.post(url("/oapi/msg/readAll"), body, JsonNode.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* WS 握手票据:以应用身份为登录人换一次性票据(UserMsg /oapi/msg/ws/ticket),
|
||||
* 拼上浏览器可达的 WS 端点返回。未配置 WS 地址 / UserMsg 不可达 → null(前端维持轮询兜底表现)。
|
||||
*/
|
||||
public String createWsTicket(Integer userId) {
|
||||
if (!enabled() || !StringUtils.hasText(properties.getUsermsgWsUrl())) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("userId", userId);
|
||||
JsonNode data = http.post(url("/oapi/msg/ws/ticket"), body, JsonNode.class);
|
||||
String ticket = data == null || !data.hasNonNull("ticket") ? null : data.get("ticket").asText();
|
||||
if (!StringUtils.hasText(ticket)) {
|
||||
return null;
|
||||
}
|
||||
String wsUrl = properties.getUsermsgWsUrl().trim();
|
||||
return wsUrl + (wsUrl.contains("?") ? "&" : "?") + "ticket=" + ticket;
|
||||
} catch (Exception e) {
|
||||
log.warn("[msgcenter] UserMsg WS 票据不可达(降级 null,前端不建立长连接)userId={}:{}",
|
||||
userId, e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 出参改写 =====
|
||||
|
||||
/** MsgListVo 逐字段透传 + jumpUrl 改写(jumpType=1 且配置了 bizType 基址时)+ 应用名补全 */
|
||||
private Map<String, Object> rewrite(JsonNode row) {
|
||||
Map<String, Object> out = new LinkedHashMap<>();
|
||||
out.put("msgId", row.has("msgId") ? row.get("msgId").asLong() : null);
|
||||
out.put("title", text(row, "title"));
|
||||
out.put("content", text(row, "content"));
|
||||
out.put("msgType", row.has("msgType") && row.get("msgType").isNumber() ? row.get("msgType").asInt() : null);
|
||||
out.put("jumpType", row.has("jumpType") && row.get("jumpType").isNumber() ? row.get("jumpType").asInt() : null);
|
||||
out.put("jumpPath", text(row, "jumpPath"));
|
||||
out.put("appKey", text(row, "appKey"));
|
||||
String appKey = text(row, "appKey");
|
||||
out.put("appName", appKey == null ? null : properties.getAppNames().get(appKey));
|
||||
out.put("bizType", text(row, "bizType"));
|
||||
out.put("bizId", text(row, "bizId"));
|
||||
out.put("sendTime", text(row, "sendTime"));
|
||||
out.put("isRead", row.has("isRead") && row.get("isRead").isNumber() ? row.get("isRead").asInt() : 0);
|
||||
out.put("jumpUrl", jumpUrl(row));
|
||||
return out;
|
||||
}
|
||||
|
||||
/** 基址 + "/#" + jumpPath;未配置基址/非应用内跳转/无路径 → null(前端不渲染跳转) */
|
||||
private String jumpUrl(JsonNode row) {
|
||||
Integer jumpType = row.has("jumpType") && row.get("jumpType").isNumber() ? row.get("jumpType").asInt() : null;
|
||||
String jumpPath = text(row, "jumpPath");
|
||||
String bizType = text(row, "bizType");
|
||||
if (jumpType == null || jumpType != 1 || !StringUtils.hasText(jumpPath)
|
||||
|| !StringUtils.hasText(bizType)) {
|
||||
return null;
|
||||
}
|
||||
String base = properties.getJumpBases().get(bizType);
|
||||
if (!StringUtils.hasText(base)) {
|
||||
return null;
|
||||
}
|
||||
String b = base.trim();
|
||||
while (b.endsWith("/")) {
|
||||
b = b.substring(0, b.length() - 1);
|
||||
}
|
||||
String path = jumpPath.startsWith("/") ? jumpPath : "/" + jumpPath;
|
||||
return b + "/#" + path;
|
||||
}
|
||||
|
||||
private static Map<String, Object> emptyPage() {
|
||||
Map<String, Object> out = new HashMap<>();
|
||||
out.put("total", 0);
|
||||
out.put("list", new ArrayList<>());
|
||||
return out;
|
||||
}
|
||||
|
||||
private static String text(JsonNode node, String field) {
|
||||
return node != null && node.has(field) && !node.get(field).isNull() ? node.get(field).asText() : null;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.yunhai.userhome.service.impl;
|
||||
|
||||
import com.yunhai.platform.openapi.client.YschBaseOpenApi;
|
||||
import com.yunhai.platform.openapi.base.YschBaseOpenApi;
|
||||
import com.yunhai.platform.utils.enums.ClientEnum;
|
||||
import com.yunhai.platform.utils.model.BoaApp;
|
||||
import com.yunhai.platform.utils.model.BoaAppType;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.yunhai.userhome.service.impl;
|
||||
|
||||
import com.yunhai.platform.openapi.client.OpenApiUserClient;
|
||||
import com.yunhai.platform.openapi.base.OpenApiUserClient;
|
||||
import com.yunhai.platform.utils.model.BoaRoleInfo;
|
||||
import com.yunhai.userhome.entity.UserCurrentRole;
|
||||
import com.yunhai.userhome.service.IUserCurrentRoleService;
|
||||
|
||||
Reference in New Issue
Block a user