Commit 6a6746b2736a9f1bc69b0c7693e90fbbda930e6c

Authored by alexyang
1 parent e839e45c

新增极光推送功能及设备ID绑定保存至Redis的接口逻辑

sl-express-ms-web-courier/src/main/java/com/sl/ms/web/courier/controller/JPushController.java 0 → 100644
  1 +package com.sl.ms.web.courier.controller;
  2 +
  3 +import com.sl.ms.web.courier.vo.jpush.JPushVO;
  4 +import com.sl.transport.common.vo.R;
  5 +import io.swagger.annotations.Api;
  6 +import io.swagger.annotations.ApiOperation;
  7 +import org.springframework.data.redis.core.StringRedisTemplate;
  8 +import org.springframework.web.bind.annotation.PostMapping;
  9 +import org.springframework.web.bind.annotation.RequestBody;
  10 +import org.springframework.web.bind.annotation.RequestMapping;
  11 +import org.springframework.web.bind.annotation.RestController;
  12 +
  13 +import javax.annotation.Resource;
  14 +
  15 +@Api(tags = "极光推送相关接口")
  16 +@RestController
  17 +@RequestMapping("jpush")
  18 +public class JPushController {
  19 +
  20 + @Resource
  21 + private StringRedisTemplate stringRedisTemplate;
  22 +
  23 + @PostMapping("saveDevice")
  24 + @ApiOperation(value = "保存设备ID到Redis", notes = "将快递员ID与极光推送设备ID绑定")
  25 + public R<Void> saveDevice(@RequestBody JPushVO jPushVO) {
  26 + // 1. 获取参数
  27 + Long userId = jPushVO.getUserId();
  28 + String deviceId = jPushVO.getDeviceId();
  29 +
  30 + // 2. 校验
  31 + if (userId == null || deviceId == null) {
  32 + return R.error("用户ID或设备ID不能为空");
  33 + }
  34 +
  35 + // 3. 存储到 Redis (参考 LoginServiceImpl 逻辑)
  36 + String redisKey = "courier:device:" + userId;
  37 + stringRedisTemplate.opsForValue().set(redisKey, deviceId);
  38 +
  39 + return R.success();
  40 + }
  41 +}
0 42 \ No newline at end of file
... ...
sl-express-ms-web-courier/src/main/java/com/sl/ms/web/courier/vo/jpush/JPushVO.java 0 → 100644
  1 +package com.sl.ms.web.courier.vo.jpush;
  2 +
  3 +
  4 +import io.swagger.annotations.ApiModel;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +
  8 +import java.io.Serializable;
  9 +
  10 +@Data
  11 +@ApiModel(value = "极光推送信息", description = "用于绑定用户与设备ID")
  12 +public class JPushVO implements Serializable {
  13 +
  14 + @ApiModelProperty(value = "用户ID", required = true)
  15 + private Long userId;
  16 +
  17 + @ApiModelProperty(value = "设备ID", required = true)
  18 + private String deviceId;
  19 +}
... ...