消息订阅

This commit is contained in:
Tankaikai
2025-03-17 13:46:37 +08:00
parent 066f70a3dd
commit d4c329e7aa
16 changed files with 408 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
package com.czg.controller.admin;
import com.czg.account.dto.WxMsgSubDTO;
import com.czg.account.dto.msg.ShopMsgEditDTO;
import com.czg.account.dto.msg.ShopPushOpenIdEditDTO;
import com.czg.account.entity.ShopPushOpenId;
@@ -14,6 +15,7 @@ import com.czg.validator.group.DefaultGroup;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -22,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
*
* @author Administrator
*/
@Slf4j
@RestController
@RequestMapping("/admin/shopMsgPush")
public class ShopMsgPushController {
@@ -30,6 +33,32 @@ public class ShopMsgPushController {
@Resource
private ShopPushOpenIdService shopPushOpenIdService;
/**
* 店铺推送状态获取
*/
@PostMapping("/subscribe")
public CzgResult<Void> subscribe(@RequestBody WxMsgSubDTO wxMsgSubDTO) {
log.info("接收到订阅消息接口调用,携带数据: {}", wxMsgSubDTO);
if (wxMsgSubDTO.getOpenId() == null || wxMsgSubDTO.getShopId() == null) {
return CzgResult.failure("shopId或openId缺失");
}
ShopPushOpenId entity = shopPushOpenIdService.getOne(QueryWrapper.create().eq(ShopPushOpenId::getOpenId, wxMsgSubDTO.getOpenId()).eq(ShopPushOpenId::getShopId, wxMsgSubDTO.getShopId()));
if (entity == null) {
entity = new ShopPushOpenId();
}
entity.setShopId(wxMsgSubDTO.getShopId());
entity.setOpenId(wxMsgSubDTO.getOpenId());
entity.setNickname(wxMsgSubDTO.getNickname());
entity.setAvatar(wxMsgSubDTO.getAvatar());
if (entity.getId() == null) {
shopPushOpenIdService.save(entity);
} else {
shopPushOpenIdService.updateById(entity);
}
return CzgResult.success();
}
/**
* 店铺推送状态获取
*/