| | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import javax.validation.Valid; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.moral.api.entity.Allocation; |
| | | import com.moral.api.pojo.query.app.AppAllocationPushUserCond; |
| | | import com.moral.api.service.UserService; |
| | | |
| | | import com.moral.api.utils.HttpClientUtil; |
| | | |
| | | import com.moral.api.utils.WechatUtils; |
| | | import com.moral.api.vo.WxMssVo; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | @GetMapping("pushOneUser") |
| | | @PostMapping("pushOneUser") |
| | | @ApiOperation(value = "小程序推送消息") |
| | | public ResultMessage pushOneUser(){ |
| | | String body = push("oOCWi6-_hnzSvrMT8HX5D7Dz7tEA"); |
| | | return ResultMessage.ok(body); |
| | | public ResultMessage pushOneUser(@Valid @RequestBody Allocation appAllocationPushUserCond){ |
| | | userService.pushOneUser(appAllocationPushUserCond); |
| | | // String body = push("oOCWi6-_hnzSvrMT8HX5D7Dz7tEA"); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | |
| | |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取) |
| | | //小程序订阅 |
| | | String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + HttpClientUtil.getAccessToken(); |
| | | String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + WechatUtils.getAccessToken(); |
| | | // String url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=" + HttpClientUtil.getAccessToken(); |
| | | // String url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=" + HttpClientUtil.getAccessToken(); |
| | | // String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + HttpClientUtil.getAccessToken(); |
| | |
| | | m.put("thing2", map3); |
| | | m.put("date4", map4); |
| | | wxMssVo.setData(JSON.toJSON(m)); |
| | | |
| | | |
| | | ResponseEntity<String> responseEntity = |
| | | restTemplate.postForEntity(url, wxMssVo, String.class); |