| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.config.annotation.LoginNoRequired; |
| | | import com.doumee.core.annotation.excel.ExcelExporter; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.core.model.ApiResponse; |
| | |
| | | */ |
| | | @Api(tags = "ä¼è®®å®¤é¢å®ä¿¡æ¯è¡¨") |
| | | @RestController |
| | | @RequestMapping("/cloud/bookings") |
| | | @RequestMapping("/cloudService/bookings") |
| | | public class CloudBookingsController extends BaseController { |
| | | |
| | | @Autowired |
| | |
| | | public ApiResponse test() { |
| | | return ApiResponse.success("ä¼è®®å®¤æµè¯æå"); |
| | | } |
| | | |
| | | @LoginNoRequired |
| | | @ApiOperation("æµè¯ç½ç®¡") |
| | | @GetMapping("/testNoLogin") |
| | | public ApiResponse testNoLogin() { |
| | | return ApiResponse.success("ä¼è®®å®¤ç®¡çæµè¯æ éç»å½æå"); |
| | | } |
| | | @PreventRepeat |
| | | @ApiOperation("æ°å»º") |
| | | @PostMapping("/create") |
| | |
| | | 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.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; |
| | | |
| | | @Configuration |
| | | //@Configuration |
| | | public class WebMvcConfig implements WebMvcConfigurer { |
| | | |
| | | |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.doumee.config.Jwt.JwtTokenUtil; |
| | | import com.doumee.config.annotation.LoginRequired; |
| | | import com.doumee.core.annotation.trace.Trace; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.PageWrap; |
| | |
| | | import com.doumee.dao.business.model.Bookings; |
| | | import com.doumee.dao.web.request.BookingsRequest; |
| | | import com.doumee.dao.web.request.MeetingPageRequest; |
| | | import com.doumee.dao.web.request.UserPageRequest; |
| | | import com.doumee.dao.web.response.MeetingDetailResponse; |
| | | import com.doumee.dao.web.response.MeetingListResponse; |
| | | import com.doumee.dao.web.response.MonthDataResponse; |
| | | import com.doumee.dao.web.response.UserResponse; |
| | | import com.doumee.service.business.BookingsService; |
| | | import com.doumee.service.system.SystemUserService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | private SystemUserService systemUserService; |
| | | |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "彿ä¼è®®è¡¨", notes = "彿ä¼è®®è¡¨") |
| | | @GetMapping("/monthMeeting") |
| | | @ApiImplicitParams({ |
| | |
| | | return ApiResponse.success("æ¥è¯¢æå",monthDataResponseList); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("æçä¼è®®å表") |
| | | @PostMapping("/myMeetingPage") |
| | | @ApiImplicitParams({ |
| | |
| | | } |
| | | |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("è·åä¼è®®å¼é¨äºç»´ç ") |
| | | @GetMapping("/getQrCode") |
| | | @ApiImplicitParams({ |
| | |
| | | */ |
| | | |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("ä¼è®®é¢çº¦") |
| | | @PostMapping("/reservationMeeting") |
| | | @ApiImplicitParams({ |
| | |
| | | return ApiResponse.success("æä½æå",bookingsService.reservationMeeting(bookingsRequest)); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("åæ¶ä¼è®®é¢çº¦") |
| | | @GetMapping("/reservationCancel") |
| | | @ApiImplicitParams({ |
| | |
| | | package com.doumee.api.web; |
| | | |
| | | import com.doumee.config.annotation.LoginRequired; |
| | | import com.doumee.core.annotation.trace.Trace; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.PageData; |
| | |
| | | |
| | | @Api(tags = "æ¶æ¯éç¥ä¿¡ä¸å¡") |
| | | @Trace(exclude = true) |
| | | @LoginRequired |
| | | @RestController |
| | | @RequestMapping("/web/notice") |
| | | @Slf4j |
| | |
| | | * @param pageWrap |
| | | * @return |
| | | */ |
| | | @LoginRequired |
| | | @ApiOperation(value = "æ¥è¯¢ç¨æ·éç¥", notes = "å°ç¨åºç«¯") |
| | | @PostMapping("/findNoticePage") |
| | | public ApiResponse<PageData<Notices>> findNoticePage(@RequestBody PageWrap<Notices> pageWrap){ |
| | |
| | | } |
| | | |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "æ¥è¯¢éç¥è¯¦æ
", notes = "å°ç¨åºç«¯") |
| | | @GetMapping("/getNoticeDetail") |
| | | public ApiResponse<Notices> getNoticeDetail(@RequestParam Integer id){ |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.doumee.config.Jwt.JwtTokenUtil; |
| | | import com.doumee.config.Jwt.WebMvcConfig; |
| | | import com.doumee.config.annotation.LoginRequired; |
| | | import com.doumee.core.annotation.trace.Trace; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.QrCodeUtils; |
| | | import com.doumee.dao.business.model.Bookings; |
| | | import com.doumee.dao.business.model.RoomTime; |
| | | import com.doumee.dao.web.request.MeetingPageRequest; |
| | | import com.doumee.dao.web.request.RoomTimeRequest; |
| | | import com.doumee.dao.web.request.RoomsRequest; |
| | | import com.doumee.dao.web.request.UserPageRequest; |
| | | import com.doumee.dao.web.response.*; |
| | | import com.doumee.service.business.BookingsService; |
| | | import com.doumee.service.business.RoomTimeService; |
| | | import com.doumee.service.business.RoomsService; |
| | | import com.doumee.service.system.SystemUserService; |
| | | import io.jsonwebtoken.JwtException; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by IntelliJ IDEA. |
| | |
| | | @Autowired |
| | | private RoomTimeService roomTimeService; |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("è·åä¼è®®å®¤å¼é¨äºç»´ç ") |
| | | @GetMapping("/getQrCode") |
| | | @ApiImplicitParams({ |
| | |
| | | } |
| | | |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("ä¼è®®å®¤å表") |
| | | @GetMapping("/roomsList") |
| | | @ApiImplicitParams({ |
| | |
| | | } |
| | | |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("ä¼è®®å®¤æ¶é´å¼æ¾å表") |
| | | @PostMapping("/getRoomUseTime") |
| | | @ApiImplicitParams({ |
| | |
| | | return ApiResponse.success("æ¥è¯¢æå",roomTimeService.getRoomUseTime(roomTimeRequest)); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("æçä¼è®®å®¤å表") |
| | | @PostMapping("/myRoomsPage") |
| | | @ApiImplicitParams({ |
| | |
| | | } |
| | | |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("ä¼è®®å®¤è¯¦æ
") |
| | | @GetMapping("/getRoomDetail") |
| | | @ApiImplicitParams({ |
| | |
| | | log_file_path="/usr/local/jars/log/admin/info.log" |
| | | log_file_error_path="/usr/local/jars/log/admin/error.log" |
| | | |
| | | nohup java -Xms512m -Xmx512m -Xmn512m -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=256m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=10031 -jar /usr/local/jars/admin_interface.jar >"${log_file_path}" 2>"${log_file_error_path}" & |
| | | nohup java -Xms2048m -Xmx2048m -Xmn2048m -XX:MetaspaceSize=1024m -XX:MaxMetaspaceSize=1024m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=10031 -jar /usr/local/jars/admin_interface.jar >"${log_file_path}" 2>"${log_file_error_path}" & |
| | |
| | | package com.doumee.api; |
| | | |
| | | import com.doumee.config.annotation.LoginNoRequired; |
| | | import com.doumee.config.jwt.JwtProperties; |
| | | import com.doumee.config.jwt.JwtTokenUtil; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.system.dto.LoginDTO; |
| | | import com.doumee.service.system.SystemLoginService; |
| | | import com.doumee.service.system.SystemUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | |
| | | * JWTè·å令çåå·æ°ä»¤çæ¥å£ |
| | | */ |
| | | @RestController |
| | | @Api("é´æç»å½æ¥å£") |
| | | @Api(tags ="é´æç»å½æ¥å£") |
| | | public class JwtAuthController { |
| | | |
| | | @Resource |
| | |
| | | @PreventRepeat(limit = 10, lockTime = 10000) |
| | | @ApiOperation("ç»å½") |
| | | @PostMapping("/login") |
| | | @LoginNoRequired |
| | | public ApiResponse<String> login (@Validated @RequestBody LoginDTO dto, ServerWebExchange serverWebExchange) { |
| | | try { |
| | | ServerHttpRequest request = serverWebExchange.getRequest(); |
| | |
| | | */ |
| | | @GetMapping("/getUserInfo") |
| | | @ApiOperation("è·åå½åç»éç¨æ·") |
| | | public ApiResponse<LoginUserInfo> getUserInfo(@RequestHeader("userToken") String token){ |
| | | public ApiResponse<LoginUserInfo> getUserInfo(@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | try { |
| | | LoginUserInfo user =jwtTokenUtil.getUserInfoByToken(token); |
| | | if(user !=null){ |
| | |
| | | package com.doumee.api.meeting; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModel; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/gateway") |
| | | @Api("æµè¯æ¥å£") |
| | | @Api(tags ="æµè¯æ¥å£") |
| | | public class CloudBookingsController { |
| | | |
| | | @GetMapping("/test") |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.config; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.LinkedHashSet; |
| | | |
| | | @Data |
| | | @Component |
| | | @ConfigurationProperties("gateway") |
| | | public class GatewayFilterProperties { |
| | | private LinkedHashSet<String> skipLoginFilterUrls; |
| | | } |
| | |
| | | return chain.filter(exchange).onErrorResume(throwable -> { |
| | | ServerHttpResponse response = exchange.getResponse(); |
| | | response.setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR); |
| | | |
| | | response.getHeaders().setContentType(MediaType.APPLICATION_JSON); |
| | | |
| | | String errorMessage = "{\"message\": \"" + throwable.getMessage() + "\"}"; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.config; |
| | | |
| | | import com.doumee.core.utils.Constants; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.AntPathMatcher; |
| | | import org.springframework.util.PathMatcher; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Order(1) |
| | | @Configuration |
| | | public class GlobalFilterConfig implements GlobalFilter { |
| | | @Autowired |
| | | private RedisTemplate<String,Object> stringRedisTemplate; |
| | | |
| | | @Resource |
| | | private GatewayFilterProperties notAuthUrlProperties; |
| | | |
| | | @Override |
| | | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
| | | /* log.info("================================================="); |
| | | log.info("è®¿é®æ¥å£ä¸»æº: {}", exchange.getRequest().getURI().getHost()); |
| | | log.info("è®¿é®æ¥å£ç«¯å£: {}", exchange.getRequest().getURI().getPort()); |
| | | log.info("è®¿é®æ¥å£URL: {}", exchange.getRequest().getURI().getPath()); |
| | | log.info("è®¿é®æ¥å£åæ°: {}", exchange.getRequest().getURI().getRawQuery());*/ |
| | | String url =exchange.getRequest().getURI().getPath(); |
| | | if(!shouldSkip(url)){ |
| | | String token = exchange.getRequest().getHeaders().getFirst(Constants.HEADER_USER_TOKEN); |
| | | if (token == null || token.isEmpty()) { |
| | | return unAuthorize(exchange); |
| | | |
| | | } |
| | | String userInfo =(String) stringRedisTemplate.opsForValue().get(Constants.REDIS_TOKEN_KEY + token); |
| | | if (StringUtils.isBlank(userInfo)) { |
| | | return unAuthorize(exchange); |
| | | } |
| | | //ææ°ç exchangeæ¾åå°è¿æ»¤é¾ |
| | | ServerHttpRequest request = exchange.getRequest().mutate().header(Constants.HEADER_USER_TOKEN, token).build(); |
| | | ServerWebExchange newExchange = exchange.mutate().request(request).build(); |
| | | return chain.filter(newExchange); |
| | | } |
| | | return chain.filter(exchange); |
| | | } |
| | | /** |
| | | * æ¹æ³å®ç°è¯´æ:ä¸éè¦è¿æ»¤çè·¯å¾ |
| | | * <p> |
| | | * // * @param currentUrl å½å请æ±è·¯å¾ |
| | | */ |
| | | private boolean shouldSkip(String currentUrl) { |
| | | if(notAuthUrlProperties.getSkipLoginFilterUrls() == null || notAuthUrlProperties.getSkipLoginFilterUrls().size() ==0){ |
| | | return false; |
| | | } |
| | | PathMatcher pathMatcher = new AntPathMatcher(); |
| | | for (String skipPath : notAuthUrlProperties.getSkipLoginFilterUrls()) { |
| | | if (pathMatcher.match(skipPath, currentUrl)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | // è¿åæªç»å½çèªå®ä¹é误 |
| | | private Mono<Void> unAuthorize(ServerWebExchange exchange) { |
| | | // 设置éè¯¯ç¶æç 为401 |
| | | exchange.getResponse().setStatusCode(HttpStatus.UNAUTHORIZED); |
| | | // 设置è¿åçä¿¡æ¯ä¸ºJSONç±»å |
| | | exchange.getResponse().getHeaders().setContentType(MediaType.APPLICATION_JSON); |
| | | // èªå®ä¹éè¯¯ä¿¡æ¯ |
| | | String errorMsg = "{\"error\": \"" + "ç¨æ·æªç»å½æç»å½è¶
æ¶,è¯·éæ°ç»å½" + "\"}"; |
| | | // å°èªå®ä¹é误ååºåå
¥ååºä½ |
| | | return exchange.getResponse() |
| | | .writeWith(Mono.just(exchange.getResponse().bufferFactory().wrap(errorMsg.getBytes()))); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.utils.Constants; |
| | | import io.jsonwebtoken.Jwts; |
| | | import io.jsonwebtoken.SignatureAlgorithm; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | claims.setLoginDate(new Date()); |
| | | refreshedToken = generateTokenDo(claims); |
| | | if(refreshedToken!=null){ |
| | | redisTemplate.delete(token);//å é¤èçtoken |
| | | redisTemplate.delete(Constants.REDIS_TOKEN_KEY+token);//å é¤èçtoken |
| | | } |
| | | } catch (Exception e) { |
| | | refreshedToken = null; |
| | |
| | | .setExpiration(expirationDate) |
| | | .signWith(SignatureAlgorithm.HS512, jwtProperties.getSecret()) |
| | | .compact(); |
| | | redisTemplate.opsForValue().set(token,JSONObject.toJSONString(userInfo),jwtProperties.getExpiration(), TimeUnit.MILLISECONDS); |
| | | redisTemplate.opsForValue().set(Constants.REDIS_TOKEN_KEY+token,JSONObject.toJSONString(userInfo),jwtProperties.getExpiration(), TimeUnit.MILLISECONDS); |
| | | return token; |
| | | } |
| | | |
| | |
| | | private LoginUserInfo getClaimsFromToken(String token) { |
| | | LoginUserInfo claims; |
| | | try { |
| | | String userInfo = (String) redisTemplate.opsForValue().get(token); |
| | | String userInfo = (String) redisTemplate.opsForValue().get(Constants.REDIS_TOKEN_KEY+token); |
| | | claims = JSONObject.toJavaObject(JSONObject.parseObject(userInfo),LoginUserInfo.class); |
| | | } catch (Exception e) { |
| | | claims = null; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.config.swagger; |
| | | |
| | | import com.doumee.config.GatewayFilterProperties; |
| | | import com.doumee.core.utils.Constants; |
| | | 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.http.HttpStatus; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.server.reactive.ServerHttpResponse; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.util.AntPathMatcher; |
| | | import org.springframework.util.PathMatcher; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import org.springframework.web.server.WebFilter; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Configuration |
| | | public class CustomWebFilterConfig { |
| | | @Autowired |
| | | private RedisTemplate<String,Object> stringRedisTemplate; |
| | | @Resource |
| | | private GatewayFilterProperties notAuthUrlProperties; |
| | | |
| | | @Bean |
| | | public WebFilter webFilter() { |
| | | return (exchange, chain) -> { |
| | | String url =exchange.getRequest().getURI().getPath(); |
| | | if(!shouldSkip(url)){ |
| | | String token = exchange.getRequest().getHeaders().getFirst(Constants.HEADER_USER_TOKEN); |
| | | if (token == null || token.isEmpty()) { |
| | | return unAuthorize(exchange); |
| | | |
| | | } |
| | | String userInfo =(String) stringRedisTemplate.opsForValue().get(Constants.REDIS_TOKEN_KEY + token); |
| | | if (StringUtils.isBlank(userInfo)) { |
| | | return unAuthorize(exchange); |
| | | } |
| | | //ææ°ç exchangeæ¾åå°è¿æ»¤é¾ |
| | | ServerHttpRequest request = exchange.getRequest().mutate().header(Constants.HEADER_USER_TOKEN, token).build(); |
| | | ServerWebExchange newExchange = exchange.mutate().request(request).build(); |
| | | return chain.filter(newExchange); |
| | | } |
| | | return chain.filter(exchange); |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * æ¹æ³å®ç°è¯´æ:ä¸éè¦è¿æ»¤çè·¯å¾ |
| | | * <p> |
| | | * // * @param currentUrl å½å请æ±è·¯å¾ |
| | | */ |
| | | private boolean shouldSkip(String currentUrl) { |
| | | if(notAuthUrlProperties.getSkipLoginFilterUrls() == null || notAuthUrlProperties.getSkipLoginFilterUrls().size() ==0){ |
| | | return false; |
| | | } |
| | | PathMatcher pathMatcher = new AntPathMatcher(); |
| | | for (String skipPath : notAuthUrlProperties.getSkipLoginFilterUrls()) { |
| | | if (pathMatcher.match(skipPath, currentUrl)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | // è¿åæªç»å½çèªå®ä¹é误 |
| | | private Mono<Void> unAuthorize(ServerWebExchange exchange) { |
| | | // 设置éè¯¯ç¶æç 为401 |
| | | exchange.getResponse().setStatusCode(HttpStatus.UNAUTHORIZED); |
| | | // 设置è¿åçä¿¡æ¯ä¸ºJSONç±»å |
| | | exchange.getResponse().getHeaders().setContentType(MediaType.APPLICATION_JSON); |
| | | // èªå®ä¹éè¯¯ä¿¡æ¯ |
| | | String errorMsg = "{\"error\": \"" + "ç¨æ·æªç»å½æç»å½è¶
æ¶,è¯·éæ°ç»å½" + "\"}"; |
| | | // å°èªå®ä¹é误ååºåå
¥ååºä½ |
| | | return exchange.getResponse() |
| | | .writeWith(Mono.just(exchange.getResponse().bufferFactory().wrap(errorMsg.getBytes()))); |
| | | } |
| | | } |
| | | |
| | |
| | | timeout: PT3H #表示12å°æ¶ |
| | | |
| | | |
| | | gateway: |
| | | skipLoginFilterUrls: |
| | | - /meetingAdmin/** |
| | | - /visitsAdmin/** |
| | | - /login |
| | | - /doc.html |
| | | - /v2/api-docs/** |
| | |
| | | exposure: |
| | | include: "*" |
| | | |
| | | |
| | | knife4j: |
| | | # èåswaggerææ¡£ |
| | | gateway: |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.config.annotation; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | @Target({ElementType.METHOD,ElementType.TYPE}) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface LoginNoRequired {} |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.config.cloudfilter; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
| | | |
| | | @Configuration |
| | | public class CloudWebConfig implements WebMvcConfigurer { |
| | | @Autowired |
| | | private RedisTemplate<String,Object> stringRedisTemplate; |
| | | @Override |
| | | public void addInterceptors(InterceptorRegistry registry) { |
| | | registry.addInterceptor(new LoginHandlerInterceptor(stringRedisTemplate)) |
| | | .addPathPatterns("/cloudService/**"); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.config.cloudfilter; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.config.annotation.LoginNoRequired; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.utils.Constants; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.method.HandlerMethod; |
| | | import org.springframework.web.servlet.HandlerInterceptor; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | public class LoginHandlerInterceptor implements HandlerInterceptor { |
| | | |
| | | private RedisTemplate<String,Object> stringRedisTemplate; |
| | | |
| | | |
| | | // ç±äºè¯¥ç±»æªäº¤ç»spring管çï¼å æ¤ä¸è½ä½¿ç¨èªå¨è£
é
çæ¹å¼è·åRedisTemplate对象 |
| | | public LoginHandlerInterceptor(RedisTemplate<String,Object> stringRedisTemplate) { |
| | | this.stringRedisTemplate = stringRedisTemplate; |
| | | } |
| | | |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
| | | HandlerMethod handlerMethod = (HandlerMethod) handler; |
| | | Class<?> beanType = handlerMethod.getBeanType(); |
| | | if (!beanType.isAnnotationPresent(LoginNoRequired.class) || !handlerMethod.hasMethodAnnotation(LoginNoRequired.class)) { |
| | | //è·åtoken |
| | | String token = request.getHeader(Constants.HEADER_USER_TOKEN); // ä» http 请æ±å¤´ä¸ååº token |
| | | if (StringUtils.isNotBlank(token)) { |
| | | checkLogin(request,response); |
| | | } else { |
| | | throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"æªç»å½"); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private void checkLogin(HttpServletRequest request, HttpServletResponse response) { |
| | | String token = request.getHeader(Constants.HEADER_USER_TOKEN); |
| | | if (token == null || token.isEmpty()) { |
| | | throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"æªç»å½"); |
| | | } |
| | | String userinfo =(String) stringRedisTemplate.opsForValue().get(Constants.REDIS_TOKEN_KEY + token); |
| | | if (StringUtils.isBlank(userinfo)) { |
| | | throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"æªç»å½"); |
| | | } |
| | | LoginUserInfo user = JSONObject.toJavaObject(JSONObject.parseObject(userinfo),LoginUserInfo.class ); |
| | | if(user ==null ){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"ç¨æ·ç»é已失æï¼è¯·éæ°ç»éï¼"); |
| | | } |
| | | } |
| | | |
| | | // @Override |
| | | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { |
| | | // UserContext.removeUser(); |
| | | } |
| | | } |
| | |
| | | import java.util.regex.Pattern; |
| | | |
| | | public class Constants { |
| | | |
| | | public static final String HEADER_USER_TOKEN = "dm_user_token"; |
| | | public static final String REDIS_TOKEN_KEY = "token_"; |
| | | public static final String[] ALL_SPELL_LIST_FIRST = new String[]{"A", "B", "C", "D", "E", "F", "G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; |
| | | public static final int ZERO = 0 ; |
| | | public static final int ONE = 1 ; |
| | |
| | | package com.doumee.api.cloud; |
| | | |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.config.annotation.LoginNoRequired; |
| | | import com.doumee.core.annotation.excel.ExcelExporter; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.core.model.ApiResponse; |
| | |
| | | */ |
| | | @Api(tags = "è½¦è¾æ¥å£") |
| | | @RestController |
| | | @RequestMapping("/cloud/cars") |
| | | @RequestMapping("/cloudService/cars") |
| | | public class CloudCarsController extends BaseController { |
| | | |
| | | @Autowired |
| | | private CarsService carsService; |
| | | @Autowired |
| | | private HkSyncVehicleFromHKServiceImpl hkSyncVehicleFromHKService; |
| | | @PreventRepeat |
| | | @ApiOperation("æµè¯ç½ç®¡") |
| | | @GetMapping("/test") |
| | | public ApiResponse test() { |
| | | return ApiResponse.success("è®¿å®¢ç®¡çæµè¯æå"); |
| | | return ApiResponse.success("è®¿å®¢ç®¡çæµè¯æææå"); |
| | | } |
| | | |
| | | @LoginNoRequired |
| | | @ApiOperation("æµè¯ç½ç®¡") |
| | | @GetMapping("/testNoLogin") |
| | | public ApiResponse testNoLogin() { |
| | | return ApiResponse.success("è®¿å®¢ç®¡çæµè¯æ éç»å½æå"); |
| | | } |
| | | |
| | | @PreventRepeat |
| | |
| | | package com.doumee.api.web; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.config.annotation.LoginRequired; |
| | | import com.doumee.core.annotation.trace.Trace; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.PageData; |
| | |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by IntelliJ IDEA. |
| | |
| | | return ApiResponse.success("ç»å½æå",wxAuthorizeVO); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "å
é¨äººåé¦é¡µ", notes = "H5") |
| | | @GetMapping("/internalHome") |
| | | @ApiImplicitParams({ |
| | |
| | | } |
| | | |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("ä»»å¡ä¸å¿") |
| | | @PostMapping("/taskCenter") |
| | | @ApiImplicitParams({ |
| | |
| | | return ApiResponse.success(visitsService.taskCenter(pageWrap)); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("访客记å½è¯¦æ
") |
| | | @GetMapping("/visitDetail") |
| | | @ApiImplicitParams({ |
| | |
| | | } |
| | | |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "人åå页",notes = "å¯æè®¿å
é¨äººå") |
| | | @PostMapping("/memberList") |
| | | @ApiImplicitParams({ |
| | |
| | | return ApiResponse.success(memberService.getVisitedMemberList(pageWrap)); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "è®¿å®¢è®°å½æäº¤", notes = "å
é¨äººåæäº¤") |
| | | @PostMapping("/createVisit") |
| | | @ApiImplicitParams({ |
| | |
| | | return ApiResponse.success("æ¥è¯¢æå", visitsService.createFk(visits,false)); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "å®¡æ¹æµè®°å½å®¡æ¹", notes = "å
é¨äººå") |
| | | @PostMapping("/auditApprove") |
| | | @ApiImplicitParams({ |
| | |
| | | package com.doumee.api.web; |
| | | |
| | | import com.doumee.config.annotation.LoginRequired; |
| | | import com.doumee.core.annotation.trace.Trace; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.utils.Constants; |