You've already forked FrameTour-BE
refactor(notify): 重构用户通知授权控制器以适应新的上下文处理器
- 将 JwtInfo 替换为 BaseContextHandler 来获取用户ID - 更新 ResponseData 类型为 ApiResponse - 修改 member ID 的获取方式为从 BaseContextHandler 中解析 - 使用 Jakarta Validation 注解替换旧的校验注解 - 调整 import 包路径以匹配新架构
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
package com.ycwl.basic.controller.mobile.notify;
|
||||
|
||||
import com.ycwl.basic.config.JwtInfo;
|
||||
import com.ycwl.basic.constant.BaseContextHandler;
|
||||
import com.ycwl.basic.model.mobile.notify.req.NotificationAuthRecordReq;
|
||||
import com.ycwl.basic.model.mobile.notify.resp.NotificationAuthRecordResp;
|
||||
import com.ycwl.basic.model.pc.notify.entity.UserNotificationAuthorizationEntity;
|
||||
import com.ycwl.basic.service.UserNotificationAuthorizationService;
|
||||
import com.ycwl.basic.utils.ResponseData;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
/**
|
||||
* 用户通知授权记录Controller (移动端API)
|
||||
@@ -33,9 +33,9 @@ public class UserNotificationAuthController {
|
||||
* 用户主动同意通知授权时调用
|
||||
*/
|
||||
@PostMapping("/record")
|
||||
public ResponseData<NotificationAuthRecordResp> recordAuthorization(
|
||||
@JwtInfo Long memberId,
|
||||
public ApiResponse<NotificationAuthRecordResp> recordAuthorization(
|
||||
@Valid @RequestBody NotificationAuthRecordReq req) {
|
||||
Long memberId = Long.parseLong(BaseContextHandler.getUserId());
|
||||
log.info("记录用户通知授权: memberId={}, templateId={}, scenicId={}",
|
||||
memberId, req.getTemplateId(), req.getScenicId());
|
||||
|
||||
@@ -46,10 +46,10 @@ public class UserNotificationAuthController {
|
||||
NotificationAuthRecordResp resp = new NotificationAuthRecordResp();
|
||||
BeanUtils.copyProperties(record, resp);
|
||||
|
||||
return ResponseData.success(resp);
|
||||
return ApiResponse.success(resp);
|
||||
} catch (Exception e) {
|
||||
log.error("记录用户通知授权失败", e);
|
||||
return ResponseData.fail("记录授权失败: " + e.getMessage());
|
||||
return ApiResponse.fail("记录授权失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user