tcm-training-admin-backend/src/main/java/com/tcm/training/admin/app/home/controller/AppLiveRoomSettingController.java
@@ -1,5 +1,6 @@ package com.tcm.training.admin.app.home.controller; import com.tcm.training.admin.app.home.dto.CreateLiveRoomEntryRequest; import com.tcm.training.admin.app.home.service.AppVzanLiveEntryService; import com.tcm.training.admin.app.home.vo.AppVzanLiveEntryVO; import com.tcm.training.admin.common.ApiResponse; @@ -7,8 +8,11 @@ import com.tcm.training.admin.live.vo.LiveRoomSettingVO; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; @RestController @@ -29,7 +33,7 @@ } @PostMapping("/live-room-entry") public ApiResponse<AppVzanLiveEntryVO> createEntry() { return ApiResponse.ok(vzanLiveEntryService.createEntry()); public ApiResponse<AppVzanLiveEntryVO> createEntry(@Valid @RequestBody CreateLiveRoomEntryRequest request) { return ApiResponse.ok(vzanLiveEntryService.createEntry(request.getUserId())); } } tcm-training-admin-backend/src/main/java/com/tcm/training/admin/app/home/service/AppVzanLiveEntryService.java
@@ -49,8 +49,9 @@ this.appAuthSessionService = appAuthSessionService; } public AppVzanLiveEntryVO createEntry() { Long userId = appAuthSessionService.getLoginUserId(); public AppVzanLiveEntryVO createEntry(Long userId) { // APP 发版完成后改为从登录会话获取用户ID,避免客户端指定其他用户。 // Long userId = appAuthSessionService.getLoginUserId(); LiveRoomSettingVO setting = liveRoomSettingService.current(); String liveRoomUrl = setting == null ? null : StrUtil.trim(setting.getLiveRoomUrl()); validateLiveRoomUrl(liveRoomUrl); tcm-training-admin-backend/src/test/java/com/tcm/training/admin/app/home/service/AppVzanLiveEntryServiceTest.java
@@ -60,8 +60,7 @@ clinic.setContactPhone("13800000000"); when(clinicMapper.selectById(34L)).thenReturn(clinic); when(appAuthSessionService.getLoginUserId()).thenReturn(12L); AppVzanLiveEntryVO result = service.createEntry(); AppVzanLiveEntryVO result = service.createEntry(12L); assertTrue(result.getUrl().startsWith("https://example.com/live?old=1&data=")); assertEquals("webchatPay/wx074c1f0cf5a0ecf4 InAppPay", result.getUa()); traditionalApp/pages/home/home.vue
@@ -468,7 +468,7 @@ try { console.log('[goWeiZanLive] 当前用户ID:', userId); console.log('[goWeiZanLive] 开始调用 createLiveRoomEntry 接口'); const res = await createLiveRoomEntry(); const res = await createLiveRoomEntry(userId); console.log('[goWeiZanLive] createLiveRoomEntry 返回:', JSON.stringify(res)); const targetUrl = res?.data?.url?.trim(); traditionalApp/pages/home/service.js
@@ -52,6 +52,6 @@ /** * 根据当前登录用户生成短时有效的微赞直播入口。 */ export const createLiveRoomEntry = () => { return request.post('/api/app/home/live-room-entry', {}, false, false) export const createLiveRoomEntry = (userId) => { return request.post('/api/app/home/live-room-entry', { userId }, false, false) }