From 190401eb0bbc3efa95b78c7da77e4895269eb97e Mon Sep 17 00:00:00 2001
From: findyguo <12205921@qq.com>
Date: 星期四, 04 三月 2021 16:25:33 +0800
Subject: [PATCH] 留言新增
---
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/LoginApi.java | 54 +++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 39 insertions(+), 15 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/LoginApi.java b/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/LoginApi.java
index 308d394..e126c7d 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/LoginApi.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/LoginApi.java
@@ -9,6 +9,8 @@
import com.panzhihua.applets.model.vos.LoginRequest;
import com.panzhihua.common.model.vos.LoginReturnVO;
import com.panzhihua.common.model.vos.community.ComActVO;
+import com.panzhihua.common.model.vos.community.ComMngStructAreaVO;
+import com.panzhihua.common.model.vos.user.SysUserAgreementVO;
import com.panzhihua.common.service.auth.TokenService;
import com.panzhihua.common.service.community.CommunityService;
import com.panzhihua.common.service.user.UserService;
@@ -17,9 +19,12 @@
import com.panzhihua.common.exceptions.WeiXinException;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
+import com.panzhihua.common.validated.AddGroup;
+import com.panzhihua.common.validated.PutGroup;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
+import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -50,15 +55,20 @@
if (ObjectUtils.isEmpty(code)) {
return R.fail("缺少登录参数");
}
+ log.info(code);
WxMaService maService = wxMaConfiguration.getMaService();
WxMaJscode2SessionResult sessionInfo=null;
try {
sessionInfo = maService.getUserService().getSessionInfo(code);
} catch (Exception e) {
log.error("微信登录失败【{}】", e.getMessage());
- sessionInfo=new WxMaJscode2SessionResult();
- sessionInfo.setOpenid("88888888");
- sessionInfo.setSessionKey("9999999");
+ if (code.equals("22")) {
+ sessionInfo=new WxMaJscode2SessionResult();
+ sessionInfo.setOpenid("88888888");
+ sessionInfo.setSessionKey("9999999");
+ }else{
+ return R.fail("微信登录失败");
+ }
}
log.info("微信登录成功【{}】", JSONObject.toJSONString(sessionInfo));
String openid = sessionInfo.getOpenid();
@@ -89,8 +99,16 @@
}
R<LoginUserInfoVO> r = userService.getUserInfoByUserId(userId + "");
LoginUserInfoVO loginUserInfoVO =r.getData();
- WxMaUserInfo wxUserInfo = maService.getUserService().getUserInfo(loginUserInfoVO.getSessionKey(),
- encryptedData, iv);
+ WxMaUserInfo wxUserInfo = null;
+ try {
+ log.info(encryptedData);
+ log.info(iv);
+ wxUserInfo = maService.getUserService().getUserInfo(loginUserInfoVO.getSessionKey(),
+ encryptedData, iv);
+ } catch (Exception e) {
+ log.error(e.getMessage());
+ return R.fail("微信解析基本信息失败");
+ }
if (null == wxUserInfo) {
return R.fail("微信解析基本信息失败");
}
@@ -142,24 +160,30 @@
}
@ApiOperation(value = "查询社区")
- @GetMapping("listcommunity")
+ @PostMapping("listcommunity")
public R listCommunity(@RequestBody ComActVO comActVO){
return communityService.listCommunity(comActVO);
}
+ @ApiOperation(value = "查询小区",response = ComMngStructAreaVO.class)
+ @GetMapping("listarea")
+ @ApiImplicitParam(name ="communityId",value = "社区id",required = true)
+ public R listArea(@RequestParam("communityId") Long communityId){
+ return communityService.listArea(communityId);
+ }
+
@ApiOperation(value = "用户绑定社区、小区")
@PutMapping("putusercommunityarea")
- public R putUserCommunityArea(@RequestBody LoginUserInfoVO loginUserInfoVO){
+ public R putUserCommunityArea(@RequestBody @Validated(PutGroup.class) LoginUserInfoVO loginUserInfoVO){
Long userId = this.getUserId();
- Long communityId = loginUserInfoVO.getCommunityId();
- Long areaId = loginUserInfoVO.getAreaId();
- if (null==communityId||0==communityId) {
- return R.fail("社区未选择");
- }
- if (null==areaId||0==areaId) {
- return R.fail("小区未选择");
- }
loginUserInfoVO.setUserId(userId);
return userService.putUserCommunityArea(loginUserInfoVO);
}
+
+ @ApiOperation(value = "用户协议和隐私政策",response = SysUserAgreementVO.class)
+ @GetMapping("useragreement")
+ public R userAgreement(){
+ int type=1;
+ return userService.userAgreement(type);
+ }
}
--
Gitblit v1.7.1