package org.jeecg.modules.lims.controller; import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.api.CommonAPI; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.lims.api.JeecgSystemClient; import org.jeecg.modules.lims.entity.SysUser; import org.jeecg.modules.lims.service.IWxService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; @RestController @RequestMapping("/wx") @Slf4j public class WxPushController { @Autowired private IWxService wxService; @Autowired private JeecgSystemClient systemClient; @GetMapping(value = "/message") public String message(@RequestParam(name = "signature") String signature, @RequestParam(name = "timestamp") Long timestamp, @RequestParam(name = "nonce") Integer nonce, @RequestParam(name = "echostr") String echostr, HttpServletRequest req) { System.err.println("1111111"); System.err.println(signature); System.err.println(timestamp); System.err.println(nonce); System.err.println(echostr); return echostr; } @GetMapping(value = "/openid") @Transactional public Result openId(@RequestParam(name = "jscode") String jscode, @RequestParam(name = "userid") String userid) { Result result = new Result<>(); String openId = wxService.getOpenId(jscode); if (!StringUtils.isEmpty(openId) && !StringUtils.isEmpty(userid)) { SysUser user = new SysUser(); user.setId(userid); user.setOpenid(openId); systemClient.miniedit(user); System.err.println("绑定openid"+userid); } else { throw new RuntimeException("异常错误!"); } SysUser sysUser = systemClient.queryUserById(userid).getResult(); result.setResult(sysUser); result.setMessage("获取成功"); return result; } }