修改微信信息
This commit is contained in:
parent
1e9648225b
commit
3877354f31
|
@ -1,6 +1,7 @@
|
|||
package com.nu.modules.NuBizAdvisoryInfo.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nu.modules.NuBizAdvisoryInfo.entity.NuBizAdvisoryInfo;
|
||||
|
@ -115,4 +116,32 @@ public class H5ApiAdvisoryInfoController extends JeecgController<NuBizAdvisoryIn
|
|||
NuBizAdvisoryInfo nuBizAdvisoryInfo = nuBizAdvisoryInfoService.queryWeixinInfo(openId,wechatName);
|
||||
return Result.OK(nuBizAdvisoryInfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据openId修改serverUrl
|
||||
* @param nuBizAdvisoryInfo
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value="修改咨询信息", notes="修改咨询信息")
|
||||
@RequestMapping(value = "/editNuBizAdvisoryInfo", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> editNuBizAdvisoryInfo(@RequestBody NuBizAdvisoryInfo nuBizAdvisoryInfo) {
|
||||
if(StringUtils.isEmpty(nuBizAdvisoryInfo.getOpenId())){
|
||||
return Result.error("填写openId");
|
||||
}
|
||||
if(StringUtils.isEmpty(nuBizAdvisoryInfo.getServerUrl())){
|
||||
return Result.error("填写微信名称");
|
||||
}
|
||||
QueryWrapper<NuBizAdvisoryInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("open_id",nuBizAdvisoryInfo.getOpenId());
|
||||
NuBizAdvisoryInfo nuBizAdvisoryInfoQuery = nuBizAdvisoryInfoService.getOne(queryWrapper);
|
||||
if(nuBizAdvisoryInfoQuery == null){
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
UpdateWrapper<NuBizAdvisoryInfo> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("open_id",nuBizAdvisoryInfo.getOpenId());
|
||||
updateWrapper.set("server_url",nuBizAdvisoryInfo.getServerUrl());
|
||||
nuBizAdvisoryInfoService.update(updateWrapper);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
@ -101,7 +102,7 @@ public class WeixinController {
|
|||
|
||||
|
||||
@GetMapping("/wechat/callback")
|
||||
public JsonNode callback(@RequestParam("code") String code, Model model) {
|
||||
public Map<String,Object> callback(@RequestParam("code") String code, Model model) {
|
||||
String tokenUrl = String.format(
|
||||
"https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code",
|
||||
appId, appSecret, code
|
||||
|
@ -115,11 +116,12 @@ public class WeixinController {
|
|||
|
||||
JsonNode retJson = null;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String accessToken = "";
|
||||
try {
|
||||
System.out.println("-------------------33333333333333----------");
|
||||
JsonNode tokenNode = objectMapper.readTree(tokenResponse);
|
||||
System.out.println("-------------------444444444444444----------"+tokenNode);
|
||||
String accessToken = tokenNode.get("access_token").asText();
|
||||
accessToken = tokenNode.get("access_token").asText();
|
||||
System.out.println("-------------------55555555555555----------"+accessToken);
|
||||
String openId = tokenNode.get("openid").asText();
|
||||
System.out.println("-------------------666666666666666----------"+openId);
|
||||
|
@ -145,8 +147,13 @@ public class WeixinController {
|
|||
e.printStackTrace();
|
||||
model.addAttribute("openid", "Error parsing JSON response");
|
||||
}
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("data",retJson);
|
||||
map.put("code",200);
|
||||
map.put("msg","success");
|
||||
map.put("accessToken",accessToken);
|
||||
|
||||
return retJson;
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue