From 1941e9fc342b3a2cb6d32e9658ad46f29f50a5df Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期一, 22 七月 2024 15:36:11 +0800
Subject: [PATCH] 代码提交
---
server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTCollectInfoResponse.java | 4
server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTCaseInfoResponse.java | 4
server/web/src/main/java/com/doumee/api/web/CustomerApi.java | 3
server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java | 60 ++++++++-------
server/web/src/main/java/com/doumee/api/web/ApiController.java | 7 +
server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTRealcaseInfoResponse.java | 4
server/service/src/main/java/com/doumee/service/business/UsersService.java | 3
server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java | 5
server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTProductNewsInfoResponse.java | 4
server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTProductInfoResponse.java | 4
server/web/src/main/java/com/doumee/api/web/PersonnelApi.java | 15 ++-
server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTVideoInfoResponse.java | 4
server/service/src/main/java/com/doumee/config/Jwt/JwtTokenUtil.java | 23 +++++
server/service/src/main/java/com/doumee/dao/web/response/AccountResponse.java | 3
server/service/src/main/java/com/doumee/service/business/impl/UsersServiceImpl.java | 41 +++++++++
server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java | 3
server/web/src/main/resources/application.yml | 2
server/admin/src/main/resources/application.yml | 2
server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTZbDecoInfoResponse.java | 4
19 files changed, 139 insertions(+), 56 deletions(-)
diff --git a/server/admin/src/main/resources/application.yml b/server/admin/src/main/resources/application.yml
index 8e8e46b..a765ed7 100644
--- a/server/admin/src/main/resources/application.yml
+++ b/server/admin/src/main/resources/application.yml
@@ -1,6 +1,6 @@
# 椤圭洰淇℃伅閰嶇疆
project:
- name: 璁垮绯荤粺
+ name: 蹇楅偊涓氱哗鏁板瓧鍖栬祴鑳藉悗鍙扮郴缁�
version: 1.0.0
env: development
# env: production
diff --git a/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTCaseInfoResponse.java b/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTCaseInfoResponse.java
index 337d193..297e7e1 100644
--- a/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTCaseInfoResponse.java
+++ b/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTCaseInfoResponse.java
@@ -16,7 +16,7 @@
/**
* 鏀惰棌閲�
*/
- private String collectCount;
+ private Integer collectCount;
/**
* 涓诲浘
*/
@@ -42,6 +42,6 @@
/**
* 娴忚閲�
*/
- private String viewCount;
+ private Integer viewCount;
}
diff --git a/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTCollectInfoResponse.java b/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTCollectInfoResponse.java
index dbd7ab3..5533479 100644
--- a/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTCollectInfoResponse.java
+++ b/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTCollectInfoResponse.java
@@ -14,7 +14,7 @@
/**
* 鏀惰棌鏁�
*/
- private String collectCount;
+ private Integer collectCount;
/**
* 鍐呭ID
*/
@@ -50,6 +50,6 @@
/**
* 鏌ョ湅鏁�
*/
- private String viewCount;
+ private Integer viewCount;
}
diff --git a/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTProductInfoResponse.java b/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTProductInfoResponse.java
index a966711..fe27696 100644
--- a/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTProductInfoResponse.java
+++ b/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTProductInfoResponse.java
@@ -16,7 +16,7 @@
* 璇︽儏椤佃疆鎾浘鍒楄〃锛堝瑙嗚鍥撅級
*/
private String[] bannerImgList;
- private String collectCount;
+ private Integer collectCount;
/**
* 璇︽儏椤靛瘜鏂囨湰锛堝叏灞嬪畾鍒堕亶鍘唖paceList鐨勫瘜鏂囨湰锛�
*/
@@ -41,7 +41,7 @@
private List<ZTSpaceInfoResponse> spaceList;
private String subtitle;
private String title;
- private String viewCount;
+ private Integer viewCount;
private String downloadCount;
private String isTop;
private String orgId;
diff --git a/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTProductNewsInfoResponse.java b/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTProductNewsInfoResponse.java
index f20c7cc..3940aa9 100644
--- a/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTProductNewsInfoResponse.java
+++ b/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTProductNewsInfoResponse.java
@@ -16,7 +16,7 @@
* 璇︽儏椤佃疆鎾浘鍒楄〃锛堝瑙嗚鍥撅級
*/
private String[] bannerImgList;
- private String collectCount;
+ private Integer collectCount;
/**
* 璇︽儏椤靛瘜鏂囨湰锛堝叏灞嬪畾鍒堕亶鍘唖paceList鐨勫瘜鏂囨湰锛�
*/
@@ -41,7 +41,7 @@
private List<ZTSpaceInfoResponse> spaceList;
private String subtitle;
private String title;
- private String viewCount;
+ private Integer viewCount;
private String downloadCount;
private String isTop;
private String orgId;
diff --git a/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTRealcaseInfoResponse.java b/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTRealcaseInfoResponse.java
index 311584e..bdf7ff7 100644
--- a/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTRealcaseInfoResponse.java
+++ b/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTRealcaseInfoResponse.java
@@ -14,7 +14,7 @@
public class ZTRealcaseInfoResponse implements Serializable {
private String caseInfo;
- private String collectCount;
+ private Integer collectCount;
/**
* 涓诲浘
*/
@@ -36,7 +36,7 @@
* 鏍囬
*/
private String title;
- private String viewCount;
+ private Integer viewCount;
private String contentCategory;
private String intro;
diff --git a/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTVideoInfoResponse.java b/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTVideoInfoResponse.java
index 3a69717..6cae997 100644
--- a/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTVideoInfoResponse.java
+++ b/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTVideoInfoResponse.java
@@ -16,7 +16,7 @@
/**
* 鏀惰棌鏁伴噺
*/
- private long collectCount;
+ private Integer collectCount;
/**
* 灏侀潰鍥�
*/
@@ -58,5 +58,5 @@
/**
* 娴忚鏁伴噺
*/
- private String viewCount;
+ private Integer viewCount;
}
diff --git a/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTZbDecoInfoResponse.java b/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTZbDecoInfoResponse.java
index 2f20d30..5994dae 100644
--- a/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTZbDecoInfoResponse.java
+++ b/server/service/src/main/java/com/doumee/biz/zbom/model/zhongtai/response/ZTZbDecoInfoResponse.java
@@ -11,7 +11,7 @@
@Data
public class ZTZbDecoInfoResponse implements Serializable {
private String author;
- private long collectCount;
+ private Integer collectCount;
/**
* 鍐呭
*/
@@ -46,5 +46,5 @@
* 鏍囬
*/
private String title;
- private String viewCount;
+ private Integer viewCount;
}
diff --git a/server/service/src/main/java/com/doumee/config/Jwt/JwtTokenUtil.java b/server/service/src/main/java/com/doumee/config/Jwt/JwtTokenUtil.java
index 132bfa8..6b1c79b 100644
--- a/server/service/src/main/java/com/doumee/config/Jwt/JwtTokenUtil.java
+++ b/server/service/src/main/java/com/doumee/config/Jwt/JwtTokenUtil.java
@@ -21,11 +21,14 @@
import com.doumee.dao.business.model.Member;
import io.jsonwebtoken.*;
import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
import java.util.concurrent.TimeUnit;
/**
@@ -47,6 +50,8 @@
public class JwtTokenUtil {
//Header 鍚嶇О
public static final String HEADER_KEY = "token";
+ //Header 鍚嶇О
+ public static final String BUSINESS_HEADER_KEY = "business_token";
//鍙栧�煎悕绉�
public static final String UserId_Name = "AppUserId";
//鍙栧�煎悕绉�
@@ -65,6 +70,24 @@
return generateToken(jwtPayLoad.getUserId(), expirationDate, jwtPayLoad.toMap());
}
+
+ /**
+ * 鐢熸垚token,鏍规嵁userId鍜岄粯璁よ繃鏈熸椂闂�
+ */
+ public static String generateTokenForZb(Long userId,String userType,String userInfo,RedisTemplate<String,Object> redisTemplate) {
+ Long expiredSeconds = getExpireSeconds();
+ final Date expirationDate = new Date(System.currentTimeMillis() + expiredSeconds * 1000);
+ return generateTokenZb(userId,userType,userInfo, expirationDate,redisTemplate);
+ }
+
+
+ public static String generateTokenZb(Long userId, String userType,String userInfo, Date expiredDate,RedisTemplate<String,Object> redisTemplate) {
+ String tokenKey = UUID.randomUUID() + "_" + userId;
+ redisTemplate.opsForValue().set(userType + "_" +tokenKey,userInfo);
+ return tokenKey;
+ }
+
+
/**
* 楠岃瘉token鏄惁澶辨晥
*/
diff --git a/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java b/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
index 5d72f5a..43272e3 100644
--- a/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
+++ b/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
@@ -65,27 +65,26 @@
HandlerMethod handlerMethod = (HandlerMethod) handler;
Class<?> beanType = handlerMethod.getBeanType();
-
-// Method method = handlerMethod.getMethod();
-
+ Boolean checkFlag = false;
// 鏈� @LoginRequired 娉ㄨВ锛岄渶瑕佺櫥褰曡璇� 瀹㈡埛绔娇鐢�
- if (beanType.isAnnotationPresent(LoginRequired.class) || handlerMethod.hasMethodAnnotation(LoginRequired.class)) {
- //鑾峰彇token
- String token = request.getHeader(JwtTokenUtil.HEADER_KEY); // 浠� http 璇锋眰澶翠腑鍙栧嚭 token
- if (StringUtils.isNotBlank(token)) {
- checkLogin(request,response);
- } else {
+ if ((beanType.isAnnotationPresent(LoginRequired.class) || handlerMethod.hasMethodAnnotation(LoginRequired.class))) {
+ String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
+ if(StringUtils.isBlank(token)){
throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
}
+ if (StringUtils.isNotBlank(token)) {
+ checkFlag = checkLogin(request,response,token);
+ }
// 鏈� @UserLoginRequired 娉ㄨВ锛岄渶瑕佺櫥褰曡璇� 鍐呴儴浜哄憳浣跨敤
- } else if(beanType.isAnnotationPresent(UserLoginRequired.class) || handlerMethod.hasMethodAnnotation(UserLoginRequired.class)){
- //ERP 涓氬姟娉ㄨВ
- String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
- if (StringUtils.isNotBlank(token)) {
- checkPersonnelLogin(request,response);
- } else {
- throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
- }
+ }
+ if(beanType.isAnnotationPresent(UserLoginRequired.class) || handlerMethod.hasMethodAnnotation(UserLoginRequired.class)){
+ String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
+ if(StringUtils.isBlank(token)){
+ throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
+ }
+ if (StringUtils.isNotBlank(token)) {
+ checkFlag = checkPersonnelLogin(request,response,token);
+ }
}
return true;
}
@@ -94,12 +93,9 @@
}
- public Boolean checkLogin(HttpServletRequest request, HttpServletResponse response){
- String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
+ public Boolean checkLogin(HttpServletRequest request, HttpServletResponse response,String token){
try {
- //鑾峰彇璐﹀彿ID
- Long memberId = JwtTokenUtil.getJwtPayLoad(token).getUserId();
- String tokenRedis = (String) redisTemplate.opsForValue().get(ZTConstants.CUSTOMER+"_"+memberId);
+ String tokenRedis = (String) redisTemplate.opsForValue().get(ZTConstants.CUSTOMER+"_"+token);
if(StringUtils.isNotBlank(tokenRedis)){
if(!tokenRedis.equals(token)){
throw new BusinessException(ResponseStatus.TOKEN_EXCEED_TIME.getCode(),"闀挎椂闂存湭鎿嶄綔,璇烽噸鏂扮櫥褰�");
@@ -107,7 +103,8 @@
}else{
throw new BusinessException(ResponseStatus.TOKEN_EXCEED_TIME.getCode(),"闀挎椂闂存湭鎿嶄綔,璇烽噸鏂扮櫥褰�");
}
- Member member = dao.queryForObject(" select * from `member` where id = ? limit 1 ", new BeanPropertyRowMapper<>(Member.class),memberId );
+ Long memberId = getTokenId(token);
+ Member member = dao.queryForObject(" select * from `member` where id = ? limit 1 ", new BeanPropertyRowMapper<>(Member.class),memberId);
if(Objects.isNull(member)){
throw new BusinessException(ResponseStatus.DATA_EMPTY);
}
@@ -125,12 +122,9 @@
}
}
- public Boolean checkPersonnelLogin(HttpServletRequest request, HttpServletResponse response){
- String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
+ public Boolean checkPersonnelLogin(HttpServletRequest request, HttpServletResponse response,String token){
try {
- //鑾峰彇璐﹀彿ID
- Long userId = JwtTokenUtil.getJwtPayLoad(token).getUserId();
- String tokenRedis = (String) redisTemplate.opsForValue().get(ZTConstants.BUSINESS+"_"+userId);
+ String tokenRedis = (String) redisTemplate.opsForValue().get(ZTConstants.BUSINESS+"_"+token);
if(StringUtils.isNotBlank(tokenRedis)){
if(!tokenRedis.equals(token)){
throw new BusinessException(ResponseStatus.TOKEN_EXCEED_TIME.getCode(),"闀挎椂闂存湭鎿嶄綔,璇烽噸鏂扮櫥褰�");
@@ -138,6 +132,7 @@
}else{
throw new BusinessException(ResponseStatus.TOKEN_EXCEED_TIME.getCode(),"闀挎椂闂存湭鎿嶄綔,璇烽噸鏂扮櫥褰�");
}
+ Long userId = getTokenId(token);
Users users = dao.queryForObject(" select * from `users` where id = ? limit 1 ", new BeanPropertyRowMapper<>(Users.class),userId);
if(Objects.isNull(users)){
throw new BusinessException(ResponseStatus.DATA_EMPTY);
@@ -161,5 +156,14 @@
return new RestTemplate();
}
+ public Long getTokenId(String token){
+ try {
+ Integer lastIndex = token.lastIndexOf("_")+1;
+ Long tokenId = Long.valueOf(token.substring(0,lastIndex));
+ return tokenId;
+ }catch (Exception e){
+ throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
+ }
+ }
}
diff --git a/server/service/src/main/java/com/doumee/dao/web/response/AccountResponse.java b/server/service/src/main/java/com/doumee/dao/web/response/AccountResponse.java
index 50f22e9..0d1b9c6 100644
--- a/server/service/src/main/java/com/doumee/dao/web/response/AccountResponse.java
+++ b/server/service/src/main/java/com/doumee/dao/web/response/AccountResponse.java
@@ -24,6 +24,9 @@
@ApiModelProperty(value = "寰俊sessionKey")
private String sessionKey;
+ @ApiModelProperty(value = "鎵嬫満鍙�")
+ private String phone;
+
@ApiModelProperty(value = "鐢ㄦ埛淇℃伅 - 瀹㈡埛绔�")
private Member member;
diff --git a/server/service/src/main/java/com/doumee/service/business/UsersService.java b/server/service/src/main/java/com/doumee/service/business/UsersService.java
index 26b5ed7..49ff950 100644
--- a/server/service/src/main/java/com/doumee/service/business/UsersService.java
+++ b/server/service/src/main/java/com/doumee/service/business/UsersService.java
@@ -7,6 +7,7 @@
import com.doumee.dao.business.model.Users;
import com.doumee.dao.web.reqeust.ContentShareImgDto;
import com.doumee.dao.web.reqeust.EditUsersRequest;
+import com.doumee.dao.web.reqeust.WxPhoneRequest;
import com.doumee.dao.web.response.AccountResponse;
import org.springframework.web.multipart.MultipartFile;
@@ -121,4 +122,6 @@
String getContentShareImg(Users loginUserInfo, ContentShareImgDto param);
ZTBaseRequst logOff(Long userId);
+
+ AccountResponse getWxMiniPhoneLogin(WxPhoneRequest wxPhoneRequest);
}
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java
index ef73633..efb2eb7 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java
@@ -275,7 +275,7 @@
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鑾峰彇openid澶辫触锛佽鑱旂郴绠$悊鍛�");
}
// String openId = code;
- Member member = memberMapper.selectOne(new QueryWrapper<Member>().eq("OPENID", openId));
+ Member member = memberMapper.selectOne(new QueryWrapper<Member>().eq("OPENID", openId).isNotNull("phone"));
Users users = new Users();
if(StringUtils.isBlank(iamId)){
users = usersMapper.selectOne(new QueryWrapper<Users>().lambda()
@@ -535,8 +535,6 @@
}
-
-
@Override
public ZTBaseRequst logOff(Long memberId){
Member member = memberMapper.selectById(memberId);
@@ -555,6 +553,7 @@
ztBaseRequst.setOpenId(member.getOpenid());
ztBaseRequst.setToken(member.getToken());
memberMapper.update(new UpdateWrapper<Member>().lambda()
+ .set(Member::getOpenid,null)
.set(Member::getPhone,null)
.set(Member::getEditDate,new Date())
.eq(Member::getId,member.getId())
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/UsersServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/UsersServiceImpl.java
index 4518fe5..e5f5dc6 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/UsersServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/UsersServiceImpl.java
@@ -1,6 +1,7 @@
package com.doumee.service.business.impl;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
+import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.hutool.core.date.DateUnit;
import com.alibaba.fastjson.JSONObject;
import com.doumee.biz.system.SystemDictDataBiz;
@@ -34,6 +35,7 @@
import com.doumee.dao.system.model.SystemUser;
import com.doumee.dao.web.reqeust.EditUsersRequest;
import com.doumee.dao.web.reqeust.ContentShareImgDto;
+import com.doumee.dao.web.reqeust.WxPhoneRequest;
import com.doumee.dao.web.response.AccountResponse;
import com.doumee.service.business.UsersService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -362,9 +364,10 @@
// }
// smsEmailMapper.updateById(model);
//鍒涘缓token
- JwtPayLoad payLoad = new JwtPayLoad(users.getId(),Constants.ONE);
- String token = JwtTokenUtil.generateToken(payLoad);
- redisTemplate.opsForValue().set(ZTConstants.BUSINESS+"_"+users.getId(),token);
+// JwtPayLoad payLoad = new JwtPayLoad(users.getId(),Constants.ONE);
+// String token = JwtTokenUtil.generateToken(payLoad);
+// redisTemplate.opsForValue().set(ZTConstants.BUSINESS+"_"+users.getId(),token);
+ String token = JwtTokenUtil.generateTokenForZb(users.getId(),ZTConstants.BUSINESS,"",redisTemplate);
AccountResponse accountResponse = new AccountResponse();
accountResponse.setToken(token);
accountResponse.setUsers(users);
@@ -384,6 +387,7 @@
accountResponse.setSessionKey(session.getSessionKey());
Users users = usersMapper.selectOne(new QueryWrapper<Users>().lambda().eq(Users::getOpenid,openId).last("limit 1"));
if(Objects.isNull(users)){
+ accountResponse.setSessionKey(session.getSessionKey());
return accountResponse;
}
if(!Constants.equalsInteger(users.getIsdeleted(),Constants.ZERO)){
@@ -400,6 +404,7 @@
redisTemplate.opsForValue().set(ZTConstants.BUSINESS+"_"+users.getId(),token);
accountResponse.setToken(token);
getUsersDetail(users);
+ accountResponse.setSessionKey(session.getSessionKey());
accountResponse.setUsers(users);
return accountResponse;
} catch (WxErrorException e) {
@@ -408,6 +413,36 @@
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"寰俊鐧诲綍寮傚父锛佽鑱旂郴绠$悊鍛�");
}
+ @Override
+ public AccountResponse getWxMiniPhoneLogin(WxPhoneRequest wxPhoneRequest){
+ try {
+ WxMaPhoneNumberInfo userPhoneInfo = WxMiniConfig.wxPersonnelService.getUserService().getPhoneNoInfo(
+ wxPhoneRequest.getSessionKey(), wxPhoneRequest.getEncryptedData(), wxPhoneRequest.getIv());
+ //鑾峰彇鎵嬫満鍙�
+ String phone= userPhoneInfo.getPurePhoneNumber();
+ if(Objects.isNull(phone)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈幏鍙栧埌鎵嬫満鍙�");
+ }
+ Users users = usersMapper.selectOne(new QueryWrapper<Users>().lambda()
+ .eq(Users::getPhone,phone).last("limit 1"));
+ AccountResponse accountResponse = new AccountResponse();
+ accountResponse.setPhone(phone);
+ if(Objects.isNull(users)){
+ return accountResponse;
+ }
+ accountResponse.setUsers(users);
+ //鍒涘缓token
+ JwtPayLoad payLoad = new JwtPayLoad(users.getId(),Constants.ZERO);
+ String token = JwtTokenUtil.generateToken(payLoad);
+ redisTemplate.opsForValue().set(ZTConstants.BUSINESS+"_"+users.getId(),token);
+ return accountResponse;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏇存柊鎵嬫満鍙峰け璐�");
+ }
+
+
@Override
public void bindingOpenid(String code,Long userId){
diff --git a/server/web/src/main/java/com/doumee/api/web/ApiController.java b/server/web/src/main/java/com/doumee/api/web/ApiController.java
index 2d6d5e8..52287ca 100644
--- a/server/web/src/main/java/com/doumee/api/web/ApiController.java
+++ b/server/web/src/main/java/com/doumee/api/web/ApiController.java
@@ -1,6 +1,8 @@
package com.doumee.api.web;
import com.doumee.config.Jwt.JwtTokenUtil;
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
import com.doumee.dao.business.model.Member;
import com.doumee.dao.business.model.Users;
import com.doumee.service.business.MemberService;
@@ -51,6 +53,9 @@
Object obj = this.getRequest().getAttribute(JwtTokenUtil.UserId_Name);
return obj != null ? (Long) obj : null;
}
+
+
+
protected Long getUserId() {
// if(isDebug){
// return 2L;
@@ -61,7 +66,7 @@
protected Users getLoginUserInfo() {
Long userId = getUserId();
if(userId== null){
- return null;
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"鏈櫥褰�");
}
Users user = usersService.findById(userId);
return user;
diff --git a/server/web/src/main/java/com/doumee/api/web/CustomerApi.java b/server/web/src/main/java/com/doumee/api/web/CustomerApi.java
index e96fd07..10b0573 100644
--- a/server/web/src/main/java/com/doumee/api/web/CustomerApi.java
+++ b/server/web/src/main/java/com/doumee/api/web/CustomerApi.java
@@ -92,6 +92,9 @@
return ApiResponse.success(memberService.wxLogin(code,iamId));
}
+
+
+
@LoginRequired
@ApiOperation(value = "鑾峰彇鎵嬫満鍙�", notes = "瀹㈡埛绔皬绋嬪簭")
@PostMapping("/getWxMiniPhone")
diff --git a/server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java b/server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java
index 3838bec..4a534ad 100644
--- a/server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java
+++ b/server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java
@@ -3,6 +3,7 @@
import com.doumee.biz.zbom.ZbomCRMService;
import com.doumee.biz.zbom.ZbomZhongTaiService;
import com.doumee.config.annotation.LoginRequired;
+import com.doumee.config.annotation.UserLoginRequired;
import com.doumee.core.annotation.trace.Trace;
import com.doumee.core.model.ApiResponse;
import com.doumee.core.model.PageData;
@@ -78,9 +79,11 @@
+ @UserLoginRequired
@ApiOperation(value = "鑾峰彇瀹㈡埛绠$悊鎺堟潈-鍒楄〃璺宠浆鍦板潃", notes = "鑾峰彇瀹㈡埛绠$悊鎺堟潈璺宠浆鍦板潃")
@GetMapping("/getCrmAuthUrl")
@ApiImplicitParams({
+ @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "鐢ㄦ埛token鍊�", required = true),
@ApiImplicitParam(paramType = "query", dataType = "Integer", name = "type", value = "绫诲瀷 0瀹㈡埛鍒楄〃 1璺宠浆鏂板鎰忓悜瀹㈡埛", required = true)
})
public ApiResponse<String> getCrmAuthUrl(@RequestParam Integer type) {
diff --git a/server/web/src/main/java/com/doumee/api/web/PersonnelApi.java b/server/web/src/main/java/com/doumee/api/web/PersonnelApi.java
index 89748ca..4ac665b 100644
--- a/server/web/src/main/java/com/doumee/api/web/PersonnelApi.java
+++ b/server/web/src/main/java/com/doumee/api/web/PersonnelApi.java
@@ -19,10 +19,7 @@
import com.doumee.dao.business.model.Shop;
import com.doumee.dao.business.model.SmsEmail;
import com.doumee.dao.business.model.Users;
-import com.doumee.dao.web.reqeust.EditMemberRequest;
-import com.doumee.dao.web.reqeust.EditShopDTO;
-import com.doumee.dao.web.reqeust.EditUsersRequest;
-import com.doumee.dao.web.reqeust.ContentShareImgDto;
+import com.doumee.dao.web.reqeust.*;
import com.doumee.dao.web.response.AccountResponse;
import com.doumee.service.business.*;
import io.swagger.annotations.Api;
@@ -35,6 +32,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import javax.validation.Valid;
import java.util.List;
import java.util.Objects;
@@ -88,7 +86,6 @@
}
-
@ApiOperation(value = "鎵嬫満鍙烽獙璇佺爜鐧婚檰", notes = "鍛樺伐绔皬绋嬪簭")
@GetMapping("/loginByPhone")
@ApiImplicitParams({
@@ -112,6 +109,14 @@
return ApiResponse.success("鎿嶄綔鎴愬姛");
}
+
+ @ApiOperation(value = "鎵嬫満鍙峰揩鎹风櫥褰�", notes = "瀹㈡埛绔皬绋嬪簭")
+ @PostMapping("/getWxMiniPhoneLogin")
+ public ApiResponse<AccountResponse> getWxMiniPhone(@Valid @RequestBody WxPhoneRequest wxPhoneRequest) {
+ return ApiResponse.success("鑾峰彇鎴愬姛",usersService.getWxMiniPhoneLogin(wxPhoneRequest));
+ }
+
+
@UserLoginRequired
@ApiOperation(value = "鑾峰彇涓汉淇℃伅璇︽儏", notes = "鍛樺伐绔皬绋嬪簭")
@GetMapping("/getUserDetail")
diff --git a/server/web/src/main/resources/application.yml b/server/web/src/main/resources/application.yml
index e5d6350..9e2db52 100644
--- a/server/web/src/main/resources/application.yml
+++ b/server/web/src/main/resources/application.yml
@@ -1,6 +1,6 @@
# 椤圭洰淇℃伅閰嶇疆
project:
- name: 鏅鸿兘浼氳瀹ゅ皬绋嬪簭绔�
+ name: 蹇楅偊涓氱哗鏁板瓧鍖栬祴鑳藉皬绋嬪簭
version: 1.0.0
env: development
# env: production
--
Gitblit v1.9.3