🎨
This commit is contained in:
parent
f663f41270
commit
a461492eba
@ -23,7 +23,7 @@ import static me.chanjar.weixin.common.api.WxConsts.MenuButtonType;
|
|||||||
*/
|
*/
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/wx/menu/{appid}")
|
@RequestMapping("/wx/menu/{appId}")
|
||||||
public class WxMenuController {
|
public class WxMenuController {
|
||||||
private final WxMpService wxService;
|
private final WxMpService wxService;
|
||||||
|
|
||||||
@ -38,12 +38,12 @@ public class WxMenuController {
|
|||||||
* @return 如果是个性化菜单,则返回menuid,否则返回null
|
* @return 如果是个性化菜单,则返回menuid,否则返回null
|
||||||
*/
|
*/
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public String menuCreate(@PathVariable String appid, @RequestBody WxMenu menu) throws WxErrorException {
|
public String menuCreate(@PathVariable String appId, @RequestBody WxMenu menu) throws WxErrorException {
|
||||||
return this.wxService.switchoverTo(appid).getMenuService().menuCreate(menu);
|
return this.wxService.switchoverTo(appId).getMenuService().menuCreate(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/create")
|
@GetMapping("/create")
|
||||||
public String menuCreateSample(@PathVariable String appid) throws WxErrorException, MalformedURLException {
|
public String menuCreateSample(@PathVariable String appId) throws WxErrorException, MalformedURLException {
|
||||||
WxMenu menu = new WxMenu();
|
WxMenu menu = new WxMenu();
|
||||||
WxMenuButton button1 = new WxMenuButton();
|
WxMenuButton button1 = new WxMenuButton();
|
||||||
button1.setType(MenuButtonType.CLICK);
|
button1.setType(MenuButtonType.CLICK);
|
||||||
@ -88,8 +88,8 @@ public class WxMenuController {
|
|||||||
if (servletRequestAttributes != null) {
|
if (servletRequestAttributes != null) {
|
||||||
HttpServletRequest request = servletRequestAttributes.getRequest();
|
HttpServletRequest request = servletRequestAttributes.getRequest();
|
||||||
URL requestURL = new URL(request.getRequestURL().toString());
|
URL requestURL = new URL(request.getRequestURL().toString());
|
||||||
String url = this.wxService.switchoverTo(appid).oauth2buildAuthorizationUrl(
|
String url = this.wxService.switchoverTo(appId).oauth2buildAuthorizationUrl(
|
||||||
String.format("%s://%s/wx/redirect/%s/greet", requestURL.getProtocol(), requestURL.getHost(), appid),
|
String.format("%s://%s/wx/redirect/%s/greet", requestURL.getProtocol(), requestURL.getHost(), appId),
|
||||||
WxConsts.OAuth2Scope.SNSAPI_USERINFO, null);
|
WxConsts.OAuth2Scope.SNSAPI_USERINFO, null);
|
||||||
button34.setUrl(url);
|
button34.setUrl(url);
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ public class WxMenuController {
|
|||||||
button3.getSubButtons().add(button33);
|
button3.getSubButtons().add(button33);
|
||||||
button3.getSubButtons().add(button34);
|
button3.getSubButtons().add(button34);
|
||||||
|
|
||||||
this.wxService.switchover(appid);
|
this.wxService.switchover(appId);
|
||||||
return this.wxService.getMenuService().menuCreate(menu);
|
return this.wxService.getMenuService().menuCreate(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,8 +114,8 @@ public class WxMenuController {
|
|||||||
* @return 如果是个性化菜单,则返回menuid,否则返回null
|
* @return 如果是个性化菜单,则返回menuid,否则返回null
|
||||||
*/
|
*/
|
||||||
@PostMapping("/createByJson")
|
@PostMapping("/createByJson")
|
||||||
public String menuCreate(@PathVariable String appid, @RequestBody String json) throws WxErrorException {
|
public String menuCreate(@PathVariable String appId, @RequestBody String json) throws WxErrorException {
|
||||||
return this.wxService.switchoverTo(appid).getMenuService().menuCreate(json);
|
return this.wxService.switchoverTo(appId).getMenuService().menuCreate(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,8 +125,8 @@ public class WxMenuController {
|
|||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
@GetMapping("/delete")
|
@GetMapping("/delete")
|
||||||
public void menuDelete(@PathVariable String appid) throws WxErrorException {
|
public void menuDelete(@PathVariable String appId) throws WxErrorException {
|
||||||
this.wxService.switchoverTo(appid).getMenuService().menuDelete();
|
this.wxService.switchoverTo(appId).getMenuService().menuDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,8 +138,8 @@ public class WxMenuController {
|
|||||||
* @param menuId 个性化菜单的menuid
|
* @param menuId 个性化菜单的menuid
|
||||||
*/
|
*/
|
||||||
@GetMapping("/delete/{menuId}")
|
@GetMapping("/delete/{menuId}")
|
||||||
public void menuDelete(@PathVariable String appid, @PathVariable String menuId) throws WxErrorException {
|
public void menuDelete(@PathVariable String appId, @PathVariable String menuId) throws WxErrorException {
|
||||||
this.wxService.switchoverTo(appid).getMenuService().menuDelete(menuId);
|
this.wxService.switchoverTo(appId).getMenuService().menuDelete(menuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,8 +149,8 @@ public class WxMenuController {
|
|||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
public WxMpMenu menuGet(@PathVariable String appid) throws WxErrorException {
|
public WxMpMenu menuGet(@PathVariable String appId) throws WxErrorException {
|
||||||
return this.wxService.switchoverTo(appid).getMenuService().menuGet();
|
return this.wxService.switchoverTo(appId).getMenuService().menuGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,8 +162,8 @@ public class WxMenuController {
|
|||||||
* @param userid 可以是粉丝的OpenID,也可以是粉丝的微信号。
|
* @param userid 可以是粉丝的OpenID,也可以是粉丝的微信号。
|
||||||
*/
|
*/
|
||||||
@GetMapping("/menuTryMatch/{userid}")
|
@GetMapping("/menuTryMatch/{userid}")
|
||||||
public WxMenu menuTryMatch(@PathVariable String appid, @PathVariable String userid) throws WxErrorException {
|
public WxMenu menuTryMatch(@PathVariable String appId, @PathVariable String userid) throws WxErrorException {
|
||||||
return this.wxService.switchoverTo(appid).getMenuService().menuTryMatch(userid);
|
return this.wxService.switchoverTo(appId).getMenuService().menuTryMatch(userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -182,7 +182,7 @@ public class WxMenuController {
|
|||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
@GetMapping("/getSelfMenuInfo")
|
@GetMapping("/getSelfMenuInfo")
|
||||||
public WxMpGetSelfMenuInfoResult getSelfMenuInfo(@PathVariable String appid) throws WxErrorException {
|
public WxMpGetSelfMenuInfoResult getSelfMenuInfo(@PathVariable String appId) throws WxErrorException {
|
||||||
return this.wxService.switchoverTo(appid).getMenuService().getSelfMenuInfo();
|
return this.wxService.switchoverTo(appId).getMenuService().getSelfMenuInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,13 @@ import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/wx/portal/{appid}")
|
@RequestMapping("/wx/portal/{appId}")
|
||||||
public class WxPortalController {
|
public class WxPortalController {
|
||||||
private final WxMpService wxService;
|
private final WxMpService wxService;
|
||||||
private final WxMpMessageRouter messageRouter;
|
private final WxMpMessageRouter messageRouter;
|
||||||
|
|
||||||
@GetMapping(produces = "text/plain;charset=utf-8")
|
@GetMapping(produces = "text/plain;charset=utf-8")
|
||||||
public String authGet(@PathVariable String appid,
|
public String authGet(@PathVariable String appId,
|
||||||
@RequestParam(name = "signature", required = false) String signature,
|
@RequestParam(name = "signature", required = false) String signature,
|
||||||
@RequestParam(name = "timestamp", required = false) String timestamp,
|
@RequestParam(name = "timestamp", required = false) String timestamp,
|
||||||
@RequestParam(name = "nonce", required = false) String nonce,
|
@RequestParam(name = "nonce", required = false) String nonce,
|
||||||
@ -44,8 +44,8 @@ public class WxPortalController {
|
|||||||
throw new IllegalArgumentException("请求参数非法,请核实!");
|
throw new IllegalArgumentException("请求参数非法,请核实!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.wxService.switchover(appid)) {
|
if (!this.wxService.switchover(appId)) {
|
||||||
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
|
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appId));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wxService.checkSignature(timestamp, nonce, signature)) {
|
if (wxService.checkSignature(timestamp, nonce, signature)) {
|
||||||
@ -56,7 +56,7 @@ public class WxPortalController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(produces = "application/xml; charset=UTF-8")
|
@PostMapping(produces = "application/xml; charset=UTF-8")
|
||||||
public String post(@PathVariable String appid,
|
public String post(@PathVariable String appId,
|
||||||
@RequestBody String requestBody,
|
@RequestBody String requestBody,
|
||||||
@RequestParam("signature") String signature,
|
@RequestParam("signature") String signature,
|
||||||
@RequestParam("timestamp") String timestamp,
|
@RequestParam("timestamp") String timestamp,
|
||||||
@ -68,8 +68,8 @@ public class WxPortalController {
|
|||||||
+ " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ",
|
+ " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ",
|
||||||
openid, signature, encType, msgSignature, timestamp, nonce, requestBody);
|
openid, signature, encType, msgSignature, timestamp, nonce, requestBody);
|
||||||
|
|
||||||
if (!this.wxService.switchover(appid)) {
|
if (!this.wxService.switchover(appId)) {
|
||||||
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
|
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appId));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wxService.checkSignature(timestamp, nonce, signature)) {
|
if (!wxService.checkSignature(timestamp, nonce, signature)) {
|
||||||
|
@ -19,14 +19,14 @@ import javax.xml.ws.Action;
|
|||||||
*/
|
*/
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/wx/redirect/{appid}")
|
@RequestMapping("/wx/redirect/{appId}")
|
||||||
public class WxRedirectController {
|
public class WxRedirectController {
|
||||||
private final WxMpService wxService;
|
private final WxMpService wxService;
|
||||||
|
|
||||||
@RequestMapping("/greet")
|
@RequestMapping("/greet")
|
||||||
public String greetUser(@PathVariable String appid, @RequestParam String code, ModelMap map) {
|
public String greetUser(@PathVariable String appId, @RequestParam String code, ModelMap map) {
|
||||||
if (!this.wxService.switchover(appid)) {
|
if (!this.wxService.switchover(appId)) {
|
||||||
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
|
throw new IllegalArgumentException(String.format("未找到对应appId=[%s]的配置,请核实!", appId));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user