Commit ef1c731c by 汪志阳

fix:子女端小程序未登录处理

parent 8ccf0086
package com.makeit.global.inteceptor; package com.makeit.global.inteceptor;
import cn.hutool.core.util.StrUtil;
import com.makeit.enums.Const;
import com.makeit.enums.order.InterceptorOrderConst; import com.makeit.enums.order.InterceptorOrderConst;
import com.makeit.global.annotation.AuthIgnore; import com.makeit.global.annotation.AuthIgnore;
import com.makeit.utils.user.TokenUtil; import com.makeit.utils.user.TokenUtil;
...@@ -31,6 +33,11 @@ public class WechatAuthenticationInterceptor implements HandlerInterceptor { ...@@ -31,6 +33,11 @@ public class WechatAuthenticationInterceptor implements HandlerInterceptor {
return true; return true;
} }
// 子女端小程序存在无需要登录状态
if (StrUtil.isBlank(request.getHeader("Token")) && StrUtil.isBlank(request.getHeader(Const.TENANT_ID))) {
return true;
}
TokenUtil.wechatGetToken(); TokenUtil.wechatGetToken();
TokenUtil.wechatRefreshToken(); TokenUtil.wechatRefreshToken();
return true; return true;
......
...@@ -2,10 +2,10 @@ package com.makeit.utils.user.wechat; ...@@ -2,10 +2,10 @@ package com.makeit.utils.user.wechat;
import com.makeit.enums.redis.RedisConst; import com.makeit.enums.redis.RedisConst;
import com.makeit.exception.BusinessException;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.user.ThreadLocalUserUtil; import com.makeit.utils.user.ThreadLocalUserUtil;
import com.makeit.utils.user.TokenUtil; import com.makeit.utils.user.TokenUtil;
import org.apache.poi.ss.formula.functions.T;
public class WechatUserUtil { public class WechatUserUtil {
...@@ -25,6 +25,12 @@ public class WechatUserUtil { ...@@ -25,6 +25,12 @@ public class WechatUserUtil {
} }
public static String getUserId() { public static String getUserId() {
return getUserVO().getId(); String userId = "";
try {
userId = getUserVO().getId();
} catch (BusinessException e) {
e.printStackTrace();
}
return userId;
} }
} }
...@@ -2,6 +2,7 @@ package com.makeit.module.controller.wechat.alarm; ...@@ -2,6 +2,7 @@ package com.makeit.module.controller.wechat.alarm;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.makeit.common.dto.BaseIdDTO; import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.page.PageReqDTO; import com.makeit.common.page.PageReqDTO;
...@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
@Api(tags = "平台端小程序-告警记录") @Api(tags = "平台端小程序-告警记录")
...@@ -36,6 +38,9 @@ public class PlatAlarmRecordWechatController { ...@@ -36,6 +38,9 @@ public class PlatAlarmRecordWechatController {
public ApiResponseEntity<Map<String,Object>> page(@RequestBody PageReqDTO<PlatAlarmRecordQueryDTO> dto) { public ApiResponseEntity<Map<String,Object>> page(@RequestBody PageReqDTO<PlatAlarmRecordQueryDTO> dto) {
//小程序告警记录只看到发给自己的告警 //小程序告警记录只看到发给自己的告警
String userId = CommonUserUtil.getUserId(); String userId = CommonUserUtil.getUserId();
if(StrUtil.isBlank(userId)){
return ApiResponseUtils.success(new HashMap<>(12));
}
PlatAlarmRecordQueryDTO data = dto.getData(); PlatAlarmRecordQueryDTO data = dto.getData();
data.setNotifyUser(userId); data.setNotifyUser(userId);
......
package com.makeit.service.platform.alarm.impl; package com.makeit.service.platform.alarm.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...@@ -167,7 +168,11 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -167,7 +168,11 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
*/ */
@Override @Override
public PageVO<PlatAlarmRecordVO> childrenPage(PageReqDTO<PlatAlarmRecordQueryDTO> dto) { public PageVO<PlatAlarmRecordVO> childrenPage(PageReqDTO<PlatAlarmRecordQueryDTO> dto) {
PlatElderChildrenInfo platElderChildrenInfo = platElderChildrenInfoService.getById(WechatUserUtil.getUserId()); String userId = WechatUserUtil.getUserId();
if (StrUtil.isBlank(userId)) {
return PageVO.emptyPage();
}
PlatElderChildrenInfo platElderChildrenInfo = platElderChildrenInfoService.getById(userId);
List<PlatElderChildrenInfo> platElderChildrenInfoList = getPlatElderChildrenInfosByOpenid(platElderChildrenInfo.getOpenid()); List<PlatElderChildrenInfo> platElderChildrenInfoList = getPlatElderChildrenInfosByOpenid(platElderChildrenInfo.getOpenid());
log.info("子女端账号:{}",JSON.toJSONString(platElderChildrenInfo)); log.info("子女端账号:{}",JSON.toJSONString(platElderChildrenInfo));
if(CollectionUtils.isEmpty(platElderChildrenInfoList)){ if(CollectionUtils.isEmpty(platElderChildrenInfoList)){
...@@ -615,7 +620,11 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -615,7 +620,11 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
@Override @Override
public Integer unreadCount(PlatAlarmRecordQueryDTO dto) { public Integer unreadCount(PlatAlarmRecordQueryDTO dto) {
PlatElderChildrenInfo platElderChildrenInfo = platElderChildrenInfoService.getById(WechatUserUtil.getUserId()); String userId = WechatUserUtil.getUserId();
if (StrUtil.isBlank(userId)) {
return 0;
}
PlatElderChildrenInfo platElderChildrenInfo = platElderChildrenInfoService.getById(userId);
List<PlatElderChildrenInfo> platElderChildrenInfoList = getPlatElderChildrenInfosByOpenid(platElderChildrenInfo.getOpenid()); List<PlatElderChildrenInfo> platElderChildrenInfoList = getPlatElderChildrenInfosByOpenid(platElderChildrenInfo.getOpenid());
log.info("子女端账号:{}",JSON.toJSONString(platElderChildrenInfo)); log.info("子女端账号:{}",JSON.toJSONString(platElderChildrenInfo));
if(CollectionUtils.isEmpty(platElderChildrenInfoList)){ if(CollectionUtils.isEmpty(platElderChildrenInfoList)){
......
...@@ -254,8 +254,12 @@ public class PlatElderChildrenInfoServiceImpl extends ServiceImpl<PlatElderChild ...@@ -254,8 +254,12 @@ public class PlatElderChildrenInfoServiceImpl extends ServiceImpl<PlatElderChild
@Override @Override
public PlatElderChildrenInfoWechatVO view() { public PlatElderChildrenInfoWechatVO view() {
String userId = WechatUserUtil.getUserId();
if (StrUtil.isBlank(userId)) {
return new PlatElderChildrenInfoWechatVO();
}
PlatElderChildrenInfoWechatVO wechatVO = PlatElderChildrenInfoWechatVO wechatVO =
BeanDtoVoUtils.convert(getById(WechatUserUtil.getUserId()), PlatElderChildrenInfoWechatVO.class); BeanDtoVoUtils.convert(getById(userId), PlatElderChildrenInfoWechatVO.class);
if (wechatVO != null && (StrUtil.isBlank(wechatVO.getName()) && StrUtil.isNotBlank(wechatVO.getPhone()))) { if (wechatVO != null && (StrUtil.isBlank(wechatVO.getName()) && StrUtil.isNotBlank(wechatVO.getPhone()))) {
wechatVO.setName(wechatVO.getPhone()); wechatVO.setName(wechatVO.getPhone());
} }
...@@ -304,7 +308,11 @@ public class PlatElderChildrenInfoServiceImpl extends ServiceImpl<PlatElderChild ...@@ -304,7 +308,11 @@ public class PlatElderChildrenInfoServiceImpl extends ServiceImpl<PlatElderChild
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void bind(String elderId) { public void bind(String elderId) {
PlatElderChildrenInfo childrenInfo = getById(WechatUserUtil.getUserId()); String userId = WechatUserUtil.getUserId();
if (StrUtil.isBlank(userId)) {
return;
}
PlatElderChildrenInfo childrenInfo = getById(userId);
if (childrenInfo == null) { if (childrenInfo == null) {
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment