├── README.md ├── mall-advertise-service ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── shepherd │ │ │ └── malladvertise │ │ │ ├── MallAdvertiseServiceApplication.java │ │ │ ├── api │ │ │ ├── service │ │ │ │ └── AdvertiseService.java │ │ │ └── vo │ │ │ │ └── AdvertiseVO.java │ │ │ ├── dao │ │ │ └── AdvertiseDAO.java │ │ │ ├── dto │ │ │ └── AdvertiseDTO.java │ │ │ ├── entity │ │ │ └── Advertise.java │ │ │ ├── listener │ │ │ └── AdvListener.java │ │ │ └── service │ │ │ └── AdvertiseServiceImpl.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application.yml │ │ ├── bootstrap.yml │ │ ├── logback.xml │ │ └── mapper │ │ └── AdvertiseMapper.xml │ └── test │ └── java │ └── com │ └── shepherd │ └── malladvertise │ └── MallAdvertiseServiceApplicationTests.java ├── mall-auth ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── shepherd │ │ └── mallauth │ │ ├── MallAuthApplication.java │ │ ├── component │ │ └── JwtTokenEnhancer.java │ │ ├── config │ │ ├── AuthServer.java │ │ ├── JwtTokenConfig.java │ │ ├── SecurityConfig.java │ │ └── SmsProperties.java │ │ ├── constant │ │ └── RedisConstant.java │ │ ├── controller │ │ └── AuthController.java │ │ ├── dao │ │ └── UserDAO.java │ │ ├── dto │ │ └── SecurityUser.java │ │ ├── entity │ │ └── User.java │ │ └── service │ │ ├── AuthService.java │ │ ├── UserService.java │ │ └── impl │ │ ├── AuthServiceImpl.java │ │ └── UserServiceImpl.java │ └── resources │ ├── application-dev.yml │ ├── application.yml │ ├── bootstrap.yml │ ├── jwt.jks │ └── logback.xml ├── mall-base-service ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── shepherd │ │ │ └── mallbase │ │ │ ├── MallBaseServiceApplication.java │ │ │ ├── api │ │ │ ├── controller │ │ │ │ ├── FileController.java │ │ │ │ └── SmsController.java │ │ │ └── service │ │ │ │ ├── FileService.java │ │ │ │ └── SmsService.java │ │ │ ├── config │ │ │ └── OssProperties.java │ │ │ ├── dto │ │ │ └── FastDFSFile.java │ │ │ ├── enums │ │ │ └── ErrorCodeEnum.java │ │ │ ├── service │ │ │ └── impl │ │ │ │ ├── FileServiceImpl.java │ │ │ │ └── SmsServiceImpl.java │ │ │ └── util │ │ │ └── FastDFSClient.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application.yml │ │ └── fdfs_client.conf │ └── test │ └── java │ └── com │ └── shepherd │ └── mallbase │ └── MallBaseServiceApplicationTests.java ├── mall-common ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── shepherd │ └── mall │ ├── advice │ ├── GlobalExceptionHandler.java │ └── ResponseResultBodyAdvice.java │ ├── annotation │ └── ResponseResultBody.java │ ├── base │ ├── BaseQuery.java │ └── CasProperties.java │ ├── config │ └── BaseRedisConfig.java │ ├── constant │ └── CommonConstant.java │ ├── enums │ └── ResponseStatusEnum.java │ ├── exception │ └── BusinessException.java │ ├── service │ ├── RedisService.java │ └── impl │ │ └── RedisServiceImpl.java │ ├── utils │ ├── CookieBaseSessionUtil.java │ ├── DateUtil.java │ ├── HttpUtil.java │ ├── IdUtil.java │ ├── IdWorker.java │ ├── JwtUtil.java │ ├── MD5Util.java │ ├── MallBeanUtil.java │ ├── NumberUtil.java │ └── WebUtil.java │ └── vo │ ├── LoginVO.java │ ├── PageInfo.java │ └── ResponseVO.java ├── mall-gateway ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── shepherd │ │ └── mallgateway │ │ ├── MallGatewayApplication.java │ │ ├── authorization │ │ └── AuthorizationManager.java │ │ ├── component │ │ ├── RestAuthenticationEntryPoint.java │ │ └── RestfulAccessDeniedHandler.java │ │ ├── config │ │ ├── GlobalCorsConfig.java │ │ ├── IgnoreUrlsConfig.java │ │ ├── ResourceServerConfig.java │ │ └── SentinelConfig.java │ │ ├── constant │ │ └── AuthConstant.java │ │ ├── dto │ │ └── UserDto.java │ │ └── filter │ │ ├── AuthGlobalFilter.java │ │ └── IgnoreUrlsRemoveJwtFilter.java │ └── resources │ ├── application-dev.yml │ ├── application.yml │ ├── bootstrap.yml │ └── logback.xml ├── mall-order-service ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── shepherd │ │ │ └── mallorder │ │ │ ├── Constant │ │ │ ├── CartConstant.java │ │ │ └── OrderConstant.java │ │ │ ├── MallOrderServiceApplication.java │ │ │ ├── SkuQuery.java │ │ │ ├── annotation │ │ │ └── JobAnnotation.java │ │ │ ├── api │ │ │ ├── controller │ │ │ │ ├── CartController.java │ │ │ │ └── OrderController.java │ │ │ ├── service │ │ │ │ ├── CartService.java │ │ │ │ ├── OrderItemService.java │ │ │ │ └── OrderService.java │ │ │ └── vo │ │ │ │ ├── CartVO.java │ │ │ │ ├── OrderSumbitVO.java │ │ │ │ └── OrderVO.java │ │ │ ├── config │ │ │ ├── ApplicationListenerConfig.java │ │ │ ├── DataSourceConfig.java │ │ │ ├── InitConfig.java │ │ │ ├── QuartzBindOperationConfig.java │ │ │ ├── QuartzConfig.java │ │ │ ├── RabbitmqConfig.java │ │ │ └── RedisConfig.java │ │ │ ├── dao │ │ │ ├── OrderDAO.java │ │ │ └── OrderItemDAO.java │ │ │ ├── dto │ │ │ ├── Address.java │ │ │ ├── CartDTO.java │ │ │ ├── CartItem.java │ │ │ ├── OrderConfirmDTO.java │ │ │ ├── OrderDTO.java │ │ │ ├── OrderSubmitDTO.java │ │ │ └── ProductSku.java │ │ │ ├── entity │ │ │ ├── Order.java │ │ │ └── OrderItem.java │ │ │ ├── factory │ │ │ └── QuartzJobFactory.java │ │ │ ├── feign │ │ │ ├── ProductService.java │ │ │ ├── UserService.java │ │ │ └── WareService.java │ │ │ ├── interceptor │ │ │ ├── AuthInterceptor.java │ │ │ ├── FeignInterceptor.java │ │ │ └── OrderWebConfig.java │ │ │ ├── listener │ │ │ └── OrderCloseListener.java │ │ │ ├── mq │ │ │ └── TestReceiveMessage.java │ │ │ ├── schedule │ │ │ ├── JobAnnotationBeanPostProcessor.java │ │ │ └── TestSchedule.java │ │ │ ├── service │ │ │ └── impl │ │ │ │ ├── CartServiceImpl.java │ │ │ │ ├── OrderItemServiceImpl.java │ │ │ │ └── OrderServiceImpl.java │ │ │ └── utils │ │ │ └── UserUtil.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application.yml │ │ ├── bootstrap.yml │ │ ├── logback.xml │ │ ├── mapper │ │ ├── OrderItemMapper.xml │ │ └── OrderMapper.xml │ │ └── quartz.properties │ └── test │ └── java │ └── com │ └── shepherd │ └── mallorder │ ├── MallOrderServiceApplicationTests.java │ └── feign │ └── ProductServiceTest.java ├── mall-pay-service ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── shepherd │ │ └── mallpay │ │ ├── MallPayServiceApplication.java │ │ ├── api │ │ ├── controller │ │ │ └── PayController.java │ │ └── service │ │ │ └── PayService.java │ │ ├── config │ │ ├── AlipayProperties.java │ │ ├── PayConfig.java │ │ └── WxProperties.java │ │ ├── constant │ │ └── PayConstant.java │ │ ├── dao │ │ └── PayInfoDAO.java │ │ ├── dto │ │ ├── AlipayNotify.java │ │ ├── Order.java │ │ └── PayInfoDTO.java │ │ ├── entity │ │ └── PayInfo.java │ │ ├── enums │ │ ├── AlipayNotifyStatusEnum.java │ │ └── PayPlatformEnum.java │ │ ├── feign │ │ └── OrderService.java │ │ └── service │ │ └── PayServiceImpl.java │ └── resources │ ├── application-dev.yml │ ├── application.yml │ ├── bootstrap.yml │ ├── logback.xml │ ├── mapper │ └── PayInfoMapper.xml │ └── templates │ ├── alipayView.ftl │ ├── createForAlipayPc.ftl │ ├── createForWxNative.ftl │ └── wxView.ftl ├── mall-product-service ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── shepherd │ │ │ └── mallproduct │ │ │ ├── MallProductServiceApplication.java │ │ │ ├── annotation │ │ │ └── Limit.java │ │ │ ├── aop │ │ │ └── LimitInterceptor.java │ │ │ ├── api │ │ │ ├── controller │ │ │ │ ├── BrandController.java │ │ │ │ ├── CategoryController.java │ │ │ │ ├── LimiterController.java │ │ │ │ └── ProductController.java │ │ │ ├── service │ │ │ │ ├── BrandService.java │ │ │ │ ├── CategoryService.java │ │ │ │ └── ProductService.java │ │ │ └── vo │ │ │ │ ├── BrandVO.java │ │ │ │ ├── CategoryVO.java │ │ │ │ └── ProductVO.java │ │ │ ├── cache │ │ │ ├── CacheTest.java │ │ │ ├── CompositeCache.java │ │ │ ├── CompositeCacheManager.java │ │ │ ├── RedisCacheEx.java │ │ │ └── listener │ │ │ │ └── CompositeCacheRemovalListener.java │ │ │ ├── config │ │ │ ├── InitConfig.java │ │ │ ├── RedisConfig.java │ │ │ ├── RedisProperties.java │ │ │ └── RedissonConfig.java │ │ │ ├── constant │ │ │ └── ProductConstant.java │ │ │ ├── dao │ │ │ ├── BrandDAO.java │ │ │ ├── CategoryDAO.java │ │ │ ├── ProductParamDAO.java │ │ │ ├── ProductSkuDAO.java │ │ │ ├── ProductSpecDAO.java │ │ │ └── ProductSpuDAO.java │ │ │ ├── dto │ │ │ ├── BrandDTO.java │ │ │ ├── CategoryDTO.java │ │ │ ├── ProductDTO.java │ │ │ ├── ProductParamDTO.java │ │ │ ├── ProductSkuDTO.java │ │ │ ├── ProductSpecDTO.java │ │ │ ├── SkuInfo.java │ │ │ └── SpecDTO.java │ │ │ ├── entity │ │ │ ├── Brand.java │ │ │ ├── Category.java │ │ │ ├── ProductParam.java │ │ │ ├── ProductSku.java │ │ │ ├── ProductSpec.java │ │ │ └── ProductSpu.java │ │ │ ├── enums │ │ │ └── LimitType.java │ │ │ ├── feign │ │ │ └── SearchService.java │ │ │ ├── interceptor │ │ │ ├── InterceptorConfig.java │ │ │ └── UserLoginInterceptor.java │ │ │ ├── listener │ │ │ └── RedisKeyExpiredListener.java │ │ │ ├── nacos │ │ │ ├── User.java │ │ │ └── UserProperties.java │ │ │ ├── query │ │ │ ├── BrandQuery.java │ │ │ ├── CategoryQuery.java │ │ │ └── ProductQuery.java │ │ │ ├── service │ │ │ ├── BrandServiceImpl.java │ │ │ ├── CategoryServiceImpl.java │ │ │ └── ProductServiceImpl.java │ │ │ └── thread │ │ │ └── ThreadTest.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application.yml │ │ ├── bootstrap.yml │ │ ├── logback.xml │ │ └── mapper │ │ ├── BrandMapper.xml │ │ ├── CategoryMapper.xml │ │ ├── ProductParamMapper.xml │ │ ├── ProductSkuMapper.xml │ │ ├── ProductSpecMapper.xml │ │ └── ProductSpuMapper.xml │ └── test │ └── java │ └── com │ └── shepherd │ └── mallproduct │ ├── listener │ └── RedisKeyExpiredListenerTest.java │ └── nacos │ └── UserTest.java ├── mall-search-service ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── shepherd │ │ │ └── mallsearch │ │ │ ├── MallSearchServiceApplication.java │ │ │ ├── api │ │ │ ├── controller │ │ │ │ └── SearchController.java │ │ │ ├── service │ │ │ │ ├── ProductService.java │ │ │ │ └── SearchService.java │ │ │ └── vo │ │ │ │ ├── BrandVO.java │ │ │ │ ├── CategoryVO.java │ │ │ │ ├── SearchResult.java │ │ │ │ └── SpecVO.java │ │ │ ├── config │ │ │ └── ElasticSearchConfig.java │ │ │ ├── dto │ │ │ └── ProductSku.java │ │ │ ├── enums │ │ │ └── ErrorCodeEnum.java │ │ │ ├── param │ │ │ └── SearchParam.java │ │ │ └── service │ │ │ └── impl │ │ │ └── SearchServiceImpl.java │ └── resources │ │ ├── application.yml │ │ └── bootstrap.yml │ └── test │ └── java │ └── com │ └── shepherd │ └── mallsearch │ ├── MallSearchServiceApplicationTests.java │ └── config │ └── ElasticSearchConfigTest.java ├── mall-seckill ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── shepherd │ │ │ └── mall │ │ │ └── seckill │ │ │ ├── MallSeckillApplication.java │ │ │ ├── annotation │ │ │ └── RateLimit.java │ │ │ ├── api │ │ │ ├── controller │ │ │ │ ├── SeckillController.java │ │ │ │ ├── TestController.java │ │ │ │ └── TestSentinelController.java │ │ │ ├── service │ │ │ │ ├── SeckillService.java │ │ │ │ ├── TestHystrixService.java │ │ │ │ └── TestSentinelService.java │ │ │ └── vo │ │ │ │ └── SeckillVO.java │ │ │ ├── config │ │ │ ├── InitConfig.java │ │ │ ├── RabbitmqConfig.java │ │ │ ├── RedisConfig.java │ │ │ ├── RedissonConfig.java │ │ │ └── SentinelConfig.java │ │ │ ├── dao │ │ │ ├── SeckillSessionDAO.java │ │ │ └── SeckillSkuDAO.java │ │ │ ├── dto │ │ │ ├── SeckillOrder.java │ │ │ ├── SeckillSessionDTO.java │ │ │ ├── SeckillSkuDTO.java │ │ │ └── SkuInfo.java │ │ │ ├── entity │ │ │ ├── SeckillSession.java │ │ │ └── SeckillSku.java │ │ │ ├── factory │ │ │ └── ProductFeignFactory.java │ │ │ ├── feign │ │ │ └── ProductService.java │ │ │ ├── interceptor │ │ │ └── RateLimitAop.java │ │ │ ├── schedule │ │ │ └── SeckillSchedule.java │ │ │ └── service │ │ │ ├── ProductFeignFallback.java │ │ │ ├── SeckillServiceImpl.java │ │ │ ├── TestHystrixServiceImpl.java │ │ │ └── TestSentinelServiceImp.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application.yml │ │ ├── bootstrap.yml │ │ ├── logback.xml │ │ └── mapper │ │ └── SeckillSessionMapper.xml │ └── test │ └── java │ └── com │ └── shepherd │ └── mall │ └── seckill │ └── MallSeckillApplicationTests.java ├── mall-swagger ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── shepherd │ └── mall │ ├── SwaggerConfig.java │ └── SwaggerProps.java ├── mall-user-service ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── shepherd │ │ │ └── malluser │ │ │ ├── MallUserServiceApplication.java │ │ │ ├── api │ │ │ ├── controller │ │ │ │ ├── AddressController.java │ │ │ │ └── UserController.java │ │ │ ├── service │ │ │ │ ├── AddressService.java │ │ │ │ ├── AuthService.java │ │ │ │ ├── OauthService.java │ │ │ │ └── UserService.java │ │ │ └── vo │ │ │ │ ├── LoginResponseVO.java │ │ │ │ ├── LoginVO.java │ │ │ │ └── UserVO.java │ │ │ ├── config │ │ │ └── SpringCacheConfig.java │ │ │ ├── constant │ │ │ └── Constant.java │ │ │ ├── dao │ │ │ ├── AddressDAO.java │ │ │ ├── ThirdOauthDAO.java │ │ │ └── UserDAO.java │ │ │ ├── dto │ │ │ ├── AddressDTO.java │ │ │ ├── ThirdOauthDTO.java │ │ │ ├── TokenResponse.java │ │ │ ├── UserDTO.java │ │ │ └── WeiboUser.java │ │ │ ├── entity │ │ │ ├── Address.java │ │ │ ├── ThirdOauth.java │ │ │ └── User.java │ │ │ ├── enums │ │ │ └── ErrorCodeEnum.java │ │ │ ├── interceptor │ │ │ ├── AuthInterceptor.java │ │ │ └── UserWebConfig.java │ │ │ ├── service │ │ │ └── impl │ │ │ │ ├── AddressServiceImpl.java │ │ │ │ ├── OauthServiceImpl.java │ │ │ │ └── UserServiceImpl.java │ │ │ ├── spel │ │ │ ├── DefaultFunctionServiceImpl.java │ │ │ ├── DistributeExceptionAspect.java │ │ │ ├── DistributeExceptionHandler.java │ │ │ ├── ExpressionEvaluator.java │ │ │ ├── ExpressionRootObject.java │ │ │ ├── IFunctionService.java │ │ │ ├── IParseFunction.java │ │ │ ├── LogRecordContext.java │ │ │ ├── LogRecordEvaluationContext.java │ │ │ ├── LogRecordExpressionEvaluator.java │ │ │ ├── LogRecordValueParser.java │ │ │ ├── ParseFunctionFactory.java │ │ │ ├── TestExpression.java │ │ │ ├── TestSpEL.java │ │ │ ├── aspectj │ │ │ │ ├── LogAspect.java │ │ │ │ ├── LogRecord.java │ │ │ │ ├── LogRecordOperationSource.java │ │ │ │ └── LogRecordOps.java │ │ │ └── getAddressMobile.java │ │ │ ├── test │ │ │ ├── CarRunServiceImpl.java │ │ │ ├── MyConfiguration.java │ │ │ ├── MyInitBean.java │ │ │ ├── RunService.java │ │ │ └── TrainRunServiceImpl.java │ │ │ ├── utils │ │ │ └── UserUtil.java │ │ │ └── web │ │ │ └── OAuth2Controller.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application.yml │ │ ├── bootstrap.yml │ │ ├── logback.xml │ │ ├── mapper │ │ ├── AddressMapper.xml │ │ ├── ThirdOauthMapper.xml │ │ └── UserMapper.xml │ │ ├── static │ │ └── static │ │ │ ├── login │ │ │ ├── JD_img │ │ │ │ ├── 4de5019d2404d347897dee637895d02b_06.png │ │ │ │ ├── 4de5019d2404d347897dee637895d02b_11.png │ │ │ │ ├── 4de5019d2404d347897dee637895d02b_15.png │ │ │ │ ├── 4de5019d2404d347897dee637895d02b_17.png │ │ │ │ ├── 4de5019d2404d347897dee637895d02b_19.png │ │ │ │ ├── 4de5019d2404d347897dee637895d02b_25.png │ │ │ │ ├── 5731485aN1134b4f0.png │ │ │ │ ├── a65a18e877a16246a92e1b755bd88a03_03.png │ │ │ │ ├── a65a18e877a16246a92e1b755bd88a03_06.png │ │ │ │ ├── f760f80838eafa4ba85463ce6ce1298d_03.png │ │ │ │ ├── grow1.png │ │ │ │ ├── grow2.png │ │ │ │ ├── img11.png │ │ │ │ ├── img22.png │ │ │ │ ├── logo.jpg │ │ │ │ ├── phone-orange.png │ │ │ │ ├── pwd-icons-new.png │ │ │ │ ├── qq.png │ │ │ │ ├── show.png │ │ │ │ ├── user_03.png │ │ │ │ ├── user_06.png │ │ │ │ ├── weibo.png │ │ │ │ └── weixin.png │ │ │ ├── JD_js │ │ │ │ ├── jquery-3.1.1.min.js │ │ │ │ └── zepto.js │ │ │ └── JD_sass │ │ │ │ ├── JD1.css │ │ │ │ ├── JD1.css.map │ │ │ │ └── JD1.scss │ │ │ └── reg │ │ │ ├── bootStrap │ │ │ └── bootstrap │ │ │ │ ├── css │ │ │ │ ├── bootstrap.css │ │ │ │ └── bootstrap.min.css │ │ │ │ ├── fonts │ │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ │ └── glyphicons-halflings-regular.woff2 │ │ │ │ └── js │ │ │ │ ├── bootstrap.js │ │ │ │ ├── bootstrap.min.js │ │ │ │ └── jquery-3.1.1.min.js │ │ │ ├── css │ │ │ └── index.css │ │ │ ├── img │ │ │ ├── 4de5019d2404d347897dee637895d02b_06.png │ │ │ ├── 4de5019d2404d347897dee637895d02b_11.png │ │ │ ├── 4de5019d2404d347897dee637895d02b_15.png │ │ │ ├── 4de5019d2404d347897dee637895d02b_17.png │ │ │ ├── 4de5019d2404d347897dee637895d02b_19.png │ │ │ ├── 4de5019d2404d347897dee637895d02b_25.png │ │ │ ├── 5731485aN1134b4f0.png │ │ │ ├── a65a18e877a16246a92e1b755bd88a03_03.png │ │ │ ├── a65a18e877a16246a92e1b755bd88a03_06.png │ │ │ ├── f760f80838eafa4ba85463ce6ce1298d_03.png │ │ │ ├── icon.png │ │ │ ├── logo.png │ │ │ ├── logo1.jpg │ │ │ ├── phone-orange.png │ │ │ ├── qq.png │ │ │ ├── show.png │ │ │ ├── user_03.png │ │ │ ├── user_06.png │ │ │ └── weixin.png │ │ │ ├── js │ │ │ ├── easyUI │ │ │ │ ├── AUTHORS.txt │ │ │ │ ├── LICENSE.txt │ │ │ │ ├── external │ │ │ │ │ └── jquery │ │ │ │ │ │ └── jquery.js │ │ │ │ ├── images │ │ │ │ │ ├── ui-icons_444444_256x240.png │ │ │ │ │ ├── ui-icons_555555_256x240.png │ │ │ │ │ ├── ui-icons_777620_256x240.png │ │ │ │ │ ├── ui-icons_777777_256x240.png │ │ │ │ │ ├── ui-icons_cc0000_256x240.png │ │ │ │ │ └── ui-icons_ffffff_256x240.png │ │ │ │ ├── index.html │ │ │ │ ├── jquery-ui.css │ │ │ │ ├── jquery-ui.js │ │ │ │ ├── jquery-ui.min.css │ │ │ │ ├── jquery-ui.min.js │ │ │ │ ├── jquery-ui.structure.css │ │ │ │ ├── jquery-ui.structure.min.css │ │ │ │ ├── jquery-ui.theme.css │ │ │ │ ├── jquery-ui.theme.min.css │ │ │ │ └── package.json │ │ │ ├── index.js │ │ │ └── jQuery │ │ │ │ ├── jquery-1.11.1.js │ │ │ │ ├── jquery-1.7.2.js │ │ │ │ ├── jquery-1.8.3.js │ │ │ │ ├── jquery-1.9.1.js │ │ │ │ ├── jquery-3.1.1.js │ │ │ │ ├── jquery-3.1.1.min.js │ │ │ │ ├── jquery-3.2.1.slim.min.js │ │ │ │ ├── jquery.form.js │ │ │ │ ├── jquery.js │ │ │ │ ├── jquery.mockjax-1.5.3.js │ │ │ │ ├── jquery.mockjax-2.2.1.js │ │ │ │ ├── jquery.mockjax.js │ │ │ │ ├── jquery.simulate.js │ │ │ │ └── require.js │ │ │ ├── libs │ │ │ └── jquery-1.12.4.min.js │ │ │ └── sass │ │ │ ├── index.css │ │ │ ├── index.css.map │ │ │ └── index.scss │ │ └── templates │ │ └── login.html │ └── test │ └── java │ └── com │ └── shepherd │ └── malluser │ ├── RedisSentinelTest.java │ ├── service │ └── impl │ │ └── AddressServiceImplTest.java │ └── spel │ └── TestExpressionTest.java ├── mall-warehouse ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── shepherd │ │ │ └── ware │ │ │ ├── MallWarehouseServiceApplication.java │ │ │ ├── api │ │ │ ├── controller │ │ │ │ └── WareSkuController.java │ │ │ └── service │ │ │ │ ├── WareOrderTaskItemService.java │ │ │ │ └── WareSkuService.java │ │ │ ├── config │ │ │ ├── DataSourceConfig.java │ │ │ └── RabbitMqConfig.java │ │ │ ├── constant │ │ │ └── OrderConstant.java │ │ │ ├── dao │ │ │ ├── WareInfoDAO.java │ │ │ ├── WareOrderTaskDAO.java │ │ │ ├── WareOrderTaskItemDAO.java │ │ │ └── WareSkuDAO.java │ │ │ ├── dto │ │ │ ├── Order.java │ │ │ ├── OrderItem.java │ │ │ ├── WareInfoDTO.java │ │ │ ├── WareOrderTaskDTO.java │ │ │ └── WareSkuDTO.java │ │ │ ├── entity │ │ │ ├── WareInfo.java │ │ │ ├── WareOrderTask.java │ │ │ ├── WareOrderTaskItem.java │ │ │ └── WareSku.java │ │ │ ├── feign │ │ │ └── OrderService.java │ │ │ ├── interceptor │ │ │ └── FeignInterceptor.java │ │ │ ├── listener │ │ │ └── StockReleaseListener.java │ │ │ ├── service │ │ │ └── impl │ │ │ │ ├── WareOrderTaskItemServiceImpl.java │ │ │ │ └── WareSkuServiceImpl.java │ │ │ └── utils │ │ │ ├── CsvUtil.java │ │ │ └── Test.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application.yml │ │ ├── bootstrap.yml │ │ └── mapper │ │ └── WareSkuMapper.xml │ └── test │ └── java │ └── com │ └── shepherd │ └── ware │ └── MallWarehouseServiceApplicationTests.java └── pom.xml /README.md: -------------------------------------------------------------------------------- 1 | # shepherd-mall 2 | ## 123 3 | ### 1111 4 | ``` 5 | 6 | ``` 7 | 8 | **阿萨德** 9 | 10 | `hello` world 11 | -------------------------------------------------------------------------------- /mall-advertise-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /mall-advertise-service/src/main/java/com/shepherd/malladvertise/MallAdvertiseServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malladvertise; 2 | 3 | import com.xpand.starter.canal.annotation.EnableCanalClient; 4 | import org.mybatis.spring.annotation.MapperScan; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.annotation.ComponentScan; 8 | 9 | @SpringBootApplication 10 | 11 | //启用canal 12 | @EnableCanalClient 13 | @MapperScan(basePackages = "com.shepherd.malladvertise.dao") 14 | @ComponentScan(basePackages = {"com.shepherd"}) 15 | public class MallAdvertiseServiceApplication { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(MallAdvertiseServiceApplication.class, args); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /mall-advertise-service/src/main/java/com/shepherd/malladvertise/api/service/AdvertiseService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malladvertise.api.service; 2 | 3 | import com.shepherd.malladvertise.dto.AdvertiseDTO; 4 | 5 | import java.util.List; 6 | import java.util.concurrent.ConcurrentHashMap; 7 | 8 | /** 9 | * @author fjZheng 10 | * @version 1.0 11 | * @date 2021/1/14 19:42 12 | */ 13 | public interface AdvertiseService { 14 | List getAdvertiseList(Integer type); 15 | } 16 | -------------------------------------------------------------------------------- /mall-advertise-service/src/main/java/com/shepherd/malladvertise/api/vo/AdvertiseVO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malladvertise.api.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author fjZheng 7 | * @version 1.0 8 | * @date 2021/1/14 19:44 9 | */ 10 | @Data 11 | public class AdvertiseVO { 12 | } 13 | -------------------------------------------------------------------------------- /mall-advertise-service/src/main/java/com/shepherd/malladvertise/dao/AdvertiseDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malladvertise.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.malladvertise.entity.Advertise; 5 | 6 | /** 7 | * @author fjZheng 8 | * @version 1.0 9 | * @date 2021/1/14 16:43 10 | */ 11 | public interface AdvertiseDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-advertise-service/src/main/java/com/shepherd/malladvertise/dto/AdvertiseDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malladvertise.dto; 2 | 3 | import com.shepherd.malladvertise.entity.Advertise; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author fjZheng 8 | * @version 1.0 9 | * @date 2021/1/14 19:44 10 | */ 11 | @Data 12 | public class AdvertiseDTO extends Advertise { 13 | private Long advertiseId; 14 | } 15 | -------------------------------------------------------------------------------- /mall-advertise-service/src/main/java/com/shepherd/malladvertise/entity/Advertise.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malladvertise.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * @author fjZheng 12 | * @version 1.0 13 | * @date 2021/1/14 16:44 14 | */ 15 | @Data 16 | public class Advertise { 17 | 18 | @TableId(type = IdType.AUTO) 19 | @ApiModelProperty("主键") 20 | private Long id; 21 | 22 | @ApiModelProperty("广告类型") 23 | private Integer type; 24 | 25 | @ApiModelProperty("广告名称") 26 | private String name; 27 | 28 | @ApiModelProperty("广告地址") 29 | private String url; 30 | 31 | @ApiModelProperty("广告图片地址") 32 | private String picture; 33 | 34 | @ApiModelProperty("状态") 35 | private String status; 36 | 37 | @ApiModelProperty("删除标志位") 38 | private String isDelete; 39 | 40 | @ApiModelProperty("创建时间") 41 | private Date createTime; 42 | 43 | @ApiModelProperty("更新时间") 44 | private Date updateTime; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /mall-advertise-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: mall-advertise-service-local 4 | cloud: 5 | nacos: 6 | config: 7 | server-addr: 10.10.0.14:8848 -------------------------------------------------------------------------------- /mall-advertise-service/src/main/resources/mapper/AdvertiseMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mall-advertise-service/src/test/java/com/shepherd/malladvertise/MallAdvertiseServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malladvertise; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class MallAdvertiseServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /mall-auth/src/main/java/com/shepherd/mallauth/MallAuthApplication.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallauth; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.context.properties.ConfigurationPropertiesScan; 7 | import org.springframework.cloud.openfeign.EnableFeignClients; 8 | 9 | @EnableFeignClients 10 | @SpringBootApplication 11 | @MapperScan("com.shepherd.mallauth.dao") 12 | @ConfigurationPropertiesScan 13 | public class MallAuthApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(MallAuthApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /mall-auth/src/main/java/com/shepherd/mallauth/component/JwtTokenEnhancer.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallauth.component; 2 | 3 | import com.shepherd.mallauth.dto.SecurityUser; 4 | import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; 5 | import org.springframework.security.oauth2.common.OAuth2AccessToken; 6 | import org.springframework.security.oauth2.provider.OAuth2Authentication; 7 | import org.springframework.security.oauth2.provider.token.TokenEnhancer; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | @Component 14 | public class JwtTokenEnhancer implements TokenEnhancer { 15 | 16 | @Override 17 | public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) { 18 | SecurityUser securityUser = (SecurityUser) authentication.getPrincipal(); 19 | Map info = new HashMap<>(); 20 | //把用户ID设置到JWT中 21 | info.put("id", securityUser.getId()); 22 | info.put("client_id",securityUser.getClientId()); 23 | ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(info); 24 | return accessToken; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /mall-auth/src/main/java/com/shepherd/mallauth/config/JwtTokenConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallauth.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.core.io.ClassPathResource; 6 | import org.springframework.security.oauth2.provider.token.AccessTokenConverter; 7 | import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; 8 | import org.springframework.security.rsa.crypto.KeyStoreKeyFactory; 9 | 10 | import java.security.KeyPair; 11 | 12 | @Configuration 13 | public class JwtTokenConfig { 14 | 15 | @Bean 16 | public JwtAccessTokenConverter accessTokenConverter() { 17 | JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter(); 18 | jwtAccessTokenConverter.setKeyPair(keyPair()); 19 | return jwtAccessTokenConverter; 20 | } 21 | 22 | @Bean 23 | public KeyPair keyPair() { 24 | //从classpath下的证书中获取秘钥对 25 | KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(new ClassPathResource("jwt.jks"), "shepherd-mall".toCharArray()); 26 | return keyStoreKeyFactory.getKeyPair("jwt", "shepherd-mall".toCharArray()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mall-auth/src/main/java/com/shepherd/mallauth/config/SmsProperties.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallauth.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | 7 | @ConfigurationProperties(prefix = "aliyun-sms") 8 | @Data 9 | public class SmsProperties { 10 | 11 | private String accessKeyId; 12 | 13 | private String accessSecret; 14 | 15 | private String signName; 16 | 17 | private String templateCode; 18 | 19 | private Long expireTime; 20 | } -------------------------------------------------------------------------------- /mall-auth/src/main/java/com/shepherd/mallauth/constant/RedisConstant.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallauth.constant; 2 | 3 | public interface RedisConstant { 4 | 5 | String VERIFICATION = "VERIFICATION_PREFIX::%s::STRING"; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /mall-auth/src/main/java/com/shepherd/mallauth/controller/AuthController.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallauth.controller; 2 | 3 | import org.springframework.web.bind.annotation.PostMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | import com.shepherd.mallauth.service.AuthService; 7 | import lombok.RequiredArgsConstructor; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | @RestController("/api/mall/auth") 11 | @RequiredArgsConstructor 12 | public class AuthController { 13 | 14 | 15 | private AuthService authService; 16 | 17 | 18 | @PostMapping("login") 19 | public String login(@RequestParam("phone") String phone, 20 | @RequestParam("code") String code) { 21 | return authService.login(phone, code); 22 | } 23 | 24 | @GetMapping("/code/{phoneNumber}") 25 | public String code(@PathVariable("phoneNumber") String phoneNumber) { 26 | return authService.getCode(phoneNumber); 27 | } 28 | 29 | @PutMapping("logout") 30 | public void logout(){ 31 | 32 | } 33 | 34 | 35 | } -------------------------------------------------------------------------------- /mall-auth/src/main/java/com/shepherd/mallauth/dao/UserDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallauth.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.mallauth.entity.User; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2020/11/17 23:40 10 | */ 11 | public interface UserDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-auth/src/main/java/com/shepherd/mallauth/service/AuthService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallauth.service; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | @Service 6 | public interface AuthService { 7 | 8 | String getCode(String phoneNumber); 9 | 10 | String login(String phone, String code);; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /mall-auth/src/main/java/com/shepherd/mallauth/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallauth.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.shepherd.mallauth.dto.SecurityUser; 5 | import com.shepherd.mallauth.entity.User; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | public interface UserService extends IService { 9 | 10 | // SecurityUser loadUser(@RequestParam String username); 11 | } 12 | -------------------------------------------------------------------------------- /mall-auth/src/main/java/com/shepherd/mallauth/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallauth.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 5 | import com.shepherd.mall.utils.MallBeanUtil; 6 | import com.shepherd.mallauth.dao.UserDAO; 7 | import com.shepherd.mallauth.dto.SecurityUser; 8 | import com.shepherd.mallauth.entity.User; 9 | import com.shepherd.mallauth.service.UserService; 10 | import org.springframework.stereotype.Service; 11 | 12 | import javax.annotation.Resource; 13 | 14 | @Service 15 | public class UserServiceImpl extends ServiceImpl implements UserService { 16 | 17 | @Resource 18 | private UserDAO userDAO; 19 | 20 | // @Override 21 | // public SecurityUser loadUser(String username) { 22 | // final LambdaQueryWrapper userLambdaQueryWrapper = new LambdaQueryWrapper<>(); 23 | // userLambdaQueryWrapper.eq(User::getNickname, username); 24 | // User user = userDAO.selectOne(userLambdaQueryWrapper); 25 | // SecurityUser securityUser = new SecurityUser(); 26 | // MallBeanUtil.copy(user, securityUser); 27 | // securityUser.setUsername(user.getNickname()); 28 | // securityUser.setClientId("mall-user"); 29 | // return securityUser; 30 | // } 31 | } 32 | -------------------------------------------------------------------------------- /mall-auth/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: mall-auth-service 4 | cloud: 5 | nacos: 6 | config: 7 | server-addr: 10.10.0.14:8848 -------------------------------------------------------------------------------- /mall-auth/src/main/resources/jwt.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-auth/src/main/resources/jwt.jks -------------------------------------------------------------------------------- /mall-base-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /mall-base-service/src/main/java/com/shepherd/mallbase/MallBaseServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallbase; 2 | 3 | 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.context.annotation.ComponentScan; 8 | 9 | @SpringBootApplication 10 | @EnableDiscoveryClient 11 | @ComponentScan(basePackages = {"com.shepherd"}) 12 | public class MallBaseServiceApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(MallBaseServiceApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /mall-base-service/src/main/java/com/shepherd/mallbase/api/controller/SmsController.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallbase.api.controller; 2 | 3 | import com.shepherd.mall.annotation.ResponseResultBody; 4 | import com.shepherd.mallbase.api.service.SmsService; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import javax.annotation.Resource; 13 | 14 | /** 15 | * @author fjzheng 16 | * @version 1.0 17 | * @date 2020/12/28 21:47 18 | */ 19 | @RestController 20 | @ResponseResultBody 21 | @RequestMapping("/api/mall/base/sms") 22 | @Api("短信相关接口") 23 | public class SmsController { 24 | @Resource 25 | private SmsService smsService; 26 | @GetMapping("/verification/{phoneNumber}") 27 | @ApiOperation("获取手机验证码") 28 | public void getCode(@PathVariable("phoneNumber") String phoneNumber) { 29 | smsService.getSmsCode(phoneNumber); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /mall-base-service/src/main/java/com/shepherd/mallbase/api/service/FileService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallbase.api.service; 2 | 3 | import org.springframework.web.multipart.MultipartFile; 4 | 5 | /** 6 | * @author fjZheng 7 | * @version 1.0 8 | * @date 2020/12/29 19:09 9 | */ 10 | public interface FileService { 11 | String uploadFileToOSS(MultipartFile file); 12 | 13 | String downloadOSSFile(String fileName); 14 | 15 | void deleteOSSFile(String fileName); 16 | } 17 | -------------------------------------------------------------------------------- /mall-base-service/src/main/java/com/shepherd/mallbase/api/service/SmsService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallbase.api.service; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2020/12/28 21:51 7 | */ 8 | public interface SmsService { 9 | 10 | String getSmsCode(String phoneNumber); 11 | } 12 | -------------------------------------------------------------------------------- /mall-base-service/src/main/java/com/shepherd/mallbase/config/OssProperties.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallbase.config; 2 | 3 | import com.aliyun.oss.OSS; 4 | import com.aliyun.oss.OSSClient; 5 | import com.aliyun.oss.OSSClientBuilder; 6 | import lombok.Data; 7 | import org.springframework.boot.context.properties.ConfigurationProperties; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * @author fjZheng 14 | * @version 1.0 15 | * @date 2020/12/29 20:00 16 | */ 17 | @Configuration 18 | @ConfigurationProperties(prefix = "aliyun-oss") 19 | @Component() 20 | @Data 21 | public class OssProperties { 22 | private String endpoint; 23 | private String accessKeyId; 24 | private String accessKeySecret; 25 | private String bucketName; 26 | private Integer maxUploadSize; 27 | private Integer maxInMemorySize; 28 | 29 | @Bean 30 | public OSS ossClient(){ 31 | OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); 32 | return ossClient; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /mall-base-service/src/main/java/com/shepherd/mallbase/dto/FastDFSFile.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallbase.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2020/12/28 23:40 11 | */ 12 | @Data 13 | public class FastDFSFile implements Serializable { 14 | //文件名字 15 | private String name; 16 | //文件内容 17 | private byte[] content; 18 | //文件扩展名 19 | private String ext; 20 | //文件MD5摘要值 21 | private String md5; 22 | //文件创建作者 23 | private String author; 24 | 25 | public FastDFSFile() { 26 | } 27 | 28 | public FastDFSFile(String name, byte[] content, String ext) { 29 | this.name = name; 30 | this.content = content; 31 | this.ext = ext; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /mall-base-service/src/main/java/com/shepherd/mallbase/enums/ErrorCodeEnum.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallbase.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * @author jfWu 7 | * @version 1.0 8 | * @date 2019/11/18 11:07 9 | */ 10 | @Getter 11 | public enum ErrorCodeEnum { 12 | 13 | SEND_MESSAGE_ERROR("SEND MESSAGE ERROR", "发送短信失败,请稍后重试"), 14 | 15 | VERIFICATION_PHONE_ERROR("VERIFICATION ERROR", "验证发生错误,请确认是否是当前手机号获取的验证码"), 16 | 17 | VERIFICATION_CODE_ERROR("VERIFICATION CODE ERROR", "验证码不正确或已过期,请重新输入"), 18 | 19 | USER_NO_NOT_EXIST_ERROR("USER NOT EXIST ERROR", "用户不存在,请重新确认再输入"), 20 | 21 | PASSWORD_ERROR("PASSWORD ERROR", "密码错误,请重新输入"), 22 | 23 | PHONE_NOT_REGISTER("PHONE NOT REGISTER", "该手机号尚未注册使用过"); 24 | 25 | private String code; 26 | private String message; 27 | 28 | ErrorCodeEnum(String code, String message) { 29 | this.code = code; 30 | this.message = message; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /mall-base-service/src/main/resources/fdfs_client.conf: -------------------------------------------------------------------------------- 1 | #连接超时的时间 s 2 | connect_timeout=60 3 | #网络超时时间 4 | network_timeout=60 5 | #字符编码 6 | charset=UTF-8 7 | # tracker的http通信协议的端口 8 | http.tracker_http_port=8080 9 | # 22122 tracker server的tcp 端口 10 | tracker_server=192.168.106.129:22122 -------------------------------------------------------------------------------- /mall-base-service/src/test/java/com/shepherd/mallbase/MallBaseServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallbase; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class MallBaseServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /mall-common/src/main/java/com/shepherd/mall/annotation/ResponseResultBody.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.annotation; 2 | 3 | import org.springframework.web.bind.annotation.ResponseBody; 4 | 5 | import java.lang.annotation.*; 6 | 7 | /** 8 | * @author fjZheng 9 | * @version 1.0 10 | * @date 2020/11/27 11:35 11 | */ 12 | 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Target({ElementType.TYPE, ElementType.METHOD}) 15 | @Documented 16 | @ResponseBody 17 | public @interface ResponseResultBody { 18 | 19 | } -------------------------------------------------------------------------------- /mall-common/src/main/java/com/shepherd/mall/base/BaseQuery.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.base; 2 | 3 | import lombok.Data; 4 | 5 | import javax.validation.constraints.Min; 6 | 7 | /** 8 | * @author fjZheng 9 | * @version 1.0 10 | * @date 2020/10/10 17:07 11 | */ 12 | @Data 13 | public class BaseQuery { 14 | 15 | @Min(value = 1) 16 | private Integer pageSize = 20; 17 | 18 | @Min(value = 1) 19 | private Integer pageNo = 1; 20 | } 21 | -------------------------------------------------------------------------------- /mall-common/src/main/java/com/shepherd/mall/base/CasProperties.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.base; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author fjzheng 7 | * @version 1.0 8 | * @date 2020/7/14 22:23 9 | */ 10 | @Data 11 | public class CasProperties { 12 | 13 | //拦截规则 14 | private String[] urlPatterns; 15 | 16 | //不拦截规则 17 | private String[] excludeUrlPatterns; 18 | 19 | 20 | //cookie名称 21 | private String cookieName = "red-book-permission-shepherd"; 22 | 23 | /** 24 | * 缓存清理的间隔时间,单位:秒,默认每分钟清理一次 25 | */ 26 | private Integer clearInterval = 1; 27 | 28 | /** 29 | * userForm保活时间,默认2小时 30 | */ 31 | private Integer userActiveMaxTimie = 120; 32 | } 33 | -------------------------------------------------------------------------------- /mall-common/src/main/java/com/shepherd/mall/constant/CommonConstant.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.constant; 2 | 3 | /** 4 | * @author fjZheng 5 | * @version 1.0 6 | * @date 2020/10/10 13:33 7 | */ 8 | public interface CommonConstant { 9 | 10 | Integer DEL = 1; 11 | 12 | Integer NOT_DEL = 0; 13 | 14 | Integer DEFAULT_PAGE_SIZE = 2000; 15 | 16 | Integer DEFAULT_PAGE_NO = 1; 17 | 18 | Integer PRODUCT_ON_SALE = 1; 19 | 20 | Integer PRODUCT_SALE_OUT = 0; 21 | 22 | Integer CATEGORY_AVAILABLE = 1; 23 | 24 | Integer CATEGORY_ABANDON = 0; 25 | 26 | /** 27 | * 本机号码一键登录 28 | */ 29 | Integer PHONE_LOCAL_LOGIN = 1; 30 | /** 31 | * 短信验证登录 32 | */ 33 | Integer PHONE_MESSAGE_LOGIN = 2; 34 | /** 35 | * 账户密码登录 36 | */ 37 | Integer USER_PASSWORD_LOGIN = 3; 38 | 39 | Integer FIRST_LOGIN = 1; 40 | 41 | Integer NOT_FIRST_LOGIN = 0; 42 | 43 | Long DEFAULT_SALE_COUNT = 0L; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /mall-common/src/main/java/com/shepherd/mall/enums/ResponseStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.enums; 2 | 3 | import lombok.Getter; 4 | import lombok.ToString; 5 | import org.springframework.http.HttpStatus; 6 | 7 | /** 8 | * @author fjZheng 9 | * @version 1.0 10 | * @date 2020/11/27 11:23 11 | */ 12 | @ToString 13 | @Getter 14 | public enum ResponseStatusEnum { 15 | FORBIDDEN(HttpStatus.FORBIDDEN, 403, "Forbidden"), 16 | UNAUTHORIZED(HttpStatus.UNAUTHORIZED, 401, "Unauthorized"), 17 | SUCCESS(HttpStatus.OK, 200, "OK"), 18 | BAD_REQUEST(HttpStatus.BAD_REQUEST, 400, "Bad Request"), 19 | SYSTEM_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 500, "系统异常错误1111"); 20 | 21 | 22 | /** 23 | * 返回的HTTP状态码, 符合http请求 24 | */ 25 | private HttpStatus httpStatus; 26 | /** 27 | * 业务异常码 28 | */ 29 | private Integer code; 30 | /** 31 | * 业务异常信息描述 32 | */ 33 | private String msg; 34 | 35 | ResponseStatusEnum(HttpStatus httpStatus, Integer code, String msg) { 36 | this.httpStatus = httpStatus; 37 | this.code = code; 38 | this.msg = msg; 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /mall-common/src/main/java/com/shepherd/mall/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.exception; 2 | 3 | import com.shepherd.mall.enums.ResponseStatusEnum; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author fjZheng 8 | * @version 1.0 9 | * @date 2020/6/24 14:08 10 | */ 11 | @Data 12 | public class BusinessException extends RuntimeException { 13 | 14 | private Integer code; 15 | private ResponseStatusEnum responseStatusEnum; 16 | 17 | public BusinessException() { 18 | super(); 19 | // TODO Auto-generated constructor stub 20 | } 21 | 22 | public BusinessException(String message) { 23 | super(message); 24 | // TODO Auto-generated constructor stub 25 | } 26 | 27 | public BusinessException(Integer code, String message) { 28 | super(message); 29 | this.code = code; 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /mall-common/src/main/java/com/shepherd/mall/utils/MallBeanUtil.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.utils; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.BeanUtils; 6 | 7 | /** 8 | * @author fjZheng 9 | * @version 1.0 10 | * @date 2020/10/10 10:51 11 | */ 12 | public class MallBeanUtil { 13 | private static Logger log = LoggerFactory.getLogger(MallBeanUtil.class); 14 | 15 | public static B copy(A a, Class clazz) { 16 | if (a == null || clazz == null) { 17 | return null; 18 | } 19 | 20 | try { 21 | B b = clazz.newInstance(); 22 | BeanUtils.copyProperties(a, b); 23 | return b; 24 | } catch (Exception e) { 25 | log.error("BeanUtil#copy error.", e); 26 | } 27 | return null; 28 | } 29 | 30 | public static B copy(A a, B b) { 31 | if (a == null || b == null) { 32 | return null; 33 | } 34 | 35 | try { 36 | BeanUtils.copyProperties(a, b); 37 | return b; 38 | } catch (Exception e) { 39 | log.error("BeanUtil#copy error.", e); 40 | } 41 | return null; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /mall-common/src/main/java/com/shepherd/mall/vo/LoginVO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.vo; 2 | 3 | 4 | import lombok.Data; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2020/7/15 22:35 10 | */ 11 | @Data 12 | public class LoginVO { 13 | 14 | private Long userId; 15 | private String ticket; 16 | private String token; 17 | private String userName; 18 | private String phone; 19 | private String email; 20 | 21 | 22 | } -------------------------------------------------------------------------------- /mall-common/src/main/java/com/shepherd/mall/vo/PageInfo.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/6/22 15:47 11 | */ 12 | @Data 13 | public class PageInfo { 14 | private int total; 15 | 16 | private int pageNo; 17 | 18 | private int pageSize; 19 | 20 | private int pages; 21 | 22 | private List list; 23 | 24 | public PageInfo() { 25 | } 26 | 27 | public PageInfo(Integer pageNo, Integer pageSize) { 28 | this.pageNo = pageNo; 29 | this.pageSize = pageSize; 30 | } 31 | 32 | public PageInfo(Integer pageNo, Integer pageSize, int total, List entityList) { 33 | this.pageNo = pageNo; 34 | this.pageSize = pageSize; 35 | this.total = total; 36 | this.pageSize = entityList == null ? 0 : entityList.size(); 37 | if (pageSize > 0) { 38 | // 计算分页数量 39 | int i = 0; 40 | if ((total % pageSize) > 0) { 41 | i = 1; 42 | } 43 | pages = total / pageSize + i; 44 | } else if (pageSize == 0) { 45 | pages = 1; 46 | } else { 47 | throw new RuntimeException(String.format("无法计算总页数,每页记录数不合法,size:", pageSize)); 48 | } 49 | list = entityList; 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /mall-gateway/src/main/java/com/shepherd/mallgateway/MallGatewayApplication.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallgateway; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class MallGatewayApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(MallGatewayApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /mall-gateway/src/main/java/com/shepherd/mallgateway/config/GlobalCorsConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallgateway.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.cors.CorsConfiguration; 6 | import org.springframework.web.cors.reactive.CorsWebFilter; 7 | import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; 8 | import org.springframework.web.util.pattern.PathPatternParser; 9 | 10 | /** 11 | * 全局跨域配置 12 | * 注意:前端从网关进行调用时需要配置 13 | */ 14 | @Configuration 15 | public class GlobalCorsConfig { 16 | 17 | @Bean 18 | public CorsWebFilter corsFilter() { 19 | CorsConfiguration config = new CorsConfiguration(); 20 | config.addAllowedMethod("*"); 21 | config.addAllowedOrigin("*"); 22 | config.addAllowedHeader("*"); 23 | config.setAllowCredentials(true); 24 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser()); 25 | source.registerCorsConfiguration("/**", config); 26 | 27 | return new CorsWebFilter(source); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /mall-gateway/src/main/java/com/shepherd/mallgateway/config/IgnoreUrlsConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallgateway.config; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 网关白名单配置 12 | */ 13 | @Data 14 | @EqualsAndHashCode(callSuper = false) 15 | @Component 16 | @ConfigurationProperties(prefix="secure.ignore") 17 | public class IgnoreUrlsConfig { 18 | private List urls; 19 | } 20 | -------------------------------------------------------------------------------- /mall-gateway/src/main/java/com/shepherd/mallgateway/config/SentinelConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallgateway.config; 2 | 3 | import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.BlockRequestHandler; 4 | import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager; 5 | import com.shepherd.mall.vo.ResponseVO; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.reactive.function.server.ServerResponse; 8 | import org.springframework.web.server.ServerWebExchange; 9 | import reactor.core.publisher.Mono; 10 | 11 | /** 12 | * @author fjzheng 13 | * @version 1.0 14 | * @date 2021/9/3 12:46 15 | */ 16 | @Configuration 17 | public class SentinelConfig { 18 | 19 | public SentinelConfig() { 20 | GatewayCallbackManager.setBlockHandler(new BlockRequestHandler() { 21 | @Override 22 | public Mono handleRequest(ServerWebExchange serverWebExchange, Throwable throwable) { 23 | ResponseVO responseVO = new ResponseVO(); 24 | responseVO.setCode(400); 25 | responseVO.setData("网关sentinel统一返回了"); 26 | Mono body = ServerResponse.ok().body(Mono.just(responseVO), ResponseVO.class); 27 | return body; 28 | } 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /mall-gateway/src/main/java/com/shepherd/mallgateway/constant/AuthConstant.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallgateway.constant; 2 | 3 | public interface AuthConstant { 4 | 5 | /** 6 | * JWT存储权限前缀 7 | */ 8 | String AUTHORITY_PREFIX = "ROLE_"; 9 | 10 | /** 11 | * JWT存储权限属性 12 | */ 13 | String AUTHORITY_CLAIM_NAME = "authorities"; 14 | 15 | /** 16 | * 后台管理client_id 17 | */ 18 | String ADMIN_CLIENT_ID = "admin-app"; 19 | 20 | /** 21 | * 前台商城client_id 22 | */ 23 | String PORTAL_CLIENT_ID = "portal-app"; 24 | 25 | /** 26 | * 后台管理接口路径匹配 27 | */ 28 | String ADMIN_URL_PATTERN = "/mall-admin/**"; 29 | 30 | /** 31 | * Redis缓存权限规则key 32 | */ 33 | String RESOURCE_ROLES_MAP_KEY = "auth:resourceRolesMap"; 34 | 35 | /** 36 | * 认证信息Http请求头 37 | */ 38 | String JWT_TOKEN_HEADER = "Authorization"; 39 | 40 | /** 41 | * JWT令牌前缀 42 | */ 43 | String JWT_TOKEN_PREFIX = "Bearer "; 44 | 45 | /** 46 | * 用户信息Http请求头 47 | */ 48 | String USER_TOKEN_HEADER = "user"; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /mall-gateway/src/main/java/com/shepherd/mallgateway/dto/UserDto.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallgateway.dto; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 登录用户信息 11 | */ 12 | @Data 13 | @EqualsAndHashCode(callSuper = false) 14 | @NoArgsConstructor 15 | public class UserDto { 16 | private Long id; 17 | private String username; 18 | private String password; 19 | private Integer status; 20 | private String clientId; 21 | private List roles; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /mall-gateway/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: mall-user-service 4 | cloud: 5 | nacos: 6 | config: 7 | server-addr: 10.10.0.14:8848 -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/Constant/CartConstant.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.Constant; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2021/7/5 17:14 7 | */ 8 | public interface CartConstant { 9 | Integer IS_NOT_CHECK = 0; 10 | Integer IS_CHECK = 1; 11 | } 12 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/Constant/OrderConstant.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.Constant; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2021/8/11 19:02 7 | */ 8 | public interface OrderConstant { 9 | 10 | Integer ORDER_STATUS_NEW = 0; 11 | Integer ORDER_STATUS_IS_PAY = 1; 12 | Integer ORDER_STATUS_CANCEL = 2; 13 | } 14 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/MallOrderServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.amqp.rabbit.annotation.EnableRabbit; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 8 | import org.springframework.cloud.openfeign.EnableFeignClients; 9 | import org.springframework.context.annotation.ComponentScan; 10 | 11 | @SpringBootApplication 12 | @EnableDiscoveryClient 13 | @MapperScan(basePackages = "com.shepherd.mallorder.dao") 14 | @ComponentScan(basePackages = {"com.shepherd"}) 15 | @EnableFeignClients(basePackages = "com.shepherd.mallorder") 16 | @EnableRabbit //要想监听队列接收消息必须开启此注解 17 | public class MallOrderServiceApplication { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(MallOrderServiceApplication.class, args); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/SkuQuery.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder; 2 | 3 | import com.shepherd.mall.base.BaseQuery; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2021/7/22 19:17 12 | */ 13 | @Data 14 | public class SkuQuery extends BaseQuery { 15 | private List skuIds; 16 | } 17 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/annotation/JobAnnotation.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.annotation; 2 | 3 | 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | @Target({ElementType.METHOD}) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | public @interface JobAnnotation { 12 | 13 | /** 14 | * 作业名称 15 | */ 16 | String jobName() default ""; 17 | 18 | /** 19 | * 分组名称 20 | */ 21 | String groupName() default ""; 22 | 23 | /** 24 | * 定时任务cron表达式 25 | */ 26 | String cron() default ""; 27 | 28 | /** 29 | * 作业回调参数 30 | */ 31 | String parameter() default ""; 32 | 33 | /** 34 | * 作业描述 35 | */ 36 | String content() default ""; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/api/service/CartService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.api.service; 2 | 3 | import com.shepherd.mallorder.dto.CartDTO; 4 | import com.shepherd.mallorder.dto.CartItem; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2021/7/1 16:48 12 | */ 13 | public interface CartService { 14 | void addCartItem(Long skuId, Integer number, Long userId); 15 | 16 | void updateCartItem(CartItem cartItem, Long userId); 17 | 18 | void deleteCartItemBatch(List skuIds, Long userId); 19 | 20 | CartDTO getCart(Long userId); 21 | 22 | List getCheckCartItemList(Long userId); 23 | } 24 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/api/service/OrderItemService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.api.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.shepherd.mallorder.dao.OrderItemDAO; 5 | import com.shepherd.mallorder.entity.OrderItem; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/7/26 19:19 11 | */ 12 | public interface OrderItemService extends IService { 13 | } 14 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/api/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.api.service; 2 | 3 | import com.shepherd.mallorder.dto.OrderConfirmDTO; 4 | import com.shepherd.mallorder.dto.OrderDTO; 5 | import com.shepherd.mallorder.dto.OrderSubmitDTO; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/7/20 19:19 11 | */ 12 | public interface OrderService { 13 | OrderConfirmDTO settlement(Long userId); 14 | 15 | void submitOrder(OrderSubmitDTO orderSubmit); 16 | 17 | void closeOrder(OrderDTO orderDTO); 18 | 19 | OrderDTO getOrderByOrderNo(String orderNo); 20 | 21 | void updateOrderStatus(String orderNo, Integer status, Integer payType); 22 | } 23 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/api/vo/CartVO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.api.vo; 2 | 3 | import com.shepherd.mallorder.dto.CartItem; 4 | import lombok.Data; 5 | 6 | import java.math.BigDecimal; 7 | import java.util.List; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/7/1 15:53 13 | */ 14 | @Data 15 | public class CartVO { 16 | private List items; 17 | 18 | private Integer countNum; 19 | 20 | private Integer countCheck; 21 | 22 | private BigDecimal totalAmount; 23 | 24 | private List skuIds; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/api/vo/OrderSumbitVO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.api.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/7/23 00:09 11 | */ 12 | @Data 13 | public class OrderSumbitVO { 14 | private Long addressId; 15 | private Integer payType; 16 | private String token; 17 | private BigDecimal payAmount; 18 | private String remark; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/config/ApplicationListenerConfig.java: -------------------------------------------------------------------------------- 1 | //package com.shepherd.mallorder.config; 2 | // 3 | //import org.springframework.beans.factory.annotation.Autowired; 4 | //import org.springframework.context.ApplicationListener; 5 | //import org.springframework.context.annotation.Configuration; 6 | //import org.springframework.context.event.ContextRefreshedEvent; 7 | //import org.slf4j.Logger; 8 | //import org.slf4j.LoggerFactory; 9 | ///** 10 | // * @author fjzheng 11 | // * @version 1.0 12 | // * @date 2021/5/20 18:44 13 | // */ 14 | //@Configuration 15 | //public class ApplicationListenerConfig implements ApplicationListener { 16 | // 17 | // private Logger logger = LoggerFactory.getLogger(getClass()); 18 | // 19 | // @Autowired 20 | // private QuartzBindOperationConfig quartzBindOperationConfig; 21 | // @Override 22 | // public void onApplicationEvent(ContextRefreshedEvent event) { 23 | //// quartzBindOperationConfig.scheduleBind(); 24 | // } 25 | // 26 | //} 27 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/config/InitConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.config; 2 | 3 | import com.shepherd.mall.utils.IdWorker; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/7/23 16:55 11 | */ 12 | @Configuration 13 | public class InitConfig { 14 | 15 | @Bean 16 | public IdWorker idWorker() { 17 | return new IdWorker(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/config/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.data.redis.connection.RedisConnectionFactory; 6 | import org.springframework.data.redis.core.RedisTemplate; 7 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; 8 | 9 | import java.net.UnknownHostException; 10 | 11 | /** 12 | * @author fjzheng 13 | * @version 1.0 14 | * @date 2021/7/27 11:02 15 | */ 16 | @Configuration 17 | public class RedisConfig { 18 | @Bean 19 | public RedisTemplate redisTemplate( 20 | RedisConnectionFactory redisConnectionFactory) 21 | throws UnknownHostException { 22 | RedisTemplate template = new RedisTemplate(); 23 | template.setConnectionFactory(redisConnectionFactory); 24 | Jackson2JsonRedisSerializer serializer = new Jackson2JsonRedisSerializer<>(Object.class); 25 | template.setDefaultSerializer(serializer); 26 | return template; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/dao/OrderDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.mallorder.entity.Order; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/7/26 15:59 10 | */ 11 | public interface OrderDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/dao/OrderItemDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.mallorder.entity.OrderItem; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/7/26 15:59 10 | */ 11 | public interface OrderItemDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/dto/Address.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2021/7/22 00:19 12 | */ 13 | @Data 14 | @Builder 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | public class Address { 18 | private Long id; 19 | private Long userId; 20 | private String name; 21 | private String mobile; 22 | private String postcode; 23 | private String province; 24 | private String city; 25 | private String region; 26 | private String detailAddress; 27 | private Integer isDefault; 28 | private Integer isDelete; 29 | } 30 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/dto/CartDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | import java.util.List; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2021/7/5 15:13 12 | */ 13 | @Data 14 | public class CartDTO { 15 | private List items; 16 | 17 | private Integer countNum; 18 | 19 | private Integer countCheck; 20 | 21 | private BigDecimal totalAmount; 22 | } 23 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/dto/CartItem.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.util.List; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/7/1 16:24 13 | */ 14 | @Data 15 | public class CartItem implements Serializable { 16 | private Long skuId; 17 | 18 | private Integer isCheck; 19 | 20 | private String name; 21 | 22 | private String image; 23 | 24 | private List specValues; 25 | 26 | private BigDecimal price; 27 | 28 | private Integer number; 29 | 30 | private BigDecimal totalAmount; 31 | 32 | private BigDecimal payAmount; 33 | } 34 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/dto/OrderConfirmDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | import java.util.List; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2021/7/22 00:21 12 | */ 13 | @Data 14 | public class OrderConfirmDTO { 15 | private List
addressList; 16 | private List orderItemList; 17 | private Integer integration; 18 | private BigDecimal totalAmount; 19 | private BigDecimal payAmount; 20 | private String token; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/dto/OrderDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.dto; 2 | 3 | import com.shepherd.mallorder.entity.Order; 4 | import com.shepherd.mallorder.entity.OrderItem; 5 | import lombok.Data; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/7/23 16:50 13 | */ 14 | @Data 15 | public class OrderDTO extends Order { 16 | private List orderItemList; 17 | private Long orderId; 18 | } 19 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/dto/OrderSubmitDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/7/23 00:35 11 | */ 12 | @Data 13 | public class OrderSubmitDTO { 14 | private Long addressId; 15 | private Integer payType; 16 | private String token; 17 | private BigDecimal payAmount; 18 | private String remark; 19 | private Long userId; 20 | } 21 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/dto/ProductSku.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | import java.util.Map; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2021/7/5 16:39 12 | */ 13 | @Data 14 | public class ProductSku { 15 | private Long skuId; 16 | private Long spuId; 17 | private String name; 18 | private BigDecimal price; 19 | private String mainImage; 20 | private String subImage; 21 | private Integer weight; 22 | private Long categoryId; 23 | private String categoryName; 24 | private Long brandId; 25 | private String brandName; 26 | private Long saleCount; 27 | private String spec; 28 | private Map specMap; 29 | 30 | /** 31 | * 是否有库存 32 | */ 33 | private Boolean hasStock; 34 | /** 35 | * 热度 36 | */ 37 | private Long hotScore; 38 | private String brandImg; 39 | } 40 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/entity/OrderItem.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import lombok.Data; 6 | 7 | import java.math.BigDecimal; 8 | import java.util.Date; 9 | 10 | 11 | /** 12 | * @author fjzheng 13 | * @version 1.0 14 | * @date 2021/7/16 15:09 15 | */ 16 | @Data 17 | public class OrderItem { 18 | 19 | @TableId(type = IdType.AUTO) 20 | private Long id; 21 | private Long orderId; 22 | private String orderNo; 23 | private Long spuId; 24 | private Long skuId; 25 | private String name; 26 | private String image; 27 | private String spec; 28 | private BigDecimal price; 29 | private Integer number; 30 | private BigDecimal postage; 31 | private BigDecimal totalAmount; 32 | private BigDecimal payAmount; 33 | private Integer isDelete; 34 | private Integer isReturn; 35 | private Date createTime; 36 | private Date updateTime; 37 | } 38 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/factory/QuartzJobFactory.java: -------------------------------------------------------------------------------- 1 | //package com.shepherd.mallorder.factory; 2 | // 3 | //import org.quartz.spi.TriggerFiredBundle; 4 | //import org.springframework.beans.factory.annotation.Autowired; 5 | //import org.springframework.beans.factory.config.AutowireCapableBeanFactory; 6 | //import org.springframework.scheduling.quartz.SpringBeanJobFactory; 7 | //import org.springframework.stereotype.Component; 8 | // 9 | ///** 10 | // * @author fjzheng 11 | // * @version 1.0 12 | // * @date 2021/5/20 18:36 13 | // */ 14 | //@Component 15 | //public class QuartzJobFactory extends SpringBeanJobFactory { 16 | // @Autowired 17 | // private AutowireCapableBeanFactory capableBeanFactory; 18 | // 19 | // @Override 20 | // protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { 21 | // Object jobInstance = super.createJobInstance(bundle); 22 | // capableBeanFactory.autowireBean(jobInstance); 23 | // return jobInstance; 24 | // } 25 | //} 26 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/feign/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.feign; 2 | 3 | import com.shepherd.mall.vo.ResponseVO; 4 | import com.shepherd.mallorder.SkuQuery; 5 | import com.shepherd.mallorder.dto.ProductSku; 6 | import org.springframework.cloud.openfeign.FeignClient; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestBody; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * @author fjzheng 16 | * @version 1.0 17 | * @date 2021/7/5 15:04 18 | */ 19 | 20 | @FeignClient(name = "${micro-server.mall-product}", path = "/api/mall/product") 21 | public interface ProductService { 22 | 23 | @GetMapping("/sku/{skuId}") 24 | ResponseVO getSku(@PathVariable("skuId") Long skuId); 25 | 26 | @PostMapping("/sku/price") 27 | ResponseVO> getSkuPrice(@RequestBody SkuQuery query); 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/feign/UserService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.feign; 2 | 3 | import com.shepherd.mall.vo.ResponseVO; 4 | import com.shepherd.mallorder.dto.Address; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author fjzheng 13 | * @version 1.0 14 | * @date 2021/7/20 19:06 15 | */ 16 | @FeignClient(name = "${micro-server.mall-user}", path = "/api/mall/user") 17 | public interface UserService { 18 | 19 | @GetMapping("/address") 20 | ResponseVO> getUserAddressList(); 21 | 22 | @GetMapping("/integration") 23 | ResponseVO getUserIntegration(); 24 | 25 | @GetMapping("/address/{id}") 26 | ResponseVO
getAddressDetail(@PathVariable("id") Long id); 27 | } 28 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/feign/WareService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.feign; 2 | 3 | import com.shepherd.mall.vo.ResponseVO; 4 | import com.shepherd.mallorder.dto.OrderDTO; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.RequestBody; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/7/26 15:50 13 | */ 14 | @FeignClient(name = "${micro-server.mall-warehouse}", path = "/api/mall/ware") 15 | public interface WareService { 16 | 17 | @PostMapping("/sku/stock/decrease") 18 | ResponseVO decreaseStock(@RequestBody OrderDTO orderDTO); 19 | } 20 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/interceptor/OrderWebConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.interceptor; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | import javax.annotation.Resource; 9 | 10 | /** 11 | * @author fjzheng 12 | * @version 1.0 13 | * @date 2021/7/16 15:48 14 | */ 15 | @Configuration 16 | public class OrderWebConfig implements WebMvcConfigurer { 17 | @Resource 18 | private AuthInterceptor authInterceptor; 19 | 20 | @Override 21 | public void addInterceptors(InterceptorRegistry registry) { 22 | registry.addInterceptor(authInterceptor).excludePathPatterns("/api/mall/order/orderNo/**"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/mq/TestReceiveMessage.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.mq; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/7/6 23:05 11 | */ 12 | @Component 13 | @Slf4j 14 | public class TestReceiveMessage { 15 | 16 | @RabbitListener(queues = {"test-queue1"}) 17 | public void receiveMessage(Object msg) { 18 | log.info("接收到消息内容:{}", msg); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/schedule/TestSchedule.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.schedule; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2021/5/20 18:47 7 | */ 8 | //import java.util.Date; 9 | //import org.quartz.DisallowConcurrentExecution; 10 | //import org.quartz.Job; 11 | //import org.quartz.JobExecutionContext; 12 | //import org.quartz.JobExecutionException; 13 | //import org.slf4j.Logger; 14 | //import org.slf4j.LoggerFactory; 15 | 16 | //@DisallowConcurrentExecution 17 | //public class TestSchedule implements Job{ 18 | // 19 | // private Logger logger = LoggerFactory.getLogger(getClass()); 20 | // 21 | // @Override 22 | // public void execute(JobExecutionContext context) throws JobExecutionException { 23 | // logger.info("*****"+new Date()); 24 | // } 25 | //} 26 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/service/impl/OrderItemServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.shepherd.mallorder.api.service.OrderItemService; 5 | import com.shepherd.mallorder.dao.OrderItemDAO; 6 | import com.shepherd.mallorder.entity.OrderItem; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.stereotype.Service; 9 | 10 | /** 11 | * @author fjzheng 12 | * @version 1.0 13 | * @date 2021/7/26 19:22 14 | */ 15 | @Service 16 | @Slf4j 17 | public class OrderItemServiceImpl extends ServiceImpl implements OrderItemService { 18 | } 19 | -------------------------------------------------------------------------------- /mall-order-service/src/main/java/com/shepherd/mallorder/utils/UserUtil.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.utils; 2 | 3 | import com.shepherd.mall.vo.LoginVO; 4 | import com.shepherd.mallorder.interceptor.AuthInterceptor; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/7/16 15:52 10 | */ 11 | 12 | public class UserUtil { 13 | 14 | 15 | public static LoginVO currentUser() { 16 | return AuthInterceptor.localUser.get(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /mall-order-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: mall-order-service 4 | cloud: 5 | nacos: 6 | config: 7 | server-addr: 10.10.0.14:8848 -------------------------------------------------------------------------------- /mall-order-service/src/main/resources/mapper/OrderItemMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mall-order-service/src/main/resources/mapper/OrderMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mall-order-service/src/main/resources/quartz.properties: -------------------------------------------------------------------------------- 1 | ##quartz集群配置 2 | ##调度标识名 集群中每一个实例都必须使用相同的名称 3 | #org.quartz.scheduler.instanceName=DefaultQuartzScheduler 4 | ##ID设置为自动获取 每一个必须不同 5 | #org.quartz.scheduler.instanceId=AUTO 6 | #org.quartz.scheduler.makeSchedulerThreadDaemon=true 7 | ##线程池的实现类(一般使用SimpleThreadPool即可满足需求) 8 | #org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool 9 | ##指定在线程池里面创建的线程是否是守护线程 10 | #org.quartz.threadPool.makeThreadsDaemons=true 11 | ##指定线程数,至少为1(无默认值) 12 | #org.quartz.threadPool.threadCount:20 13 | ##设置线程的优先级(最大为java.lang.Thread.MAX_PRIORITY 10,最小为Thread.MIN_PRIORITY 1,默认为5) 14 | #org.quartz.threadPool.threadPriority:5 15 | ##数据保存方式为数据库持久化 16 | #org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX 17 | ##数据库代理类,一般org.quartz.impl.jdbcjobstore.StdJDBCDelegate可以满足大部分数据库 18 | #org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate 19 | ##表的前缀,默认QRTZ_ 20 | #org.quartz.jobStore.tablePrefix=QRTZ_ 21 | ##是否加入集群 22 | #org.quartz.jobStore.isClustered=true 23 | ## 信息保存时间 默认值60秒 24 | #org.quartz.jobStore.misfireThreshold=25000 25 | # 26 | # 27 | # 28 | # 29 | -------------------------------------------------------------------------------- /mall-order-service/src/test/java/com/shepherd/mallorder/feign/ProductServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallorder.feign; 2 | 3 | import com.shepherd.mall.vo.ResponseVO; 4 | import com.shepherd.mallorder.dto.ProductSku; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | import javax.annotation.Resource; 11 | 12 | import static org.junit.Assert.*; 13 | 14 | /** 15 | * @author fjzheng 16 | * @version 1.0 17 | * @date 2022/6/1 18:52 18 | */ 19 | @SpringBootTest 20 | @RunWith(SpringRunner.class) 21 | public class ProductServiceTest { 22 | @Resource 23 | private ProductService productService; 24 | 25 | @Test 26 | public void getSku() { 27 | 28 | ResponseVO sku = productService.getSku(1l); 29 | System.out.println(sku); 30 | 31 | } 32 | } -------------------------------------------------------------------------------- /mall-pay-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/java/com/shepherd/mallpay/MallPayServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallpay; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.cloud.openfeign.EnableFeignClients; 8 | 9 | @SpringBootApplication 10 | @EnableDiscoveryClient 11 | @MapperScan(basePackages = "com.shepherd.mallpay.dao") 12 | @EnableFeignClients(basePackages = "com.shepherd.mallpay.feign") 13 | public class MallPayServiceApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(MallPayServiceApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/java/com/shepherd/mallpay/api/service/PayService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallpay.api.service; 2 | 3 | import com.lly835.bestpay.enums.BestPayTypeEnum; 4 | import com.lly835.bestpay.model.PayResponse; 5 | import com.shepherd.mallpay.dto.PayInfoDTO; 6 | 7 | import java.math.BigDecimal; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2020/10/8 15:42 13 | */ 14 | public interface PayService { 15 | /** 16 | * 创建/发起支付 17 | */ 18 | PayResponse create(String orderNo, Integer payType); 19 | 20 | /** 21 | * 异步通知处理 22 | * @param notifyData 23 | */ 24 | String asyncNotify(String notifyData); 25 | 26 | /** 27 | * 查询支付记录(通过订单号) 28 | * @param orderNo 29 | * @return 30 | */ 31 | PayInfoDTO getPayInfoByOrderNo(String orderNo); 32 | } 33 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/java/com/shepherd/mallpay/config/AlipayProperties.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallpay.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2020/10/8 22:45 11 | */ 12 | @Data 13 | @Component 14 | @ConfigurationProperties(prefix = "alipay") 15 | public class AlipayProperties { 16 | private String appId; 17 | 18 | private String privateKey; 19 | 20 | private String publicKey; 21 | 22 | private String notifyUrl; 23 | 24 | private String returnUrl; 25 | 26 | /** 27 | * 默认沙箱测试 28 | */ 29 | private boolean sandbox = true; 30 | } 31 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/java/com/shepherd/mallpay/config/WxProperties.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallpay.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2020/10/8 22:42 11 | */ 12 | @Data 13 | @Component 14 | @ConfigurationProperties(prefix = "wx") 15 | public class WxProperties { 16 | private String appId; 17 | 18 | private String mchId; 19 | 20 | private String mchKey; 21 | 22 | private String notifyUrl; 23 | 24 | private String returnUrl; 25 | } 26 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/java/com/shepherd/mallpay/constant/PayConstant.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallpay.constant; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2021/8/16 18:27 7 | */ 8 | public interface PayConstant { 9 | Integer TYPE_ALIPAY = 1; 10 | Integer TYPE_WXPAY = 2; 11 | 12 | Integer IS_PAY = 1; 13 | } 14 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/java/com/shepherd/mallpay/dao/PayInfoDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallpay.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.mallpay.entity.PayInfo; 5 | 6 | /** 7 | * @author fjZheng 8 | * @version 1.0 9 | * @date 2020/10/10 10:58 10 | */ 11 | public interface PayInfoDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/java/com/shepherd/mallpay/dto/AlipayNotify.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallpay.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/8/19 11:28 11 | */ 12 | @Data 13 | public class AlipayNotify { 14 | private String gmt_create; 15 | private String charset; 16 | private String gmt_payment; 17 | private Date notify_time; 18 | private String subject; 19 | private String sign; 20 | private String buyer_id;//支付者的id 21 | private String body;//订单的信息 22 | private String invoice_amount;//支付金额 23 | private String version; 24 | private String notify_id;//通知id 25 | private String fund_bill_list; 26 | private String notify_type;//通知类型; trade_status_sync 27 | private String out_trade_no;//订单号 28 | private String total_amount;//支付的总额 29 | private String trade_status;//交易状态 TRADE_SUCCESS 30 | private String trade_no;//流水号 31 | private String auth_app_id;// 32 | private String receipt_amount;//商家收到的款 33 | private String point_amount;// 34 | private String app_id;//应用id 35 | private String buyer_pay_amount;//最终支付的金额 36 | private String sign_type;//签名类型 37 | private String seller_id;//商家的id 38 | } 39 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/java/com/shepherd/mallpay/dto/Order.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallpay.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | import java.util.Date; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2021/8/16 18:20 12 | */ 13 | @Data 14 | public class Order { 15 | private Long id; 16 | private Long userId; 17 | private String orderNo; 18 | private Integer totalNum; 19 | private BigDecimal totalAmount; 20 | private BigDecimal preAmount; 21 | private BigDecimal postage; 22 | private BigDecimal payAmount; 23 | private Integer payType; 24 | private Date createTime; 25 | private Date updateTime; 26 | private Date payTime; 27 | private Date deliveryTime; 28 | private Date endTime; 29 | private Date closeTime; 30 | private String deliveryCompanyName; 31 | private String deliveryNo; 32 | private String orderRemark; 33 | private String receiverName; 34 | private String receiverMobile; 35 | private String receiverProvince; 36 | private String receiverCity; 37 | private String receiverRegion; 38 | private String receiverDetailAddress; 39 | private Integer sourceType; 40 | private String transactionId; 41 | private Integer status; 42 | private Integer isDelete; 43 | private Long orderId; 44 | } 45 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/java/com/shepherd/mallpay/dto/PayInfoDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallpay.dto; 2 | 3 | import com.shepherd.mallpay.entity.PayInfo; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.math.BigDecimal; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2020/10/9 20:27 13 | */ 14 | @Data 15 | public class PayInfoDTO extends PayInfo { 16 | private Long payInfoId; 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/java/com/shepherd/mallpay/enums/AlipayNotifyStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallpay.enums; 2 | 3 | import lombok.Getter; 4 | 5 | import java.util.Objects; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/8/19 11:38 11 | */ 12 | @Getter 13 | public enum AlipayNotifyStatusEnum { 14 | WAIT_BUYER_PAY(0, "等待支付"), 15 | TRADE_SUCCESS(1, "TRADE_SUCCESS"), 16 | TRADE_FINISHED(2, "TRADE_FINISHED"), 17 | TRADE_CLOSED(-1, "TRADE_CLOSED"); 18 | Integer status; 19 | String desc; 20 | 21 | AlipayNotifyStatusEnum(Integer status, String desc) { 22 | this.status = status; 23 | this.desc = desc; 24 | } 25 | 26 | public static AlipayNotifyStatusEnum getAlipayNotifyStatusEnum(String name) { 27 | for (AlipayNotifyStatusEnum alipayNotifyStatusEnum : AlipayNotifyStatusEnum.values()) { 28 | if (Objects.equals(name.toUpperCase(), alipayNotifyStatusEnum.name())) { 29 | return alipayNotifyStatusEnum; 30 | } 31 | } 32 | return null; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/java/com/shepherd/mallpay/enums/PayPlatformEnum.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallpay.enums; 2 | 3 | import com.lly835.bestpay.enums.BestPayTypeEnum; 4 | import lombok.Getter; 5 | 6 | /** 7 | * Created by 廖师兄 8 | */ 9 | @Getter 10 | public enum PayPlatformEnum { 11 | 12 | //1-支付宝,2-微信 13 | ALIPAY(1), 14 | 15 | WX(2), 16 | ; 17 | 18 | Integer code; 19 | 20 | PayPlatformEnum(Integer code) { 21 | this.code = code; 22 | } 23 | 24 | public static PayPlatformEnum getByBestPayTypeEnum(BestPayTypeEnum bestPayTypeEnum) { 25 | for (PayPlatformEnum payPlatformEnum : PayPlatformEnum.values()) { 26 | if (bestPayTypeEnum.getPlatform().name().equals(payPlatformEnum.name())) { 27 | return payPlatformEnum; 28 | } 29 | } 30 | throw new RuntimeException("错误的支付平台: " + bestPayTypeEnum.name()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/java/com/shepherd/mallpay/feign/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallpay.feign; 2 | 3 | import com.shepherd.mall.vo.ResponseVO; 4 | import com.shepherd.mallpay.dto.Order; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.PutMapping; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | 11 | /** 12 | * @author fjzheng 13 | * @version 1.0 14 | * @date 2021/8/16 18:19 15 | */ 16 | @FeignClient(name = "${micro-server.mall-order}", path = "/api/mall/order") 17 | public interface OrderService { 18 | 19 | @GetMapping("/orderNo/{orderNo}") 20 | ResponseVO getOrderByOrderNo(@PathVariable("orderNo") String orderNo); 21 | 22 | @PutMapping("/status") 23 | ResponseVO updateOrderStatus(@RequestParam("orderNo") String orderNo, @RequestParam("status") Integer status, @RequestParam("payType") Integer payType); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 18100 3 | spring: 4 | profiles: 5 | active: dev 6 | application: 7 | name: mall-pay-service 8 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: mall-pay-service 4 | cloud: 5 | nacos: 6 | config: 7 | server-addr: 10.10.0.14:8848 -------------------------------------------------------------------------------- /mall-pay-service/src/main/resources/mapper/PayInfoMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/resources/templates/alipayView.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 支付 5 | 6 | 7 | ${body} 8 | 9 | 10 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/resources/templates/createForAlipayPc.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 支付 5 | 6 | 7 | ${body} 8 | 9 | 10 | -------------------------------------------------------------------------------- /mall-pay-service/src/main/resources/templates/createForWxNative.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 支付 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 42 | 43 | -------------------------------------------------------------------------------- /mall-product-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/MallProductServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.cloud.openfeign.EnableFeignClients; 8 | import org.springframework.context.annotation.ComponentScan; 9 | 10 | @SpringBootApplication 11 | @EnableDiscoveryClient 12 | @MapperScan(basePackages = "com.shepherd.mallproduct.dao") 13 | @ComponentScan(basePackages = {"com.shepherd"}) 14 | @EnableFeignClients(basePackages = "com.shepherd.mallproduct") 15 | public class MallProductServiceApplication { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(MallProductServiceApplication.class, args); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/annotation/Limit.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.annotation; 2 | 3 | import com.shepherd.mallproduct.enums.LimitType; 4 | 5 | import java.lang.annotation.*; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2022/4/7 15:58 11 | */ 12 | @Target({ElementType.METHOD, ElementType.TYPE}) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Inherited 15 | @Documented 16 | public @interface Limit { 17 | 18 | /** 19 | * 名字 20 | */ 21 | String name() default ""; 22 | 23 | /** 24 | * key 25 | */ 26 | String key() default ""; 27 | 28 | /** 29 | * Key的前缀 30 | */ 31 | String prefix() default ""; 32 | 33 | /** 34 | * 给定的时间范围 单位(秒) 35 | */ 36 | int period(); 37 | 38 | /** 39 | * 一定时间内最多访问次数 40 | */ 41 | int count(); 42 | 43 | /** 44 | * 限流的类型(用户自定义key 或者 请求ip) 45 | */ 46 | LimitType limitType() default LimitType.CUSTOMER; 47 | } 48 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/api/service/BrandService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.api.service; 2 | 3 | import com.shepherd.mallproduct.dto.BrandDTO; 4 | import com.shepherd.mallproduct.query.BrandQuery; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author fjZheng 10 | * @version 1.0 11 | * @date 2021/2/2 18:59 12 | */ 13 | public interface BrandService { 14 | 15 | void addBrand(BrandDTO brandDTO); 16 | 17 | List getBrandList(Long categoryId); 18 | 19 | BrandDTO getBrandDetail(Long brandId); 20 | 21 | List getBrandList(List brandIds); 22 | 23 | List getList(BrandQuery query); 24 | } 25 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/api/vo/BrandVO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.api.vo; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | 6 | import javax.validation.constraints.NotBlank; 7 | import javax.validation.constraints.NotNull; 8 | import java.util.List; 9 | 10 | /** 11 | * @author fjZheng 12 | * @version 1.0 13 | * @date 2021/2/2 18:54 14 | */ 15 | @Data 16 | public class BrandVO { 17 | 18 | private Long brandId; 19 | @NotNull(message = "categoryId不能为空") 20 | private Long categoryId; 21 | @NotBlank(message = "name不能为空") 22 | private String name; 23 | private String image; 24 | private String description; 25 | private String letter; 26 | private List brandIds; 27 | } 28 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/api/vo/CategoryVO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.api.vo; 2 | 3 | import com.shepherd.mallproduct.dto.CategoryDTO; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.util.Date; 8 | import java.util.List; 9 | 10 | /** 11 | * @author fjZheng 12 | * @version 1.0 13 | * @date 2020/10/10 16:38 14 | */ 15 | @Data 16 | public class CategoryVO { 17 | 18 | private Long categoryId; 19 | private Long parentId; 20 | private String name; 21 | private Boolean status; 22 | private Integer sortOrder; 23 | private Date createTime; 24 | private Date updateTime; 25 | private Integer isDelete; 26 | private List categoryDTOList; 27 | private List categoryIds; 28 | } 29 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/api/vo/ProductVO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.api.vo; 2 | 3 | import com.shepherd.mallproduct.entity.ProductSku; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.math.BigDecimal; 8 | import java.util.Date; 9 | import java.util.List; 10 | 11 | /** 12 | * @author fjZheng 13 | * @version 1.0 14 | * @date 2020/10/10 16:37 15 | */ 16 | @Data 17 | public class ProductVO { 18 | 19 | private Long categoryId; 20 | private Long brandId; 21 | private String name; 22 | private String subtitle; 23 | private String mainImage; 24 | private String subImages; 25 | private String detail; 26 | private String specItems; 27 | private String paramItems; 28 | private Long productSpuId; 29 | private List productSpuIds; 30 | private List skuList; 31 | private List skuIds; 32 | } 33 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/cache/CacheTest.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.cache; 2 | 3 | import com.github.benmanes.caffeine.cache.Cache; 4 | import com.github.benmanes.caffeine.cache.Caffeine; 5 | 6 | import java.util.concurrent.TimeUnit; 7 | 8 | 9 | /** 10 | * @author fjZheng 11 | * @version 1.0 12 | * @date 2020/12/30 11:12 13 | */ 14 | public class CacheTest { 15 | 16 | public static void test() throws InterruptedException { 17 | Cache cache = Caffeine.newBuilder().maximumSize(1) 18 | .expireAfterAccess(1, TimeUnit.SECONDS).build(); 19 | cache.put("1", 1); 20 | long size = cache.estimatedSize(); 21 | // Thread.sleep(1000); 22 | cache.put("2", 2); 23 | // cache.cleanUp(); 24 | //cache.invalidate("1"); 25 | Object o = cache.get("1", key -> "hello"); 26 | Object o2 = cache.get("2", key -> "hello2"); 27 | System.out.println(o); 28 | System.out.println(o2); 29 | 30 | } 31 | 32 | public static void main(String[] args) throws InterruptedException { 33 | test(); 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/cache/RedisCacheEx.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.cache; 2 | 3 | import org.springframework.data.redis.cache.RedisCache; 4 | import org.springframework.data.redis.cache.RedisCacheConfiguration; 5 | import org.springframework.data.redis.cache.RedisCacheWriter; 6 | 7 | /** 8 | * @author fjZheng 9 | * @version 1.0 10 | * @date 2021/1/4 21:14 11 | */ 12 | public class RedisCacheEx extends RedisCache { 13 | /** 14 | * Create new {@link RedisCache}. 15 | * 16 | * @param name must not be {@literal null}. 17 | * @param cacheWriter must not be {@literal null}. 18 | * @param cacheConfig must not be {@literal null}. 19 | */ 20 | protected RedisCacheEx(String name, RedisCacheWriter cacheWriter, RedisCacheConfiguration cacheConfig) { 21 | super(name, cacheWriter, cacheConfig); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/config/InitConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.config; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * @author fjZheng 9 | * @version 1.0 10 | * @date 2020/10/13 18:37 11 | */ 12 | @Configuration 13 | public class InitConfig { 14 | 15 | 16 | @Bean 17 | public PaginationInterceptor paginationInterceptor() { 18 | //必须注入这个分页插件拦截器,否则分页不成功 19 | return new PaginationInterceptor(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/config/RedisProperties.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * @author fjZheng 9 | * @version 1.0 10 | * @date 2021/1/5 16:59 11 | */ 12 | @Configuration 13 | @ConfigurationProperties(prefix = "spring.redis") 14 | @Data 15 | public class RedisProperties { 16 | private String host = "localhost"; 17 | 18 | private Integer port = 6379; 19 | 20 | private String password; 21 | 22 | private Integer database = 0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/config/RedissonConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.config; 2 | 3 | 4 | import org.redisson.Redisson; 5 | import org.redisson.api.RedissonClient; 6 | import org.redisson.config.Config; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | import java.io.IOException; 12 | 13 | /** 14 | * @author fjzheng 15 | * @version 1.0 16 | * @date 2021/6/18 14:47 17 | */ 18 | @Configuration 19 | public class RedissonConfig { 20 | 21 | private static final String REDISSON_PREFIX = "redis://"; 22 | @Value("${spring.redis.host}") 23 | private String redisHost; 24 | @Value("${spring.redis.port}") 25 | private String redisPort; 26 | 27 | 28 | 29 | @Bean(destroyMethod = "shutdown") 30 | public RedissonClient redisson() { 31 | // 1、创建配置 32 | Config config = new Config(); 33 | // Redis url should start with redis:// or rediss:// 34 | config.useSingleServer().setAddress(REDISSON_PREFIX+redisHost+":"+redisPort); 35 | 36 | // 2、根据 Config 创建出 RedissonClient 实例 37 | return Redisson.create(config); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/constant/ProductConstant.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.constant; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2021/5/1 0:53 7 | */ 8 | public interface ProductConstant { 9 | 10 | Integer PRODUCT_NEW = 0; 11 | Integer PRODUCT_UP = 1; 12 | } 13 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/dao/BrandDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.mallproduct.entity.Brand; 5 | 6 | /** 7 | * @author fjZheng 8 | * @version 1.0 9 | * @date 2021/2/2 18:37 10 | */ 11 | public interface BrandDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/dao/CategoryDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.mallproduct.entity.Category; 5 | 6 | /** 7 | * @author fjZheng 8 | * @version 1.0 9 | * @date 2020/10/10 16:21 10 | */ 11 | public interface CategoryDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/dao/ProductParamDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.mallproduct.entity.ProductParam; 5 | 6 | /** 7 | * @author fjZheng 8 | * @version 1.0 9 | * @date 2021/2/2 18:38 10 | */ 11 | public interface ProductParamDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/dao/ProductSkuDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.mallproduct.entity.ProductSku; 5 | 6 | /** 7 | * @author fjZheng 8 | * @version 1.0 9 | * @date 2021/2/2 16:02 10 | */ 11 | public interface ProductSkuDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/dao/ProductSpecDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.mallproduct.entity.ProductSpec; 5 | 6 | /** 7 | * @author fjZheng 8 | * @version 1.0 9 | * @date 2021/2/2 18:38 10 | */ 11 | public interface ProductSpecDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/dao/ProductSpuDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.mallproduct.entity.ProductSpu; 5 | 6 | /** 7 | * @author fjZheng 8 | * @version 1.0 9 | * @date 2020/10/10 15:54 10 | */ 11 | public interface ProductSpuDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/dto/BrandDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.dto; 2 | 3 | import com.shepherd.mallproduct.entity.Brand; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author fjZheng 8 | * @version 1.0 9 | * @date 2021/2/2 18:57 10 | */ 11 | @Data 12 | public class BrandDTO extends Brand { 13 | private Long brandId; 14 | } 15 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/dto/CategoryDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.shepherd.mallproduct.entity.Category; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | import java.util.List; 9 | 10 | /** 11 | * @author fjZheng 12 | * @version 1.0 13 | * @date 2020/10/10 16:32 14 | */ 15 | @Data 16 | @JsonInclude(value = JsonInclude.Include.NON_NULL) 17 | public class CategoryDTO extends Category implements Serializable { 18 | private Long categoryId; 19 | private List nodeList; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/dto/ProductDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.dto; 2 | 3 | import com.shepherd.mallproduct.entity.ProductSku; 4 | import com.shepherd.mallproduct.entity.ProductSpu; 5 | import lombok.Data; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author fjZheng 11 | * @version 1.0 12 | * @date 2020/10/10 16:32 13 | */ 14 | @Data 15 | public class ProductDTO extends ProductSpu { 16 | private Long productSpuId; 17 | private List productSpuIds; 18 | private List skuList; 19 | } 20 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/dto/ProductParamDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.dto; 2 | 3 | import com.shepherd.mallproduct.entity.ProductParam; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author fjZheng 8 | * @version 1.0 9 | * @date 2021/2/3 11:52 10 | */ 11 | @Data 12 | public class ProductParamDTO extends ProductParam { 13 | private Long productParamId; 14 | } 15 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/dto/ProductSkuDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.dto; 2 | 3 | import com.shepherd.mallproduct.entity.ProductSku; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/4/30 0:58 13 | */ 14 | 15 | @Data 16 | public class ProductSkuDTO extends ProductSku { 17 | private Long skuId; 18 | private String brandName; 19 | private String categoryName; 20 | private Map specMap; 21 | /** 22 | * 是否有库存 23 | */ 24 | private Boolean hasStock; 25 | /** 26 | * 热度 27 | */ 28 | private Long hotScore; 29 | private String brandImg; 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/dto/ProductSpecDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.dto; 2 | 3 | import com.shepherd.mallproduct.entity.ProductSpec; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author fjZheng 10 | * @version 1.0 11 | * @date 2021/2/3 11:51 12 | */ 13 | @Data 14 | public class ProductSpecDTO extends ProductSpec { 15 | private Long productSpecId; 16 | private List productSpecIds; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/dto/SkuInfo.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.dto; 2 | 3 | import com.shepherd.mallproduct.entity.ProductSku; 4 | import com.shepherd.mallproduct.entity.ProductSpu; 5 | import lombok.Data; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/6/24 18:08 11 | */ 12 | @Data 13 | public class SkuInfo { 14 | private ProductSku sku; 15 | private ProductSpu spu; 16 | private SpecDTO spec; 17 | private BrandDTO brand; 18 | private CategoryDTO category; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/dto/SpecDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/6/24 18:12 11 | */ 12 | @Data 13 | public class SpecDTO { 14 | 15 | private String specName; 16 | private List specValues; 17 | } 18 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/entity/Brand.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * @author fjZheng 13 | * @version 1.0 14 | * @date 2021/2/2 17:31 15 | */ 16 | @Data 17 | @ApiModel("品牌") 18 | public class Brand { 19 | @TableId(type = IdType.AUTO) 20 | @ApiModelProperty("主键") 21 | private Long id; 22 | 23 | @ApiModelProperty("类目id") 24 | private Long categoryId; 25 | 26 | @ApiModelProperty("品牌名称") 27 | private String name; 28 | 29 | @ApiModelProperty("品牌图片") 30 | private String image; 31 | 32 | @ApiModelProperty("品牌描述") 33 | private String description; 34 | 35 | @ApiModelProperty("品牌首字母") 36 | private String letter; 37 | 38 | @ApiModelProperty("删除标志位") 39 | private Integer isDelete; 40 | 41 | @ApiModelProperty("创建时间") 42 | private Date createTime; 43 | 44 | @ApiModelProperty("更新时间") 45 | private Date updateTime; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/entity/Category.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * @author fjZheng 14 | * @version 1.0 15 | * @date 2020/10/10 16:01 16 | */ 17 | @Data 18 | @ApiModel("商品分类") 19 | public class Category implements Serializable { 20 | @TableId(type= IdType.AUTO) 21 | @ApiModelProperty("主键") 22 | private Long id; 23 | 24 | @ApiModelProperty("父级类目id") 25 | private Long parentId; 26 | 27 | @ApiModelProperty("类目名称") 28 | private String name; 29 | 30 | @ApiModelProperty("类别状态1-正常,0-已废弃") 31 | private Integer status; 32 | 33 | @ApiModelProperty("排序编号,同类展示顺序,数值相等则自然排序") 34 | private Integer sortOrder; 35 | 36 | @ApiModelProperty("创建时间") 37 | private Date createTime; 38 | 39 | @ApiModelProperty("更新时间") 40 | private Date updateTime; 41 | 42 | @ApiModelProperty("删除标志位") 43 | private Integer isDelete; 44 | } 45 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/entity/ProductParam.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * @author fjZheng 13 | * @version 1.0 14 | * @date 2021/2/2 18:22 15 | */ 16 | 17 | /** 18 | * 这个实体类商品参数和商品规格是有区别: 19 | */ 20 | @Data 21 | @ApiModel("商品参数") 22 | public class ProductParam { 23 | @TableId(type = IdType.AUTO) 24 | @ApiModelProperty("主键") 25 | private Long id; 26 | 27 | @ApiModelProperty("类目id") 28 | private Long categoryId; 29 | 30 | @ApiModelProperty("商品参数名称") 31 | private String name; 32 | 33 | @ApiModelProperty("商品参数可选值") 34 | private String options; 35 | 36 | @ApiModelProperty("删除标志位") 37 | private String isDelete; 38 | 39 | @ApiModelProperty("创建时间") 40 | private Date createTime; 41 | 42 | @ApiModelProperty("更新时间") 43 | private Date updateTime; 44 | } 45 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/entity/ProductSpec.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * @author fjZheng 13 | * @version 1.0 14 | * @date 2021/2/2 18:14 15 | */ 16 | @Data 17 | @ApiModel("商品规格表") 18 | public class ProductSpec { 19 | @TableId(type = IdType.AUTO) 20 | @ApiModelProperty("主键") 21 | private Long id; 22 | 23 | @ApiModelProperty("类目id") 24 | private Long categoryId; 25 | 26 | @ApiModelProperty("商品规格名称") 27 | private String name; 28 | 29 | @ApiModelProperty("商品规格类型") 30 | private String options; 31 | 32 | @ApiModelProperty("删除标志位") 33 | private String isDelete; 34 | 35 | @ApiModelProperty("创建时间") 36 | private Date createTime; 37 | 38 | @ApiModelProperty("更新时间") 39 | private Date updateTime; 40 | } 41 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/enums/LimitType.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.enums; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2022/4/7 15:59 7 | */ 8 | public enum LimitType { 9 | 10 | /** 11 | * 自定义key 12 | */ 13 | CUSTOMER, 14 | 15 | /** 16 | * 请求者IP 17 | */ 18 | IP; 19 | } 20 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/feign/SearchService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.feign; 2 | 3 | import com.shepherd.mall.vo.ResponseVO; 4 | import com.shepherd.mallproduct.dto.ProductSkuDTO; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.RequestBody; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author fjzheng 13 | * @version 1.0 14 | * @date 2021/4/30 14:54 15 | */ 16 | 17 | @FeignClient(name = "mall-search-service", path = "/api/mall/search") 18 | public interface SearchService { 19 | 20 | @PostMapping("/product") 21 | ResponseVO addProductToEs(@RequestBody List productSkuDTOs); 22 | } 23 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/interceptor/InterceptorConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.interceptor; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | /** 8 | * Created by 廖师兄 9 | */ 10 | @Configuration 11 | public class InterceptorConfig implements WebMvcConfigurer { 12 | 13 | @Override 14 | public void addInterceptors(InterceptorRegistry registry) { 15 | registry.addInterceptor(new UserLoginInterceptor()) 16 | .addPathPatterns("/api/mall/test") 17 | .excludePathPatterns("/error", "/user/login", "/user/register", "/categories", "/products", "/products/*"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/interceptor/UserLoginInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.interceptor; 2 | 3 | import com.shepherd.mall.exception.BusinessException; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.web.servlet.HandlerInterceptor; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | 10 | /** 11 | * @author fjZheng 12 | * @version 1.0 13 | * @date 2020/11/11 10:21 14 | */ 15 | @Slf4j 16 | public class UserLoginInterceptor implements HandlerInterceptor { 17 | 18 | /** 19 | * true 表示继续流程,false表示中断 20 | * @param request 21 | * @param response 22 | * @param handler 23 | * @return 24 | * @throws Exception 25 | */ 26 | @Override 27 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { 28 | log.info("preHandle..."); 29 | if (1==1) { 30 | throw new BusinessException("dfgdfgdf"); 31 | } 32 | return false; 33 | } 34 | } -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/nacos/User.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.nacos; 2 | 3 | import com.alibaba.nacos.api.config.annotation.NacosConfigurationProperties; 4 | import lombok.Data; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2022/4/20 14:55 12 | */ 13 | @Data 14 | @Configuration 15 | @NacosConfigurationProperties(prefix = "user", autoRefreshed = true, dataId = "mall-product-service-dev.yaml") 16 | public class User { 17 | private String name; 18 | private Integer age; 19 | private Long id; 20 | } 21 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/nacos/UserProperties.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.nacos; 2 | 3 | import lombok.Data; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2022/4/20 15:22 12 | */ 13 | @Configuration 14 | @Data 15 | public class UserProperties { 16 | @Value("${user.name}") 17 | private String name; 18 | } 19 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/query/BrandQuery.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.query; 2 | 3 | import com.shepherd.mall.base.BaseQuery; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2022/6/6 11:06 11 | */ 12 | @Data 13 | public class BrandQuery extends BaseQuery { 14 | @ApiModelProperty("类目id") 15 | private Long categoryId; 16 | @ApiModelProperty("品牌名称") 17 | private String name; 18 | @ApiModelProperty("品牌首字母") 19 | private String letter; 20 | } 21 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/query/CategoryQuery.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.query; 2 | 3 | import com.shepherd.mall.base.BaseQuery; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author fjZheng 8 | * @version 1.0 9 | * @date 2020/10/10 17:34 10 | */ 11 | @Data 12 | public class CategoryQuery extends BaseQuery { 13 | } 14 | -------------------------------------------------------------------------------- /mall-product-service/src/main/java/com/shepherd/mallproduct/query/ProductQuery.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.query; 2 | 3 | import com.shepherd.mall.base.BaseQuery; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author fjZheng 8 | * @version 1.0 9 | * @date 2020/10/10 17:24 10 | */ 11 | @Data 12 | public class ProductQuery extends BaseQuery { 13 | private Long categoryId; 14 | private String name; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /mall-product-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: mall-product-service 4 | cloud: 5 | nacos: 6 | config: 7 | server-addr: 10.10.0.14:8848 8 | file-extension: yaml 9 | namespace: 92d02ff4-3e0b-4363-8421-95b20d9bf618 10 | profiles: 11 | active: dev -------------------------------------------------------------------------------- /mall-product-service/src/main/resources/mapper/BrandMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mall-product-service/src/main/resources/mapper/CategoryMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mall-product-service/src/main/resources/mapper/ProductParamMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mall-product-service/src/main/resources/mapper/ProductSkuMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mall-product-service/src/main/resources/mapper/ProductSpecMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mall-product-service/src/main/resources/mapper/ProductSpuMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mall-product-service/src/test/java/com/shepherd/mallproduct/nacos/UserTest.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallproduct.nacos; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | import javax.annotation.Resource; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * @author fjzheng 14 | * @version 1.0 15 | * @date 2022/4/20 15:06 16 | */ 17 | @SpringBootTest 18 | @RunWith(SpringRunner.class) 19 | public class UserTest { 20 | @Resource 21 | private User user; 22 | @Resource 23 | private UserProperties userProperties; 24 | 25 | @Test 26 | public void test() { 27 | System.out.println(userProperties.getName()); 28 | System.out.println(user); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /mall-search-service/src/main/java/com/shepherd/mallsearch/MallSearchServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallsearch; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 7 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 8 | import org.springframework.cloud.openfeign.EnableFeignClients; 9 | import org.springframework.context.annotation.ComponentScan; 10 | 11 | 12 | @EnableDiscoveryClient 13 | @ComponentScan(basePackages = {"com.shepherd"}) 14 | @EnableFeignClients(basePackages = "com.shepherd.mallsearch") 15 | @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) 16 | public class MallSearchServiceApplication { 17 | 18 | public static void main(String[] args) { 19 | 20 | SpringApplication.run(MallSearchServiceApplication.class, args); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /mall-search-service/src/main/java/com/shepherd/mallsearch/api/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallsearch.api.service; 2 | 3 | import com.shepherd.mall.vo.ResponseVO; 4 | import com.shepherd.mallsearch.dto.ProductSku; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author fjZheng 12 | * @version 1.0 13 | * @date 2021/2/9 15:47 14 | */ 15 | 16 | @FeignClient(name = "${micro-server.mall-product}", path = "/api/mall/product") 17 | public interface ProductService { 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /mall-search-service/src/main/java/com/shepherd/mallsearch/api/service/SearchService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallsearch.api.service; 2 | 3 | import com.shepherd.mallsearch.api.vo.SearchResult; 4 | import com.shepherd.mallsearch.dto.ProductSku; 5 | import com.shepherd.mallsearch.param.SearchParam; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author fjZheng 11 | * @version 1.0 12 | * @date 2021/2/9 16:03 13 | */ 14 | public interface SearchService { 15 | /** 16 | * 批量上架商品到es中 17 | * @param productSkuList 18 | * @return 19 | */ 20 | Boolean addProductToEsBatch(List productSkuList); 21 | 22 | SearchResult searchProduct(SearchParam param); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /mall-search-service/src/main/java/com/shepherd/mallsearch/api/vo/BrandVO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallsearch.api.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author fjzheng 7 | * @version 1.0 8 | * @date 2021/6/23 00:43 9 | */ 10 | @Data 11 | public class BrandVO { 12 | 13 | private Long brandId; 14 | 15 | private String brandName; 16 | 17 | private String brandImg; 18 | } -------------------------------------------------------------------------------- /mall-search-service/src/main/java/com/shepherd/mallsearch/api/vo/CategoryVO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallsearch.api.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author fjzheng 7 | * @version 1.0 8 | * @date 2021/6/23 00:44 9 | */ 10 | 11 | @Data 12 | public class CategoryVO { 13 | 14 | private Long categoryId; 15 | 16 | private String categoryName; 17 | } 18 | -------------------------------------------------------------------------------- /mall-search-service/src/main/java/com/shepherd/mallsearch/api/vo/SpecVO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallsearch.api.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/6/23 00:45 11 | */ 12 | @Data 13 | public class SpecVO { 14 | private String specName; 15 | //这里属性的value值声明为list,为了保证有序,同时把value值去重之后在插入list 16 | private List specValues; 17 | } 18 | -------------------------------------------------------------------------------- /mall-search-service/src/main/java/com/shepherd/mallsearch/enums/ErrorCodeEnum.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallsearch.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * @author jfWu 7 | * @version 1.0 8 | * @date 2019/11/18 11:07 9 | */ 10 | @Getter 11 | public enum ErrorCodeEnum { 12 | 13 | UP_PRODUCT_IS_EMPTY("up product is empty", "上架的商品为空"), 14 | SEARCH_ERROR("search error", "搜索数据发生错误"); 15 | 16 | private String code; 17 | private String message; 18 | 19 | ErrorCodeEnum(String code, String message) { 20 | this.code = code; 21 | this.message = message; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mall-search-service/src/main/java/com/shepherd/mallsearch/param/SearchParam.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallsearch.param; 2 | 3 | import com.shepherd.mall.base.BaseQuery; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/6/22 15:07 13 | */ 14 | @Data 15 | public class SearchParam extends BaseQuery { 16 | 17 | /** 18 | * 页面传递过来的全文匹配关键字 19 | */ 20 | private String keyword; 21 | 22 | /** 23 | * 品牌id,可以多选 24 | */ 25 | private List brandId; 26 | 27 | /** 28 | * 三级分类id 29 | */ 30 | private Long categoryId; 31 | 32 | /** 33 | * 排序条件:sort=price/salecount/hotscore_desc/asc 34 | */ 35 | private String sort; 36 | 37 | /** 38 | * 是否显示有货 39 | */ 40 | private Integer hasStock; 41 | 42 | /** 43 | * 价格区间查询 44 | */ 45 | private String price; 46 | 47 | /** 48 | * 按照属性进行筛选 49 | */ 50 | private Map specMap; 51 | 52 | 53 | /** 54 | * 原生的所有查询条件 55 | */ 56 | private String _queryString; 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /mall-search-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 18600 3 | spring: 4 | application: 5 | name: mall-search-service 6 | elasticsearch: 7 | rest: 8 | uris: http://10.10.0.18:9200 9 | cloud: 10 | nacos: 11 | discovery: 12 | server-addr: 10.10.0.14:8848 13 | feign: 14 | hystrix: 15 | enabled: true 16 | #超时配置 17 | ribbon: 18 | ReadTimeout: 300000 19 | 20 | hystrix: 21 | command: 22 | default: 23 | execution: 24 | isolation: 25 | thread: 26 | timeoutInMilliseconds: 10000 27 | 28 | 29 | micro-server: 30 | mall-product: mall-product-service 31 | 32 | 33 | #swagger 34 | swagger-web: 35 | api-title: "Shepherd-mall Restful Apis" 36 | api-description: "Shepherd-mall swagger-ui" 37 | contact-name: "shepherd" 38 | contact-url: "https://github.com/ICoder0" 39 | contact-email: "1059959730@qq.com" 40 | scan-package: "com.shepherd.mallsearch.api.controller" 41 | 42 | #注意:这里写成user.name获取的本机电脑的名字shepherdmy,这里填写的meiying无效 43 | search: 44 | user: 45 | name: meiying 46 | age: 25 47 | 48 | -------------------------------------------------------------------------------- /mall-search-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: mall-search-service 4 | cloud: 5 | nacos: 6 | config: 7 | server-addr: 10.10.0.14:8848 8 | #file-extension表示nacos的配置中心的配置文件后缀,不设置时默认为properties, 9 | #注意不能设置为yml,应该nacos配置中心没有yml这个格式,导致不能配置中心的文件没有用 10 | file-extension: yaml 11 | namespace: 00908414-c284-45b9-9fc4-69eee62d0d9d 12 | profiles: 13 | active: test 14 | -------------------------------------------------------------------------------- /mall-search-service/src/test/java/com/shepherd/mallsearch/MallSearchServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mallsearch; 2 | 3 | 4 | import org.junit.Test; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | 7 | @SpringBootTest 8 | class MallSearchServiceApplicationTests { 9 | 10 | @Test 11 | void contextLoads() { 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/annotation/RateLimit.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.annotation; 2 | 3 | import java.lang.annotation.*; 4 | import java.util.concurrent.TimeUnit; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/10/25 00:06 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target({ElementType.METHOD, ElementType.TYPE}) 13 | @Documented 14 | public @interface RateLimit { 15 | /** 16 | * 资源的key,唯一 17 | * 作用:不同的接口,不同的流量控制 18 | */ 19 | String key() default ""; 20 | 21 | /** 22 | * 最多的访问限制次数 23 | */ 24 | double permitsPerSecond () ; 25 | 26 | /** 27 | * 获取令牌最大等待时间 28 | */ 29 | long timeout(); 30 | 31 | /** 32 | * 获取令牌最大等待时间,单位(例:分钟/秒/毫秒) 默认:毫秒 33 | */ 34 | TimeUnit timeunit() default TimeUnit.MILLISECONDS; 35 | 36 | /** 37 | * 得不到令牌的提示语 38 | */ 39 | String msg() default "系统繁忙,请稍后再试."; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/api/service/SeckillService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.api.service; 2 | 3 | import com.shepherd.mall.seckill.dto.SeckillSessionDTO; 4 | 5 | /** 6 | * @author fjzheng 7 | * @version 1.0 8 | * @date 2021/8/25 23:50 9 | */ 10 | public interface SeckillService { 11 | /** 12 | * 上架最近3天秒杀活动信息和关联商品到redis中,预热 13 | */ 14 | void upSeckillSessionLast3Day(); 15 | 16 | SeckillSessionDTO getCurrentSeckillSessionInfo(); 17 | 18 | String kill(String killId, String key, Integer num); 19 | } 20 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/api/service/TestHystrixService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.api.service; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2021/9/1 10:32 7 | */ 8 | public interface TestHystrixService { 9 | 10 | String testHystrix(Long skuId); 11 | 12 | String testFeignWithHystrix(Long skuId); 13 | } 14 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/api/service/TestSentinelService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.api.service; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2021/9/2 00:20 7 | */ 8 | public interface TestSentinelService { 9 | String degrade(Long skuId); 10 | String customResource(); 11 | String annotationCustomResource() throws InterruptedException; 12 | } 13 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/api/vo/SeckillVO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.api.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author fjzheng 7 | * @version 1.0 8 | * @date 2021/8/27 11:02 9 | */ 10 | @Data 11 | public class SeckillVO { 12 | private String killId; 13 | private String key; 14 | private Integer num; 15 | } 16 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/config/InitConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.config; 2 | 3 | import com.shepherd.mall.utils.IdWorker; 4 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.client.RestTemplate; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/8/27 17:52 13 | */ 14 | @Configuration 15 | public class InitConfig { 16 | 17 | @Bean 18 | public IdWorker idWorker() { 19 | return new IdWorker(); 20 | } 21 | 22 | @Bean 23 | @LoadBalanced 24 | RestTemplate restTemplate() { 25 | return new RestTemplate(); 26 | } 27 | } -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/config/RabbitmqConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.config; 2 | 3 | import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; 4 | import org.springframework.amqp.support.converter.MessageConverter; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2021/8/27 17:37 12 | */ 13 | @Configuration 14 | public class RabbitmqConfig { 15 | @Bean 16 | public MessageConverter messageConverter() { 17 | //在容器中导入Json的消息转换器 18 | return new Jackson2JsonMessageConverter(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/config/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.data.redis.connection.RedisConnectionFactory; 6 | import org.springframework.data.redis.core.RedisTemplate; 7 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; 8 | 9 | import java.net.UnknownHostException; 10 | 11 | /** 12 | * @author fjzheng 13 | * @version 1.0 14 | * @date 2021/8/26 15:05 15 | */ 16 | @Configuration 17 | public class RedisConfig { 18 | @Bean 19 | public RedisTemplate redisTemplate( 20 | RedisConnectionFactory redisConnectionFactory) 21 | throws UnknownHostException { 22 | RedisTemplate template = new RedisTemplate(); 23 | template.setConnectionFactory(redisConnectionFactory); 24 | Jackson2JsonRedisSerializer serializer = new Jackson2JsonRedisSerializer<>(Object.class); 25 | template.setDefaultSerializer(serializer); 26 | return template; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/config/RedissonConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.config; 2 | 3 | import lombok.Data; 4 | import org.redisson.Redisson; 5 | import org.redisson.api.RedissonClient; 6 | import org.redisson.config.Config; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | /** 12 | * @author fjzheng 13 | * @version 1.0 14 | * @date 2021/8/26 15:04 15 | */ 16 | @Configuration 17 | public class RedissonConfig { 18 | 19 | private static final String REDISSON_PREFIX = "redis://"; 20 | @Value("${spring.redis.host}") 21 | private String redisHost; 22 | @Value("${spring.redis.port}") 23 | private String redisPort; 24 | 25 | 26 | 27 | @Bean(destroyMethod = "shutdown") 28 | public RedissonClient redisson() { 29 | // 1、创建配置 30 | Config config = new Config(); 31 | // Redis url should start with redis:// or rediss:// 32 | config.useSingleServer().setAddress(REDISSON_PREFIX+redisHost+":"+redisPort); 33 | 34 | // 2、根据 Config 创建出 RedissonClient 实例 35 | return Redisson.create(config); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/config/SentinelConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.config; 2 | 3 | import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler; 4 | import com.alibaba.csp.sentinel.slots.block.BlockException; 5 | import com.alibaba.fastjson.JSON; 6 | import com.shepherd.mall.vo.ResponseVO; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.stereotype.Component; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import java.io.IOException; 14 | 15 | /** 16 | * @author fjzheng 17 | * @version 1.0 18 | * @date 2021/9/2 11:56 19 | */ 20 | 21 | @Configuration 22 | public class SentinelConfig { 23 | 24 | 25 | @Bean 26 | public BlockExceptionHandler blockExceptionHandler() { 27 | return (httpServletRequest, httpServletResponse, e) -> { 28 | ResponseVO responseVO = ResponseVO.failure(400, "太多的请求"); 29 | httpServletResponse.setContentType("application/json;charset=utf-8"); 30 | httpServletResponse.getWriter().write(JSON.toJSONString(responseVO)); 31 | }; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/dao/SeckillSessionDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.mall.seckill.entity.SeckillSession; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/8/25 23:43 10 | */ 11 | public interface SeckillSessionDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/dao/SeckillSkuDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.mall.seckill.entity.SeckillSku; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/8/25 23:44 10 | */ 11 | public interface SeckillSkuDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/dto/SeckillOrder.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/8/27 17:27 11 | */ 12 | @Data 13 | public class SeckillOrder { 14 | private Long userId; 15 | private Integer number; 16 | private Long skuId; 17 | private BigDecimal seckillPrice; 18 | private Long sessionId; 19 | private String orderNo; 20 | } 21 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/dto/SeckillSessionDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.dto; 2 | 3 | import com.shepherd.mall.seckill.entity.SeckillSession; 4 | import com.shepherd.mall.seckill.entity.SeckillSku; 5 | import lombok.Data; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/8/26 13:43 13 | */ 14 | @Data 15 | public class SeckillSessionDTO extends SeckillSession { 16 | private List skuList; 17 | } 18 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/dto/SeckillSkuDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.dto; 2 | 3 | import com.shepherd.mall.seckill.entity.SeckillSku; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/8/26 14:52 10 | */ 11 | @Data 12 | public class SeckillSkuDTO extends SeckillSku { 13 | private SkuInfo skuInfo; 14 | 15 | //当前商品秒杀的开始时间 16 | private Long startTime; 17 | 18 | //当前商品秒杀的结束时间 19 | private Long endTime; 20 | 21 | //当前商品秒杀的随机码 22 | private String randomCode; 23 | } 24 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/dto/SkuInfo.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | import java.util.Map; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2021/8/26 14:49 12 | */ 13 | @Data 14 | public class SkuInfo { 15 | private Long skuId; 16 | private Long spuId; 17 | private String name; 18 | private BigDecimal price; 19 | private String mainImage; 20 | private String subImage; 21 | private Integer weight; 22 | private Long categoryId; 23 | private String categoryName; 24 | private Long brandId; 25 | private String brandName; 26 | private Long saleCount; 27 | private String spec; 28 | private Map specMap; 29 | 30 | /** 31 | * 是否有库存 32 | */ 33 | private Boolean hasStock; 34 | /** 35 | * 热度 36 | */ 37 | private Long hotScore; 38 | private String brandImg; 39 | } 40 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/entity/SeckillSession.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import lombok.Data; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/8/25 23:18 13 | */ 14 | @Data 15 | public class SeckillSession { 16 | @TableId(type = IdType.AUTO) 17 | private Long id; 18 | private String name; 19 | private Date startTime; 20 | private Date endTime; 21 | private Integer status; 22 | private Integer isDelete; 23 | private Date createTime; 24 | private Date updateTime; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/entity/SeckillSku.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import lombok.Data; 6 | 7 | import java.math.BigDecimal; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/8/25 23:25 13 | * id 14 | * promotion_id 15 | * session_id 16 | * sku_id 17 | * seckill_price 18 | * total_number 19 | * limit_number 20 | * sort 21 | * is_delete 22 | */ 23 | @Data 24 | public class SeckillSku { 25 | @TableId(type = IdType.AUTO) 26 | private Long id; 27 | private Long promotionId; 28 | private Long sessionId; 29 | private Long skuId; 30 | private BigDecimal seckillPrice; 31 | private Integer totalNumber; 32 | private Integer limitNumber; 33 | private Integer sort; 34 | private Integer isDelete; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/factory/ProductFeignFactory.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.factory; 2 | 3 | import com.shepherd.mall.seckill.feign.ProductService; 4 | import com.shepherd.mall.seckill.service.ProductFeignFallback; 5 | import feign.hystrix.FallbackFactory; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.stereotype.Component; 8 | 9 | import javax.annotation.Resource; 10 | 11 | /** 12 | * @author fjzheng 13 | * @version 1.0 14 | * @date 2021/9/1 15:56 15 | */ 16 | @Component 17 | @Slf4j 18 | public class ProductFeignFactory implements FallbackFactory { 19 | @Resource 20 | private ProductFeignFallback productFeignFallback; 21 | 22 | @Override 23 | public ProductService create(Throwable throwable) { 24 | log.info("执行ProductFeignFactory了"); 25 | throwable.printStackTrace(); 26 | log.error("异常信息:{}", throwable.getMessage()); 27 | return productFeignFallback; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /mall-seckill/src/main/java/com/shepherd/mall/seckill/service/ProductFeignFallback.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill.service; 2 | 3 | import com.oracle.tools.packager.Log; 4 | import com.shepherd.mall.seckill.dto.SkuInfo; 5 | import com.shepherd.mall.seckill.feign.ProductService; 6 | import com.shepherd.mall.vo.ResponseVO; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.stereotype.Component; 9 | 10 | /** 11 | * @author fjzheng 12 | * @version 1.0 13 | * @date 2021/9/1 15:07 14 | */ 15 | @Component 16 | @Slf4j 17 | public class ProductFeignFallback implements ProductService { 18 | @Override 19 | public ResponseVO getSku(Long skuId) { 20 | log.info("执行feign接口对应的fallback方法了"); 21 | ResponseVO responseVO = new ResponseVO(); 22 | responseVO.setCode(200); 23 | responseVO.setMsg("success"); 24 | SkuInfo skuInfo = new SkuInfo(); 25 | skuInfo.setBrandName("自定义"); 26 | skuInfo.setName("name"); 27 | responseVO.setData(skuInfo); 28 | return responseVO; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /mall-seckill/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: mall-seckill-service 4 | cloud: 5 | nacos: 6 | config: 7 | server-addr: 10.10.0.14:8848 -------------------------------------------------------------------------------- /mall-seckill/src/main/resources/mapper/SeckillSessionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mall-seckill/src/test/java/com/shepherd/mall/seckill/MallSeckillApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall.seckill; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class MallSeckillApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /mall-swagger/src/main/java/com/shepherd/mall/SwaggerProps.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.mall; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; /** * @author bofa1ex * @since 2020/6/15 */ @Data @Configuration @ConfigurationProperties(prefix = SwaggerProps.PREFIX) public class SwaggerProps { public static final String PREFIX = "swagger-web"; private String apiTitle; private String apiDescription; private String contactName; private String contactUrl; private String contactEmail; private String scanPackage; } -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/api/service/AddressService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.api.service; 2 | 3 | import com.shepherd.malluser.dto.AddressDTO; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/7/18 11:04 11 | */ 12 | public interface AddressService { 13 | 14 | List getAddressList(Long userId); 15 | 16 | AddressDTO getAddressDetail(Long id); 17 | } 18 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/api/service/AuthService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.api.service; 2 | 3 | import com.shepherd.malluser.dto.TokenResponse; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.PostMapping; 6 | import org.springframework.web.bind.annotation.RequestBody; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | 9 | import java.util.Map; 10 | 11 | @FeignClient("mall-auth-service") 12 | public interface AuthService { 13 | @PostMapping("/oauth/token") 14 | TokenResponse getToken(@RequestParam Map params); 15 | } 16 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/api/service/OauthService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.api.service; 2 | 3 | import com.shepherd.malluser.api.vo.LoginResponseVO; 4 | import com.shepherd.malluser.dto.UserDTO; 5 | 6 | import javax.servlet.http.HttpSession; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2021/6/29 14:34 12 | */ 13 | public interface OauthService { 14 | 15 | LoginResponseVO weibo(String code); 16 | 17 | void bind(Long thirdOauthId, String phoneNumber, HttpSession session); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/api/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.api.service; 2 | 3 | import com.shepherd.malluser.api.vo.UserVO; 4 | import com.shepherd.malluser.dto.TokenResponse; 5 | import com.shepherd.malluser.dto.UserDTO; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | import java.util.List; 10 | 11 | /** 12 | * @author fjzheng 13 | * @version 1.0 14 | * @date 2020/11/17 23:23 15 | */ 16 | public interface UserService { 17 | String getCode(String phoneNumber); 18 | 19 | TokenResponse login(UserVO userVO); 20 | 21 | void update(UserDTO userDTO); 22 | 23 | UserDTO status(HttpServletRequest request, HttpServletResponse response); 24 | 25 | List getList(); 26 | 27 | void logout(HttpServletRequest request, HttpServletResponse response); 28 | 29 | void retrievePassword(UserDTO userDTO); 30 | 31 | UserDTO loadUserByUsername(String name); 32 | 33 | UserDTO getUserInfoByPhoneNumber(String phoneNumber); 34 | 35 | Integer getUserIntegration(Long userId); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/api/vo/LoginResponseVO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.api.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author fjzheng 7 | * @version 1.0 8 | * @date 2021/6/29 15:57 9 | */ 10 | @Data 11 | public class LoginResponseVO { 12 | private Integer isFirstLogin; 13 | private String token; 14 | private String accessToken; 15 | private Long thirdOauthId; 16 | } 17 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/api/vo/LoginVO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.api.vo; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2020/7/15 22:35 10 | */ 11 | @Data 12 | public class LoginVO { 13 | 14 | @ApiModelProperty("用户ID") 15 | private Long userId; 16 | 17 | @ApiModelProperty("ticket,有效时间20s") 18 | private String ticket; 19 | 20 | @ApiModelProperty("token,有效时间2H") 21 | private String token; 22 | 23 | private Integer type; 24 | 25 | @ApiModelProperty("用户名") 26 | private String userName; 27 | 28 | @ApiModelProperty("电话") 29 | private String phone; 30 | 31 | @ApiModelProperty("邮箱") 32 | private String email; 33 | 34 | 35 | } -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/api/vo/UserVO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.api.vo; 2 | 3 | import lombok.Data; 4 | import org.springframework.format.annotation.DateTimeFormat; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2020/11/17 23:19 12 | */ 13 | @Data 14 | public class UserVO { 15 | private String userNo; 16 | private String password; 17 | private String nickname; 18 | private String email; 19 | private String phone; 20 | private Integer sex; 21 | private String headPhoto; 22 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 23 | private Date birthday; 24 | private Integer isDelete; 25 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 26 | private Date lastLoginTime; 27 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 28 | private Date createTime; 29 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 30 | private Date updateTime; 31 | private String code; 32 | private Integer type;//0 -> password 1 -> phone + code 33 | private Integer firstLogin; 34 | private Integer count; 35 | private String ticket; 36 | private String token; 37 | 38 | private String username; 39 | } 40 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/constant/Constant.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.constant; 2 | 3 | public interface Constant { 4 | Integer PASSWORD_TYPE = 0; 5 | Integer PHONE_TYPE = 1; 6 | String CLIENT_ID = "mall-user"; 7 | String CLIENT_SECRET = "admin"; 8 | String GRANT_PASSWORD = "password"; 9 | String GRANT_PHONE = "phone"; 10 | Integer THIRD_TYPE_WEIBO = 0; 11 | 12 | Integer IS_NOT_FIRST_LOGIN = 0; 13 | Integer IS_FIRST_LOGIN = 1; 14 | } 15 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/dao/AddressDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.malluser.entity.Address; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/7/18 11:02 10 | */ 11 | public interface AddressDAO extends BaseMapper
{ 12 | } 13 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/dao/ThirdOauthDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.malluser.entity.ThirdOauth; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/6/29 14:16 10 | */ 11 | public interface ThirdOauthDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/dao/UserDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.malluser.entity.User; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2020/11/17 23:40 10 | */ 11 | public interface UserDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/dto/AddressDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.dto; 2 | 3 | import com.shepherd.malluser.entity.Address; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2021/7/18 11:05 12 | */ 13 | @Data 14 | public class AddressDTO extends Address implements Serializable { 15 | } 16 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/dto/ThirdOauthDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.dto; 2 | 3 | import com.shepherd.malluser.entity.ThirdOauth; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/6/29 14:24 10 | */ 11 | @Data 12 | public class ThirdOauthDTO extends ThirdOauth { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/dto/TokenResponse.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.dto; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class TokenResponse { 7 | private String access_token; 8 | private String token_type; 9 | private String refresh_token; 10 | private Long expires_in; 11 | private String scope; 12 | private Long id; 13 | private String client_id; 14 | } 15 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/dto/UserDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.dto; 2 | 3 | import com.shepherd.malluser.entity.User; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2020/11/17 23:19 10 | */ 11 | @Data 12 | public class UserDTO extends User { 13 | private String code; 14 | private Integer type; 15 | private Integer firstLogin; 16 | private String ticket; 17 | private String token; 18 | private String username; 19 | private String clientId; 20 | } -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/dto/WeiboUser.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.dto; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author fjzheng 7 | * @version 1.0 8 | * @date 2021/6/28 16:25 9 | */ 10 | @Data 11 | public class WeiboUser { 12 | 13 | private String access_token; 14 | 15 | private String remind_in; 16 | 17 | private long expires_in; 18 | 19 | private String uid; 20 | 21 | private String isRealName; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/entity/Address.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Builder; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | /** 11 | * @author fjzheng 12 | * @version 1.0 13 | * @date 2021/7/18 10:56 14 | */ 15 | @Data 16 | @Builder 17 | @NoArgsConstructor 18 | @AllArgsConstructor 19 | public class Address { 20 | @TableId(type = IdType.AUTO) 21 | private Long id; 22 | private Long userId; 23 | private String name; 24 | private String mobile; 25 | private String postcode; 26 | private String province; 27 | private String city; 28 | private String region; 29 | private String detailAddress; 30 | private Integer isDefault; 31 | private Integer isDelete; 32 | } 33 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/entity/ThirdOauth.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import lombok.Data; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/6/29 14:12 13 | */ 14 | @Data 15 | public class ThirdOauth { 16 | @TableId(type = IdType.AUTO) 17 | private Long id; 18 | private Long userId; 19 | private Long outId; 20 | private Integer type; 21 | private String accessToken; 22 | private Date expireTime; 23 | private Date createTime; 24 | private Date updateTime; 25 | } 26 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/enums/ErrorCodeEnum.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * @author jfWu 7 | * @version 1.0 8 | * @date 2019/11/18 11:07 9 | */ 10 | @Getter 11 | public enum ErrorCodeEnum { 12 | 13 | SEND_MESSAGE_ERROR("SEND MESSAGE ERROR", "发送短信失败,请稍后重试"), 14 | 15 | VERIFICATION_PHONE_ERROR("VERIFICATION ERROR", "验证发生错误,请确认是否是当前手机号获取的验证码"), 16 | 17 | VERIFICATION_CODE_ERROR("VERIFICATION CODE ERROR", "验证码不正确或已过期,请重新输入"), 18 | 19 | USER_NO_NOT_EXIST_ERROR("USER NOT EXIST ERROR", "用户不存在,请重新确认再输入"), 20 | 21 | PASSWORD_ERROR("PASSWORD ERROR", "密码错误,请重新输入"), 22 | 23 | PHONE_NOT_REGISTER("PHONE NOT REGISTER", "该手机号尚未注册使用过"); 24 | 25 | private String code; 26 | private String message; 27 | 28 | ErrorCodeEnum(String code, String message) { 29 | this.code = code; 30 | this.message = message; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/interceptor/UserWebConfig.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.interceptor; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | import javax.annotation.Resource; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/7/16 15:48 13 | */ 14 | @Configuration 15 | public class UserWebConfig implements WebMvcConfigurer { 16 | @Resource 17 | private AuthInterceptor authInterceptor; 18 | 19 | @Override 20 | public void addInterceptors(InterceptorRegistry registry) { 21 | registry.addInterceptor(authInterceptor).excludePathPatterns("/api/mall/user/login"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/DefaultFunctionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2021/12/17 17:57 7 | */ 8 | public class DefaultFunctionServiceImpl implements IFunctionService { 9 | 10 | private final ParseFunctionFactory parseFunctionFactory; 11 | 12 | public DefaultFunctionServiceImpl(ParseFunctionFactory parseFunctionFactory) { 13 | this.parseFunctionFactory = parseFunctionFactory; 14 | } 15 | 16 | @Override 17 | public String apply(String functionName, String value) { 18 | IParseFunction function = parseFunctionFactory.getFunction(functionName); 19 | if (function == null) { 20 | return value; 21 | } 22 | return function.apply(value); 23 | } 24 | 25 | @Override 26 | public boolean beforeFunction(String functionName) { 27 | return parseFunctionFactory.isBeforeFunction(functionName); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/DistributeExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2021/12/16 17:52 12 | */ 13 | @Target(ElementType.METHOD) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface DistributeExceptionHandler { 16 | String attachmentId(); 17 | } 18 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/ExpressionRootObject.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2021/12/16 17:59 7 | */ 8 | public class ExpressionRootObject { 9 | private final Object object; 10 | private final Object[] args; 11 | 12 | public ExpressionRootObject(Object object, Object[] args) { 13 | this.object = object; 14 | this.args = args; 15 | } 16 | 17 | public Object getObject() { 18 | return object; 19 | } 20 | 21 | public Object[] getArgs() { 22 | return args; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/IFunctionService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2021/12/20 17:51 7 | */ 8 | public interface IFunctionService { 9 | String apply(String functionName, String value); 10 | boolean beforeFunction(String functionName); 11 | } 12 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/IParseFunction.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2021/12/17 17:55 7 | */ 8 | public interface IParseFunction { 9 | 10 | default boolean executeBefore(){ 11 | return false; 12 | } 13 | 14 | String functionName(); 15 | 16 | String apply(String value); 17 | } 18 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/LogRecordContext.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel; 2 | 3 | import java.util.Map; 4 | import java.util.Stack; 5 | import java.util.concurrent.ConcurrentHashMap; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/12/31 17:13 11 | */ 12 | public class LogRecordContext { 13 | 14 | private static final InheritableThreadLocal>> variableMapStack = new InheritableThreadLocal<>(); 15 | 16 | private static final Map varMap = new ConcurrentHashMap<>(); 17 | 18 | public static void putVariable(String key, Object value) { 19 | varMap.put(key, value); 20 | } 21 | 22 | public static Map getVariables() { 23 | return varMap; 24 | } 25 | 26 | //其他省略.... 27 | } 28 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/LogRecordEvaluationContext.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel; 2 | 3 | import org.springframework.context.expression.MethodBasedEvaluationContext; 4 | import org.springframework.core.ParameterNameDiscoverer; 5 | 6 | import java.lang.reflect.Method; 7 | import java.util.Map; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/12/31 17:10 13 | */ 14 | public class LogRecordEvaluationContext extends MethodBasedEvaluationContext { 15 | 16 | public LogRecordEvaluationContext(Object rootObject, Method method, Object[] arguments, 17 | ParameterNameDiscoverer parameterNameDiscoverer, Object ret, String errorMsg) { 18 | //把方法的参数都放到 SpEL 解析的 RootObject 中 19 | super(rootObject, method, arguments, parameterNameDiscoverer); 20 | //把 LogRecordContext 中的变量都放到 RootObject 中 21 | Map variables = LogRecordContext.getVariables(); 22 | if (variables != null && variables.size() > 0) { 23 | for (Map.Entry entry : variables.entrySet()) { 24 | setVariable(entry.getKey(), entry.getValue()); 25 | } 26 | } 27 | //把方法的返回值和 ErrorMsg 都放到 RootObject 中 28 | setVariable("_ret", ret); 29 | setVariable("_errorMsg", errorMsg); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/LogRecordExpressionEvaluator.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel; 2 | 3 | import org.springframework.context.expression.AnnotatedElementKey; 4 | import org.springframework.context.expression.CachedExpressionEvaluator; 5 | import org.springframework.expression.EvaluationContext; 6 | import org.springframework.expression.Expression; 7 | 8 | import java.lang.reflect.Method; 9 | import java.util.Map; 10 | import java.util.concurrent.ConcurrentHashMap; 11 | 12 | /** 13 | * @author fjzheng 14 | * @version 1.0 15 | * @date 2021/12/16 17:38 16 | */ 17 | public class LogRecordExpressionEvaluator extends CachedExpressionEvaluator { 18 | private Map expressionCache = new ConcurrentHashMap<>(64); 19 | 20 | private final Map targetMethodCache = new ConcurrentHashMap<>(64); 21 | 22 | public String parseExpression(String conditionExpression, AnnotatedElementKey methodKey, EvaluationContext evalContext) { 23 | return getExpression(this.expressionCache, methodKey, conditionExpression).getValue(evalContext, String.class); 24 | 25 | } 26 | } -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/LogRecordValueParser.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2021/12/20 18:12 7 | */ 8 | public class LogRecordValueParser { 9 | } 10 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/ParseFunctionFactory.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.springframework.util.CollectionUtils; 5 | 6 | import java.util.HashMap; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | /** 11 | * @author fjzheng 12 | * @version 1.0 13 | * @date 2021/12/17 17:56 14 | */ 15 | public class ParseFunctionFactory { 16 | private Map allFunctionMap; 17 | 18 | public ParseFunctionFactory(List parseFunctions) { 19 | if (CollectionUtils.isEmpty(parseFunctions)) { 20 | return; 21 | } 22 | allFunctionMap = new HashMap<>(); 23 | for (IParseFunction parseFunction : parseFunctions) { 24 | if (StringUtils.isEmpty(parseFunction.functionName())) { 25 | continue; 26 | } 27 | allFunctionMap.put(parseFunction.functionName(), parseFunction); 28 | } 29 | } 30 | 31 | public IParseFunction getFunction(String functionName) { 32 | return allFunctionMap.get(functionName); 33 | } 34 | 35 | public boolean isBeforeFunction(String functionName) { 36 | return allFunctionMap.get(functionName) != null && allFunctionMap.get(functionName).executeBefore(); 37 | } 38 | } -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/TestExpression.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel; 2 | 3 | 4 | import com.shepherd.malluser.entity.Address; 5 | import com.shepherd.malluser.spel.aspectj.LogRecord; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2021/12/16 17:52 12 | */ 13 | @Component 14 | public class TestExpression { 15 | @DistributeExceptionHandler(attachmentId = "#address.id") 16 | public void test(Address address){ 17 | String city = address.getCity(); 18 | int length = city.length(); 19 | System.out.println(address); 20 | } 21 | 22 | public Long getAddressId(Address address) { 23 | return address.getId(); 24 | } 25 | 26 | @LogRecord(success = "成功了", fail = "失败了", bizNo = "#address.id", detail = "修改了订单的配送员:从“{queryOldUser{#request.deliveryOrderNo()}}”, 修改到“{deveryUser{#request.userId}}") 27 | public void testAspectj(Address address) { 28 | address.setIsDefault(1); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/aspectj/LogAspect.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel.aspectj; 2 | 3 | import org.aspectj.lang.ProceedingJoinPoint; 4 | import org.aspectj.lang.annotation.Around; 5 | import org.aspectj.lang.annotation.Aspect; 6 | import org.aspectj.lang.annotation.Pointcut; 7 | import org.aspectj.lang.reflect.MethodSignature; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.lang.reflect.Method; 11 | 12 | /** 13 | * @author fjzheng 14 | * @version 1.0 15 | * @date 2021/12/20 18:28 16 | */ 17 | @Component 18 | @Aspect 19 | public class LogAspect { 20 | 21 | @Pointcut("@annotation(com.shepherd.malluser.spel.aspectj.LogRecord)") 22 | public void logRecordPointCut() { 23 | 24 | } 25 | 26 | @Around("logRecordPointCut()") 27 | public Object handleLogRecord(ProceedingJoinPoint pjp) throws Throwable { 28 | Object[] args = pjp.getArgs(); 29 | Object target = pjp.getTarget(); 30 | MethodSignature signature = (MethodSignature) pjp.getSignature(); 31 | Method method = signature.getMethod(); 32 | LogRecord logRecord = method.getAnnotation(LogRecord.class); 33 | String bizNo = logRecord.bizNo(); 34 | String detail = logRecord.detail(); 35 | return pjp.proceed(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/aspectj/LogRecord.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel.aspectj; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author fjzheng 7 | * @version 1.0 8 | * @date 2021/12/20 18:27 9 | */ 10 | @Target({ElementType.METHOD}) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Inherited 13 | @Documented 14 | public @interface LogRecord { 15 | String success(); 16 | 17 | String fail() default ""; 18 | 19 | String operator() default ""; 20 | 21 | String bizNo(); 22 | 23 | String category() default ""; 24 | 25 | String detail() default ""; 26 | 27 | String condition() default ""; 28 | } -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/aspectj/LogRecordOps.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel.aspectj; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author fjzheng 7 | * @version 1.0 8 | * @date 2021/12/20 18:39 9 | */ 10 | @Data 11 | public class LogRecordOps { 12 | private String attr; 13 | private String value; 14 | } 15 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/spel/getAddressMobile.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2021/12/31 17:38 7 | */ 8 | 9 | public class getAddressMobile implements IParseFunction{ 10 | 11 | @Override 12 | public boolean executeBefore() { 13 | return true; 14 | } 15 | 16 | @Override 17 | public String functionName() { 18 | return "getAddressMobile"; 19 | } 20 | 21 | @Override 22 | public String apply(String value) { 23 | return "178168759339"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/test/CarRunServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.test; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2022/2/23 16:58 7 | */ 8 | public class CarRunServiceImpl implements RunService { 9 | @Override 10 | public void run() { 11 | System.out.println("汽车,dididi"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/test/MyInitBean.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.test; 2 | 3 | import org.springframework.beans.factory.InitializingBean; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | import javax.annotation.Resource; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2022/2/23 16:59 13 | */ 14 | @Component 15 | public class MyInitBean implements InitializingBean { 16 | @Resource 17 | private RunService runService; 18 | 19 | @Override 20 | public void afterPropertiesSet() throws Exception { 21 | runService.run(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/test/RunService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.test; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2022/2/23 16:57 7 | */ 8 | public interface RunService { 9 | void run(); 10 | } 11 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/test/TrainRunServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.test; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2022/2/23 16:59 7 | */ 8 | public class TrainRunServiceImpl implements RunService { 9 | @Override 10 | public void run() { 11 | System.out.println("开火车,wuwuwuwuwu"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/utils/UserUtil.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.utils; 2 | 3 | import com.shepherd.mall.vo.LoginVO; 4 | import com.shepherd.malluser.interceptor.AuthInterceptor; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/7/18 11:44 10 | */ 11 | public class UserUtil { 12 | 13 | 14 | public static LoginVO currentUser() { 15 | return AuthInterceptor.localUser.get(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /mall-user-service/src/main/java/com/shepherd/malluser/web/OAuth2Controller.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.web; 2 | 3 | import com.shepherd.malluser.api.service.OauthService; 4 | import com.shepherd.malluser.api.vo.LoginResponseVO; 5 | import io.swagger.annotations.Api; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | import javax.annotation.Resource; 10 | import javax.servlet.http.HttpSession; 11 | 12 | /** 13 | * @author fjzheng 14 | * @version 1.0 15 | * @date 2021/6/28 16:27 16 | */ 17 | @RestController 18 | @Api("第三方登录接口") 19 | @RequestMapping("/api/mall/oauth2") 20 | @Slf4j 21 | public class OAuth2Controller { 22 | 23 | @Resource 24 | private OauthService oauthService; 25 | 26 | @GetMapping(value = "/weibo/success") 27 | public LoginResponseVO weibo(@RequestParam("code") String code, HttpSession session) throws Exception { 28 | LoginResponseVO loginResponseVO = oauthService.weibo(code); 29 | return loginResponseVO; 30 | } 31 | 32 | 33 | @GetMapping(value = "/weibo/bind/{thirdOauthId}") 34 | public void bind(@PathVariable("thirdOauthId") Long thirdOauthId, @RequestParam("phoneNumber") String phoneNumber, HttpSession session) { 35 | oauthService.bind(thirdOauthId, phoneNumber, session); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: mall-user-service 4 | cloud: 5 | nacos: 6 | config: 7 | server-addr: 10.10.0.14:8848 -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/mapper/AddressMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/mapper/ThirdOauthMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/4de5019d2404d347897dee637895d02b_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/4de5019d2404d347897dee637895d02b_06.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/4de5019d2404d347897dee637895d02b_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/4de5019d2404d347897dee637895d02b_11.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/4de5019d2404d347897dee637895d02b_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/4de5019d2404d347897dee637895d02b_15.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/4de5019d2404d347897dee637895d02b_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/4de5019d2404d347897dee637895d02b_17.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/4de5019d2404d347897dee637895d02b_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/4de5019d2404d347897dee637895d02b_19.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/4de5019d2404d347897dee637895d02b_25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/4de5019d2404d347897dee637895d02b_25.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/5731485aN1134b4f0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/5731485aN1134b4f0.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/a65a18e877a16246a92e1b755bd88a03_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/a65a18e877a16246a92e1b755bd88a03_03.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/a65a18e877a16246a92e1b755bd88a03_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/a65a18e877a16246a92e1b755bd88a03_06.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/f760f80838eafa4ba85463ce6ce1298d_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/f760f80838eafa4ba85463ce6ce1298d_03.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/grow1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/grow1.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/grow2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/grow2.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/img11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/img11.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/img22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/img22.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/logo.jpg -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/phone-orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/phone-orange.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/pwd-icons-new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/pwd-icons-new.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/qq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/qq.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/show.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/user_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/user_03.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/user_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/user_06.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/weibo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/weibo.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/login/JD_img/weixin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/login/JD_img/weixin.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/bootStrap/bootstrap/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/bootStrap/bootstrap/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/bootStrap/bootstrap/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/bootStrap/bootstrap/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/bootStrap/bootstrap/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/bootStrap/bootstrap/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/bootStrap/bootstrap/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/bootStrap/bootstrap/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/4de5019d2404d347897dee637895d02b_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/4de5019d2404d347897dee637895d02b_06.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/4de5019d2404d347897dee637895d02b_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/4de5019d2404d347897dee637895d02b_11.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/4de5019d2404d347897dee637895d02b_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/4de5019d2404d347897dee637895d02b_15.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/4de5019d2404d347897dee637895d02b_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/4de5019d2404d347897dee637895d02b_17.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/4de5019d2404d347897dee637895d02b_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/4de5019d2404d347897dee637895d02b_19.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/4de5019d2404d347897dee637895d02b_25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/4de5019d2404d347897dee637895d02b_25.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/5731485aN1134b4f0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/5731485aN1134b4f0.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/a65a18e877a16246a92e1b755bd88a03_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/a65a18e877a16246a92e1b755bd88a03_03.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/a65a18e877a16246a92e1b755bd88a03_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/a65a18e877a16246a92e1b755bd88a03_06.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/f760f80838eafa4ba85463ce6ce1298d_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/f760f80838eafa4ba85463ce6ce1298d_03.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/icon.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/logo.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/logo1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/logo1.jpg -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/phone-orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/phone-orange.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/qq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/qq.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/show.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/user_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/user_03.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/user_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/user_06.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/img/weixin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/img/weixin.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/js/easyUI/images/ui-icons_444444_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/js/easyUI/images/ui-icons_444444_256x240.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/js/easyUI/images/ui-icons_555555_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/js/easyUI/images/ui-icons_555555_256x240.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/js/easyUI/images/ui-icons_777620_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/js/easyUI/images/ui-icons_777620_256x240.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/js/easyUI/images/ui-icons_777777_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/js/easyUI/images/ui-icons_777777_256x240.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/js/easyUI/images/ui-icons_cc0000_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/js/easyUI/images/ui-icons_cc0000_256x240.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/js/easyUI/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShepherdZFJ/shepherd-mall/c56b96727055686b55a81cb0e0c5832b91cb712c/mall-user-service/src/main/resources/static/static/reg/js/easyUI/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/js/jQuery/jquery.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 3 | var parts = document.location.search.slice( 1 ).split( "&" ), 4 | length = parts.length, 5 | scripts = document.getElementsByTagName("script"), 6 | src = scripts[ scripts.length - 1].src, 7 | i = 0, 8 | current, 9 | version = "3.1.1", 10 | file = "http://code.jquery.com/jquery-git.js"; 11 | 12 | for ( ; i < length; i++ ) { 13 | current = parts[ i ].split( "=" ); 14 | if ( current[ 0 ] === "jquery" ) { 15 | version = current[ 1 ]; 16 | break; 17 | } 18 | } 19 | 20 | if (version != "git") { 21 | file = src.replace(/jquery\.js$/, "jquery-" + version + ".js"); 22 | } 23 | 24 | 25 | document.write( "" ); 26 | 27 | })(); 28 | -------------------------------------------------------------------------------- /mall-user-service/src/main/resources/static/static/reg/js/jQuery/jquery.mockjax.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 3 | var parts = document.location.search.slice( 1 ).split( "&" ), 4 | length = parts.length, 5 | scripts = document.getElementsByTagName("script"), 6 | src = scripts[ scripts.length - 1].src, 7 | i = 0, 8 | current, 9 | version = "2.2.1", 10 | file = "../lib/jquery.mockjax-2.2.1.js"; 11 | 12 | for ( ; i < length; i++ ) { 13 | current = parts[ i ].split( "=" ); 14 | if ( current[ 0 ] === "jquery.mockjax" ) { 15 | version = current[ 1 ]; 16 | break; 17 | } 18 | } 19 | 20 | if (version != "git" || version < "3") { 21 | file = src.replace(/jquery.mockjax\.js$/, "jquery.mockjax-" + version + ".js"); 22 | } 23 | 24 | 25 | document.write( "" ); 26 | 27 | })(); 28 | -------------------------------------------------------------------------------- /mall-user-service/src/test/java/com/shepherd/malluser/RedisSentinelTest.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.data.redis.core.RedisTemplate; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | import javax.annotation.Resource; 11 | import java.util.Date; 12 | import java.util.concurrent.TimeUnit; 13 | 14 | /** 15 | * @author fjzheng 16 | * @version 1.0 17 | * @date 2022/2/21 17:40 18 | */ 19 | @SpringBootTest 20 | @RunWith(SpringRunner.class) 21 | public class RedisSentinelTest { 22 | 23 | 24 | @Resource 25 | private RedisTemplate redisTemplate; 26 | 27 | @Test 28 | public void test001() throws Exception { 29 | while (true) { 30 | String key = "time:" + new Date().getTime(); 31 | redisTemplate.opsForValue().set(key, new Date().getTime(),5, TimeUnit.MINUTES); 32 | TimeUnit.SECONDS.sleep(5); 33 | System.out.println(redisTemplate.opsForValue().get(key)); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /mall-user-service/src/test/java/com/shepherd/malluser/service/impl/AddressServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.service.impl; 2 | 3 | import com.shepherd.malluser.dto.AddressDTO; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | import javax.annotation.Resource; 10 | 11 | import java.util.List; 12 | 13 | import static org.junit.Assert.*; 14 | 15 | /** 16 | * @author fjzheng 17 | * @version 1.0 18 | * @date 2021/12/13 14:39 19 | */ 20 | @SpringBootTest 21 | @RunWith(SpringRunner.class) 22 | public class AddressServiceImplTest { 23 | @Resource 24 | private AddressServiceImpl addressService; 25 | 26 | @Test 27 | public void test() { 28 | List addressDTOList = addressService.testSpringCache(1l); 29 | System.out.println(addressDTOList); 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /mall-user-service/src/test/java/com/shepherd/malluser/spel/TestExpressionTest.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.malluser.spel; 2 | 3 | import com.shepherd.malluser.entity.Address; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | import javax.annotation.Resource; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * @author fjzheng 15 | * @version 1.0 16 | * @date 2022/1/5 16:42 17 | */ 18 | @SpringBootTest 19 | @RunWith(SpringRunner.class) 20 | public class TestExpressionTest { 21 | @Resource 22 | private TestExpression testExpression; 23 | @Test 24 | public void test() { 25 | Address address = Address.builder().id(10l).province("浙江").detailAddress("余杭区未来科技城").build(); 26 | testExpression.test(address); 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/MallWarehouseServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.amqp.rabbit.annotation.EnableRabbit; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 8 | import org.springframework.cloud.openfeign.EnableFeignClients; 9 | import org.springframework.context.annotation.ComponentScan; 10 | 11 | @SpringBootApplication 12 | @EnableDiscoveryClient 13 | @MapperScan(basePackages = "com.shepherd.ware.dao") 14 | @ComponentScan(basePackages = {"com.shepherd"}) 15 | @EnableFeignClients(basePackages = "com.shepherd.ware") 16 | @EnableRabbit 17 | public class MallWarehouseServiceApplication { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(MallWarehouseServiceApplication.class, args); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/api/controller/WareSkuController.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.api.controller; 2 | 3 | import com.shepherd.mall.annotation.ResponseResultBody; 4 | import com.shepherd.ware.api.service.WareSkuService; 5 | import com.shepherd.ware.dto.Order; 6 | import com.shepherd.ware.dto.WareSkuDTO; 7 | import io.swagger.annotations.Api; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.annotation.Resource; 12 | 13 | /** 14 | * @author fjzheng 15 | * @version 1.0 16 | * @date 2021/7/26 10:56 17 | */ 18 | @RestController 19 | @RequestMapping("/api/mall/ware/sku") 20 | @Api(tags = "仓库相关接口") 21 | @ResponseResultBody 22 | public class WareSkuController { 23 | @Resource 24 | private WareSkuService wareSkuService; 25 | 26 | @GetMapping() 27 | @ApiOperation("查询仓库sku商品详情") 28 | public WareSkuDTO getWareSkuDetail(@RequestParam("wareId") Long wareId, @RequestParam("skuId") Long skuId) { 29 | WareSkuDTO wareSkuDTO = wareSkuService.getWareSkuDetail(wareId, skuId); 30 | return wareSkuDTO; 31 | } 32 | 33 | @PostMapping("/stock/decrease") 34 | public void decreaseStock(@RequestBody Order order) { 35 | wareSkuService.decreaseStock(order); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/api/service/WareOrderTaskItemService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.api.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.shepherd.ware.entity.WareOrderTask; 5 | import com.shepherd.ware.entity.WareOrderTaskItem; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/8/11 16:40 11 | */ 12 | public interface WareOrderTaskItemService extends IService { 13 | } 14 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/api/service/WareSkuService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.api.service; 2 | 3 | import com.shepherd.ware.dto.Order; 4 | import com.shepherd.ware.dto.WareInfoDTO; 5 | import com.shepherd.ware.dto.WareOrderTaskDTO; 6 | import com.shepherd.ware.dto.WareSkuDTO; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author fjzheng 12 | * @version 1.0 13 | * @date 2021/7/26 11:00 14 | */ 15 | public interface WareSkuService { 16 | 17 | WareSkuDTO getWareSkuDetail(Long wareId, Long skuId); 18 | 19 | List getHasStockWare(Long skuId, Integer number); 20 | 21 | void decreaseStock(Order order); 22 | 23 | void releaseStock(WareOrderTaskDTO wareOrderTaskDTO); 24 | 25 | void releaseStock(Order order); 26 | } 27 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/constant/OrderConstant.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.constant; 2 | 3 | /** 4 | * @author fjzheng 5 | * @version 1.0 6 | * @date 2021/8/12 17:18 7 | */ 8 | public interface OrderConstant { 9 | Integer ORDER_STATUS_NEW = 0; 10 | Integer ORDER_STATUS_IS_PAY = 1; 11 | Integer ORDER_STATUS_CANCEL = 2; 12 | } 13 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/dao/WareInfoDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.ware.entity.WareInfo; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/7/26 15:07 10 | */ 11 | public interface WareInfoDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/dao/WareOrderTaskDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.ware.entity.WareOrderTask; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/8/11 16:35 10 | */ 11 | public interface WareOrderTaskDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/dao/WareOrderTaskItemDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.ware.entity.WareOrderTaskItem; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/8/11 16:38 10 | */ 11 | public interface WareOrderTaskItemDAO extends BaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/dao/WareSkuDAO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.dao; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shepherd.ware.entity.WareSku; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | /** 8 | * @author fjzheng 9 | * @version 1.0 10 | * @date 2021/7/26 10:53 11 | */ 12 | public interface WareSkuDAO extends BaseMapper { 13 | 14 | 15 | Integer decreaseStock(@Param("wareId") Long wareId, @Param("skuId") Long skuId, @Param("number") Integer number); 16 | 17 | Integer increaseStock(@Param("wareId") Long wareId, @Param("skuId") Long skuId, @Param("number") Integer number); 18 | } 19 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/dto/Order.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/7/26 15:13 13 | */ 14 | @Data 15 | public class Order { 16 | private Long id; 17 | private Long userId; 18 | private String orderNo; 19 | private Integer totalNum; 20 | private BigDecimal totalAmount; 21 | private BigDecimal preAmount; 22 | private BigDecimal postage; 23 | private BigDecimal payAmount; 24 | private Integer payType; 25 | private Date createTime; 26 | private Date updateTime; 27 | private Date payTime; 28 | private Date deliveryTime; 29 | private Date endTime; 30 | private Date closeTime; 31 | private String deliveryCompanyName; 32 | private String deliveryNo; 33 | private String orderRemark; 34 | private String receiverName; 35 | private String receiverMobile; 36 | private String receiverProvince; 37 | private String receiverCity; 38 | private String receiverRegion; 39 | private String receiverDetailAddress; 40 | private Integer sourceType; 41 | private String transactionId; 42 | private Integer status; 43 | private Integer isDelete; 44 | private Long orderId; 45 | List orderItemList; 46 | } 47 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/dto/OrderItem.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.dto; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author fjzheng 7 | * @version 1.0 8 | * @date 2021/7/26 15:14 9 | */ 10 | @Data 11 | public class OrderItem { 12 | private Long skuId; 13 | private String skuName; 14 | private Integer number; 15 | } 16 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/dto/WareInfoDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.dto; 2 | 3 | import com.shepherd.ware.entity.WareInfo; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/7/26 14:53 10 | */ 11 | @Data 12 | public class WareInfoDTO extends WareInfo { 13 | private Long wareId; 14 | } 15 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/dto/WareOrderTaskDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.dto; 2 | 3 | import com.shepherd.ware.entity.WareOrderTask; 4 | import com.shepherd.ware.entity.WareOrderTaskItem; 5 | import lombok.Data; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/8/11 17:27 13 | */ 14 | @Data 15 | public class WareOrderTaskDTO extends WareOrderTask { 16 | private List wareOrderTaskItems; 17 | } 18 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/dto/WareSkuDTO.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.dto; 2 | 3 | import com.shepherd.ware.entity.WareSku; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author fjzheng 8 | * @version 1.0 9 | * @date 2021/7/26 11:06 10 | */ 11 | @Data 12 | public class WareSkuDTO extends WareSku { 13 | } 14 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/entity/WareInfo.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import lombok.Data; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/7/26 14:51 13 | */ 14 | @Data 15 | public class WareInfo { 16 | @TableId(type = IdType.AUTO) 17 | private Long id; 18 | private String name; 19 | private String areaNo; 20 | private Integer isDelete; 21 | private Date createTime; 22 | private Date updateTime; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/entity/WareOrderTaskItem.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.entity; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * @author fjzheng 12 | * @version 1.0 13 | * @date 2021/8/11 15:07 14 | */ 15 | @Data 16 | @Builder 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | public class WareOrderTaskItem { 20 | /** 21 | * id 22 | * sku_id 23 | * sku_name 24 | * sku_num 25 | * task_id 26 | * ware_id 27 | * lock_status 28 | * create_time 29 | * update_time 30 | * is_delete 31 | */ 32 | private Long id; 33 | private Long skuId; 34 | private String skuName; 35 | private Integer skuNum; 36 | private Long taskId; 37 | private Long wareId; 38 | private Integer status; 39 | private Date createTime; 40 | private Date updateTime; 41 | private Integer isDelete; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/entity/WareSku.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import lombok.Data; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/7/26 10:48 13 | */ 14 | @Data 15 | public class WareSku { 16 | @TableId(type = IdType.AUTO) 17 | private Long id; 18 | private Long wareId; 19 | private Long skuId; 20 | private Integer stock; 21 | private String skuName; 22 | private Integer isDelete; 23 | private Date createTime; 24 | private Date updateTime; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/feign/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.feign; 2 | 3 | import com.shepherd.mall.vo.ResponseVO; 4 | import com.shepherd.ware.dto.Order; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/8/12 16:59 13 | */ 14 | @FeignClient(name = "${micro-server.mall-order}", path = "/api/mall/order") 15 | public interface OrderService { 16 | 17 | @GetMapping("/orderNo/{orderNo}") 18 | ResponseVO getOrderByOrderNo(@PathVariable("orderNo") String orderNo); 19 | } 20 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/service/impl/WareOrderTaskItemServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.shepherd.ware.api.service.WareOrderTaskItemService; 5 | import com.shepherd.ware.dao.WareOrderTaskItemDAO; 6 | import com.shepherd.ware.entity.WareOrderTaskItem; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author fjzheng 11 | * @version 1.0 12 | * @date 2021/8/11 16:48 13 | */ 14 | @Service 15 | public class WareOrderTaskItemServiceImpl extends ServiceImpl implements WareOrderTaskItemService { 16 | } 17 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/java/com/shepherd/ware/utils/Test.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware.utils; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * @author fjzheng 10 | * @version 1.0 11 | * @date 2021/8/16 13:53 12 | */ 13 | @Data 14 | @Builder 15 | public class Test { 16 | private Long id; 17 | private String name; 18 | private String no; 19 | private Date date; 20 | private String uuid; 21 | private String str; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /mall-warehouse/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: mall-warehouse-service 4 | cloud: 5 | nacos: 6 | config: 7 | server-addr: 10.10.0.14:8848 -------------------------------------------------------------------------------- /mall-warehouse/src/main/resources/mapper/WareSkuMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | update ware_sku set stock = stock - #{number} where ware_id=#{wareId} and sku_id=#{skuId} and stock >=#{number} 7 | 8 | 9 | 10 | update ware_sku set stock = stock + #{number} where ware_id=#{wareId} and sku_id=#{skuId} and stock >=#{number} 11 | 12 | 13 | -------------------------------------------------------------------------------- /mall-warehouse/src/test/java/com/shepherd/ware/MallWarehouseServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.shepherd.ware; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class MallWarehouseServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | --------------------------------------------------------------------------------