登录接口
parent
a9699a3c6b
commit
c6b3d1f43e
|
@ -125,120 +125,7 @@ public class TokenController {
|
||||||
}
|
}
|
||||||
return new ResponseEntity(D0, HttpStatus.OK);
|
return new ResponseEntity(D0, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
@ApiOperation(value = "wxauthv3")
|
|
||||||
@RequestMapping(value = "/authv3",method = RequestMethod.GET)
|
|
||||||
@ResponseBody
|
|
||||||
public ResponseMessage<?> authV3(@RequestParam(value="JSCODE", required=false) String JSCODE, @RequestParam(value="appCode", required=false) String appCode) {
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(JSCODE)) {
|
|
||||||
return Result.error("JSCODE不能为空!");
|
|
||||||
}
|
|
||||||
WxConfigEntity wxConfigEntity = systemService.findUniqueByProperty(WxConfigEntity.class,"appCode",appCode);
|
|
||||||
Assert.notNull(JSCODE, "JSCODE can not be empty");
|
|
||||||
String url="https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfigEntity.getAppId() +
|
|
||||||
"&secret=" + wxConfigEntity.getAppSecret() +
|
|
||||||
"&js_code=" +
|
|
||||||
JSCODE+"&grant_type=authorization_code";
|
|
||||||
String result= com.xiaoleilu.hutool.http.HttpUtil.get(url);
|
|
||||||
logger.info("JSCODE=="+JSCODE);
|
|
||||||
logger.info("url=="+url );
|
|
||||||
logger.info("authv2=="+ result);
|
|
||||||
|
|
||||||
net.sf.json.JSONObject resultJson = net.sf.json.JSONObject.fromObject(result);
|
|
||||||
String openid = String.valueOf(resultJson.get("openid"));
|
|
||||||
try{
|
|
||||||
|
|
||||||
FxjOtherLoginEntity fxjOtherLoginEntity = userService.findUniqueByProperty(FxjOtherLoginEntity.class,"otherid",openid);
|
|
||||||
if(fxjOtherLoginEntity!=null){
|
|
||||||
return Result.success(openid,(long)1);
|
|
||||||
}else{
|
|
||||||
return Result.success(openid,(long)0);
|
|
||||||
}
|
|
||||||
}catch (Exception e){
|
|
||||||
return Result.success(openid,(long)0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "三方openid保存")
|
|
||||||
@RequestMapping(value = "/otherloginsave",method = RequestMethod.POST)
|
|
||||||
@ResponseBody
|
|
||||||
public ResponseMessage<?> otherloginsave(@RequestParam(value="openid", required=false) String openid, @RequestParam(value="unionid", required=false) String unionid, @RequestParam(value="username", required=true) String username, @RequestParam(value="password", required=true) String password, @RequestParam(value="appCode", required=false) String appCode) {
|
|
||||||
// 验证
|
|
||||||
if (StringUtils.isEmpty(openid)) {
|
|
||||||
return org.jeecgframework.jwt.util.Result.error("用户账号不能为空!");
|
|
||||||
}
|
|
||||||
TSUser user = userService.checkUserExits(username, password);
|
|
||||||
|
|
||||||
if (user == null) {
|
|
||||||
// 提示用户名或密码错误
|
|
||||||
return Result.error("用户账号密码错误!" );
|
|
||||||
}
|
|
||||||
FxjOtherLoginEntity fxjOtherLoginEntity = userService.findUniqueByProperty(FxjOtherLoginEntity.class,"otherid",openid);
|
|
||||||
|
|
||||||
if (fxjOtherLoginEntity!=null){
|
|
||||||
fxjOtherLoginEntity.setUsername(username);
|
|
||||||
fxjOtherLoginEntity.setOtherid(openid);
|
|
||||||
userService.updateEntitie(fxjOtherLoginEntity);
|
|
||||||
}else{
|
|
||||||
fxjOtherLoginEntity = new FxjOtherLoginEntity();
|
|
||||||
fxjOtherLoginEntity.setUsername(username);
|
|
||||||
fxjOtherLoginEntity.setOtherid(openid);
|
|
||||||
userService.save(fxjOtherLoginEntity);
|
|
||||||
}
|
|
||||||
return Result.success(fxjOtherLoginEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/postkey", method = RequestMethod.POST)
|
|
||||||
@ResponseBody
|
|
||||||
public ResponseEntity<?> postkeys(@RequestParam String devEui, @RequestParam String keyValue) {
|
|
||||||
logger.info("获取TOKEN[{}]" + devEui);
|
|
||||||
ResultDO D0 = new ResultDO();
|
|
||||||
|
|
||||||
D0.setObj("");
|
|
||||||
D0.setOK(true);
|
|
||||||
|
|
||||||
// 生成一个token,保存用户登录状态
|
|
||||||
return new ResponseEntity(D0, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/controlcallback", method = RequestMethod.POST)
|
|
||||||
@ResponseBody
|
|
||||||
public ResponseEntity<?> controlcallback(@RequestParam String devEui, @RequestParam String ctlDisplayStatus) {
|
|
||||||
logger.info("获取TOKEN[{}]" + devEui);
|
|
||||||
ResultDO D0 = new ResultDO();
|
|
||||||
|
|
||||||
D0.setObj("");
|
|
||||||
D0.setOK(true);
|
|
||||||
|
|
||||||
// 生成一个token,保存用户登录状态
|
|
||||||
return new ResponseEntity(D0, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
@RequestMapping(value = "/callback", method = RequestMethod.POST)
|
|
||||||
@ResponseBody
|
|
||||||
public ResponseEntity<?> callback(@RequestParam String devEui, @RequestParam String type, @RequestParam String obj) {
|
|
||||||
logger.info("获取TOKEN[{}]" + devEui);
|
|
||||||
ResultDO D0 = new ResultDO();
|
|
||||||
|
|
||||||
D0.setObj("");
|
|
||||||
D0.setOK(true);
|
|
||||||
|
|
||||||
// 生成一个token,保存用户登录状态
|
|
||||||
return new ResponseEntity(D0, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
@RequestMapping(value = "/lighrcallback", method = RequestMethod.POST)
|
|
||||||
@ResponseBody
|
|
||||||
public ResponseEntity<?> lighrcallback(@RequestParam String devEui, @RequestParam String ctlLedStatus ) {
|
|
||||||
logger.info("获取TOKEN[{}]" + devEui);
|
|
||||||
ResultDO D0 = new ResultDO();
|
|
||||||
|
|
||||||
D0.setObj("");
|
|
||||||
D0.setOK(true);
|
|
||||||
|
|
||||||
// 生成一个token,保存用户登录状态
|
|
||||||
return new ResponseEntity(D0, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
// 文件上传
|
// 文件上传
|
||||||
@RequestMapping(value = "/saveImage", method = RequestMethod.PUT)
|
@RequestMapping(value = "/saveImage", method = RequestMethod.PUT)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
|
Loading…
Reference in New Issue