| | |
| | | package com.doumee.api.web; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.config.Jwt.JwtTokenUtil; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | |
| | | import com.doumee.service.business.MemberService; |
| | | import com.doumee.service.business.UsersService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.ss.formula.ptg.MemAreaPtg; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | return obj != null ? (Long) obj : null; |
| | | } |
| | | |
| | | protected String getToken() { |
| | | Object obj = this.getRequest().getAttribute(JwtTokenUtil.HEADER_KEY); |
| | | return obj != null ? (String) obj : null; |
| | | } |
| | | |
| | | |
| | | protected Long getUserId() { |
| | |
| | | return obj != null ? (Long) obj : null; |
| | | } |
| | | protected Users getLoginUserInfo() { |
| | | Long userId = getUserId(); |
| | | if(userId== null){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"未登录"); |
| | | } |
| | | Users user = usersService.findById(userId); |
| | | return user; |
| | | Long userId = getUserId(); |
| | | if(userId== null){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"未登录"); |
| | | } |
| | | Object obj = this.getRequest().getAttribute(JwtTokenUtil.UserInfo); |
| | | String userInfo = obj != null ? (String) obj : null; |
| | | Users user = new Users(); |
| | | if(StringUtils.isNotBlank(userInfo)){ |
| | | user = JSONObject.toJavaObject(JSONObject.parseObject(userInfo),Users.class); |
| | | } |
| | | return user; |
| | | } |
| | | protected Member getLoginMemberInfo() { |
| | | Long userId = getMemberId(); |
| | | if(userId== null){ |
| | | return null; |
| | | } |
| | | Member user = memberService.findById(userId); |
| | | return user; |
| | | Object obj = this.getRequest().getAttribute(JwtTokenUtil.UserInfo); |
| | | String userInfo = obj != null ? (String) obj : null; |
| | | Member member = new Member(); |
| | | if(StringUtils.isNotBlank(userInfo)){ |
| | | member = JSONObject.toJavaObject(JSONObject.parseObject(userInfo),Member.class); |
| | | } |
| | | return member; |
| | | } |
| | | |
| | | protected Long getUserType() { |
| | | protected String getUserType() { |
| | | Object obj = this.getRequest().getAttribute(JwtTokenUtil.UserType); |
| | | return obj != null ? (Long) obj : null; |
| | | return obj != null ? (String) obj : null; |
| | | } |
| | | |
| | | } |