3 changed files with 66 additions and 0 deletions
@ -0,0 +1,55 @@ |
|||
package com.ccsens.carbasics.api; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.ccsens.wechatutil.bean.dto.wxmini.NoticeDto; |
|||
import com.ccsens.wechatutil.bean.vo.wxmini.Custom; |
|||
import com.ccsens.wechatutil.wxcommon.WxCommonUtil; |
|||
import com.ccsens.wechatutil.wxmini.MiniCustomSendUtil; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.security.NoSuchAlgorithmException; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2021/10/21 14:46 |
|||
*/ |
|||
@Api(tags = "微信小程序相关" , description = "") |
|||
@RestController |
|||
@RequestMapping("/mini") |
|||
@Slf4j |
|||
public class MiniController { |
|||
|
|||
@Value("wx.mini.token") |
|||
private String token; |
|||
@Value("wx.mini.appId") |
|||
private String appId; |
|||
@Value("wx.mini.secret") |
|||
private String secret; |
|||
|
|||
@ApiOperation(value = "接收微信小程序消息通知", notes = "") |
|||
@RequestMapping(value = "/notice", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) |
|||
public String noticeGet(@Validated NoticeDto.ValidMsg validMsg) throws NoSuchAlgorithmException { |
|||
log.info("接收微信小程序token:{}",validMsg); |
|||
return validMsg.check(token) ? validMsg.getEchostr() : null; |
|||
} |
|||
|
|||
@ApiOperation(value = "接收微信小程序消息通知", notes = "") |
|||
@RequestMapping(value = "/notice", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public String notice(@Validated NoticeDto.Notice notice) { |
|||
log.info("接收微信小程序消息通知:{}", notice); |
|||
Custom.Text text = new Custom.Text(); |
|||
text.setContent("客服人员正在赶来的路上..."); |
|||
MiniCustomSendUtil.send(notice.getFromUserName(), Custom.Type.TEXT, text); |
|||
|
|||
return "success"; |
|||
} |
|||
} |
Loading…
Reference in new issue