| | |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.redis.RedisUtil; |
| | | import com.doumee.dao.business.model.Member; |
| | | import io.jsonwebtoken.JwtException; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.jdbc.core.BeanPropertyRowMapper; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.web.client.RestTemplate; |
| | | import org.springframework.web.method.HandlerMethod; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.lang.reflect.Method; |
| | | import java.util.Objects; |
| | | |
| | | @Configuration |
| | | public class WebMvcConfig implements WebMvcConfigurer { |
| | |
| | | } |
| | | //获取账号ID |
| | | String memberId = JwtTokenUtil.getJwtPayLoad(token).getMemberId(); |
| | | Integer isDeleted = dao.queryForObject(" select COALESCE(DELETED,1) from `system_user` where id = ?", Integer.class, memberId); |
| | | if(isDeleted== Constants.ONE){ |
| | | 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); |
| | | } |
| | | if(member.getIsdeleted()== Constants.ONE){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户已删除,请联系管理员"); |
| | | } |
| | | Integer isForbidden = dao.queryForObject(" select COALESCE(STATUS,1) from `system_user` where id = ?", Integer.class, memberId); |
| | | if(isForbidden== Constants.ONE){ |
| | | if(member.getStatus() != Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户已禁用,请联系管理员"); |
| | | } |
| | | Integer count = dao.queryForObject("select count(1) from `system_user` where id = ?", Integer.class, memberId); |
| | | if (count != null && count > 0) { |
| | | request.setAttribute(JwtTokenUtil.UserId_Name, memberId); |
| | | return true; |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"用户信息出错"); |
| | | } |
| | | request.setAttribute(JwtTokenUtil.UserId_Name, memberId); |
| | | request.setAttribute(JwtTokenUtil.MEMBER, member); |
| | | return true; |
| | | } catch (IllegalArgumentException | JwtException e) { |
| | | throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"未登录"); |
| | | } |