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); + } + }