|
@ -661,48 +661,19 @@ public class WechatController extends WeixinBaseController {
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取微信openid
|
|
|
* 获取微信openid 和 unionid
|
|
|
*
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "getOpenidByCode", method = {RequestMethod.POST, RequestMethod.GET})
|
|
|
@ResponseBody
|
|
|
public String getOpenidByCode(String code) {
|
|
|
public String getOpenidAndUnionidByCode(String code) {
|
|
|
try {
|
|
|
String openid = super.getOpenidByCode(code);
|
|
|
if (!StringUtils.isEmpty(openid)) {
|
|
|
return write(200, "获取openid成功!", "openid", openid);
|
|
|
} else {
|
|
|
return error(-1, "获取openid失败!");
|
|
|
}
|
|
|
return write(200, "获取openid成功!", "openid", super.getOpenidByCode(code));
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "获取openid失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取微信unionid
|
|
|
*
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "getUnionidByCode", method = {RequestMethod.POST, RequestMethod.GET})
|
|
|
@ResponseBody
|
|
|
public String getUnionidByCode(String code) {
|
|
|
try {
|
|
|
String unionid = super.getOpenidByCode(code);
|
|
|
if (!StringUtils.isEmpty(unionid)) {
|
|
|
return write(200, "获取unionid成功!", "unionid", unionid);
|
|
|
} else {
|
|
|
return error(-1, "获取unionid失败!");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "获取unionid失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|