You've already forked FrameTour-BE
Merge branch 'notify_v2'
This commit is contained in:
@@ -41,7 +41,8 @@ public class UserNotificationAuthController {
|
||||
@PostMapping("/record")
|
||||
public ApiResponse<NotificationAuthRecordResp> recordAuthorization(
|
||||
@RequestBody NotificationAuthRecordReq req) {
|
||||
log.debug("记录用户通知授权: templateIds={}, scenicId={}", req.getTemplateIds(), req.getScenicId());
|
||||
log.debug("记录用户通知授权: templateIds={}, scenicId={}, requestId={}",
|
||||
req.getTemplateIds(), req.getScenicId(), req.getRequestId());
|
||||
|
||||
try {
|
||||
// 获取当前用户ID
|
||||
@@ -50,7 +51,7 @@ public class UserNotificationAuthController {
|
||||
// 调用批量授权记录方法
|
||||
List<UserNotificationAuthorizationService.AuthorizationRecord> records =
|
||||
userNotificationAuthorizationService.batchRecordAuthorization(
|
||||
memberId, req.getTemplateIds(), req.getScenicId());
|
||||
memberId, req.getTemplateIds(), req.getScenicId(), req.getRequestId());
|
||||
|
||||
NotificationAuthRecordResp resp = new NotificationAuthRecordResp();
|
||||
|
||||
@@ -187,4 +188,4 @@ public class UserNotificationAuthController {
|
||||
return ApiResponse.fail("获取授权信息失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.ycwl.basic.controller.mobile.notify;
|
||||
|
||||
import com.ycwl.basic.model.mobile.notify.resp.WechatSubscribeSceneTemplatesResp;
|
||||
import com.ycwl.basic.model.pc.notify.entity.WechatSubscribeTemplateConfigEntity;
|
||||
import com.ycwl.basic.service.notify.WechatSubscribeNotifyConfigService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import com.ycwl.basic.utils.JwtTokenUtil;
|
||||
import com.ycwl.basic.utils.NotificationAuthUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 微信小程序订阅消息:场景模板查询(移动端API)
|
||||
*
|
||||
* @Author: System
|
||||
* @Date: 2025/12/31
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/mobile/notify/subscribe")
|
||||
@Slf4j
|
||||
public class WechatSubscribeNotifyController {
|
||||
|
||||
private final WechatSubscribeNotifyConfigService configService;
|
||||
private final NotificationAuthUtils notificationAuthUtils;
|
||||
|
||||
public WechatSubscribeNotifyController(WechatSubscribeNotifyConfigService configService,
|
||||
NotificationAuthUtils notificationAuthUtils) {
|
||||
this.configService = configService;
|
||||
this.notificationAuthUtils = notificationAuthUtils;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取“场景”下可申请授权的模板列表(支持按 scenicId 覆盖模板ID/开关/文案)
|
||||
*/
|
||||
@GetMapping("/scenic/{scenicId}/scenes/{sceneKey}/templates")
|
||||
public ApiResponse<WechatSubscribeSceneTemplatesResp> listSceneTemplates(@PathVariable("scenicId") Long scenicId,
|
||||
@PathVariable("sceneKey") String sceneKey) {
|
||||
if (scenicId == null) {
|
||||
return ApiResponse.fail("scenicId不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(sceneKey)) {
|
||||
return ApiResponse.fail("sceneKey不能为空");
|
||||
}
|
||||
|
||||
Long memberId = JwtTokenUtil.getWorker().getUserId();
|
||||
List<WechatSubscribeTemplateConfigEntity> configs = configService.listSceneTemplateConfigs(scenicId, sceneKey);
|
||||
|
||||
WechatSubscribeSceneTemplatesResp resp = new WechatSubscribeSceneTemplatesResp();
|
||||
resp.setScenicId(scenicId);
|
||||
resp.setSceneKey(sceneKey);
|
||||
|
||||
List<WechatSubscribeSceneTemplatesResp.TemplateInfo> templates = new ArrayList<>();
|
||||
for (WechatSubscribeTemplateConfigEntity cfg : configs) {
|
||||
if (cfg == null || StringUtils.isBlank(cfg.getWechatTemplateId())) {
|
||||
continue;
|
||||
}
|
||||
String title = StringUtils.isNotBlank(cfg.getTitleTemplate())
|
||||
? cfg.getTitleTemplate()
|
||||
: cfg.getTemplateKey();
|
||||
int remaining = notificationAuthUtils.getRemainingCount(memberId, cfg.getWechatTemplateId(), scenicId);
|
||||
|
||||
WechatSubscribeSceneTemplatesResp.TemplateInfo info = new WechatSubscribeSceneTemplatesResp.TemplateInfo();
|
||||
info.setTemplateKey(cfg.getTemplateKey());
|
||||
info.setWechatTemplateId(cfg.getWechatTemplateId());
|
||||
info.setTitle(title);
|
||||
info.setDescription(cfg.getDescription());
|
||||
info.setRemainingCount(remaining);
|
||||
info.setHasAuthorization(remaining > 0);
|
||||
templates.add(info);
|
||||
}
|
||||
resp.setTemplates(templates);
|
||||
|
||||
log.debug("场景模板查询: scenicId={}, sceneKey={}, memberId={}, templateCount={}",
|
||||
scenicId, sceneKey, memberId, Objects.requireNonNullElse(templates.size(), 0));
|
||||
return ApiResponse.success(resp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.ycwl.basic.controller.pc;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.model.pc.notify.entity.WechatSubscribeEventTemplateEntity;
|
||||
import com.ycwl.basic.model.pc.notify.entity.WechatSubscribeSceneTemplateEntity;
|
||||
import com.ycwl.basic.model.pc.notify.entity.WechatSubscribeSendLogEntity;
|
||||
import com.ycwl.basic.model.pc.notify.entity.WechatSubscribeTemplateConfigEntity;
|
||||
import com.ycwl.basic.model.pc.notify.req.WechatSubscribeEventTemplatePageReq;
|
||||
import com.ycwl.basic.model.pc.notify.req.WechatSubscribeEventTemplateSaveReq;
|
||||
import com.ycwl.basic.model.pc.notify.req.WechatSubscribeSceneTemplatePageReq;
|
||||
import com.ycwl.basic.model.pc.notify.req.WechatSubscribeSceneTemplateSaveReq;
|
||||
import com.ycwl.basic.model.pc.notify.req.WechatSubscribeSendLogPageReq;
|
||||
import com.ycwl.basic.model.pc.notify.req.WechatSubscribeTemplateConfigPageReq;
|
||||
import com.ycwl.basic.model.pc.notify.req.WechatSubscribeTemplateConfigSaveReq;
|
||||
import com.ycwl.basic.service.pc.WechatSubscribeNotifyAdminService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 微信小程序订阅消息:配置管理(管理后台)
|
||||
*
|
||||
* @Author: System
|
||||
* @Date: 2025/12/31
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/wechatSubscribeNotify/v1")
|
||||
@RequiredArgsConstructor
|
||||
public class WechatSubscribeNotifyAdminController {
|
||||
|
||||
private final WechatSubscribeNotifyAdminService adminService;
|
||||
|
||||
// ========================= 模板配置 =========================
|
||||
|
||||
@PostMapping("/templateConfig/page")
|
||||
public ApiResponse<PageInfo<WechatSubscribeTemplateConfigEntity>> pageTemplateConfig(
|
||||
@RequestBody WechatSubscribeTemplateConfigPageReq req) {
|
||||
return adminService.pageTemplateConfig(req);
|
||||
}
|
||||
|
||||
@GetMapping("/templateConfig/detail/{id}")
|
||||
public ApiResponse<WechatSubscribeTemplateConfigEntity> getTemplateConfig(@PathVariable("id") Long id) {
|
||||
return adminService.getTemplateConfig(id);
|
||||
}
|
||||
|
||||
@PostMapping("/templateConfig/save")
|
||||
public ApiResponse<Boolean> saveTemplateConfig(@RequestBody WechatSubscribeTemplateConfigSaveReq req) {
|
||||
return adminService.saveTemplateConfig(req);
|
||||
}
|
||||
|
||||
@DeleteMapping("/templateConfig/delete/{id}")
|
||||
public ApiResponse<Boolean> deleteTemplateConfig(@PathVariable("id") Long id) {
|
||||
return adminService.deleteTemplateConfig(id);
|
||||
}
|
||||
|
||||
// ========================= 场景映射 =========================
|
||||
|
||||
@PostMapping("/sceneTemplate/page")
|
||||
public ApiResponse<PageInfo<WechatSubscribeSceneTemplateEntity>> pageSceneTemplate(
|
||||
@RequestBody WechatSubscribeSceneTemplatePageReq req) {
|
||||
return adminService.pageSceneTemplate(req);
|
||||
}
|
||||
|
||||
@GetMapping("/sceneTemplate/detail/{id}")
|
||||
public ApiResponse<WechatSubscribeSceneTemplateEntity> getSceneTemplate(@PathVariable("id") Long id) {
|
||||
return adminService.getSceneTemplate(id);
|
||||
}
|
||||
|
||||
@PostMapping("/sceneTemplate/save")
|
||||
public ApiResponse<Boolean> saveSceneTemplate(@RequestBody WechatSubscribeSceneTemplateSaveReq req) {
|
||||
return adminService.saveSceneTemplate(req);
|
||||
}
|
||||
|
||||
@DeleteMapping("/sceneTemplate/delete/{id}")
|
||||
public ApiResponse<Boolean> deleteSceneTemplate(@PathVariable("id") Long id) {
|
||||
return adminService.deleteSceneTemplate(id);
|
||||
}
|
||||
|
||||
// ========================= 事件映射 =========================
|
||||
|
||||
@PostMapping("/eventTemplate/page")
|
||||
public ApiResponse<PageInfo<WechatSubscribeEventTemplateEntity>> pageEventTemplate(
|
||||
@RequestBody WechatSubscribeEventTemplatePageReq req) {
|
||||
return adminService.pageEventTemplate(req);
|
||||
}
|
||||
|
||||
@GetMapping("/eventTemplate/detail/{id}")
|
||||
public ApiResponse<WechatSubscribeEventTemplateEntity> getEventTemplate(@PathVariable("id") Long id) {
|
||||
return adminService.getEventTemplate(id);
|
||||
}
|
||||
|
||||
@PostMapping("/eventTemplate/save")
|
||||
public ApiResponse<Boolean> saveEventTemplate(@RequestBody WechatSubscribeEventTemplateSaveReq req) {
|
||||
return adminService.saveEventTemplate(req);
|
||||
}
|
||||
|
||||
@DeleteMapping("/eventTemplate/delete/{id}")
|
||||
public ApiResponse<Boolean> deleteEventTemplate(@PathVariable("id") Long id) {
|
||||
return adminService.deleteEventTemplate(id);
|
||||
}
|
||||
|
||||
// ========================= 发送日志 =========================
|
||||
|
||||
@PostMapping("/sendLog/page")
|
||||
public ApiResponse<PageInfo<WechatSubscribeSendLogEntity>> pageSendLog(@RequestBody WechatSubscribeSendLogPageReq req) {
|
||||
return adminService.pageSendLog(req);
|
||||
}
|
||||
|
||||
@GetMapping("/sendLog/detail/{id}")
|
||||
public ApiResponse<WechatSubscribeSendLogEntity> getSendLog(@PathVariable("id") Long id) {
|
||||
return adminService.getSendLog(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user