From 0c3216c6d38459db6ec515c86cdccd6537159537 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Tue, 6 Sep 2022 17:15:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=A5=E5=8F=A3=EF=BC=9A?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/common/config/WebSecurityConfig.java | 1 + .../com/xkrs/controller/PushController.java | 26 +++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index f0e768b..82354b0 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -34,6 +34,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter { // 所有OPTIONS请求都放行 .antMatchers(HttpMethod.OPTIONS).permitAll() .antMatchers("/global/configuration/**").permitAll() + .antMatchers("/push/**").permitAll() .antMatchers(HttpMethod.GET, "/selectGlobalConfigDict").permitAll() .antMatchers(HttpMethod.GET, "/selectGlobalConfigValue").permitAll() .antMatchers(HttpMethod.GET, "/selectGlobalConfig").permitAll() diff --git a/src/main/java/com/xkrs/controller/PushController.java b/src/main/java/com/xkrs/controller/PushController.java index cc1769b..7c69505 100644 --- a/src/main/java/com/xkrs/controller/PushController.java +++ b/src/main/java/com/xkrs/controller/PushController.java @@ -4,12 +4,11 @@ import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.dao.SysUserDao; import com.xkrs.model.entity.SysUserEntity; import com.xkrs.model.qo.SysUserPushAccountQo; +import com.xkrs.sms.PushHelper; import com.xkrs.utils.ListUtils; import org.apache.hc.core5.util.TextUtils; import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.ArrayList; @@ -20,6 +19,7 @@ import java.util.Optional; import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; @RestController +@RequestMapping(value = "/push") public class PushController { private final Locale locale = LocaleContextHolder.getLocale(); @@ -27,8 +27,11 @@ public class PushController { @Resource private SysUserDao sysUserDao; - @PostMapping("/bindPushInfo") - public String bindPushInfo(@RequestBody SysUserPushAccountQo sysUserPushAccountQo) { + @Resource + private PushHelper pushHelper; + + @PostMapping("/bindUserPushInfo") + public String bindUserPushInfo(@RequestBody SysUserPushAccountQo sysUserPushAccountQo) { Integer id = sysUserPushAccountQo.getId(); String userAccount = sysUserPushAccountQo.getUserAccount(); String regID = sysUserPushAccountQo.getRegID(); @@ -69,4 +72,17 @@ public class PushController { return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "绑定成功", locale); } + @GetMapping("/testPush") + public String testPush(@RequestParam(value = "userAccount") String userAccount) { + //推送 + try { + List userAccountList = new ArrayList<>(); + userAccountList.add(userAccount); + pushHelper.dispatchPushMessage(userAccountList, null); + } catch (Exception e) { + e.printStackTrace(); + } + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "OKK", locale); + } + }