├── common ├── foodie-cloud-common │ └── src │ │ └── main │ │ └── java │ │ ├── org │ │ ├── .gitignore │ │ └── n3r │ │ │ └── idworker │ │ │ ├── WorkerIdStrategy.java │ │ │ ├── InvalidSystemClock.java │ │ │ ├── RandomCodeStrategy.java │ │ │ ├── Test.java │ │ │ ├── DayCode.java │ │ │ ├── Id.java │ │ │ ├── Code.java │ │ │ ├── strategy │ │ │ └── DayPrefixRandomCodeStrategy.java │ │ │ ├── utils │ │ │ ├── Ip.java │ │ │ ├── IPv4Utils.java │ │ │ └── Props.java │ │ │ └── Sid.java │ │ └── com │ │ └── pacee1 │ │ ├── utils │ │ ├── MD5Utils.java │ │ ├── MobileEmailUtils.java │ │ └── JsonUtils.java │ │ └── my │ │ └── mapper │ │ └── MyMapper.java ├── foodie-cloud-shared-pojo │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── pacee1 │ │ │ ├── enums │ │ │ ├── YesOrNo.java │ │ │ ├── PayMethod.java │ │ │ ├── Sex.java │ │ │ ├── CommentLevel.java │ │ │ └── OrderStatusEnum.java │ │ │ └── pojo │ │ │ ├── PagedGridResult.java │ │ │ └── ShopcartBO.java │ └── pom.xml └── foodie-cloud-web-components │ ├── src │ └── main │ │ └── java │ │ └── com │ │ └── pacee1 │ │ ├── config │ │ ├── TomcatConfig.java │ │ ├── MvcConfig.java │ │ ├── CorsConfig.java │ │ └── Swagger2.java │ │ └── aspect │ │ └── ServiceLogAspect.java │ └── pom.xml ├── platform ├── config-server │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── bootstrap.yml │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── pacee1 │ │ │ └── ConfigServerApplication.java │ └── pom.xml ├── hystrix-dashboard │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── pacee1 │ │ │ └── HystrixDashboardApplication.java │ └── pom.xml ├── registry-center │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── pacee1 │ │ │ └── EurekaServerApplication.java │ └── pom.xml ├── zipkin-server │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── pacee1 │ │ │ └── ZipkinApplication.java │ └── pom.xml ├── hystrix-turbine │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── pacee1 │ │ │ │ └── HystrixTurbineApplication.java │ │ │ └── resources │ │ │ └── application.yml │ └── pom.xml └── gateway │ └── src │ └── main │ ├── java │ └── com │ │ └── pacee1 │ │ ├── GatewayApplication.java │ │ └── RedisLimiterConfiguration.java │ └── resources │ ├── application.yml │ └── logback-spring.xml ├── resource └── image │ ├── 144526_dff4f76c_1185227.jpeg │ └── 151140_08bddc92_1185227.jpeg ├── domain ├── item │ ├── foodie-item-mapper │ │ ├── src │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── pacee1 │ │ │ │ │ └── item │ │ │ │ │ └── mapper │ │ │ │ │ ├── ItemsMapper.java │ │ │ │ │ ├── ItemsImgMapper.java │ │ │ │ │ ├── ItemsSpecMapper.java │ │ │ │ │ ├── ItemsParamMapper.java │ │ │ │ │ ├── ItemsCommentsMapper.java │ │ │ │ │ ├── ItemsCommentsMapperCustom.java │ │ │ │ │ └── ItemsMapperCustom.java │ │ │ │ └── resources │ │ │ │ └── mapper │ │ │ │ ├── ItemsImgMapper.xml │ │ │ │ ├── ItemsMapper.xml │ │ │ │ ├── ItemsSpecMapper.xml │ │ │ │ ├── ItemsCommentsMapper.xml │ │ │ │ ├── ItemsParamMapper.xml │ │ │ │ └── ItemsCommentsMapperCustom.xml │ │ └── pom.xml │ ├── foodie-item-web │ │ ├── src │ │ │ └── main │ │ │ │ ├── resources │ │ │ │ ├── application-prod.yml │ │ │ │ ├── application-dev.yml │ │ │ │ ├── bootstrap.yml │ │ │ │ ├── log4j.properties │ │ │ │ └── application.yml │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── pacee1 │ │ │ │ └── item │ │ │ │ └── ItemApplication.java │ │ └── pom.xml │ ├── foodie-item-pojo │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── pacee1 │ │ │ └── item │ │ │ └── pojo │ │ │ └── vo │ │ │ ├── CommentLevelCountsVO.java │ │ │ ├── ItemInfoVO.java │ │ │ ├── ItemCommentVO.java │ │ │ ├── MyCommentVO.java │ │ │ └── ShopcartVO.java │ ├── foodie-item-service │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com.pacee1.item.service.impl │ │ │ └── ItemCommentsServiceImpl.java │ └── foodie-item-api │ │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── pacee1 │ │ │ └── item │ │ │ └── service │ │ │ └── ItemCommentsService.java │ │ └── pom.xml ├── user │ ├── foodie-user-mapper │ │ ├── src │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── pacee1 │ │ │ │ │ └── user │ │ │ │ │ └── mapper │ │ │ │ │ ├── UsersMapper.java │ │ │ │ │ └── UserAddressMapper.java │ │ │ │ └── resources │ │ │ │ └── mapper │ │ │ │ ├── UsersMapper.xml │ │ │ │ └── UserAddressMapper.xml │ │ └── pom.xml │ ├── foodie-user-web │ │ └── src │ │ │ └── main │ │ │ ├── resources │ │ │ ├── application-prod.yml │ │ │ ├── application-dev.yml │ │ │ ├── bootstrap.yml │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── pacee1 │ │ │ └── user │ │ │ ├── exception │ │ │ └── CustomExceptionHandler.java │ │ │ ├── UserApplication.java │ │ │ └── controller │ │ │ └── center │ │ │ └── CenterController.java │ ├── foodie-user-api │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── pacee1 │ │ │ │ └── user │ │ │ │ └── service │ │ │ │ ├── UserService.java │ │ │ │ ├── center │ │ │ │ └── CenterUserService.java │ │ │ │ └── AddressService.java │ │ └── pom.xml │ ├── foodie-user-pojo │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── pacee1 │ │ │ └── user │ │ │ └── pojo │ │ │ ├── bo │ │ │ ├── UserBO.java │ │ │ └── UserAddressBO.java │ │ │ └── vo │ │ │ └── UsersVO.java │ └── foodie-user-service │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── pacee1 │ │ └── user │ │ └── service │ │ └── center │ │ └── impl │ │ └── CenterUserServiceImpl.java ├── order │ ├── foodie-order-mapper │ │ ├── src │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── pacee1 │ │ │ │ │ └── order │ │ │ │ │ └── mapper │ │ │ │ │ ├── OrdersMapper.java │ │ │ │ │ ├── OrderItemsMapper.java │ │ │ │ │ ├── OrderStatusMapper.java │ │ │ │ │ └── OrderMapperCustom.java │ │ │ │ └── resources │ │ │ │ └── mapper │ │ │ │ ├── OrderStatusMapper.xml │ │ │ │ ├── OrderItemsMapper.xml │ │ │ │ └── OrdersMapper.xml │ │ └── pom.xml │ ├── foodie-order-web │ │ └── src │ │ │ └── main │ │ │ ├── resources │ │ │ ├── application-prod.yml │ │ │ ├── log4j.properties │ │ │ ├── application-dev.yml │ │ │ ├── bootstrap.yml │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── pacee1 │ │ │ └── order │ │ │ ├── config │ │ │ └── RestConfig.java │ │ │ ├── job │ │ │ └── OrderJob.java │ │ │ └── OrderApplication.java │ ├── foodie-order-pojo │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── pacee1 │ │ │ │ └── order │ │ │ │ └── pojo │ │ │ │ ├── bo │ │ │ │ ├── PlaceOrderBO.java │ │ │ │ ├── OrderBO.java │ │ │ │ └── center │ │ │ │ │ └── OrderItemsCommentBO.java │ │ │ │ └── vo │ │ │ │ ├── OrderVO.java │ │ │ │ ├── MerchantOrderVO.java │ │ │ │ ├── MySubOrderItemVO.java │ │ │ │ ├── OrderStatusCountsVO.java │ │ │ │ └── MyOrdersVO.java │ │ └── pom.xml │ ├── foodie-order-service │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── pacee1 │ │ │ │ └── order │ │ │ │ └── fallback │ │ │ │ └── itemservice │ │ │ │ ├── ItemCommentsFallback.java │ │ │ │ ├── ItemCommentsFallbackFactory.java │ │ │ │ └── ItemCommentsFeignClient.java │ │ └── pom.xml │ └── foodie-order-api │ │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── pacee1 │ │ │ └── order │ │ │ └── service │ │ │ ├── OrderService.java │ │ │ └── center │ │ │ ├── MyCommentService.java │ │ │ └── MyOrderService.java │ │ └── pom.xml ├── cart │ ├── foodie-cart-web │ │ ├── src │ │ │ └── main │ │ │ │ ├── resources │ │ │ │ ├── application-prod.yml │ │ │ │ ├── application-dev.yml │ │ │ │ ├── bootstrap.yml │ │ │ │ ├── log4j.properties │ │ │ │ └── application.yml │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── pacee1 │ │ │ │ └── cart │ │ │ │ ├── CartApplication.java │ │ │ │ └── controller │ │ │ │ └── ShopcartController.java │ │ └── pom.xml │ ├── foodie-cart-api │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── pacee1 │ │ │ │ └── cart │ │ │ │ └── service │ │ │ │ └── CartService.java │ │ └── pom.xml │ ├── foodie-cart-pojo │ │ └── pom.xml │ ├── foodie-cart-mapper │ │ └── pom.xml │ └── foodie-cart-service │ │ └── pom.xml ├── search │ ├── foodie-search-web │ │ └── src │ │ │ └── main │ │ │ ├── resources │ │ │ ├── application-prod.yml │ │ │ ├── application-dev.yml │ │ │ ├── bootstrap.yml │ │ │ ├── log4j.properties │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── pacee1 │ │ │ └── search │ │ │ └── SearchApplication.java │ ├── foodie-search-mapper │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── pacee1 │ │ │ │ └── search │ │ │ │ └── mapper │ │ │ │ └── SearchMapper.java │ │ └── pom.xml │ ├── foodie-search-service │ │ └── pom.xml │ ├── foodie-search-pojo │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── pacee1 │ │ │ │ └── search │ │ │ │ └── pojo │ │ │ │ ├── vo │ │ │ │ └── SearchItemsVO.java │ │ │ │ └── bo │ │ │ │ └── ItemsDoc.java │ │ └── pom.xml │ └── foodie-search-api │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── pacee1 │ │ └── search │ │ └── service │ │ └── SearchService.java └── auth │ ├── foodie-auth-api │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── pacee1 │ │ │ └── auth │ │ │ └── service │ │ │ ├── pojo │ │ │ ├── AuthCode.java │ │ │ ├── AuthResponse.java │ │ │ └── Account.java │ │ │ └── AuthService.java │ └── pom.xml │ └── foodie-auth-service │ └── src │ └── main │ ├── java │ └── com │ │ └── pacee1 │ │ └── auth │ │ ├── AuthApplication.java │ │ └── service │ │ └── impl │ │ └── JwtService.java │ └── resources │ └── application.yml ├── .gitignore └── README.md /common/foodie-cloud-common/src/main/java/org/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /platform/config-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | encrypt: 2 | key: mytreasurewaterbaby -------------------------------------------------------------------------------- /resource/image/144526_dff4f76c_1185227.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PAcee1/foodie-cloud/HEAD/resource/image/144526_dff4f76c_1185227.jpeg -------------------------------------------------------------------------------- /resource/image/151140_08bddc92_1185227.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PAcee1/foodie-cloud/HEAD/resource/image/151140_08bddc92_1185227.jpeg -------------------------------------------------------------------------------- /platform/hystrix-dashboard/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: hystrix-dashboard 4 | server: 5 | port: 20002 -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/org/n3r/idworker/WorkerIdStrategy.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | public interface WorkerIdStrategy { 4 | void initialize(); 5 | 6 | long availableWorkerId(); 7 | 8 | void release(); 9 | } 10 | -------------------------------------------------------------------------------- /domain/item/foodie-item-mapper/src/main/java/com/pacee1/item/mapper/ItemsMapper.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item.mapper; 2 | 3 | import com.pacee1.my.mapper.MyMapper; 4 | import com.pacee1.item.pojo.Items; 5 | 6 | public interface ItemsMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /domain/user/foodie-user-mapper/src/main/java/com/pacee1/user/mapper/UsersMapper.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.user.mapper; 2 | 3 | import com.pacee1.my.mapper.MyMapper; 4 | import com.pacee1.user.pojo.Users; 5 | 6 | public interface UsersMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/org/n3r/idworker/InvalidSystemClock.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | public class InvalidSystemClock extends RuntimeException { 4 | public InvalidSystemClock(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/org/n3r/idworker/RandomCodeStrategy.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | public interface RandomCodeStrategy { 4 | void init(); 5 | 6 | int prefix(); 7 | 8 | int next(); 9 | 10 | void release(); 11 | } 12 | -------------------------------------------------------------------------------- /domain/item/foodie-item-mapper/src/main/java/com/pacee1/item/mapper/ItemsImgMapper.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item.mapper; 2 | 3 | import com.pacee1.my.mapper.MyMapper; 4 | import com.pacee1.item.pojo.ItemsImg; 5 | 6 | public interface ItemsImgMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /domain/order/foodie-order-mapper/src/main/java/com/pacee1/order/mapper/OrdersMapper.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.mapper; 2 | 3 | import com.pacee1.my.mapper.MyMapper; 4 | import com.pacee1.order.pojo.Orders; 5 | 6 | public interface OrdersMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /domain/item/foodie-item-mapper/src/main/java/com/pacee1/item/mapper/ItemsSpecMapper.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item.mapper; 2 | 3 | import com.pacee1.my.mapper.MyMapper; 4 | import com.pacee1.item.pojo.ItemsSpec; 5 | 6 | public interface ItemsSpecMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /domain/item/foodie-item-mapper/src/main/java/com/pacee1/item/mapper/ItemsParamMapper.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item.mapper; 2 | 3 | import com.pacee1.my.mapper.MyMapper; 4 | import com.pacee1.item.pojo.ItemsParam; 5 | 6 | public interface ItemsParamMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /domain/order/foodie-order-mapper/src/main/java/com/pacee1/order/mapper/OrderItemsMapper.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.mapper; 2 | 3 | import com.pacee1.my.mapper.MyMapper; 4 | import com.pacee1.order.pojo.OrderItems; 5 | 6 | public interface OrderItemsMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /domain/user/foodie-user-mapper/src/main/java/com/pacee1/user/mapper/UserAddressMapper.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.user.mapper; 2 | 3 | import com.pacee1.my.mapper.MyMapper; 4 | import com.pacee1.user.pojo.UserAddress; 5 | 6 | public interface UserAddressMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /domain/item/foodie-item-mapper/src/main/java/com/pacee1/item/mapper/ItemsCommentsMapper.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item.mapper; 2 | 3 | import com.pacee1.my.mapper.MyMapper; 4 | import com.pacee1.item.pojo.ItemsComments; 5 | 6 | public interface ItemsCommentsMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /domain/order/foodie-order-mapper/src/main/java/com/pacee1/order/mapper/OrderStatusMapper.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.mapper; 2 | 3 | import com.pacee1.my.mapper.MyMapper; 4 | import com.pacee1.order.pojo.OrderStatus; 5 | 6 | public interface OrderStatusMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/org/n3r/idworker/Test.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | for (int i = 0 ; i < 1000 ; i ++) { 8 | // System.out.println(Sid.nextShort()); 9 | } 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /domain/cart/foodie-cart-web/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8088 3 | spring: 4 | datasource: # 数据源的相关配置 5 | url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 6 | username: root 7 | password: zhaoyujie -------------------------------------------------------------------------------- /domain/item/foodie-item-web/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8088 3 | spring: 4 | datasource: # 数据源的相关配置 5 | url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 6 | username: root 7 | password: zhaoyujie -------------------------------------------------------------------------------- /platform/registry-center/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # 1 2 | 3 | spring: 4 | application: 5 | name: registry-center 6 | profiles: 7 | active: dev 8 | 9 | server: 10 | port: 22222 11 | 12 | eureka: 13 | instance: 14 | hostname: localhost 15 | # 不注册自己 16 | client: 17 | register-with-eureka: false 18 | fetch-registry: false -------------------------------------------------------------------------------- /platform/zipkin-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | main: 3 | allow-bean-definition-overriding: true 4 | application: 5 | name: zipkin-server 6 | 7 | server: 8 | port: 20005 9 | 10 | eureka: 11 | client: 12 | service-url: 13 | defaultZone: http://localhost:22222/eureka 14 | management: 15 | metrics: 16 | web: 17 | server: 18 | auto-time-requests: false -------------------------------------------------------------------------------- /domain/search/foodie-search-web/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8088 3 | spring: 4 | data: 5 | elasticsearch: 6 | cluster-nodes: 127.0.0.1:9300 7 | cluster-name: es 8 | datasource: # 数据源的相关配置 9 | url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 10 | username: root 11 | password: zhaoyujie -------------------------------------------------------------------------------- /domain/user/foodie-user-web/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8088 3 | spring: 4 | datasource: # 数据源的相关配置 5 | url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 6 | username: root 7 | password: zhaoyujie 8 | # 照片相关配置 9 | pacee1: 10 | image: 11 | faceLocation: /file/image/foodie/faces 12 | serverUrl: http://api.enbuys.com:8088/foodie/faces/ -------------------------------------------------------------------------------- /domain/item/foodie-item-mapper/src/main/java/com/pacee1/item/mapper/ItemsCommentsMapperCustom.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item.mapper; 2 | 3 | import com.pacee1.item.pojo.vo.MyCommentVO; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public interface ItemsCommentsMapperCustom{ 10 | 11 | void saveCommentList(Map paramMap); 12 | 13 | List queryCommentList(@Param("userId") String userId); 14 | } -------------------------------------------------------------------------------- /common/foodie-cloud-shared-pojo/src/main/java/com/pacee1/enums/YesOrNo.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.enums; 2 | 3 | /** 4 | * @author pace 5 | * @version v1.0 6 | * @Type Sex.java 7 | * @Desc 8 | * @date 2020/5/17 16:47 9 | */ 10 | public enum YesOrNo { 11 | NO(0,"否"), 12 | YES(1,"是"); 13 | 14 | public final Integer type; 15 | public final String value; 16 | 17 | YesOrNo(Integer type, String value) { 18 | this.type = type; 19 | this.value = value; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /domain/auth/foodie-auth-api/src/main/java/com/pacee1/auth/service/pojo/AuthCode.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.auth.service.pojo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | 6 | /** 7 | *

鉴权状态码

8 | * 9 | * @author : Pace 10 | * @date : 2020-12-10 15:12 11 | **/ 12 | @AllArgsConstructor 13 | public enum AuthCode { 14 | 15 | SUCCESS(1L), 16 | USER_NOT_FOUND(1000L), 17 | INVALID_CREDENTIAL(2000L); 18 | 19 | @Getter 20 | private Long code; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /common/foodie-cloud-shared-pojo/src/main/java/com/pacee1/enums/PayMethod.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.enums; 2 | 3 | /** 4 | * @author pace 5 | * @version v1.0 6 | * @Type Sex.java 7 | * @Desc 8 | * @date 2020/5/17 16:47 9 | */ 10 | public enum PayMethod { 11 | WX(1,"微信"), 12 | ZFB(2,"支付宝"); 13 | 14 | public final Integer type; 15 | public final String value; 16 | 17 | PayMethod(Integer type, String value) { 18 | this.type = type; 19 | this.value = value; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /common/foodie-cloud-shared-pojo/src/main/java/com/pacee1/enums/Sex.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.enums; 2 | 3 | /** 4 | * @author pace 5 | * @version v1.0 6 | * @Type Sex.java 7 | * @Desc 8 | * @date 2020/5/17 16:47 9 | */ 10 | public enum Sex { 11 | WOMAN(0,"女"), 12 | MAN(1,"男"), 13 | SECRET(2,"保密"); 14 | 15 | public final Integer type; 16 | public final String value; 17 | 18 | Sex(Integer type, String value) { 19 | this.type = type; 20 | this.value = value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /domain/order/foodie-order-web/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8088 3 | spring: 4 | datasource: # 数据源的相关配置 5 | url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 6 | username: root 7 | password: zhaoyujie 8 | # 支付相关配置 9 | pacee1: 10 | image: 11 | faceLocation: E:\\pic\\foodie-image 12 | serverUrl: http://localhost:8088/ 13 | pay: 14 | returnUrl: http://raqpsv.natappfree.cc/orders/notifyMerchantOrderPaid -------------------------------------------------------------------------------- /domain/auth/foodie-auth-api/src/main/java/com/pacee1/auth/service/pojo/AuthResponse.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.auth.service.pojo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | *

鉴权响应对象

10 | * 11 | * @author : Pace 12 | * @date : 2020-12-10 15:14 13 | **/ 14 | @Data 15 | @Builder 16 | @NoArgsConstructor 17 | @AllArgsConstructor 18 | public class AuthResponse { 19 | private Account account; 20 | 21 | private Long code; 22 | } 23 | -------------------------------------------------------------------------------- /common/foodie-cloud-shared-pojo/src/main/java/com/pacee1/enums/CommentLevel.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.enums; 2 | 3 | /** 4 | * @author pace 5 | * @version v1.0 6 | * @Type Sex.java 7 | * @Desc 8 | * @date 2020/5/17 16:47 9 | */ 10 | public enum CommentLevel { 11 | GOOD(1,"好评"), 12 | NORMAL(2,"中评"), 13 | BAD(3,"差评"); 14 | 15 | public final Integer type; 16 | public final String value; 17 | 18 | CommentLevel(Integer type, String value) { 19 | this.type = type; 20 | this.value = value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /platform/config-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: config-server 4 | cloud: 5 | config: 6 | server: 7 | git: 8 | uri: https://github.com/PAcee1/foodie-cloud-config.git 9 | # 强制拉取 10 | force-pull: true 11 | # username: 12 | # password: 13 | search-paths: '{application}' # 配置拉取某个目录下,通过服务名称对应 14 | server: 15 | port: 20003 16 | 17 | eureka: 18 | client: 19 | service-url: 20 | defaultZone: http://localhost:22222/eureka -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /domain/order/foodie-order-pojo/src/main/java/com/pacee1/order/pojo/bo/PlaceOrderBO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.pojo.bo; 2 | 3 | import com.pacee1.pojo.ShopcartBO; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | *

下单BO

12 | * 13 | * @author : Pace 14 | * @date : 2020-10-22 11:26 15 | **/ 16 | @Data 17 | @NoArgsConstructor 18 | @AllArgsConstructor 19 | public class PlaceOrderBO { 20 | 21 | private OrderBO orderBO; 22 | 23 | private List shopcartList; 24 | } 25 | -------------------------------------------------------------------------------- /domain/search/foodie-search-web/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10005 3 | spring: 4 | datasource: # 数据源的相关配置 5 | # url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 6 | uri: ${db.uri} 7 | username: ${db.username} 8 | password: ${db.password} 9 | redis: 10 | host: ${redis.host} 11 | database: ${redis.database} 12 | password: ${redis.password} 13 | data: 14 | elasticsearch: 15 | cluster-nodes: ${es.cluster-nodes} 16 | cluster-name: ${es.cluster-name} -------------------------------------------------------------------------------- /common/foodie-cloud-shared-pojo/src/main/java/com/pacee1/enums/OrderStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.enums; 2 | 3 | /** 4 | * @Created by pace 5 | * @Date 2020/6/12 11:13 6 | * @Classname OrderStatus 7 | */ 8 | public enum OrderStatusEnum { 9 | WAIT_PAY(10,"待付款"), 10 | WAIT_DELIVER(20,"待发货"), 11 | WAIT_RECEIVE(30,"待收货"), 12 | SUCCESS(40,"交易成功"), 13 | CLOSE(50,"交易关闭"); 14 | 15 | public final Integer type; 16 | public final String value; 17 | 18 | OrderStatusEnum(Integer type, String value) { 19 | this.type = type; 20 | this.value = value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /domain/auth/foodie-auth-service/src/main/java/com/pacee1/auth/AuthApplication.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.auth; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | /** 8 | *

9 | * 10 | * @author : Pace 11 | * @date : 2020-12-10 15:16 12 | **/ 13 | @SpringBootApplication 14 | @EnableDiscoveryClient 15 | public class AuthApplication { 16 | public static void main(String[] args) { 17 | SpringApplication.run(AuthApplication.class,args); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /platform/registry-center/src/main/java/com/pacee1/EurekaServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.pacee1; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | /** 8 | *

注册中心

9 | * 10 | * @author : Pace 11 | * @date : 2020-10-21 11:30 12 | **/ 13 | @SpringBootApplication 14 | @EnableEurekaServer 15 | public class EurekaServerApplication { 16 | public static void main(String[] args) { 17 | SpringApplication.run(EurekaServerApplication.class,args); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /platform/hystrix-dashboard/src/main/java/com/pacee1/HystrixDashboardApplication.java: -------------------------------------------------------------------------------- 1 | package com.pacee1; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 6 | 7 | /** 8 | *

9 | * 10 | * @author : Pace 11 | * @date : 2020-11-25 10:31 12 | **/ 13 | @SpringCloudApplication 14 | @EnableHystrixDashboard 15 | public class HystrixDashboardApplication { 16 | public static void main(String[] args) { 17 | SpringApplication.run(HystrixDashboardApplication.class,args); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /domain/order/foodie-order-web/src/main/java/com/pacee1/order/config/RestConfig.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.config; 2 | 3 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.client.RestTemplate; 7 | 8 | /** 9 | *

10 | * 11 | * @author : Pace 12 | * @date : 2020-10-27 10:14 13 | **/ 14 | @Configuration 15 | public class RestConfig { 16 | 17 | @Bean("RestTemplateLB") 18 | @LoadBalanced 19 | public RestTemplate restTemplate(){ 20 | return new RestTemplate(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /platform/zipkin-server/src/main/java/com/pacee1/ZipkinApplication.java: -------------------------------------------------------------------------------- 1 | package com.pacee1; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import zipkin.server.internal.EnableZipkinServer; 7 | 8 | /** 9 | *

10 | * 11 | * @author : Pace 12 | * @date : 2020-12-23 09:34 13 | **/ 14 | @SpringBootApplication 15 | @EnableZipkinServer 16 | @EnableDiscoveryClient 17 | public class ZipkinApplication { 18 | public static void main(String[] args) { 19 | SpringApplication.run(ZipkinApplication.class,args); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /domain/auth/foodie-auth-api/src/main/java/com/pacee1/auth/service/pojo/Account.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.auth.service.pojo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | *

存放账户信息,用户id,token,刷新token等

12 | * 13 | * @author : Pace 14 | * @date : 2020-12-10 15:12 15 | **/ 16 | @Data 17 | @Builder 18 | @NoArgsConstructor 19 | @AllArgsConstructor 20 | public class Account implements Serializable { 21 | private String userId; 22 | 23 | private String token; 24 | 25 | private String refreshToken; 26 | 27 | private boolean skipVerification = false; 28 | } 29 | -------------------------------------------------------------------------------- /domain/cart/foodie-cart-web/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10004 3 | spring: 4 | datasource: # 数据源的相关配置 5 | # url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 6 | uri: ${db.uri} 7 | username: ${db.username} 8 | password: ${db.password} 9 | redis: 10 | host: ${redis.host} 11 | database: ${redis.database} 12 | password: ${redis.password} 13 | ## 开启所有actuator-endpoint 配置在配置中心 14 | #management: 15 | # endpoint: 16 | # health: 17 | # show-details: always 18 | # endpoints: 19 | # web: 20 | # exposure: 21 | # include: '*' 22 | # security: 23 | # enabled: false -------------------------------------------------------------------------------- /domain/item/foodie-item-web/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10001 3 | spring: 4 | datasource: # 数据源的相关配置 5 | # url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 6 | uri: ${db.uri} 7 | username: ${db.username} 8 | password: ${db.password} 9 | redis: 10 | host: ${redis.host} 11 | database: ${redis.database} 12 | password: ${redis.password} 13 | ## 开启所有actuator-endpoint 配置在配置中心 14 | #management: 15 | # endpoint: 16 | # health: 17 | # show-details: always 18 | # endpoints: 19 | # web: 20 | # exposure: 21 | # include: '*' 22 | # security: 23 | # enabled: false -------------------------------------------------------------------------------- /platform/hystrix-turbine/src/main/java/com/pacee1/HystrixTurbineApplication.java: -------------------------------------------------------------------------------- 1 | package com.pacee1; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | import org.springframework.cloud.netflix.hystrix.EnableHystrix; 6 | import org.springframework.cloud.netflix.turbine.EnableTurbine; 7 | 8 | /** 9 | *

10 | * 11 | * @author : Pace 12 | * @date : 2020-11-25 10:14 13 | **/ 14 | @EnableTurbine 15 | @SpringCloudApplication 16 | @EnableHystrix 17 | public class HystrixTurbineApplication { 18 | public static void main(String[] args) { 19 | SpringApplication.run(HystrixTurbineApplication.class,args); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /platform/hystrix-turbine/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: hystrix-turbine 4 | server: 5 | port: 20001 6 | management: 7 | server: 8 | port: 52001 9 | # Eureka 10 | eureka: 11 | client: 12 | service-url: 13 | defaultZone: http://localhost:22222/eureka 14 | # turbine配置 15 | turbine: 16 | aggregator: 17 | # 集群配置,因为我们单节点所以默认default 18 | cluster-config: default 19 | # app-config: foodie-user-service,foodie-order-service,foodie-item-service 20 | # 先使用order 21 | app-config: foodie-order-service 22 | # 集群名称 23 | cluster-name-expression: "default" 24 | combine-host-port: true 25 | instanceUrlSuffix: 26 | default: actuator/hystrix.stream -------------------------------------------------------------------------------- /domain/order/foodie-order-mapper/src/main/java/com/pacee1/order/mapper/OrderMapperCustom.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.mapper; 2 | 3 | import com.pacee1.order.pojo.OrderStatus; 4 | import com.pacee1.order.pojo.vo.MyOrdersVO; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | /** 11 | * @Created by pace 12 | * @Date 2020/6/8 10:58 13 | * @Classname CategoryMapperCustom 14 | */ 15 | public interface OrderMapperCustom { 16 | 17 | List queryMyOrderList(Map paramMap); 18 | 19 | Integer queryOrderCountByStatus(Map paramMap); 20 | 21 | List queryOrderTrend(@Param("userId") String userId); 22 | } 23 | -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/org/n3r/idworker/DayCode.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | import org.n3r.idworker.strategy.DayPrefixRandomCodeStrategy; 4 | 5 | public class DayCode { 6 | static RandomCodeStrategy strategy; 7 | 8 | static { 9 | DayPrefixRandomCodeStrategy dayPrefixCodeStrategy = new DayPrefixRandomCodeStrategy("yyMM"); 10 | dayPrefixCodeStrategy.setMinRandomSize(7); 11 | dayPrefixCodeStrategy.setMaxRandomSize(7); 12 | strategy = dayPrefixCodeStrategy; 13 | strategy.init(); 14 | } 15 | 16 | public static synchronized String next() { 17 | return String.format("%d-%04d-%07d", Id.getWorkerId(), strategy.prefix(), strategy.next()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /platform/config-server/src/main/java/com/pacee1/ConfigServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.pacee1; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.config.server.EnableConfigServer; 7 | 8 | /** 9 | *

10 | * 11 | * @author : Pace 12 | * @date : 2020-12-02 15:24 13 | **/ 14 | @SpringBootApplication 15 | @EnableDiscoveryClient 16 | @EnableConfigServer 17 | public class ConfigServerApplication { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(ConfigServerApplication.class,args); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /domain/search/foodie-search-mapper/src/main/java/com/pacee1/search/mapper/SearchMapper.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.search.mapper; 2 | 3 | import com.pacee1.search.pojo.vo.SearchItemsVO; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.List; 7 | 8 | public interface SearchMapper { 9 | 10 | /** 11 | * 根据分类搜索商品 12 | * @param catId 13 | * @param sort 14 | * @return 15 | */ 16 | List searchItemsByCat(@Param("catId") Integer catId, @Param("sort") String sort); 17 | 18 | /** 19 | * 搜索商品 20 | * @param keyword 21 | * @param sort 22 | * @return 23 | */ 24 | List searchItems(@Param("keyword")String keyword, @Param("sort") String sort); 25 | 26 | } -------------------------------------------------------------------------------- /domain/cart/foodie-cart-web/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | # Eureka 2 | eureka: 3 | client: 4 | service-url: 5 | defaultZone: http://localhost:22222/eureka 6 | # config 7 | spring: 8 | zipkin: 9 | base-url: http://ZIPKIN-SERVER/ 10 | discovery-client-enabled: true 11 | locator: 12 | discovery: 13 | enabled: true 14 | sender: 15 | type: web 16 | sleuth: 17 | sampler: 18 | probability: 1 19 | cloud: 20 | config: 21 | # 不需要填写name,因为会根据我们的服务名称拉取 22 | #name: config-consumer 23 | #uri: http://localhost:60000 24 | discovery: 25 | enabled: true 26 | service-id: CONFIG-SERVER 27 | # profile 一般是由动态配置的,比如在获取当前机器的系统环境变量 28 | profile: dev 29 | label: master -------------------------------------------------------------------------------- /domain/item/foodie-item-web/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | # Eureka 2 | eureka: 3 | client: 4 | service-url: 5 | defaultZone: http://localhost:22222/eureka 6 | # config 7 | spring: 8 | zipkin: 9 | base-url: http://ZIPKIN-SERVER/ 10 | discovery-client-enabled: true 11 | locator: 12 | discovery: 13 | enabled: true 14 | sender: 15 | type: web 16 | sleuth: 17 | sampler: 18 | probability: 1 19 | cloud: 20 | config: 21 | # 不需要填写name,因为会根据我们的服务名称拉取 22 | #name: config-consumer 23 | #uri: http://localhost:60000 24 | discovery: 25 | enabled: true 26 | service-id: CONFIG-SERVER 27 | # profile 一般是由动态配置的,比如在获取当前机器的系统环境变量 28 | profile: dev 29 | label: master -------------------------------------------------------------------------------- /domain/search/foodie-search-web/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | # Eureka 2 | eureka: 3 | client: 4 | service-url: 5 | defaultZone: http://localhost:22222/eureka 6 | # config 7 | spring: 8 | zipkin: 9 | base-url: http://ZIPKIN-SERVER/ 10 | discovery-client-enabled: true 11 | locator: 12 | discovery: 13 | enabled: true 14 | sender: 15 | type: web 16 | sleuth: 17 | sampler: 18 | probability: 1 19 | cloud: 20 | config: 21 | # 不需要填写name,因为会根据我们的服务名称拉取 22 | #name: config-consumer 23 | #uri: http://localhost:60000 24 | discovery: 25 | enabled: true 26 | service-id: CONFIG-SERVER 27 | # profile 一般是由动态配置的,比如在获取当前机器的系统环境变量 28 | profile: dev 29 | label: master -------------------------------------------------------------------------------- /domain/cart/foodie-cart-web/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=DEBUG,stdout,file 2 | log4j.additivity.org.apache=true 3 | 4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 5 | log4j.appender.stdout.threshold=INFO 6 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.stdout.layout.ConversionPattern=%-5p %c{1}:%L - %m%n 8 | 9 | log4j.appender.file=org.apache.log4j.DailyRollingFileAppender 10 | log4j.appender.file.layout=org.apache.log4j.PatternLayout 11 | log4j.appender.file.DatePattern='.'yyyy-MM-dd-HH-mm 12 | log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n 13 | log4j.appender.file.Threshold=INFO 14 | log4j.appender.file.append=true 15 | log4j.appender.file.File=/workspaces/logs/foodie-api/mylog.log -------------------------------------------------------------------------------- /domain/item/foodie-item-web/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=DEBUG,stdout,file 2 | log4j.additivity.org.apache=true 3 | 4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 5 | log4j.appender.stdout.threshold=INFO 6 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.stdout.layout.ConversionPattern=%-5p %c{1}:%L - %m%n 8 | 9 | log4j.appender.file=org.apache.log4j.DailyRollingFileAppender 10 | log4j.appender.file.layout=org.apache.log4j.PatternLayout 11 | log4j.appender.file.DatePattern='.'yyyy-MM-dd-HH-mm 12 | log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n 13 | log4j.appender.file.Threshold=INFO 14 | log4j.appender.file.append=true 15 | log4j.appender.file.File=/workspaces/logs/foodie-api/mylog.log -------------------------------------------------------------------------------- /domain/order/foodie-order-web/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=DEBUG,stdout,file 2 | log4j.additivity.org.apache=true 3 | 4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 5 | log4j.appender.stdout.threshold=INFO 6 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.stdout.layout.ConversionPattern=%-5p %c{1}:%L - %m%n 8 | 9 | log4j.appender.file=org.apache.log4j.DailyRollingFileAppender 10 | log4j.appender.file.layout=org.apache.log4j.PatternLayout 11 | log4j.appender.file.DatePattern='.'yyyy-MM-dd-HH-mm 12 | log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n 13 | log4j.appender.file.Threshold=INFO 14 | log4j.appender.file.append=true 15 | log4j.appender.file.File=/workspaces/logs/foodie-api/mylog.log -------------------------------------------------------------------------------- /domain/order/foodie-order-web/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10003 3 | spring: 4 | datasource: # 数据源的相关配置 5 | # url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 6 | uri: ${db.uri} 7 | username: ${db.username} 8 | password: ${db.password} 9 | redis: 10 | host: ${redis.host} 11 | database: ${redis.database} 12 | password: ${redis.password} 13 | # 支付相关配置 配置到配置中心 14 | #pacee1: 15 | # image: 16 | # faceLocation: E:\\pic\\foodie-image 17 | # serverUrl: http://localhost:8088/ 18 | # pay: 19 | # returnUrl: http://raqpsv.natappfree.cc/orders/notifyMerchantOrderPaid 20 | # paymentUrl: http://payment.t.mukewang.com/foodie-payment/payment/createMerchantOrder 21 | -------------------------------------------------------------------------------- /domain/search/foodie-search-web/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=DEBUG,stdout,file 2 | log4j.additivity.org.apache=true 3 | 4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 5 | log4j.appender.stdout.threshold=INFO 6 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.stdout.layout.ConversionPattern=%-5p %c{1}:%L - %m%n 8 | 9 | log4j.appender.file=org.apache.log4j.DailyRollingFileAppender 10 | log4j.appender.file.layout=org.apache.log4j.PatternLayout 11 | log4j.appender.file.DatePattern='.'yyyy-MM-dd-HH-mm 12 | log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n 13 | log4j.appender.file.Threshold=INFO 14 | log4j.appender.file.append=true 15 | log4j.appender.file.File=/workspaces/logs/foodie-api/mylog.log -------------------------------------------------------------------------------- /platform/gateway/src/main/java/com/pacee1/GatewayApplication.java: -------------------------------------------------------------------------------- 1 | package com.pacee1; 2 | 3 | import com.pacee1.auth.service.AuthService; 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 | /** 10 | *

11 | * 12 | * @author : Pace 13 | * @date : 2020-12-10 11:15 14 | **/ 15 | @SpringBootApplication 16 | @EnableDiscoveryClient 17 | @EnableFeignClients( 18 | basePackageClasses = {AuthService.class} 19 | ) 20 | public class GatewayApplication { 21 | public static void main(String[] args) { 22 | SpringApplication.run(GatewayApplication.class,args); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/com/pacee1/utils/MD5Utils.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.utils; 2 | 3 | import org.apache.commons.codec.binary.Base64; 4 | 5 | import java.security.MessageDigest; 6 | 7 | public class MD5Utils { 8 | 9 | /** 10 | * 11 | * @Title: MD5Utils.java 12 | * @Package com.imooc.utils 13 | * @Description: 对字符串进行md5加密 14 | */ 15 | public static String getMD5Str(String strValue) throws Exception { 16 | MessageDigest md5 = MessageDigest.getInstance("MD5"); 17 | String newstr = Base64.encodeBase64String(md5.digest(strValue.getBytes())); 18 | return newstr; 19 | } 20 | 21 | public static void main(String[] args) { 22 | try { 23 | String md5 = getMD5Str("imooc"); 24 | System.out.println(md5); 25 | } catch (Exception e) { 26 | e.printStackTrace(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /domain/auth/foodie-auth-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10006 3 | 4 | spring: 5 | application: 6 | name: foodie-auth-service 7 | redis: 8 | database: 1 9 | host: 120.78.80.109 10 | port: 6379 11 | password: zhaoyujie 12 | zipkin: 13 | base-url: http://ZIPKIN-SERVER/ 14 | discovery-client-enabled: true 15 | locator: 16 | discovery: 17 | enabled: true 18 | sender: 19 | type: web 20 | sleuth: 21 | sampler: 22 | probability: 1 23 | eureka: 24 | client: 25 | serviceUrl: 26 | defaultZone: http://localhost:22222/eureka/ 27 | 28 | management: 29 | endpoint: 30 | health: 31 | show-details: always 32 | endpoints: 33 | web: 34 | exposure: 35 | include: '*' 36 | security: 37 | enabled: false -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/com/pacee1/utils/MobileEmailUtils.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.utils; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | public class MobileEmailUtils { 7 | 8 | public static boolean checkMobileIsOk(String mobile) { 9 | String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$"; 10 | Pattern p = Pattern.compile(regex); 11 | Matcher m = p.matcher(mobile); 12 | boolean isMatch = m.matches(); 13 | return isMatch; 14 | } 15 | 16 | public static boolean checkEmailIsOk(String email) { 17 | boolean isMatch = true; 18 | if (!email.matches("[\\w\\.\\-]+@([\\w\\-]+\\.)+[\\w\\-]+")) { 19 | isMatch = false; 20 | } 21 | return isMatch; 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /domain/user/foodie-user-web/src/main/java/com/pacee1/user/exception/CustomExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.user.exception; 2 | 3 | import com.pacee1.pojo.ResponseResult; 4 | import org.springframework.web.bind.annotation.ExceptionHandler; 5 | import org.springframework.web.bind.annotation.RestControllerAdvice; 6 | import org.springframework.web.multipart.MaxUploadSizeExceededException; 7 | 8 | /** 9 | * @Created by pace 10 | * @Date 2020/6/16 10:43 11 | * @Classname CustomException 12 | */ 13 | @RestControllerAdvice // 增强 14 | public class CustomExceptionHandler { 15 | 16 | //MaxUploadSizeExceededException异常捕获 17 | @ExceptionHandler(MaxUploadSizeExceededException.class) 18 | public ResponseResult handlerMaxUploadFile(MaxUploadSizeExceededException e){ 19 | return ResponseResult.errorMsg("文件大小超过500kb限制"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /domain/user/foodie-user-web/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 10002 3 | spring: 4 | datasource: # 数据源的相关配置 5 | # url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 6 | uri: ${db.uri} 7 | username: ${db.username} 8 | password: ${db.password} 9 | redis: 10 | database: 1 11 | host: 120.78.80.109 12 | port: 6379 13 | password: zhaoyujie 14 | # 照片相关配置 ,全部配置到了配置中心,所以不需要配置 15 | #pacee1: 16 | # image: 17 | # faceLocation: /file/image/foodie/faces 18 | # serverUrl: http://api.enbuys.com:8088/foodie/faces/ 19 | 20 | ## 开启所有actuator-endpoint,全部配置到了配置中心,所以不需要配置 21 | #management: 22 | # endpoint: 23 | # health: 24 | # show-details: always 25 | # endpoints: 26 | # web: 27 | # exposure: 28 | # include: '*' 29 | # security: 30 | # enabled: false -------------------------------------------------------------------------------- /common/foodie-cloud-shared-pojo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-cloud-shared-pojo 14 | 15 | 16 | 17 | com.github.pagehelper 18 | pagehelper 19 | RELEASE 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /common/foodie-cloud-web-components/src/main/java/com/pacee1/config/TomcatConfig.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.config; 2 | 3 | import org.apache.tomcat.util.http.LegacyCookieProcessor; 4 | import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; 5 | import org.springframework.boot.web.server.WebServerFactoryCustomizer; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | /** 10 | *

tomcat Cookie域问题配置

11 | * 12 | * @author : Pace 13 | * @date : 2020-07-03 16:56 14 | **/ 15 | @Configuration 16 | public class TomcatConfig { 17 | 18 | @Bean 19 | public WebServerFactoryCustomizer cookieProcessorCustomizer() { 20 | return (factory) -> factory.addContextCustomizers( 21 | (context) -> context.setCookieProcessor(new LegacyCookieProcessor())); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /domain/cart/foodie-cart-web/src/main/java/com/pacee1/cart/CartApplication.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.cart; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import tk.mybatis.spring.annotation.MapperScan; 8 | 9 | /** 10 | *

Cart服务

11 | * 12 | * @author : Pace 13 | * @date : 2020-10-21 15:54 14 | **/ 15 | @SpringBootApplication 16 | // tk Mybatis扫描Mapper 17 | @MapperScan(basePackages = "com.pacee1.cart.mapper") 18 | // 扫描Component 19 | @ComponentScan(basePackages = {"com.pacee1","org.n3r.idworker"}) 20 | @EnableDiscoveryClient 21 | public class CartApplication { 22 | public static void main(String[] args) { 23 | SpringApplication.run(CartApplication.class,args); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /domain/item/foodie-item-web/src/main/java/com/pacee1/item/ItemApplication.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import tk.mybatis.spring.annotation.MapperScan; 8 | 9 | /** 10 | *

Item服务

11 | * 12 | * @author : Pace 13 | * @date : 2020-10-21 15:54 14 | **/ 15 | @SpringBootApplication 16 | // tk Mybatis扫描Mapper 17 | @MapperScan(basePackages = "com.pacee1.item.mapper") 18 | // 扫描Component 19 | @ComponentScan(basePackages = {"com.pacee1","org.n3r.idworker"}) 20 | @EnableDiscoveryClient 21 | public class ItemApplication { 22 | public static void main(String[] args) { 23 | SpringApplication.run(ItemApplication.class,args); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /domain/search/foodie-search-web/src/main/java/com/pacee1/search/SearchApplication.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.search; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import tk.mybatis.spring.annotation.MapperScan; 8 | 9 | /** 10 | *

Cart服务

11 | * 12 | * @author : Pace 13 | * @date : 2020-10-21 15:54 14 | **/ 15 | @SpringBootApplication 16 | // tk Mybatis扫描Mapper 17 | @MapperScan(basePackages = "com.pacee1.search.mapper") 18 | // 扫描Component 19 | @ComponentScan(basePackages = {"com.pacee1","org.n3r.idworker"}) 20 | @EnableDiscoveryClient 21 | public class SearchApplication { 22 | public static void main(String[] args) { 23 | SpringApplication.run(SearchApplication.class,args); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/org/n3r/idworker/Id.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | import org.n3r.idworker.strategy.DefaultWorkerIdStrategy; 4 | 5 | public class Id { 6 | private static WorkerIdStrategy workerIdStrategy; 7 | private static IdWorker idWorker; 8 | 9 | static { 10 | configure(DefaultWorkerIdStrategy.instance); 11 | } 12 | 13 | public static synchronized void configure(WorkerIdStrategy custom) { 14 | if (workerIdStrategy == custom) return; 15 | 16 | if (workerIdStrategy != null) workerIdStrategy.release(); 17 | workerIdStrategy = custom; 18 | workerIdStrategy.initialize(); 19 | idWorker = new IdWorker(workerIdStrategy.availableWorkerId()); 20 | } 21 | 22 | public static long next() { 23 | return idWorker.nextId(); 24 | } 25 | 26 | public static long getWorkerId() { 27 | return idWorker.getWorkerId(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /domain/item/foodie-item-mapper/src/main/resources/mapper/ItemsImgMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /common/foodie-cloud-shared-pojo/src/main/java/com/pacee1/pojo/PagedGridResult.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.pojo; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @Description: 用来返回分页Grid的数据格式 7 | * Copyright: Copyright (c) 2019 8 | */ 9 | public class PagedGridResult { 10 | 11 | private int page; // 当前页数 12 | private int total; // 总页数 13 | private long records; // 总记录数 14 | private List rows; // 每行显示的内容 15 | 16 | public int getPage() { 17 | return page; 18 | } 19 | public void setPage(int page) { 20 | this.page = page; 21 | } 22 | public int getTotal() { 23 | return total; 24 | } 25 | public void setTotal(int total) { 26 | this.total = total; 27 | } 28 | public long getRecords() { 29 | return records; 30 | } 31 | public void setRecords(long records) { 32 | this.records = records; 33 | } 34 | public List getRows() { 35 | return rows; 36 | } 37 | public void setRows(List rows) { 38 | this.rows = rows; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /domain/auth/foodie-auth-api/src/main/java/com/pacee1/auth/service/AuthService.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.auth.service; 2 | 3 | import com.pacee1.auth.service.pojo.Account; 4 | import com.pacee1.auth.service.pojo.AuthResponse; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.*; 7 | 8 | /** 9 | *

10 | * 11 | * @author : Pace 12 | * @date : 2020-12-10 15:10 13 | **/ 14 | @FeignClient("foodie-auth-service") 15 | @RequestMapping("auth-service") 16 | public interface AuthService { 17 | @PostMapping("token") 18 | public AuthResponse tokenize(@RequestParam("userId") String userId); 19 | 20 | @PostMapping("verify") 21 | public AuthResponse verify(@RequestBody Account account); 22 | 23 | @PostMapping("refresh") 24 | public AuthResponse refresh(@RequestParam("refresh") String refresh); 25 | 26 | @DeleteMapping("delete") 27 | public AuthResponse delete(@RequestBody Account account); 28 | } 29 | -------------------------------------------------------------------------------- /domain/cart/foodie-cart-api/src/main/java/com/pacee1/cart/service/CartService.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.cart.service; 2 | 3 | import com.pacee1.pojo.ShopcartBO; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.*; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | *

11 | * 12 | * @author : Pace 13 | * @date : 2020-10-22 15:33 14 | **/ 15 | @FeignClient("foodie-cart-service") 16 | @RequestMapping("cart-api") 17 | public interface CartService { 18 | 19 | @PostMapping("/cart") 20 | void add(@RequestParam("userId") String userId, 21 | @RequestBody ShopcartBO shopcartBO); 22 | 23 | @DeleteMapping("/cart") 24 | void del(@RequestParam("userId") String userId, 25 | @RequestParam("itemSpecId") String itemSpecId); 26 | 27 | @DeleteMapping("/clearCart") 28 | void clear(@RequestParam("userId") String userId, 29 | @RequestParam("jsonShop") String jsonShop); 30 | } 31 | -------------------------------------------------------------------------------- /domain/user/foodie-user-api/src/main/java/com/pacee1/user/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.user.service; 2 | 3 | import com.pacee1.user.pojo.Users; 4 | import com.pacee1.user.pojo.bo.UserBO; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.*; 7 | 8 | /** 9 | * @author pace 10 | * @version v1.0 11 | * @Type UserService.java 12 | * @Desc 13 | * @date 2020/5/17 15:16 14 | */ 15 | @FeignClient("foodie-user-service") 16 | @RequestMapping("user-api") 17 | public interface UserService { 18 | 19 | // 判断用户名是否存在 20 | @GetMapping("usernameIsExist") 21 | boolean queryUsernameIsExist(@RequestParam("userName") String username); 22 | 23 | // 创建用户 24 | @PostMapping("user") 25 | Users createUser(@RequestBody UserBO userBO); 26 | 27 | @GetMapping("verify") 28 | Users queryUserForLogin(@RequestParam("userName") String username, 29 | @RequestParam("password") String password); 30 | } 31 | -------------------------------------------------------------------------------- /domain/order/foodie-order-web/src/main/java/com/pacee1/order/job/OrderJob.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.job; 2 | 3 | import com.pacee1.order.service.OrderService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.scheduling.annotation.Scheduled; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * @Created by pace 12 | * @Date 2020/6/12 16:55 13 | * @Classname OrderJob 14 | */ 15 | @Component 16 | public class OrderJob { 17 | 18 | @Autowired 19 | private OrderService orderService; 20 | 21 | /** 22 | * 使用定时任务关闭,缺点较多 23 | * 1.时间差 24 | * 10:50下单,会在12点才能检查出来,超出关闭时间 25 | * 2.不支持集群 26 | * 只能使用一个单独节点,来运行所有定时任务 27 | * 3.全表查询,影响数据库性能 28 | * 定时任务只适合小型项目 29 | * 30 | * 后期使用MQ来优化自动关闭任务(延时队列) 31 | */ 32 | @Scheduled(cron = "0 0 0/1 * * ? ") 33 | public void autoCloseOrder(){ 34 | orderService.closeOrder(); 35 | System.out.println(new Date()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /domain/auth/foodie-auth-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-auth-api 14 | 15 | 16 | 17 | org.springframework.boot 18 | spring-boot-starter-web 19 | 20 | 21 | 22 | org.springframework.cloud 23 | spring-cloud-starter-openfeign 24 | 25 | 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 天天吃货商城项目 2 | 3 | **该工程为微服务实现,单体实现项目地址为**:https://github.com/PAcee1/foodie 4 | 5 | 开发中,未完待续 6 | 7 | ### 项目介绍 8 | 9 | 该项目为SpringCloud微服务版本天天吃货在线购物平台。包括首页门户、商品推荐、商品搜索、商品展示、商品评价、购物车、订单流程、用户中心等功能。SpringCloud Greenwich.SR1+SpringBoot 2.1.5.RELEASE版本。集成Redis缓存、消息队列(RabbitMq、RocketMQ)、分布式搜索ElasticSearch、分布式文件系统(FastDFS、OSS)、分布式锁、分库分表(MyCat、Sharding-Jdbc)、分布式全局ID、分布式事务、分布式限流、监控、ELK日志搜索等 10 | 11 | ### 项目功能 12 | 13 | ![输入图片说明](/resource/image/151140_08bddc92_1185227.jpeg) 14 | 15 | ### 项目架构 16 | 17 | ![输入图片说明](/resource/image/144526_dff4f76c_1185227.jpeg) 18 | 19 | ### 服务 20 | 21 | | **组件名称** | **application name** | **端口** | 22 | | ------------ | -------------------- | -------- | 23 | | 注册中心 | registry-center | 22222 | 24 | | 配置中心 | config-server | 20003 | 25 | | 服务网关 | platform-gateway | 20004 | 26 | | Hystrix大盘 | hystrix-dashboard | 20002 | 27 | | Turbine | hystrix-turbine | 20001 | 28 | | | | | 29 | | | | | 30 | 31 | -------------------------------------------------------------------------------- /domain/cart/foodie-cart-pojo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-cart-pojo 14 | 15 | 16 | 17 | javax.persistence 18 | persistence-api 19 | 1.0 20 | 21 | 22 | org.hibernate.validator 23 | hibernate-validator 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /domain/item/foodie-item-pojo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-item-pojo 14 | 15 | 16 | 17 | javax.persistence 18 | persistence-api 19 | 1.0 20 | 21 | 22 | org.hibernate.validator 23 | hibernate-validator 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /domain/user/foodie-user-api/src/main/java/com/pacee1/user/service/center/CenterUserService.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.user.service.center; 2 | 3 | import com.pacee1.user.pojo.Users; 4 | import com.pacee1.user.pojo.bo.center.CenterUserBO; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.*; 7 | 8 | /** 9 | * @author pace 10 | * @version v1.0 11 | * @Type UserService.java 12 | * @Desc 13 | * @date 2020/5/17 15:16 14 | */ 15 | @FeignClient("foodie-user-service") 16 | @RequestMapping("center-user-api") 17 | public interface CenterUserService { 18 | 19 | @GetMapping("userInfo") 20 | Users queryUserInfo(@RequestParam("userId") String userId); 21 | 22 | @PutMapping("userInfo/{userId}") 23 | Users updateUserInfo(@PathVariable("userId") String userId, 24 | @RequestBody CenterUserBO userBO); 25 | 26 | @PostMapping("updateFace") 27 | Users updateUserFace(@RequestParam("userId") String userId, 28 | @RequestParam("faceUrl") String faceUrl); 29 | } 30 | -------------------------------------------------------------------------------- /domain/user/foodie-user-pojo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-user-pojo 14 | 15 | 16 | 17 | javax.persistence 18 | persistence-api 19 | 1.0 20 | 21 | 22 | org.hibernate.validator 23 | hibernate-validator 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /domain/order/foodie-order-mapper/src/main/resources/mapper/OrderStatusMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /common/foodie-cloud-web-components/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-cloud-web-components 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-cloud-common 19 | ${project.version} 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-actuator 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /domain/order/foodie-order-mapper/src/main/resources/mapper/OrderItemsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /domain/item/foodie-item-mapper/src/main/resources/mapper/ItemsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /domain/item/foodie-item-mapper/src/main/resources/mapper/ItemsSpecMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /domain/cart/foodie-cart-mapper/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-cart-mapper 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-cart-pojo 19 | ${project.version} 20 | 21 | 22 | 23 | ${project.groupId} 24 | foodie-cloud-common 25 | ${project.version} 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /domain/cart/foodie-cart-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-cart-service 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-cart-api 19 | ${project.version} 20 | 21 | 22 | 23 | ${project.groupId} 24 | foodie-cart-mapper 25 | ${project.version} 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /domain/item/foodie-item-mapper/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-item-mapper 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-item-pojo 19 | ${project.version} 20 | 21 | 22 | 23 | ${project.groupId} 24 | foodie-cloud-common 25 | ${project.version} 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /domain/item/foodie-item-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-item-service 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-item-api 19 | ${project.version} 20 | 21 | 22 | 23 | ${project.groupId} 24 | foodie-item-mapper 25 | ${project.version} 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /domain/user/foodie-user-mapper/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-user-mapper 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-user-pojo 19 | ${project.version} 20 | 21 | 22 | 23 | ${project.groupId} 24 | foodie-cloud-common 25 | ${project.version} 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /domain/order/foodie-order-mapper/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-order-mapper 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-order-pojo 19 | ${project.version} 20 | 21 | 22 | 23 | ${project.groupId} 24 | foodie-cloud-common 25 | ${project.version} 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /domain/search/foodie-search-mapper/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-search-mapper 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-search-pojo 19 | ${project.version} 20 | 21 | 22 | 23 | ${project.groupId} 24 | foodie-cloud-common 25 | ${project.version} 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /domain/search/foodie-search-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-search-service 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-search-api 19 | ${project.version} 20 | 21 | 22 | 23 | ${project.groupId} 24 | foodie-search-mapper 25 | ${project.version} 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /domain/item/foodie-item-api/src/main/java/com/pacee1/item/service/ItemCommentsService.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item.service; 2 | 3 | import com.pacee1.pojo.PagedGridResult; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.*; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | *

商品评论服务

11 | * 12 | * @author : Pace 13 | * @date : 2020-10-21 15:29 14 | **/ 15 | @FeignClient("foodie-item-service") 16 | @RequestMapping("item-comments-api") 17 | public interface ItemCommentsService { 18 | 19 | /** 20 | * 我的评价查询 分页 21 | * 22 | * @param userId 23 | * @param page 24 | * @param pageSize 25 | * @return 26 | */ 27 | @GetMapping("myComments") 28 | public PagedGridResult queryMyComments(@RequestParam("userId") String userId, 29 | @RequestParam(value = "page", required = false) Integer page, 30 | @RequestParam(value = "pageSize", required = false) Integer pageSize); 31 | 32 | @PostMapping("saveComments") 33 | public void saveComments(@RequestBody Map map); 34 | } 35 | -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/org/n3r/idworker/Code.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | import org.n3r.idworker.strategy.DefaultRandomCodeStrategy; 4 | 5 | public class Code { 6 | private static RandomCodeStrategy strategy; 7 | 8 | static { 9 | RandomCodeStrategy strategy = new DefaultRandomCodeStrategy(); 10 | strategy.init(); 11 | configure(strategy); 12 | } 13 | 14 | public static synchronized void configure(RandomCodeStrategy custom) { 15 | if (strategy == custom) return; 16 | if (strategy != null) strategy.release(); 17 | 18 | strategy = custom; 19 | } 20 | 21 | /** 22 | * Next Unique code. 23 | * The max length will be 1024-Integer.MAX-Integer.MAX(2147483647) which has 4+10+10+2*1=26 characters. 24 | * The min length will be 0-0. 25 | * 26 | * @return unique string code. 27 | */ 28 | public static synchronized String next() { 29 | long workerId = Id.getWorkerId(); 30 | int prefix = strategy.prefix(); 31 | int next = strategy.next(); 32 | 33 | return String.format("%d-%03d-%06d", workerId, prefix, next); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /domain/order/foodie-order-pojo/src/main/java/com/pacee1/order/pojo/vo/OrderVO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.pojo.vo; 2 | 3 | import com.pacee1.pojo.ShopcartBO; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @Created by pace 9 | * @Date 2020/6/12 15:13 10 | * @Classname OrderVO 11 | * 12 | * 保存订单id和支付中心订单信息 13 | */ 14 | public class OrderVO { 15 | 16 | private String orderId; 17 | private MerchantOrderVO merchantOrderVO; 18 | // 保存Redis需要清除的商品集合 19 | private List needRemoveList; 20 | 21 | public String getOrderId() { 22 | return orderId; 23 | } 24 | 25 | public void setOrderId(String orderId) { 26 | this.orderId = orderId; 27 | } 28 | 29 | public MerchantOrderVO getMerchantOrderVO() { 30 | return merchantOrderVO; 31 | } 32 | 33 | public void setMerchantOrderVO(MerchantOrderVO merchantOrderVO) { 34 | this.merchantOrderVO = merchantOrderVO; 35 | } 36 | 37 | public List getNeedRemoveList() { 38 | return needRemoveList; 39 | } 40 | 41 | public void setNeedRemoveList(List needRemoveList) { 42 | this.needRemoveList = needRemoveList; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /domain/user/foodie-user-web/src/main/java/com/pacee1/user/UserApplication.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.user; 2 | 3 | import com.pacee1.auth.service.AuthService; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; 7 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 8 | import org.springframework.cloud.openfeign.EnableFeignClients; 9 | import org.springframework.context.annotation.ComponentScan; 10 | import tk.mybatis.spring.annotation.MapperScan; 11 | 12 | /** 13 | *

用户中心服务

14 | * 15 | * @author : Pace 16 | * @date : 2020-10-22 09:52 17 | **/ 18 | @SpringBootApplication 19 | // tk Mybatis扫描Mapper 20 | @MapperScan(basePackages = "com.pacee1.user.mapper") 21 | // 扫描Component 22 | @ComponentScan(basePackages = {"com.pacee1","org.n3r.idworker"}) 23 | @EnableDiscoveryClient 24 | @EnableCircuitBreaker 25 | @EnableFeignClients(basePackageClasses = {AuthService.class}) 26 | public class UserApplication { 27 | public static void main(String[] args) { 28 | SpringApplication.run(UserApplication.class,args); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /domain/item/foodie-item-mapper/src/main/resources/mapper/ItemsCommentsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/org/n3r/idworker/strategy/DayPrefixRandomCodeStrategy.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.strategy; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | public class DayPrefixRandomCodeStrategy extends DefaultRandomCodeStrategy { 7 | private final String dayFormat; 8 | private String lastDay; 9 | 10 | public DayPrefixRandomCodeStrategy(String dayFormat) { 11 | this.dayFormat = dayFormat; 12 | } 13 | 14 | @Override 15 | public void init() { 16 | String day = createDate(); 17 | if (day.equals(lastDay)) 18 | throw new RuntimeException("init failed for day unrolled"); 19 | 20 | lastDay = day; 21 | 22 | availableCodes.clear(); 23 | release(); 24 | 25 | prefixIndex = Integer.parseInt(lastDay); 26 | if (tryUsePrefix()) return; 27 | 28 | throw new RuntimeException("prefix is not available " + prefixIndex); 29 | } 30 | 31 | private String createDate() { 32 | return new SimpleDateFormat(dayFormat).format(new Date()); 33 | } 34 | 35 | @Override 36 | public int next() { 37 | if (!lastDay.equals(createDate())) init(); 38 | 39 | return super.next(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /domain/item/foodie-item-pojo/src/main/java/com/pacee1/item/pojo/vo/CommentLevelCountsVO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item.pojo.vo; 2 | 3 | /** 4 | * @Created by pace 5 | * @Date 2020/6/9 16:17 6 | * @Classname CommentLevelCountsVO 7 | * 好评,差评,中评,总评价数量vo 8 | */ 9 | public class CommentLevelCountsVO { 10 | 11 | private Integer totalCounts; 12 | private Integer goodCounts; 13 | private Integer normalCounts; 14 | private Integer badCounts; 15 | 16 | public Integer getTotalCounts() { 17 | return totalCounts; 18 | } 19 | 20 | public void setTotalCounts(Integer totalCounts) { 21 | this.totalCounts = totalCounts; 22 | } 23 | 24 | public Integer getGoodCounts() { 25 | return goodCounts; 26 | } 27 | 28 | public void setGoodCounts(Integer goodCounts) { 29 | this.goodCounts = goodCounts; 30 | } 31 | 32 | public Integer getNormalCounts() { 33 | return normalCounts; 34 | } 35 | 36 | public void setNormalCounts(Integer normalCounts) { 37 | this.normalCounts = normalCounts; 38 | } 39 | 40 | public Integer getBadCounts() { 41 | return badCounts; 42 | } 43 | 44 | public void setBadCounts(Integer badCounts) { 45 | this.badCounts = badCounts; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /domain/order/foodie-order-pojo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-order-pojo 14 | 15 | 16 | 17 | javax.persistence 18 | persistence-api 19 | 1.0 20 | 21 | 22 | org.hibernate.validator 23 | hibernate-validator 24 | 25 | 26 | ${project.groupId} 27 | foodie-cloud-shared-pojo 28 | ${project.version} 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /domain/user/foodie-user-mapper/src/main/resources/mapper/UsersMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /domain/user/foodie-user-mapper/src/main/resources/mapper/UserAddressMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /domain/user/foodie-user-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-user-service 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-user-api 19 | ${project.version} 20 | 21 | 22 | 23 | ${project.groupId} 24 | foodie-user-mapper 25 | ${project.version} 26 | 27 | 28 | 29 | org.springframework.cloud 30 | spring-cloud-starter-netflix-hystrix 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /domain/order/foodie-order-service/src/main/java/com/pacee1/order/fallback/itemservice/ItemCommentsFallback.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.fallback.itemservice; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.pacee1.item.pojo.vo.MyCommentVO; 5 | import com.pacee1.pojo.PagedGridResult; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | 9 | import java.util.Map; 10 | 11 | /** 12 | *

13 | * 14 | * @author : Pace 15 | * @date : 2020-11-25 17:44 16 | **/ 17 | @Component 18 | /** 19 | * 这里必须添加请求路径,不然会和之前一样的问题,请求路径重复 20 | * 所以我们这里随便写了一个请求路径 21 | * 因为这个类是降级类,不会发起远程调用,写什么都无所谓 22 | */ 23 | @RequestMapping("itemCommentsFallback") 24 | public class ItemCommentsFallback implements ItemCommentsFeignClient { 25 | 26 | // 降级逻辑 27 | @Override 28 | public PagedGridResult queryMyComments(String userId, Integer page, Integer pageSize) { 29 | MyCommentVO commentVO = new MyCommentVO(); 30 | commentVO.setContent("正在加载中"); 31 | 32 | PagedGridResult result = new PagedGridResult(); 33 | result.setRows(Lists.newArrayList(commentVO)); 34 | result.setTotal(1); 35 | result.setRecords(1); 36 | return result; 37 | } 38 | 39 | @Override 40 | public void saveComments(Map map) { 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /domain/order/foodie-order-api/src/main/java/com/pacee1/order/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.service; 2 | 3 | import com.pacee1.order.pojo.OrderStatus; 4 | import com.pacee1.order.pojo.bo.PlaceOrderBO; 5 | import com.pacee1.pojo.ShopcartBO; 6 | import com.pacee1.order.pojo.bo.OrderBO; 7 | import com.pacee1.order.pojo.vo.OrderVO; 8 | import org.springframework.cloud.openfeign.FeignClient; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @Created by pace 15 | * @Date 2020/6/8 17:20 16 | * @Classname ItemService 17 | */ 18 | @FeignClient("foodie-order-service") 19 | @RequestMapping("order-api") 20 | public interface OrderService { 21 | 22 | @PostMapping("order") 23 | OrderVO create(@RequestBody PlaceOrderBO placeOrderBO); 24 | //OrderVO create(OrderBO orderBO, List shopcartList); 25 | 26 | /** 27 | * 更新订单支付状态 28 | * @param merchantOrderId 29 | * @param type 30 | */ 31 | @PutMapping("orderStatus") 32 | void updateOrderStatus(@RequestParam("merchantOrderId") String merchantOrderId, 33 | @RequestParam("type") Integer type); 34 | 35 | @GetMapping("orderStatus") 36 | OrderStatus getOrderStatus(@RequestParam("orderId") String orderId); 37 | 38 | @DeleteMapping("closePendingOrders") 39 | void closeOrder(); 40 | } 41 | -------------------------------------------------------------------------------- /common/foodie-cloud-web-components/src/main/java/com/pacee1/config/MvcConfig.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.config; 2 | 3 | import org.springframework.boot.web.client.RestTemplateBuilder; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.http.client.OkHttp3ClientHttpRequestFactory; 7 | import org.springframework.web.client.RestTemplate; 8 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 9 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 10 | 11 | /** 12 | * @Created by pace 13 | * @Date 2020/6/12 15:15 14 | * @Classname MvcConfig 15 | */ 16 | @Configuration 17 | public class MvcConfig implements WebMvcConfigurer { 18 | 19 | @Bean 20 | public RestTemplate restTemplate(RestTemplateBuilder builder){ 21 | return builder.build(); 22 | } 23 | 24 | /** 25 | * 本地路径映射 26 | * @param registry 27 | */ 28 | @Override 29 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 30 | registry.addResourceHandler("/**") // 所有路径 31 | .addResourceLocations("classpath:/META-INF/resources/") // Swagger2的映射 32 | .addResourceLocations("file:E:/pic/foodie-image/") // 添加图片本地映射 33 | .addResourceLocations("file:/file/image/"); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /domain/search/foodie-search-pojo/src/main/java/com/pacee1/search/pojo/vo/SearchItemsVO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.search.pojo.vo; 2 | 3 | /** 4 | * @Created by pace 5 | * @Date 2020/6/9 16:29 6 | * @Classname ItemCommentVO 7 | * 商品搜索使用的VO 8 | */ 9 | public class SearchItemsVO { 10 | 11 | private String itemId; 12 | private String itemName; 13 | private Integer sellCounts; 14 | private String imgUrl; 15 | private Integer price; // 全部用分表示,所以用int接收 16 | 17 | public String getItemId() { 18 | return itemId; 19 | } 20 | 21 | public void setItemId(String itemId) { 22 | this.itemId = itemId; 23 | } 24 | 25 | public String getItemName() { 26 | return itemName; 27 | } 28 | 29 | public void setItemName(String itemName) { 30 | this.itemName = itemName; 31 | } 32 | 33 | public Integer getSellCounts() { 34 | return sellCounts; 35 | } 36 | 37 | public void setSellCounts(Integer sellCounts) { 38 | this.sellCounts = sellCounts; 39 | } 40 | 41 | public String getImgUrl() { 42 | return imgUrl; 43 | } 44 | 45 | public void setImgUrl(String imgUrl) { 46 | this.imgUrl = imgUrl; 47 | } 48 | 49 | public Integer getPrice() { 50 | return price; 51 | } 52 | 53 | public void setPrice(Integer price) { 54 | this.price = price; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /domain/search/foodie-search-pojo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-search-pojo 14 | 15 | 16 | 17 | javax.persistence 18 | persistence-api 19 | 1.0 20 | 21 | 22 | org.hibernate.validator 23 | hibernate-validator 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-data-elasticsearch 30 | 31 | 2.2.2.RELEASE 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /domain/order/foodie-order-service/src/main/java/com/pacee1/order/fallback/itemservice/ItemCommentsFallbackFactory.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.fallback.itemservice; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.pacee1.item.pojo.vo.MyCommentVO; 5 | import com.pacee1.pojo.PagedGridResult; 6 | import feign.hystrix.FallbackFactory; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.Map; 10 | 11 | /** 12 | *

13 | * 14 | * @author : Pace 15 | * @date : 2020-11-25 17:48 16 | **/ 17 | @Component 18 | public class ItemCommentsFallbackFactory implements FallbackFactory { 19 | @Override 20 | public ItemCommentsFeignClient create(Throwable cause) { 21 | return new ItemCommentsFeignClient() { 22 | @Override 23 | public PagedGridResult queryMyComments(String userId, Integer page, Integer pageSize) { 24 | MyCommentVO commentVO = new MyCommentVO(); 25 | commentVO.setContent("正在加载中"); 26 | 27 | PagedGridResult result = new PagedGridResult(); 28 | result.setRows(Lists.newArrayList(commentVO)); 29 | result.setTotal(1); 30 | result.setRecords(1); 31 | return result; 32 | } 33 | 34 | @Override 35 | public void saveComments(Map map) { 36 | 37 | } 38 | }; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /domain/user/foodie-user-pojo/src/main/java/com/pacee1/user/pojo/bo/UserBO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.user.pojo.bo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | /** 7 | * @author pace 8 | * @version v1.0 9 | * @Type UserBO.java 10 | * @Desc 11 | * @date 2020/5/17 16:43 12 | */ 13 | @ApiModel(value = "用户注册BO",description = "从客户端,由用户传入的数据封装在此Entity中") 14 | public class UserBO { 15 | 16 | @ApiModelProperty(value = "用户名",name = "username",example = "pace",required = true) 17 | private String username; 18 | @ApiModelProperty(value = "密码",name = "password",example = "123456",required = true) 19 | private String password; 20 | @ApiModelProperty(value = "确认密码",name = "confirmPassword",example = "123456",required = true) 21 | private String confirmPassword; 22 | 23 | public String getUsername() { 24 | return username; 25 | } 26 | 27 | public void setUsername(String username) { 28 | this.username = username; 29 | } 30 | 31 | public String getPassword() { 32 | return password; 33 | } 34 | 35 | public void setPassword(String password) { 36 | this.password = password; 37 | } 38 | 39 | public String getConfirmPassword() { 40 | return confirmPassword; 41 | } 42 | 43 | public void setConfirmPassword(String confirmPassword) { 44 | this.confirmPassword = confirmPassword; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /domain/item/foodie-item-pojo/src/main/java/com/pacee1/item/pojo/vo/ItemInfoVO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item.pojo.vo; 2 | 3 | import com.pacee1.item.pojo.Items; 4 | import com.pacee1.item.pojo.ItemsImg; 5 | import com.pacee1.item.pojo.ItemsParam; 6 | import com.pacee1.item.pojo.ItemsSpec; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @Created by pace 12 | * @Date 2020/6/8 17:34 13 | * @Classname ItemInfoVO 14 | * 保存商品相关VO 15 | */ 16 | public class ItemInfoVO { 17 | 18 | private Items item; 19 | private List itemImgList; 20 | private List itemSpecList; 21 | private ItemsParam itemParams; 22 | 23 | public Items getItem() { 24 | return item; 25 | } 26 | 27 | public void setItem(Items item) { 28 | this.item = item; 29 | } 30 | 31 | public List getItemImgList() { 32 | return itemImgList; 33 | } 34 | 35 | public void setItemImgList(List itemImgList) { 36 | this.itemImgList = itemImgList; 37 | } 38 | 39 | public List getItemSpecList() { 40 | return itemSpecList; 41 | } 42 | 43 | public void setItemSpecList(List itemSpecList) { 44 | this.itemSpecList = itemSpecList; 45 | } 46 | 47 | public ItemsParam getItemParams() { 48 | return itemParams; 49 | } 50 | 51 | public void setItemParams(ItemsParam itemParams) { 52 | this.itemParams = itemParams; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /domain/order/foodie-order-api/src/main/java/com/pacee1/order/service/center/MyCommentService.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.service.center; 2 | 3 | import com.pacee1.order.pojo.OrderItems; 4 | import com.pacee1.order.pojo.bo.center.OrderItemsCommentBO; 5 | import com.pacee1.pojo.PagedGridResult; 6 | import org.springframework.cloud.openfeign.FeignClient; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author pace 13 | * @version v1.0 14 | * @Type UserService.java 15 | * @Desc 16 | * @date 2020/5/17 15:16 17 | */ 18 | @FeignClient("foodie-order-service") 19 | @RequestMapping("order-comments-api") 20 | public interface MyCommentService { 21 | 22 | @GetMapping("pendingComment") 23 | List queryPendingComment(@RequestParam("orderId") String orderId); 24 | 25 | @PostMapping("comments") 26 | void saveCommentList(@RequestParam("userId") String userId, 27 | @RequestParam("orderId") String orderId, 28 | @RequestBody List orderItemList); 29 | 30 | // 移到了Item微服务,ItemCommentsService 31 | /*@GetMapping("pagedComments") 32 | PagedGridResult queryCommentList(@RequestParam("userId") String userId, 33 | @RequestParam(value = "page",required = false) Integer page, 34 | @RequestParam(value = "pagesize",required = false) Integer pagesize);*/ 35 | } 36 | -------------------------------------------------------------------------------- /domain/item/foodie-item-mapper/src/main/resources/mapper/ItemsParamMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /domain/user/foodie-user-api/src/main/java/com/pacee1/user/service/AddressService.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.user.service; 2 | 3 | import com.pacee1.user.pojo.UserAddress; 4 | import com.pacee1.user.pojo.bo.UserAddressBO; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.*; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author pace 12 | * @version v1.0 13 | * @Type UserService.java 14 | * @Desc 15 | * @date 2020/5/17 15:16 16 | */ 17 | @FeignClient("foodie-user-service") 18 | @RequestMapping("address-api") 19 | public interface AddressService { 20 | 21 | /** 22 | * 查 23 | * @param userId 24 | * @return 25 | */ 26 | @GetMapping("addressList") 27 | List queryUserAddress(@RequestParam("userId") String userId); 28 | 29 | @PostMapping("address") 30 | void add(@RequestBody UserAddressBO userAddressBO); 31 | 32 | @PutMapping("address") 33 | void edit(@RequestBody UserAddressBO userAddressBO); 34 | 35 | @DeleteMapping("address") 36 | void delete(@RequestParam("userId") String userId, 37 | @RequestParam("addressId") String addressId); 38 | 39 | @PostMapping("setDefaultAddress") 40 | void setDefaultAddress(@RequestParam("userId") String userId, 41 | @RequestParam("addressId") String addressId); 42 | 43 | @GetMapping("address") 44 | UserAddress queryById(@RequestParam("addressId") String addressId); 45 | } 46 | -------------------------------------------------------------------------------- /domain/item/foodie-item-mapper/src/main/java/com/pacee1/item/mapper/ItemsMapperCustom.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item.mapper; 2 | 3 | import com.pacee1.item.pojo.vo.ItemCommentVO; 4 | import com.pacee1.item.pojo.vo.ShopcartVO; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | public interface ItemsMapperCustom { 10 | 11 | /** 12 | * 查询商品评价 13 | * @param itemId 14 | * @param level 15 | * @return 16 | */ 17 | List queryItemComments(@Param("itemId") String itemId, @Param("level") Integer level); 18 | 19 | // 搜索相关的放到foodie-search微服务中 20 | /* *//** 21 | * 搜索商品 22 | * @param keyword 23 | * @param sort 24 | * @return 25 | *//* 26 | List searchItems(@Param("keyword") String keyword, @Param("sort") String sort); 27 | 28 | *//** 29 | * 根据分类搜索商品 30 | * @param catId 31 | * @param sort 32 | * @return 33 | *//* 34 | List searchItemsByCat(@Param("catId") Integer catId, @Param("sort") String sort);*/ 35 | 36 | /** 37 | * 根据规格id获取商品信息列表 38 | * @param specIdsList 39 | * @return 40 | */ 41 | List queryItemsBySpecIds(@Param("specIdsList") List specIdsList); 42 | 43 | /** 44 | * 简单使用乐观锁,减少库存防止超卖 45 | * @param specId 46 | * @param pendingCounts 47 | * @return 48 | */ 49 | Integer decreaseItemSpecStock(@Param("specId") String specId, @Param("pendingCounts") Integer pendingCounts); 50 | } -------------------------------------------------------------------------------- /domain/order/foodie-order-pojo/src/main/java/com/pacee1/order/pojo/vo/MerchantOrderVO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.pojo.vo; 2 | 3 | /** 4 | * @Created by pace 5 | * @Date 2020/6/12 15:09 6 | * @Classname MerchantOrderVO 7 | * 8 | * 向支付中心发订单 9 | */ 10 | public class MerchantOrderVO { 11 | 12 | private String merchantOrderId; 13 | private String merchantUserId; 14 | private Integer amount; 15 | private Integer payMethod; 16 | private String returnUrl; 17 | 18 | public String getMerchantOrderId() { 19 | return merchantOrderId; 20 | } 21 | 22 | public void setMerchantOrderId(String merchantOrderId) { 23 | this.merchantOrderId = merchantOrderId; 24 | } 25 | 26 | public String getMerchantUserId() { 27 | return merchantUserId; 28 | } 29 | 30 | public void setMerchantUserId(String merchantUserId) { 31 | this.merchantUserId = merchantUserId; 32 | } 33 | 34 | public Integer getAmount() { 35 | return amount; 36 | } 37 | 38 | public void setAmount(Integer amount) { 39 | this.amount = amount; 40 | } 41 | 42 | public Integer getPayMethod() { 43 | return payMethod; 44 | } 45 | 46 | public void setPayMethod(Integer payMethod) { 47 | this.payMethod = payMethod; 48 | } 49 | 50 | public String getReturnUrl() { 51 | return returnUrl; 52 | } 53 | 54 | public void setReturnUrl(String returnUrl) { 55 | this.returnUrl = returnUrl; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /domain/user/foodie-user-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-user-api 14 | 15 | 16 | ${project.groupId} 17 | foodie-cloud-shared-pojo 18 | ${project.version} 19 | 20 | 21 | 22 | ${project.groupId} 23 | foodie-user-pojo 24 | ${project.version} 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-web 30 | 31 | 32 | 33 | 34 | org.springframework.cloud 35 | spring-cloud-starter-openfeign 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /domain/cart/foodie-cart-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-cart-api 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-cloud-shared-pojo 19 | ${project.version} 20 | 21 | 22 | 23 | ${project.groupId} 24 | foodie-cart-pojo 25 | ${project.version} 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-openfeign 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /domain/item/foodie-item-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-item-api 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-cloud-shared-pojo 19 | ${project.version} 20 | 21 | 22 | 23 | ${project.groupId} 24 | foodie-item-pojo 25 | ${project.version} 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-openfeign 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /domain/order/foodie-order-pojo/src/main/java/com/pacee1/order/pojo/vo/MySubOrderItemVO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.pojo.vo; 2 | 3 | /** 4 | * 用户中心,我的订单列表嵌套商品VO 5 | */ 6 | public class MySubOrderItemVO { 7 | 8 | private String itemId; 9 | private String itemImg; 10 | private String itemName; 11 | private String itemSpecName; 12 | private Integer buyCounts; 13 | private Integer price; 14 | 15 | public String getItemId() { 16 | return itemId; 17 | } 18 | 19 | public void setItemId(String itemId) { 20 | this.itemId = itemId; 21 | } 22 | 23 | public String getItemImg() { 24 | return itemImg; 25 | } 26 | 27 | public void setItemImg(String itemImg) { 28 | this.itemImg = itemImg; 29 | } 30 | 31 | public String getItemName() { 32 | return itemName; 33 | } 34 | 35 | public void setItemName(String itemName) { 36 | this.itemName = itemName; 37 | } 38 | 39 | public String getItemSpecName() { 40 | return itemSpecName; 41 | } 42 | 43 | public void setItemSpecName(String itemSpecName) { 44 | this.itemSpecName = itemSpecName; 45 | } 46 | 47 | public Integer getBuyCounts() { 48 | return buyCounts; 49 | } 50 | 51 | public void setBuyCounts(Integer buyCounts) { 52 | this.buyCounts = buyCounts; 53 | } 54 | 55 | public Integer getPrice() { 56 | return price; 57 | } 58 | 59 | public void setPrice(Integer price) { 60 | this.price = price; 61 | } 62 | } -------------------------------------------------------------------------------- /domain/order/foodie-order-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-order-api 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-cloud-shared-pojo 19 | ${project.version} 20 | 21 | 22 | 23 | ${project.groupId} 24 | foodie-order-pojo 25 | ${project.version} 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-openfeign 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /domain/search/foodie-search-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-search-api 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-cloud-shared-pojo 19 | ${project.version} 20 | 21 | 22 | 23 | ${project.groupId} 24 | foodie-search-pojo 25 | ${project.version} 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-openfeign 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/com/pacee1/my/mapper/MyMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014-2016 abel533@gmail.com 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.pacee1.my.mapper; 26 | 27 | import tk.mybatis.mapper.common.Mapper; 28 | import tk.mybatis.mapper.common.MySqlMapper; 29 | 30 | /** 31 | * 继承自己的MyMapper 32 | */ 33 | public interface MyMapper extends Mapper, MySqlMapper { 34 | } 35 | -------------------------------------------------------------------------------- /domain/user/foodie-user-web/src/main/java/com/pacee1/user/controller/center/CenterController.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.user.controller.center; 2 | 3 | import com.pacee1.user.pojo.Users; 4 | import com.pacee1.user.service.center.CenterUserService; 5 | import com.pacee1.pojo.ResponseResult; 6 | import io.swagger.annotations.Api; 7 | import io.swagger.annotations.ApiOperation; 8 | import io.swagger.annotations.ApiParam; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestParam; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | /** 16 | * @Created by pace 17 | * @Date 2020/6/15 15:36 18 | * @Classname CenterController 19 | */ 20 | @RestController 21 | @RequestMapping("center") 22 | @Api(value = "用户中心相关接口",tags = "用户中心相关接口") 23 | public class CenterController { 24 | 25 | @Autowired 26 | private CenterUserService centerUserService; 27 | 28 | @PostMapping("/userInfo") 29 | @ApiOperation(value = "获取用户信息",notes = "获取用户信息接口") 30 | public ResponseResult userInfo( 31 | @ApiParam(name = "userId",value = "用户id",required = true) 32 | @RequestParam String userId){ 33 | if(userId == null){ 34 | return ResponseResult.errorMsg("用户不存在"); 35 | } 36 | 37 | Users users = centerUserService.queryUserInfo(userId); 38 | 39 | return ResponseResult.ok(users); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /domain/order/foodie-order-pojo/src/main/java/com/pacee1/order/pojo/bo/OrderBO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.pojo.bo; 2 | 3 | /** 4 | * @Created by pace 5 | * @Date 2020/6/12 11:06 6 | * @Classname OrderBO 7 | */ 8 | public class OrderBO { 9 | 10 | private String userId; 11 | private String itemSpecIds; 12 | private String addressId; 13 | private Integer payMethod; 14 | private String leftMsg; 15 | private String token; 16 | 17 | public String getUserId() { 18 | return userId; 19 | } 20 | 21 | public void setUserId(String userId) { 22 | this.userId = userId; 23 | } 24 | 25 | public String getItemSpecIds() { 26 | return itemSpecIds; 27 | } 28 | 29 | public void setItemSpecIds(String itemSpecIds) { 30 | this.itemSpecIds = itemSpecIds; 31 | } 32 | 33 | public String getAddressId() { 34 | return addressId; 35 | } 36 | 37 | public void setAddressId(String addressId) { 38 | this.addressId = addressId; 39 | } 40 | 41 | public Integer getPayMethod() { 42 | return payMethod; 43 | } 44 | 45 | public void setPayMethod(Integer payMethod) { 46 | this.payMethod = payMethod; 47 | } 48 | 49 | public String getLeftMsg() { 50 | return leftMsg; 51 | } 52 | 53 | public void setLeftMsg(String leftMsg) { 54 | this.leftMsg = leftMsg; 55 | } 56 | 57 | public String getToken() { 58 | return token; 59 | } 60 | 61 | public void setToken(String token) { 62 | this.token = token; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /domain/order/foodie-order-service/src/main/java/com/pacee1/order/fallback/itemservice/ItemCommentsFeignClient.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.fallback.itemservice; 2 | 3 | import com.pacee1.item.service.ItemCommentsService; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | 6 | /** 7 | *

Item降级类

8 | * 9 | * @author : Pace 10 | * @date : 2020-11-25 17:38 11 | **/ 12 | 13 | /** 14 | * 讨厌的地方来了,对于需要在调用端指定降级业务的场景来说,由于@RequestMapping和@xxxMapping注解 15 | * 可以从原始接口上继承,因此不能配置两个完全一样的访问路径,否则启动报错。 16 | * 17 | * 在我们的实际案例中,ItemCommentsService上面定义了RequestMapping,同时 18 | * ItemCommentsServiceFeign继承自ItemCommentsService,因此相当于在Spring上下文 19 | * 中加载了两个访问路径一样的方法,会报错"Ambiguous mapping" 20 | * 21 | * 解决问题的思路就是,避免让Spring的上下文中,同时加载两个访问路径相同的方法 22 | * 23 | * 解决方案: 24 | * 1)在启动类扫包的时候,不要把原始Feign接口扫描进来 25 | * 具体做法:可以使用EnableFeignClients注解的clients属性,只加载需要的Feign接口 26 | * * 优点:服务提供者和服务调用者都不需要额外的配置 27 | * * 缺点:启动的时候配置麻烦一点,要指定加载每一个用到的接口 28 | * 29 | * 2) 原始Feign接口不要定义RequestMapping注解 30 | * 优点:启动的时候直接扫包即可,不用指定加载接口 31 | * 缺点:a, 服务提供者要额外配置路径访问的注解 32 | * b, 任何情况下,即使不需要在调用端定义fallback类,服务调用者都需要声明一个 33 | * 34 | * 3) 原始Feign接口不要定义@FeignClients注解,这样就不会被加载到上下文当中 35 | * * 优点:启动的时候直接扫包即可,不用指定加载接口,服务提供者不用额外配置 36 | * * 缺点:任何情况下,服务调用者都需要声明一个额外@FeignCliet接口 37 | * 38 | * 各有利弊,按照喜好来选就行,个人比较喜欢1),毕竟懒人 39 | * 40 | */ 41 | //@FeignClient(value = "foodie-item-service",fallback = ItemCommentsFallback.class) 42 | @FeignClient(value = "foodie-item-service",fallbackFactory = ItemCommentsFallbackFactory.class) 43 | public interface ItemCommentsFeignClient extends ItemCommentsService { 44 | } 45 | -------------------------------------------------------------------------------- /platform/registry-center/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | registry-center 14 | 15 | 16 | 17 | org.springframework.cloud 18 | spring-cloud-starter-netflix-eureka-server 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-maven-plugin 28 | 29 | com.pacee1.EurekaServerApplication 30 | 31 | 32 | 33 | 34 | repackage 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /domain/order/foodie-order-mapper/src/main/resources/mapper/OrdersMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /domain/item/foodie-item-pojo/src/main/java/com/pacee1/item/pojo/vo/ItemCommentVO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item.pojo.vo; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @Created by pace 7 | * @Date 2020/6/9 16:29 8 | * @Classname ItemCommentVO 9 | * 商品评价VO 10 | */ 11 | public class ItemCommentVO { 12 | private Integer commentLevel; 13 | private String content; 14 | private String specName; 15 | private Date createdTime; 16 | private String userFace; 17 | private String nickname; 18 | 19 | public Integer getCommentLevel() { 20 | return commentLevel; 21 | } 22 | 23 | public void setCommentLevel(Integer commentLevel) { 24 | this.commentLevel = commentLevel; 25 | } 26 | 27 | public String getContent() { 28 | return content; 29 | } 30 | 31 | public void setContent(String content) { 32 | this.content = content; 33 | } 34 | 35 | public String getspecName() { 36 | return specName; 37 | } 38 | 39 | public void setspecName(String specName) { 40 | this.specName = specName; 41 | } 42 | 43 | public Date getCreatedTime() { 44 | return createdTime; 45 | } 46 | 47 | public void setCreatedTime(Date createdTime) { 48 | this.createdTime = createdTime; 49 | } 50 | 51 | public String getUserFace() { 52 | return userFace; 53 | } 54 | 55 | public void setUserFace(String userFace) { 56 | this.userFace = userFace; 57 | } 58 | 59 | public String getNickname() { 60 | return nickname; 61 | } 62 | 63 | public void setNickname(String nickname) { 64 | this.nickname = nickname; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /platform/gateway/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: platform-gateway 4 | redis: 5 | host: 120.78.80.109 6 | database: 1 7 | password: zhaoyujie 8 | main: 9 | allow-bean-definition-overriding: true 10 | zipkin: 11 | base-url: http://ZIPKIN-SERVER/ 12 | discovery-client-enabled: true 13 | locator: 14 | discovery: 15 | enabled: true 16 | sender: 17 | type: web 18 | sleuth: 19 | sampler: 20 | probability: 1 21 | cloud: 22 | gateway: 23 | globalcors: 24 | cors-configurations: 25 | '[/**]': 26 | # 返回的资源共享给请求来源 27 | allowed-origins: 28 | - "http://localhost:8080" 29 | - "http://www.enbuys.com:8080" 30 | - "http://www.enbuys.com" 31 | - "http://center.enbuys.com:8080" 32 | - "http://center.enbuys.com" 33 | - "*" 34 | # 运行携带比如cookie, authorization之类的认证信息 35 | allow-credentials: true 36 | allowed-headers: "*" 37 | allowed-methods: "*" 38 | expose-headers: "*" 39 | # 表示Options可以在浏览器缓存多长时间,秒 40 | max-age: 600 41 | discovery: 42 | locator: 43 | enabled: true 44 | lower-case-service-id: true 45 | # routes: 在java代码中配置 46 | server: 47 | port: 20004 48 | eureka: 49 | client: 50 | service-url: 51 | defaultZone: http://localhost:22222/eureka 52 | management: 53 | security: 54 | enabled: true 55 | endpoints: 56 | web: 57 | exposure: 58 | include: "*" 59 | endpoint: 60 | health: 61 | show-details: always 62 | -------------------------------------------------------------------------------- /common/foodie-cloud-web-components/src/main/java/com/pacee1/config/CorsConfig.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.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.UrlBasedCorsConfigurationSource; 7 | import org.springframework.web.filter.CorsFilter; 8 | 9 | /** 10 | * @author pace 11 | * @version v1.0 12 | * @Type CorsConfig.java 13 | * @Desc 14 | * @date 2020/5/17 17:56 15 | */ 16 | // 不需要了,我们在网关层就完成了跨域 17 | //@Configuration 18 | public class CorsConfig { 19 | 20 | public CorsConfig(){} 21 | 22 | @Bean 23 | public CorsFilter corsFilter(){ 24 | CorsConfiguration corsConfiguration = new CorsConfiguration(); 25 | // 允许的路径 26 | corsConfiguration.addAllowedOrigin("http://localhost:8080"); 27 | corsConfiguration.addAllowedOrigin("http://www.enbuys.com:8080"); 28 | corsConfiguration.addAllowedOrigin("http://www.enbuys.com"); 29 | corsConfiguration.addAllowedOrigin("http://center.enbuys.com:8080"); 30 | corsConfiguration.addAllowedOrigin("http://center.enbuys.com"); 31 | // 允许cookie 32 | corsConfiguration.setAllowCredentials(true); 33 | // 允许的方法 34 | corsConfiguration.addAllowedMethod("*"); 35 | // 允许的Header 36 | corsConfiguration.addAllowedHeader("*"); 37 | 38 | // 设置映射 39 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); 40 | // 所有映射 41 | source.registerCorsConfiguration("/**",corsConfiguration); 42 | return new CorsFilter(source); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /domain/item/foodie-item-pojo/src/main/java/com/pacee1/item/pojo/vo/MyCommentVO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item.pojo.vo; 2 | 3 | import java.util.Date; 4 | 5 | public class MyCommentVO { 6 | 7 | private String commentId; 8 | private String content; 9 | private Date createdTime; 10 | private String itemId; 11 | private String itemName; 12 | private String specName; 13 | private String itemImg; 14 | 15 | public String getCommentId() { 16 | return commentId; 17 | } 18 | 19 | public void setCommentId(String commentId) { 20 | this.commentId = commentId; 21 | } 22 | 23 | public String getContent() { 24 | return content; 25 | } 26 | 27 | public void setContent(String content) { 28 | this.content = content; 29 | } 30 | 31 | public Date getCreatedTime() { 32 | return createdTime; 33 | } 34 | 35 | public void setCreatedTime(Date createdTime) { 36 | this.createdTime = createdTime; 37 | } 38 | 39 | public String getItemId() { 40 | return itemId; 41 | } 42 | 43 | public void setItemId(String itemId) { 44 | this.itemId = itemId; 45 | } 46 | 47 | public String getItemName() { 48 | return itemName; 49 | } 50 | 51 | public void setItemName(String itemName) { 52 | this.itemName = itemName; 53 | } 54 | 55 | public String getSpecName() { 56 | return specName; 57 | } 58 | 59 | public void setSpecName(String specName) { 60 | this.specName = specName; 61 | } 62 | 63 | public String getItemImg() { 64 | return itemImg; 65 | } 66 | 67 | public void setItemImg(String itemImg) { 68 | this.itemImg = itemImg; 69 | } 70 | } -------------------------------------------------------------------------------- /platform/config-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | config-server 14 | 15 | 16 | 17 | org.springframework.cloud 18 | spring-cloud-config-server 19 | 20 | 21 | org.springframework.cloud 22 | spring-cloud-starter-netflix-eureka-client 23 | 24 | 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-maven-plugin 31 | 32 | com.pacee1.ConfigServerApplication 33 | 34 | 35 | 36 | 37 | repackage 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /domain/order/foodie-order-pojo/src/main/java/com/pacee1/order/pojo/vo/OrderStatusCountsVO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.pojo.vo; 2 | 3 | /** 4 | * 订单状态概览数量VO 5 | */ 6 | public class OrderStatusCountsVO { 7 | 8 | private Integer waitPayCounts; 9 | private Integer waitDeliverCounts; 10 | private Integer waitReceiveCounts; 11 | private Integer waitCommentCounts; 12 | 13 | public OrderStatusCountsVO() { 14 | } 15 | 16 | public OrderStatusCountsVO(Integer waitPayCounts, Integer waitDeliverCounts, Integer waitReceiveCounts, Integer waitCommentCounts) { 17 | this.waitPayCounts = waitPayCounts; 18 | this.waitDeliverCounts = waitDeliverCounts; 19 | this.waitReceiveCounts = waitReceiveCounts; 20 | this.waitCommentCounts = waitCommentCounts; 21 | } 22 | 23 | public Integer getWaitPayCounts() { 24 | return waitPayCounts; 25 | } 26 | 27 | public void setWaitPayCounts(Integer waitPayCounts) { 28 | this.waitPayCounts = waitPayCounts; 29 | } 30 | 31 | public Integer getWaitDeliverCounts() { 32 | return waitDeliverCounts; 33 | } 34 | 35 | public void setWaitDeliverCounts(Integer waitDeliverCounts) { 36 | this.waitDeliverCounts = waitDeliverCounts; 37 | } 38 | 39 | public Integer getWaitReceiveCounts() { 40 | return waitReceiveCounts; 41 | } 42 | 43 | public void setWaitReceiveCounts(Integer waitReceiveCounts) { 44 | this.waitReceiveCounts = waitReceiveCounts; 45 | } 46 | 47 | public Integer getWaitCommentCounts() { 48 | return waitCommentCounts; 49 | } 50 | 51 | public void setWaitCommentCounts(Integer waitCommentCounts) { 52 | this.waitCommentCounts = waitCommentCounts; 53 | } 54 | } -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/org/n3r/idworker/utils/Ip.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.net.Inet4Address; 8 | import java.net.InetAddress; 9 | import java.net.NetworkInterface; 10 | import java.net.SocketException; 11 | import java.util.Enumeration; 12 | 13 | public class Ip { 14 | static Logger logger = LoggerFactory.getLogger(Ip.class); 15 | 16 | public static String ip; 17 | public static long lip; 18 | 19 | static { 20 | try { 21 | InetAddress localHostLANAddress = getFirstNonLoopbackAddress(); 22 | ip = localHostLANAddress.getHostAddress(); 23 | 24 | byte[] address = localHostLANAddress.getAddress(); 25 | lip = ((address [0] & 0xFFL) << (3*8)) + 26 | ((address [1] & 0xFFL) << (2*8)) + 27 | ((address [2] & 0xFFL) << (1*8)) + 28 | (address [3] & 0xFFL); 29 | } catch (Exception e) { 30 | logger.error("get ipv4 failed ", e); 31 | } 32 | } 33 | 34 | private static InetAddress getFirstNonLoopbackAddress() throws SocketException { 35 | Enumeration en = NetworkInterface.getNetworkInterfaces(); 36 | while (en.hasMoreElements()) { 37 | NetworkInterface i = (NetworkInterface) en.nextElement(); 38 | for (Enumeration en2 = i.getInetAddresses(); en2.hasMoreElements(); ) { 39 | InetAddress addr = (InetAddress) en2.nextElement(); 40 | if (addr.isLoopbackAddress()) continue; 41 | 42 | if (addr instanceof Inet4Address) { 43 | return addr; 44 | } 45 | } 46 | } 47 | return null; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/com/pacee1/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.utils; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.JavaType; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | 7 | import java.util.List; 8 | 9 | public class JsonUtils { 10 | 11 | // 定义jackson对象 12 | private static final ObjectMapper MAPPER = new ObjectMapper(); 13 | 14 | /** 15 | * 将对象转换成json字符串。 16 | * @param data 17 | * @return 18 | */ 19 | public static String objectToJson(Object data) { 20 | try { 21 | String string = MAPPER.writeValueAsString(data); 22 | return string; 23 | } catch (JsonProcessingException e) { 24 | e.printStackTrace(); 25 | } 26 | return null; 27 | } 28 | 29 | /** 30 | * 将json结果集转化为对象 31 | * 32 | * @param jsonData json数据 33 | * @param beanType 对象中的object类型 34 | * @return 35 | */ 36 | public static T jsonToPojo(String jsonData, Class beanType) { 37 | try { 38 | T t = MAPPER.readValue(jsonData, beanType); 39 | return t; 40 | } catch (Exception e) { 41 | e.printStackTrace(); 42 | } 43 | return null; 44 | } 45 | 46 | /** 47 | * 将json数据转换成pojo对象list 48 | * @param jsonData 49 | * @param beanType 50 | * @return 51 | */ 52 | public static List jsonToList(String jsonData, Class beanType) { 53 | JavaType javaType = MAPPER.getTypeFactory().constructParametricType(List.class, beanType); 54 | try { 55 | List list = MAPPER.readValue(jsonData, javaType); 56 | return list; 57 | } catch (Exception e) { 58 | e.printStackTrace(); 59 | } 60 | 61 | return null; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /domain/order/foodie-order-web/src/main/java/com/pacee1/order/OrderApplication.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order; 2 | 3 | import com.pacee1.cart.service.CartService; 4 | import com.pacee1.item.service.ItemService; 5 | import com.pacee1.order.fallback.itemservice.ItemCommentsFeignClient; 6 | import com.pacee1.user.service.AddressService; 7 | import com.pacee1.user.service.UserService; 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 11 | import org.springframework.cloud.openfeign.EnableFeignClients; 12 | import org.springframework.context.annotation.ComponentScan; 13 | import org.springframework.scheduling.annotation.EnableScheduling; 14 | import tk.mybatis.spring.annotation.MapperScan; 15 | 16 | /** 17 | *

Order服务

18 | * 19 | * @author : Pace 20 | * @date : 2020-10-21 15:54 21 | **/ 22 | @SpringBootApplication 23 | // tk Mybatis扫描Mapper 24 | @MapperScan(basePackages = "com.pacee1.order.mapper") 25 | // 扫描Component 26 | @ComponentScan(basePackages = {"com.pacee1","org.n3r.idworker"}) 27 | @EnableDiscoveryClient 28 | // 开启Feign,并添加需要扫描的包 29 | @EnableFeignClients( 30 | clients = { 31 | ItemCommentsFeignClient.class, 32 | ItemService.class, 33 | UserService.class, 34 | AddressService.class, 35 | CartService.class 36 | } 37 | /*basePackages = { 38 | "com.pacee1.user.service", 39 | "com.pacee1.item.service", 40 | "com.pacee1.cart.service" 41 | }*/ 42 | ) 43 | @EnableScheduling // 需要使用定时任务 44 | public class OrderApplication { 45 | public static void main(String[] args) { 46 | SpringApplication.run(OrderApplication.class,args); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /domain/item/foodie-item-mapper/src/main/resources/mapper/ItemsCommentsMapperCustom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | insert into 7 | items_comments 8 | ( 9 | id, 10 | user_id, 11 | item_id, 12 | item_name, 13 | item_spec_id, 14 | spec_name, 15 | comment_level, 16 | content, 17 | created_time, 18 | updated_time 19 | ) 20 | values 21 | 22 | ( 23 | #{item.commentId}, 24 | #{userId}, 25 | #{item.itemId}, 26 | #{item.itemName}, 27 | #{item.itemSpecId}, 28 | #{item.itemSpecName}, 29 | #{item.commentLevel}, 30 | #{item.content}, 31 | now(), 32 | now() 33 | ) 34 | 35 | 36 | 37 | 55 | -------------------------------------------------------------------------------- /common/foodie-cloud-web-components/src/main/java/com/pacee1/aspect/ServiceLogAspect.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.aspect; 2 | 3 | import org.aspectj.lang.ProceedingJoinPoint; 4 | import org.aspectj.lang.annotation.Around; 5 | import org.aspectj.lang.annotation.Aspect; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.stereotype.Component; 9 | 10 | /** 11 | * @Created by pace 12 | * @Date 2020/5/18 15:38 13 | * @Classname ServiceLogAspect 14 | */ 15 | @Aspect 16 | @Component 17 | public class ServiceLogAspect { 18 | 19 | public static final Logger log = LoggerFactory.getLogger(ServiceLogAspect.class); 20 | /** 21 | * 环绕通知,在方法执行前后执行 22 | * 切面表达式: 23 | * 第一个 * 返回值类型,所有返回 24 | * 第二个 包名 25 | * 第三个 .. 表示包下所有类包含子包 26 | * 第四个 * 类名,表示所有类 27 | * 第五个 .*(..) 类中所有方法,且入参为任何参数 28 | * @param joinPoint 29 | * @return 30 | */ 31 | @Around("execution(* com.pacee1..*.impl..*.*(..))") 32 | public Object recordTimeLog(ProceedingJoinPoint joinPoint) throws Throwable { 33 | log.info("====== 开始执行 {}.{} ======", 34 | joinPoint.getTarget().getClass(), 35 | joinPoint.getSignature().getName()); 36 | 37 | // 记录开始时间 38 | long begin = System.currentTimeMillis(); 39 | 40 | // 执行目标 service 41 | Object result = joinPoint.proceed(); 42 | 43 | // 记录结束时间 44 | long end = System.currentTimeMillis(); 45 | long takeTime = end - begin; 46 | 47 | if (takeTime > 3000) { 48 | log.error("====== 执行结束,耗时:{} 毫秒 ======", takeTime); 49 | } else if (takeTime > 2000) { 50 | log.warn("====== 执行结束,耗时:{} 毫秒 ======", takeTime); 51 | } else { 52 | log.info("====== 执行结束,耗时:{} 毫秒 ======", takeTime); 53 | } 54 | 55 | return result; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/org/n3r/idworker/Sid.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | import org.n3r.idworker.strategy.DefaultWorkerIdStrategy; 4 | import org.n3r.idworker.utils.Utils; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | 10 | @Component 11 | public class Sid { 12 | private static WorkerIdStrategy workerIdStrategy; 13 | private static IdWorker idWorker; 14 | 15 | static { 16 | configure(DefaultWorkerIdStrategy.instance); 17 | } 18 | 19 | 20 | public static synchronized void configure(WorkerIdStrategy custom) { 21 | if (workerIdStrategy != null) workerIdStrategy.release(); 22 | workerIdStrategy = custom; 23 | idWorker = new IdWorker(workerIdStrategy.availableWorkerId()) { 24 | @Override 25 | public long getEpoch() { 26 | return Utils.midnightMillis(); 27 | } 28 | }; 29 | } 30 | 31 | /** 32 | * 一天最大毫秒86400000,最大占用27比特 33 | * 27+10+11=48位 最大值281474976710655(15字),YK0XXHZ827(10字) 34 | * 6位(YYMMDD)+15位,共21位 35 | * 36 | * @return 固定21位数字字符串 37 | */ 38 | 39 | public static String next() { 40 | long id = idWorker.nextId(); 41 | String yyMMdd = new SimpleDateFormat("yyMMdd").format(new Date()); 42 | return yyMMdd + String.format("%014d", id); 43 | } 44 | 45 | 46 | /** 47 | * 返回固定16位的字母数字混编的字符串。 48 | */ 49 | public String nextShort() { 50 | long id = idWorker.nextId(); 51 | String yyMMdd = new SimpleDateFormat("yyMMdd").format(new Date()); 52 | return yyMMdd + Utils.padLeft(Utils.encode(id), 10, '0'); 53 | } 54 | 55 | // public static void main(String[] args) { 56 | // String aa = new Sid().nextShort(); 57 | // String bb = new Sid().next(); 58 | // 59 | // System.out.println(aa); 60 | // System.out.println(bb); 61 | // } 62 | } 63 | -------------------------------------------------------------------------------- /platform/zipkin-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | zipkin-server 14 | 15 | 16 | 17 | io.zipkin.java 18 | zipkin-server 19 | 2.8.4 20 | 21 | 22 | io.zipkin.java 23 | zipkin-autoconfigure-ui 24 | 2.8.4 25 | 26 | 27 | org.springframework.cloud 28 | spring-cloud-starter-netflix-eureka-client 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-maven-plugin 37 | 38 | com.pacee1.ZipkinApplication 39 | 40 | 41 | 42 | 43 | repackage 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /domain/user/foodie-user-pojo/src/main/java/com/pacee1/user/pojo/vo/UsersVO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.user.pojo.vo; 2 | 3 | import javax.persistence.Id; 4 | 5 | public class UsersVO { 6 | /** 7 | * 主键id 用户id 8 | */ 9 | @Id 10 | private String id; 11 | 12 | /** 13 | * 用户名 用户名 14 | */ 15 | private String username; 16 | 17 | /** 18 | * 密码 密码 19 | */ 20 | private String password; 21 | 22 | /** 23 | * 昵称 昵称 24 | */ 25 | private String nickname; 26 | 27 | private String face; 28 | 29 | /** 30 | * 性别 性别 1:男 0:女 2:保密 31 | */ 32 | private Integer sex; 33 | 34 | // 用户会话Token 35 | private String userUniqueToken; 36 | 37 | public String getId() { 38 | return id; 39 | } 40 | 41 | public void setId(String id) { 42 | this.id = id; 43 | } 44 | 45 | public String getUsername() { 46 | return username; 47 | } 48 | 49 | public void setUsername(String username) { 50 | this.username = username; 51 | } 52 | 53 | public String getPassword() { 54 | return password; 55 | } 56 | 57 | public void setPassword(String password) { 58 | this.password = password; 59 | } 60 | 61 | public String getNickname() { 62 | return nickname; 63 | } 64 | 65 | public void setNickname(String nickname) { 66 | this.nickname = nickname; 67 | } 68 | 69 | public String getFace() { 70 | return face; 71 | } 72 | 73 | public void setFace(String face) { 74 | this.face = face; 75 | } 76 | 77 | public Integer getSex() { 78 | return sex; 79 | } 80 | 81 | public void setSex(Integer sex) { 82 | this.sex = sex; 83 | } 84 | 85 | public String getUserUniqueToken() { 86 | return userUniqueToken; 87 | } 88 | 89 | public void setUserUniqueToken(String userToken) { 90 | this.userUniqueToken = userToken; 91 | } 92 | } -------------------------------------------------------------------------------- /platform/hystrix-dashboard/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | hystrix-dashboard 14 | 15 | 16 | 17 | org.springframework.cloud 18 | spring-cloud-starter-netflix-hystrix-dashboard 19 | 20 | 21 | org.springframework.cloud 22 | spring-cloud-starter-netflix-hystrix 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-maven-plugin 36 | 37 | com.pacee1.HystrixDashboardApplication 38 | 39 | 40 | 41 | 42 | repackage 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /domain/item/foodie-item-pojo/src/main/java/com/pacee1/item/pojo/vo/ShopcartVO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item.pojo.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | 5 | /** 6 | * @author pace 7 | * @version v1.0 8 | * @Type UserBO.java 9 | * @Desc 10 | * @date 2020/5/17 16:43 11 | */ 12 | @ApiModel(value = "获取购物车中商品信息VO",description = "获取购物车中商品信息VO") 13 | public class ShopcartVO { 14 | 15 | private String itemId; 16 | private String itemImgUrl; 17 | private String itemName; 18 | private String specId; 19 | private String specName; 20 | private String priceDiscount; 21 | private String priceNormal; 22 | 23 | public String getItemId() { 24 | return itemId; 25 | } 26 | 27 | public void setItemId(String itemId) { 28 | this.itemId = itemId; 29 | } 30 | 31 | public String getItemImgUrl() { 32 | return itemImgUrl; 33 | } 34 | 35 | public void setItemImgUrl(String itemImgUrl) { 36 | this.itemImgUrl = itemImgUrl; 37 | } 38 | 39 | public String getItemName() { 40 | return itemName; 41 | } 42 | 43 | public void setItemName(String itemName) { 44 | this.itemName = itemName; 45 | } 46 | 47 | public String getSpecId() { 48 | return specId; 49 | } 50 | 51 | public void setSpecId(String specId) { 52 | this.specId = specId; 53 | } 54 | 55 | public String getSpecName() { 56 | return specName; 57 | } 58 | 59 | public void setSpecName(String specName) { 60 | this.specName = specName; 61 | } 62 | 63 | public String getPriceDiscount() { 64 | return priceDiscount; 65 | } 66 | 67 | public void setPriceDiscount(String priceDiscount) { 68 | this.priceDiscount = priceDiscount; 69 | } 70 | 71 | public String getPriceNormal() { 72 | return priceNormal; 73 | } 74 | 75 | public void setPriceNormal(String priceNormal) { 76 | this.priceNormal = priceNormal; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /platform/gateway/src/main/java/com/pacee1/RedisLimiterConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.pacee1; 2 | 3 | import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver; 4 | import org.springframework.cloud.gateway.filter.ratelimit.RedisRateLimiter; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.context.annotation.Primary; 8 | import reactor.core.publisher.Mono; 9 | 10 | /** 11 | *

Redis限流

12 | * 13 | * @author : Pace 14 | * @date : 2020-12-10 14:07 15 | **/ 16 | @Configuration 17 | public class RedisLimiterConfiguration { 18 | 19 | @Bean 20 | @Primary 21 | // Key制造器,这里我们以地址为区分Key的约束 22 | public KeyResolver addressKeyResolver(){ 23 | return exchange -> Mono.just( 24 | exchange.getRequest() 25 | .getRemoteAddress() 26 | .getAddress() 27 | .getHostAddress() 28 | ); 29 | } 30 | 31 | @Bean("rateLimiterUser") 32 | @Primary // 需要一个主Bean 33 | // 创建User服务限流规则 34 | public RedisRateLimiter rateLimiterUser(){ 35 | // 这里使用最简单的实现方式,令牌桶 36 | // 第一个参数为令牌桶的每秒发放令牌速率,第二个参数为令牌桶的最大容量 37 | return new RedisRateLimiter(5,10); 38 | } 39 | 40 | @Bean("rateLimiterOrder") 41 | // 创建Order服务限流规则 42 | public RedisRateLimiter rateLimiterOrder(){ 43 | return new RedisRateLimiter(20,40); 44 | } 45 | 46 | @Bean("rateLimiterCart") 47 | // 创建Cart服务限流规则 48 | public RedisRateLimiter rateLimiterCart(){ 49 | return new RedisRateLimiter(20,40); 50 | } 51 | 52 | @Bean("rateLimiterItem") 53 | // 创建Item服务限流规则 54 | public RedisRateLimiter rateLimiterItem(){ 55 | return new RedisRateLimiter(50,100); 56 | } 57 | 58 | @Bean("rateLimiterSearch") 59 | // 创建Search服务限流规则 60 | public RedisRateLimiter rateLimiterSearch(){ 61 | return new RedisRateLimiter(50,100); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /domain/user/foodie-user-web/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | # Eureka 2 | eureka: 3 | client: 4 | service-url: 5 | defaultZone: http://localhost:22222/eureka 6 | # config 7 | spring: 8 | zipkin: 9 | base-url: http://ZIPKIN-SERVER/ 10 | discovery-client-enabled: true 11 | locator: 12 | discovery: 13 | enabled: true 14 | sender: 15 | type: web 16 | sleuth: 17 | sampler: 18 | probability: 1 19 | cloud: 20 | config: 21 | # 不需要填写name,因为会根据我们的服务名称拉取 22 | #name: config-consumer 23 | #uri: http://localhost:60000 24 | discovery: 25 | enabled: true 26 | service-id: CONFIG-SERVER 27 | # profile 一般是由动态配置的,比如在获取当前机器的系统环境变量 28 | profile: dev 29 | label: master 30 | ## hystrix配置 31 | hystrix: 32 | command: 33 | # 有的属性是默认值,写不写都行 34 | default: 35 | fallback: 36 | enabled: true 37 | circuitBreaker: 38 | enabled: true 39 | # 超过50%错误,那么开启熔断 40 | errorThresholdPercentage: 50 41 | # 5个request之后才进行统计 42 | requestVolumeThreshold: 5 43 | # 10秒之后进入半开状态 44 | sleepWindowInMilliseconds: 10000 45 | # forceClosed, forceOpen 强制关闭/开启熔断开关 46 | # 执行参数 47 | execution: 48 | timeout: 49 | enabled: true 50 | # 可以指定隔离方式是线程池还是信号量 51 | isolation: 52 | thread: 53 | interruptOnTimeout: true 54 | interruptOnFutureCancel: true 55 | timeoutInMilliseconds: 10000 56 | metrics: 57 | rollingStats: 58 | # 时间窗口统计 59 | timeInMilliseconds: 20000 60 | # numBuckets: 10 61 | # rollingPercentile: 62 | # # 时间窗口统计 63 | # timeInMilliseconds: 20000 64 | # # numBuckets: 10 65 | # bucketSize: 300 66 | # 照这个方法,覆盖其他的属性 67 | # loginFail是在HystrixCommand中指定的ID 68 | loginFail: 69 | execution: 70 | isolation: 71 | thread: 72 | timeoutInMilliseconds: 3000 -------------------------------------------------------------------------------- /domain/order/foodie-order-pojo/src/main/java/com/pacee1/order/pojo/bo/center/OrderItemsCommentBO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.pojo.bo.center; 2 | 3 | public class OrderItemsCommentBO { 4 | 5 | private String commentId; 6 | private String itemId; 7 | private String itemName; 8 | private String itemSpecId; 9 | private String itemSpecName; 10 | private Integer commentLevel; 11 | private String content; 12 | 13 | public String getCommentId() { 14 | return commentId; 15 | } 16 | 17 | public void setCommentId(String commentId) { 18 | this.commentId = commentId; 19 | } 20 | 21 | public String getItemId() { 22 | return itemId; 23 | } 24 | 25 | public void setItemId(String itemId) { 26 | this.itemId = itemId; 27 | } 28 | 29 | public String getItemName() { 30 | return itemName; 31 | } 32 | 33 | public void setItemName(String itemName) { 34 | this.itemName = itemName; 35 | } 36 | 37 | public String getItemSpecId() { 38 | return itemSpecId; 39 | } 40 | 41 | public void setItemSpecId(String itemSpecId) { 42 | this.itemSpecId = itemSpecId; 43 | } 44 | 45 | public String getItemSpecName() { 46 | return itemSpecName; 47 | } 48 | 49 | public void setItemSpecName(String itemSpecName) { 50 | this.itemSpecName = itemSpecName; 51 | } 52 | 53 | public Integer getCommentLevel() { 54 | return commentLevel; 55 | } 56 | 57 | public void setCommentLevel(Integer commentLevel) { 58 | this.commentLevel = commentLevel; 59 | } 60 | 61 | public String getContent() { 62 | return content; 63 | } 64 | 65 | public void setContent(String content) { 66 | this.content = content; 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return "OrderItemsCommentBO{" + 72 | "commentLevel=" + commentLevel + 73 | ", content='" + content + '\'' + 74 | '}'; 75 | } 76 | } -------------------------------------------------------------------------------- /domain/user/foodie-user-service/src/main/java/com/pacee1/user/service/center/impl/CenterUserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.user.service.center.impl; 2 | 3 | import com.pacee1.user.mapper.UsersMapper; 4 | import com.pacee1.user.pojo.Users; 5 | import com.pacee1.user.pojo.bo.center.CenterUserBO; 6 | import com.pacee1.user.service.center.CenterUserService; 7 | import org.springframework.beans.BeanUtils; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.transaction.annotation.Propagation; 11 | import org.springframework.transaction.annotation.Transactional; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import java.util.Date; 15 | 16 | /** 17 | * @author pace 18 | * @version v1.0 19 | * @Type UserServiceImpl.java 20 | * @Desc 21 | * @date 2020/5/17 15:16 22 | */ 23 | @RestController 24 | public class CenterUserServiceImpl implements CenterUserService { 25 | 26 | @Autowired 27 | private UsersMapper usersMapper; 28 | 29 | @Override 30 | @Transactional(propagation = Propagation.SUPPORTS) 31 | public Users queryUserInfo(String userId) { 32 | return usersMapper.selectByPrimaryKey(userId); 33 | } 34 | 35 | @Override 36 | @Transactional(propagation = Propagation.REQUIRED) 37 | public Users updateUserInfo(String userId, CenterUserBO userBO) { 38 | Users users = new Users(); 39 | BeanUtils.copyProperties(userBO,users); 40 | users.setUpdatedTime(new Date()); 41 | users.setId(userId); 42 | usersMapper.updateByPrimaryKeySelective(users); 43 | return users; 44 | } 45 | 46 | @Override 47 | @Transactional(propagation = Propagation.REQUIRED) 48 | public Users updateUserFace(String userId, String faceUrl) { 49 | Users users = new Users(); 50 | users.setUpdatedTime(new Date()); 51 | users.setFace(faceUrl); 52 | users.setId(userId); 53 | usersMapper.updateByPrimaryKeySelective(users); 54 | return users; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /domain/order/foodie-order-web/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | # Eureka 2 | eureka: 3 | client: 4 | service-url: 5 | defaultZone: http://localhost:22222/eureka 6 | # config 7 | spring: 8 | zipkin: 9 | base-url: http://ZIPKIN-SERVER/ 10 | discovery-client-enabled: true 11 | locator: 12 | discovery: 13 | enabled: true 14 | sender: 15 | type: web 16 | sleuth: 17 | sampler: 18 | probability: 1 19 | cloud: 20 | config: 21 | # 不需要填写name,因为会根据我们的服务名称拉取 22 | #name: config-consumer 23 | #uri: http://localhost:60000 24 | discovery: 25 | enabled: true 26 | service-id: CONFIG-SERVER 27 | # profile 一般是由动态配置的,比如在获取当前机器的系统环境变量 28 | profile: dev 29 | label: master 30 | ### Feign 超时重试策略 31 | feign: 32 | hystrix: 33 | enabled: true 34 | client: 35 | config: 36 | default: 37 | OkToRetryOnAllOperations: GET 38 | ConnectTimeout: 2000 39 | ReadTimeout: 5000 40 | MaxAutoRetries: 1 41 | ## hystrix配置 42 | hystrix: 43 | command: 44 | # 有的属性是默认值,写不写都行 45 | default: 46 | fallback: 47 | enabled: true 48 | circuitBreaker: 49 | enabled: true 50 | # 超过50%错误,那么开启熔断 51 | errorThresholdPercentage: 50 52 | # 5个request之后才进行统计 53 | requestVolumeThreshold: 5 54 | # 10秒之后进入半开状态 55 | sleepWindowInMilliseconds: 10000 56 | # forceClosed, forceOpen 强制关闭/开启熔断开关 57 | # 执行参数 58 | execution: 59 | timeout: 60 | enabled: true 61 | # 可以指定隔离方式是线程池还是信号量 62 | isolation: 63 | thread: 64 | interruptOnTimeout: true 65 | interruptOnFutureCancel: true 66 | timeoutInMilliseconds: 10000 67 | metrics: 68 | rollingStats: 69 | # 时间窗口统计 70 | timeInMilliseconds: 20000 71 | # numBuckets: 10 72 | # rollingPercentile: 73 | # # 时间窗口统计 74 | # timeInMilliseconds: 20000 75 | # # numBuckets: 10 76 | # bucketSize: 300 -------------------------------------------------------------------------------- /domain/search/foodie-search-api/src/main/java/com/pacee1/search/service/SearchService.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.search.service; 2 | 3 | import com.pacee1.pojo.PagedGridResult; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.*; 6 | 7 | /** 8 | *

9 | * 10 | * @author : Pace 11 | * @date : 2020-10-22 15:33 12 | **/ 13 | @FeignClient("foodie-search-service") 14 | @RequestMapping("search-api") 15 | public interface SearchService { 16 | 17 | /** 18 | * 分页搜索商品 19 | * @param keyword 20 | * @param sort 21 | * @param page 22 | * @param pageSize 23 | * @return 24 | */ 25 | @GetMapping("/searchItems") 26 | PagedGridResult searchItems(@RequestParam("keyword") String keyword, 27 | @RequestParam(value = "sort",required = false) String sort, 28 | @RequestParam(value = "page",required = false) Integer page, 29 | @RequestParam(value = "pageSize",required = false) Integer pageSize); 30 | 31 | // 通过ES搜索 32 | @GetMapping("/searchItemsES") 33 | PagedGridResult searchItemsES(@RequestParam("keyword") String keyword, 34 | @RequestParam(value = "sort",required = false) String sort, 35 | @RequestParam(value = "page",required = false) Integer page, 36 | @RequestParam(value = "pageSize",required = false) Integer pageSize); 37 | 38 | /** 39 | * 分页搜索商品根据分类 40 | * @param catId 41 | * @param sort 42 | * @param page 43 | * @param pageSize 44 | * @return 45 | */ 46 | @GetMapping("/searchCatItems") 47 | PagedGridResult searchItemsByCat(@RequestParam("catId") Integer catId, 48 | @RequestParam(value = "sort",required = false) String sort, 49 | @RequestParam(value = "page",required = false) Integer page, 50 | @RequestParam(value = "pageSize",required = false) Integer pageSize); 51 | } 52 | -------------------------------------------------------------------------------- /domain/user/foodie-user-pojo/src/main/java/com/pacee1/user/pojo/bo/UserAddressBO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.user.pojo.bo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | 5 | /** 6 | * @author pace 7 | * @version v1.0 8 | * @Type UserBO.java 9 | * @Desc 10 | * @date 2020/5/17 16:43 11 | */ 12 | @ApiModel(value = "用户地址BO",description = "用户增删改地址BO") 13 | public class UserAddressBO { 14 | 15 | private String addressId; 16 | private String userId; 17 | private String receiver; 18 | private String mobile; 19 | private String detail; 20 | private String province; 21 | private String city; 22 | private String district; 23 | 24 | public String getAddressId() { 25 | return addressId; 26 | } 27 | 28 | public void setAddressId(String addressId) { 29 | this.addressId = addressId; 30 | } 31 | 32 | public String getUserId() { 33 | return userId; 34 | } 35 | 36 | public void setUserId(String userId) { 37 | this.userId = userId; 38 | } 39 | 40 | public String getReceiver() { 41 | return receiver; 42 | } 43 | 44 | public void setReceiver(String receiver) { 45 | this.receiver = receiver; 46 | } 47 | 48 | public String getMobile() { 49 | return mobile; 50 | } 51 | 52 | public void setMobile(String mobile) { 53 | this.mobile = mobile; 54 | } 55 | 56 | public String getDetail() { 57 | return detail; 58 | } 59 | 60 | public void setDetail(String detail) { 61 | this.detail = detail; 62 | } 63 | 64 | public String getProvince() { 65 | return province; 66 | } 67 | 68 | public void setProvince(String province) { 69 | this.province = province; 70 | } 71 | 72 | public String getCity() { 73 | return city; 74 | } 75 | 76 | public void setCity(String city) { 77 | this.city = city; 78 | } 79 | 80 | public String getDistrict() { 81 | return district; 82 | } 83 | 84 | public void setDistrict(String district) { 85 | this.district = district; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /common/foodie-cloud-web-components/src/main/java/com/pacee1/config/Swagger2.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.bind.annotation.RestController; 6 | import springfox.documentation.builders.ApiInfoBuilder; 7 | import springfox.documentation.builders.PathSelectors; 8 | import springfox.documentation.builders.RequestHandlerSelectors; 9 | import springfox.documentation.service.ApiInfo; 10 | import springfox.documentation.service.Contact; 11 | import springfox.documentation.spi.DocumentationType; 12 | import springfox.documentation.spring.web.plugins.Docket; 13 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 14 | 15 | @Configuration 16 | @EnableSwagger2 17 | public class Swagger2 { 18 | 19 | // http://localhost:8088/swagger-ui.html 原路径 20 | // http://localhost:8088/doc.html 原路径 21 | 22 | // 配置swagger2核心配置 docket 23 | @Bean 24 | public Docket createRestApi() { 25 | return new Docket(DocumentationType.SWAGGER_2) // 指定api类型为swagger2 26 | .apiInfo(apiInfo()) // 用于定义api文档汇总信息 27 | .select() 28 | .apis(RequestHandlerSelectors 29 | .withClassAnnotation(RestController.class) // 指定RestController注解 30 | //.basePackage("com.pacee1.controller") // 指定controller包 31 | ) 32 | .paths(PathSelectors.any()) // 所有controller 33 | .build(); 34 | } 35 | 36 | private ApiInfo apiInfo() { 37 | return new ApiInfoBuilder() 38 | .title("嗯恰 电商平台接口api") // 文档页标题 39 | .contact(new Contact("pacee1", 40 | "https://www.pacee1.com", 41 | "abc@pacee1.com")) // 联系人信息 42 | .description("专为嗯恰平台提供的api文档") // 详细信息 43 | .version("1.0.1") // 文档版本号 44 | .termsOfServiceUrl("https://www.pacee1.com") // 网站地址 45 | .build(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /common/foodie-cloud-shared-pojo/src/main/java/com/pacee1/pojo/ShopcartBO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.pojo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | 5 | /** 6 | * @author pace 7 | * @version v1.0 8 | * @Type UserBO.java 9 | * @Desc 10 | * @date 2020/5/17 16:43 11 | */ 12 | @ApiModel(value = "购物车添加BO",description = "商品信息需添加到购物车中") 13 | public class ShopcartBO { 14 | 15 | private String itemId; 16 | private String itemImgUrl; 17 | private String itemName; 18 | private String specId; 19 | private String specName; 20 | private String buyCounts; 21 | private String priceDiscount; 22 | private String priceNormal; 23 | 24 | public String getItemId() { 25 | return itemId; 26 | } 27 | 28 | public void setItemId(String itemId) { 29 | this.itemId = itemId; 30 | } 31 | 32 | public String getItemImgUrl() { 33 | return itemImgUrl; 34 | } 35 | 36 | public void setItemImgUrl(String itemImgUrl) { 37 | this.itemImgUrl = itemImgUrl; 38 | } 39 | 40 | public String getItemName() { 41 | return itemName; 42 | } 43 | 44 | public void setItemName(String itemName) { 45 | this.itemName = itemName; 46 | } 47 | 48 | public String getSpecId() { 49 | return specId; 50 | } 51 | 52 | public void setSpecId(String specId) { 53 | this.specId = specId; 54 | } 55 | 56 | public String getSpecName() { 57 | return specName; 58 | } 59 | 60 | public void setSpecName(String specName) { 61 | this.specName = specName; 62 | } 63 | 64 | public String getBuyCounts() { 65 | return buyCounts; 66 | } 67 | 68 | public void setBuyCounts(String buyCounts) { 69 | this.buyCounts = buyCounts; 70 | } 71 | 72 | public String getPriceDiscount() { 73 | return priceDiscount; 74 | } 75 | 76 | public void setPriceDiscount(String priceDiscount) { 77 | this.priceDiscount = priceDiscount; 78 | } 79 | 80 | public String getPriceNormal() { 81 | return priceNormal; 82 | } 83 | 84 | public void setPriceNormal(String priceNormal) { 85 | this.priceNormal = priceNormal; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /domain/order/foodie-order-api/src/main/java/com/pacee1/order/service/center/MyOrderService.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.service.center; 2 | 3 | import com.pacee1.order.pojo.Orders; 4 | import com.pacee1.order.pojo.vo.OrderStatusCountsVO; 5 | import com.pacee1.pojo.PagedGridResult; 6 | import org.springframework.cloud.openfeign.FeignClient; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | /** 10 | * @author pace 11 | * @version v1.0 12 | * @Type UserService.java 13 | * @Desc 14 | * @date 2020/5/17 15:16 15 | */ 16 | @FeignClient("foodie-order-service") 17 | @RequestMapping("myorder-api") 18 | public interface MyOrderService { 19 | 20 | /** 21 | * 分页查询订单 22 | * @param userId 23 | * @param orderStatus 24 | * @param page 25 | * @param pagesize 26 | * @return 27 | */ 28 | @GetMapping("order/query") 29 | PagedGridResult queryMyOrderList(@RequestParam("userId") String userId, 30 | @RequestParam("orderStatus") String orderStatus, 31 | @RequestParam(value = "page",required = false) Integer page, 32 | @RequestParam(value = "pagesize",required = false) Integer pagesize); 33 | 34 | @PostMapping("order/delivered") 35 | void updateDeliverOrder(@RequestParam("orderId") String orderId); 36 | 37 | @PostMapping("order/received") 38 | void updateConfirmOrder(@RequestParam("orderId") String orderId); 39 | 40 | @DeleteMapping("order") 41 | void updateDeleteOrder(@RequestParam("orderId") String orderId); 42 | 43 | @GetMapping("checkUserOrder") 44 | Orders checkUserOrder(@RequestParam("orderId") String userId, 45 | @RequestParam("orderId") String orderId); 46 | 47 | @GetMapping("order/counts") 48 | OrderStatusCountsVO queryOrderStatusCounts(String userId); 49 | 50 | @GetMapping("order/trend") 51 | PagedGridResult queryOrderTrend(@RequestParam("orderId") String userId, 52 | @RequestParam(value = "page",required = false) Integer page, 53 | @RequestParam(value = "pagesize",required = false) Integer pagesize); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /domain/order/foodie-order-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-order-service 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-order-api 19 | ${project.version} 20 | 21 | 22 | 23 | ${project.groupId} 24 | foodie-order-mapper 25 | ${project.version} 26 | 27 | 28 | 29 | 30 | ${project.groupId} 31 | foodie-user-api 32 | ${project.version} 33 | 34 | 35 | 36 | ${project.groupId} 37 | foodie-item-api 38 | ${project.version} 39 | 40 | 41 | 42 | ${project.groupId} 43 | foodie-cart-api 44 | ${project.version} 45 | 46 | 47 | 50 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /domain/order/foodie-order-pojo/src/main/java/com/pacee1/order/pojo/vo/MyOrdersVO.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.order.pojo.vo; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | /** 7 | * 用户中心,我的订单列表VO 8 | */ 9 | public class MyOrdersVO { 10 | 11 | private String orderId; 12 | private Date createdTime; 13 | private Integer payMethod; 14 | private Integer realPayAmount; 15 | private Integer postAmount; 16 | private Integer isComment; 17 | private Integer orderStatus; 18 | 19 | private List subOrderItemList; 20 | 21 | public String getOrderId() { 22 | return orderId; 23 | } 24 | 25 | public void setOrderId(String orderId) { 26 | this.orderId = orderId; 27 | } 28 | 29 | public Date getCreatedTime() { 30 | return createdTime; 31 | } 32 | 33 | public void setCreatedTime(Date createdTime) { 34 | this.createdTime = createdTime; 35 | } 36 | 37 | public Integer getPayMethod() { 38 | return payMethod; 39 | } 40 | 41 | public void setPayMethod(Integer payMethod) { 42 | this.payMethod = payMethod; 43 | } 44 | 45 | public Integer getRealPayAmount() { 46 | return realPayAmount; 47 | } 48 | 49 | public void setRealPayAmount(Integer realPayAmount) { 50 | this.realPayAmount = realPayAmount; 51 | } 52 | 53 | public Integer getPostAmount() { 54 | return postAmount; 55 | } 56 | 57 | public void setPostAmount(Integer postAmount) { 58 | this.postAmount = postAmount; 59 | } 60 | 61 | public Integer getOrderStatus() { 62 | return orderStatus; 63 | } 64 | 65 | public void setOrderStatus(Integer orderStatus) { 66 | this.orderStatus = orderStatus; 67 | } 68 | 69 | public List getSubOrderItemList() { 70 | return subOrderItemList; 71 | } 72 | 73 | public void setSubOrderItemList(List subOrderItemList) { 74 | this.subOrderItemList = subOrderItemList; 75 | } 76 | 77 | public Integer getIsComment() { 78 | return isComment; 79 | } 80 | 81 | public void setIsComment(Integer isComment) { 82 | this.isComment = isComment; 83 | } 84 | } -------------------------------------------------------------------------------- /domain/cart/foodie-cart-web/src/main/java/com/pacee1/cart/controller/ShopcartController.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.cart.controller; 2 | 3 | import com.pacee1.cart.service.CartService; 4 | import com.pacee1.pojo.ShopcartBO; 5 | import com.pacee1.utils.JsonUtils; 6 | import com.pacee1.utils.RedisOperator; 7 | import com.pacee1.pojo.ResponseResult; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import io.swagger.annotations.ApiParam; 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | import javax.servlet.http.HttpServletRequest; 16 | import javax.servlet.http.HttpServletResponse; 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | /** 21 | * @author pace 22 | * @version v1.0 23 | * @Type IndexController.java 24 | * @Desc 25 | * @date 2020/6/8 15:20 26 | */ 27 | @RestController 28 | @RequestMapping("shopcart") 29 | @Api(value = "购物车相关接口",tags = "购物车相关接口") 30 | public class ShopcartController { 31 | 32 | /** 购物车使用Cookie+Redis实现 **/ 33 | 34 | @Autowired 35 | private CartService cartService; 36 | 37 | @PostMapping("/add") 38 | @ApiOperation(value = "添加购物车接口",notes = "添加购物车接口") 39 | public ResponseResult add( 40 | @ApiParam(name = "userId",value = "用户id",required = true) 41 | @RequestParam String userId, 42 | @RequestBody ShopcartBO shopcartBO){ 43 | if(userId == null){ 44 | return ResponseResult.errorMsg("用户不存在"); 45 | } 46 | 47 | cartService.add(userId,shopcartBO); 48 | 49 | return ResponseResult.ok(); 50 | } 51 | 52 | 53 | @PostMapping("/del") 54 | @ApiOperation(value = "删除购物车商品接口",notes = "删除购物车商品接口") 55 | public ResponseResult del( 56 | @ApiParam(name = "userId",value = "用户id",required = true) 57 | @RequestParam String userId, 58 | @RequestParam String itemSpecId){ 59 | if(StringUtils.isBlank(userId) || StringUtils.isBlank(itemSpecId)){ 60 | return ResponseResult.errorMsg("参数为空"); 61 | } 62 | 63 | cartService.del(userId, itemSpecId); 64 | 65 | return ResponseResult.ok(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/org/n3r/idworker/utils/IPv4Utils.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | /** 4 | * This utility provides methods to either convert an IPv4 address to its long format or a 32bit dotted format. 5 | * 6 | * @author Aion 7 | * Created on 22/11/12 8 | */ 9 | public class IPv4Utils { 10 | 11 | /** 12 | * Returns the long format of the provided IP address. 13 | * 14 | * @param ipAddress the IP address 15 | * @return the long format of ipAddress 16 | * @throws IllegalArgumentException if ipAddress is invalid 17 | */ 18 | public static long toLong(String ipAddress) { 19 | if (ipAddress == null || ipAddress.isEmpty()) { 20 | throw new IllegalArgumentException("ip address cannot be null or empty"); 21 | } 22 | String[] octets = ipAddress.split(java.util.regex.Pattern.quote(".")); 23 | if (octets.length != 4) { 24 | throw new IllegalArgumentException("invalid ip address"); 25 | } 26 | long ip = 0; 27 | for (int i = 3; i >= 0; i--) { 28 | long octet = Long.parseLong(octets[3 - i]); 29 | if (octet > 255 || octet < 0) { 30 | throw new IllegalArgumentException("invalid ip address"); 31 | } 32 | ip |= octet << (i * 8); 33 | } 34 | return ip; 35 | } 36 | 37 | /** 38 | * Returns the 32bit dotted format of the provided long ip. 39 | * 40 | * @param ip the long ip 41 | * @return the 32bit dotted format of ip 42 | * @throws IllegalArgumentException if ip is invalid 43 | */ 44 | public static String toString(long ip) { 45 | // if ip is bigger than 255.255.255.255 or smaller than 0.0.0.0 46 | if (ip > 4294967295l || ip < 0) { 47 | throw new IllegalArgumentException("invalid ip"); 48 | } 49 | StringBuilder ipAddress = new StringBuilder(); 50 | for (int i = 3; i >= 0; i--) { 51 | int shift = i * 8; 52 | ipAddress.append((ip & (0xff << shift)) >> shift); 53 | if (i > 0) { 54 | ipAddress.append("."); 55 | } 56 | } 57 | return ipAddress.toString(); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /platform/hystrix-turbine/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | hystrix-turbine 14 | 15 | 16 | 17 | org.springframework.cloud 18 | spring-cloud-starter-netflix-eureka-client 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-web 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | 28 | 29 | org.springframework.cloud 30 | spring-cloud-starter-netflix-hystrix 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-starter-netflix-turbine 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-maven-plugin 44 | 45 | com.pacee1.HystrixTurbineApplication 46 | 47 | 48 | 49 | 50 | repackage 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /domain/search/foodie-search-pojo/src/main/java/com/pacee1/search/pojo/bo/ItemsDoc.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.search.pojo.bo; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.elasticsearch.annotations.Document; 5 | import org.springframework.data.elasticsearch.annotations.Field; 6 | import org.springframework.data.elasticsearch.annotations.FieldType; 7 | 8 | /** 9 | *

商品信息

10 | * 11 | * @author : Pace 12 | * @date : 2020-08-12 17:00 13 | **/ 14 | @Document(indexName = "foodie-items",type = "doc") 15 | public class ItemsDoc { 16 | 17 | @Id 18 | @Field(store = true,type = FieldType.Text,index = false) 19 | private String itemId; 20 | 21 | @Field(store = true,type = FieldType.Text,index = true) 22 | private String itemName; 23 | 24 | @Field(store = true,type = FieldType.Text,index = false) 25 | private String imgUrl; 26 | 27 | @Field(store = true,type = FieldType.Integer) 28 | private Integer price; 29 | 30 | @Field(store = true,type = FieldType.Integer) 31 | private Integer sellCounts; 32 | 33 | public String getItemId() { 34 | return itemId; 35 | } 36 | 37 | public void setItemId(String itemId) { 38 | this.itemId = itemId; 39 | } 40 | 41 | public String getItemName() { 42 | return itemName; 43 | } 44 | 45 | public void setItemName(String itemName) { 46 | this.itemName = itemName; 47 | } 48 | 49 | public String getImgUrl() { 50 | return imgUrl; 51 | } 52 | 53 | public void setImgUrl(String imgUrl) { 54 | this.imgUrl = imgUrl; 55 | } 56 | 57 | public Integer getPrice() { 58 | return price; 59 | } 60 | 61 | public void setPrice(Integer price) { 62 | this.price = price; 63 | } 64 | 65 | public Integer getSellCounts() { 66 | return sellCounts; 67 | } 68 | 69 | public void setSellCounts(Integer sellCounts) { 70 | this.sellCounts = sellCounts; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | return "Items{" + 76 | "itemId='" + itemId + '\'' + 77 | ", itemName='" + itemName + '\'' + 78 | ", imgUrl='" + imgUrl + '\'' + 79 | ", price=" + price + 80 | ", sellCounts=" + sellCounts + 81 | '}'; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /domain/cart/foodie-cart-web/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | ############################################################ 2 | # 3 | # tomcat 配置 4 | # 5 | ############################################################ 6 | server: 7 | port: 8088 8 | tomcat: 9 | uri-encoding: UTF-8 10 | max-http-header-size: 80KB 11 | ############################################################ 12 | # 13 | # 配置数据源信息 14 | # 15 | ############################################################ 16 | spring: 17 | application: 18 | name: foodie-cart-service 19 | profiles: 20 | active: dev 21 | ## 为Feign开启,防止@FeignClient注解重复出现 22 | main: 23 | allow-bean-definition-overriding: true 24 | datasource: # 数据源的相关配置 25 | type: com.zaxxer.hikari.HikariDataSource # 数据源类型:HikariCP 26 | driver-class-name: com.mysql.jdbc.Driver # mysql驱动 27 | url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 28 | username: root 29 | password: 30 | hikari: 31 | connection-timeout: 30000 # 等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQ 32 | minimum-idle: 5 # 最小连接数 33 | maximum-pool-size: 20 # 最大连接数 34 | auto-commit: true # 自动提交 35 | idle-timeout: 600000 # 连接超时的最大时长(毫秒),超时则被释放(retired),默认:10分钟 36 | pool-name: DateSourceHikariCP # 连接池名字 37 | max-lifetime: 1800000 # 连接的生命时长(毫秒),超时而且没被使用则被释放(retired),默认:30分钟 38 | connection-test-query: SELECT 1 39 | redis: 40 | host: localhost 41 | database: 1 42 | password: 43 | servlet: 44 | multipart: 45 | max-file-size: 512000 # 500kb 46 | max-request-size: 512000 # 500kb 47 | ############################################################ 48 | # 49 | # mybatis 配置 50 | # 51 | ############################################################ 52 | mybatis: 53 | type-aliases-package: com.pacee1.cart.pojo # 所有POJO类所在包路径 54 | mapper-locations: classpath:mapper/*.xml # mapper映射文件 55 | configuration: 56 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 控制台打印sql 57 | ############################################################ 58 | # 59 | # mybatis mapper 配置 60 | # 61 | ############################################################ 62 | # 通用 Mapper 配置 63 | mapper: 64 | mappers: com.pacee1.my.mapper.MyMapper 65 | not-empty: false # 当使用动态sql时,如果有name != null,会自动添加name != '' 不需要 66 | identity: MYSQL 67 | # 分页插件配置 68 | pagehelper: 69 | helperDialect: mysql 70 | supportMethodsArguments: true 71 | 72 | -------------------------------------------------------------------------------- /domain/item/foodie-item-web/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | ############################################################ 2 | # 3 | # tomcat 配置 4 | # 5 | ############################################################ 6 | server: 7 | port: 8088 8 | tomcat: 9 | uri-encoding: UTF-8 10 | max-http-header-size: 80KB 11 | ############################################################ 12 | # 13 | # 配置数据源信息 14 | # 15 | ############################################################ 16 | spring: 17 | application: 18 | name: foodie-item-service 19 | profiles: 20 | active: dev 21 | ## 为Feign开启,防止@FeignClient注解重复出现 22 | main: 23 | allow-bean-definition-overriding: true 24 | datasource: # 数据源的相关配置 25 | type: com.zaxxer.hikari.HikariDataSource # 数据源类型:HikariCP 26 | driver-class-name: com.mysql.jdbc.Driver # mysql驱动 27 | url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 28 | username: root 29 | password: 30 | hikari: 31 | connection-timeout: 30000 # 等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQ 32 | minimum-idle: 5 # 最小连接数 33 | maximum-pool-size: 20 # 最大连接数 34 | auto-commit: true # 自动提交 35 | idle-timeout: 600000 # 连接超时的最大时长(毫秒),超时则被释放(retired),默认:10分钟 36 | pool-name: DateSourceHikariCP # 连接池名字 37 | max-lifetime: 1800000 # 连接的生命时长(毫秒),超时而且没被使用则被释放(retired),默认:30分钟 38 | connection-test-query: SELECT 1 39 | redis: 40 | host: localhost 41 | database: 1 42 | password: 43 | servlet: 44 | multipart: 45 | max-file-size: 512000 # 500kb 46 | max-request-size: 512000 # 500kb 47 | ############################################################ 48 | # 49 | # mybatis 配置 50 | # 51 | ############################################################ 52 | mybatis: 53 | type-aliases-package: com.pacee1.item.pojo # 所有POJO类所在包路径 54 | mapper-locations: classpath:mapper/*.xml # mapper映射文件 55 | configuration: 56 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 控制台打印sql 57 | ############################################################ 58 | # 59 | # mybatis mapper 配置 60 | # 61 | ############################################################ 62 | # 通用 Mapper 配置 63 | mapper: 64 | mappers: com.pacee1.my.mapper.MyMapper 65 | not-empty: false # 当使用动态sql时,如果有name != null,会自动添加name != '' 不需要 66 | identity: MYSQL 67 | # 分页插件配置 68 | pagehelper: 69 | helperDialect: mysql 70 | supportMethodsArguments: true 71 | 72 | -------------------------------------------------------------------------------- /domain/order/foodie-order-web/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | ############################################################ 2 | # 3 | # tomcat 配置 4 | # 5 | ############################################################ 6 | server: 7 | port: 8088 8 | tomcat: 9 | uri-encoding: UTF-8 10 | max-http-header-size: 80KB 11 | ############################################################ 12 | # 13 | # 配置数据源信息 14 | # 15 | ############################################################ 16 | spring: 17 | application: 18 | name: foodie-order-service 19 | profiles: 20 | active: dev 21 | ## 为Feign开启,防止@FeignClient注解重复出现 22 | main: 23 | allow-bean-definition-overriding: true 24 | datasource: # 数据源的相关配置 25 | type: com.zaxxer.hikari.HikariDataSource # 数据源类型:HikariCP 26 | driver-class-name: com.mysql.jdbc.Driver # mysql驱动 27 | url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 28 | username: root 29 | password: 30 | hikari: 31 | connection-timeout: 30000 # 等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQ 32 | minimum-idle: 5 # 最小连接数 33 | maximum-pool-size: 20 # 最大连接数 34 | auto-commit: true # 自动提交 35 | idle-timeout: 600000 # 连接超时的最大时长(毫秒),超时则被释放(retired),默认:10分钟 36 | pool-name: DateSourceHikariCP # 连接池名字 37 | max-lifetime: 1800000 # 连接的生命时长(毫秒),超时而且没被使用则被释放(retired),默认:30分钟 38 | connection-test-query: SELECT 1 39 | redis: 40 | host: localhost 41 | database: 1 42 | password: 43 | servlet: 44 | multipart: 45 | max-file-size: 512000 # 500kb 46 | max-request-size: 512000 # 500kb 47 | ############################################################ 48 | # 49 | # mybatis 配置 50 | # 51 | ############################################################ 52 | mybatis: 53 | type-aliases-package: com.pacee1.order.pojo # 所有POJO类所在包路径 54 | mapper-locations: classpath:mapper/*.xml # mapper映射文件 55 | configuration: 56 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 控制台打印sql 57 | ############################################################ 58 | # 59 | # mybatis mapper 配置 60 | # 61 | ############################################################ 62 | # 通用 Mapper 配置 63 | mapper: 64 | mappers: com.pacee1.my.mapper.MyMapper 65 | not-empty: false # 当使用动态sql时,如果有name != null,会自动添加name != '' 不需要 66 | identity: MYSQL 67 | # 分页插件配置 68 | pagehelper: 69 | helperDialect: mysql 70 | supportMethodsArguments: true 71 | 72 | -------------------------------------------------------------------------------- /domain/search/foodie-search-web/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | ############################################################ 2 | # 3 | # tomcat 配置 4 | # 5 | ############################################################ 6 | server: 7 | port: 8088 8 | tomcat: 9 | uri-encoding: UTF-8 10 | max-http-header-size: 80KB 11 | ############################################################ 12 | # 13 | # 配置数据源信息 14 | # 15 | ############################################################ 16 | spring: 17 | application: 18 | name: foodie-search-service 19 | profiles: 20 | active: dev 21 | ## 为Feign开启,防止@FeignClient注解重复出现 22 | main: 23 | allow-bean-definition-overriding: true 24 | datasource: # 数据源的相关配置 25 | type: com.zaxxer.hikari.HikariDataSource # 数据源类型:HikariCP 26 | driver-class-name: com.mysql.jdbc.Driver # mysql驱动 27 | url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 28 | username: root 29 | password: 30 | hikari: 31 | connection-timeout: 30000 # 等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQ 32 | minimum-idle: 5 # 最小连接数 33 | maximum-pool-size: 20 # 最大连接数 34 | auto-commit: true # 自动提交 35 | idle-timeout: 600000 # 连接超时的最大时长(毫秒),超时则被释放(retired),默认:10分钟 36 | pool-name: DateSourceHikariCP # 连接池名字 37 | max-lifetime: 1800000 # 连接的生命时长(毫秒),超时而且没被使用则被释放(retired),默认:30分钟 38 | connection-test-query: SELECT 1 39 | redis: 40 | host: localhost 41 | database: 1 42 | password: 43 | servlet: 44 | multipart: 45 | max-file-size: 512000 # 500kb 46 | max-request-size: 512000 # 500kb 47 | ############################################################ 48 | # 49 | # mybatis 配置 50 | # 51 | ############################################################ 52 | mybatis: 53 | type-aliases-package: com.pacee1.search.pojo # 所有POJO类所在包路径 54 | mapper-locations: classpath:mapper/*.xml # mapper映射文件 55 | configuration: 56 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 控制台打印sql 57 | ############################################################ 58 | # 59 | # mybatis mapper 配置 60 | # 61 | ############################################################ 62 | # 通用 Mapper 配置 63 | mapper: 64 | mappers: com.pacee1.my.mapper.MyMapper 65 | not-empty: false # 当使用动态sql时,如果有name != null,会自动添加name != '' 不需要 66 | identity: MYSQL 67 | # 分页插件配置 68 | pagehelper: 69 | helperDialect: mysql 70 | supportMethodsArguments: true 71 | 72 | -------------------------------------------------------------------------------- /domain/item/foodie-item-service/src/main/java/com.pacee1.item.service.impl/ItemCommentsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.item.service.impl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.pacee1.item.mapper.ItemsCommentsMapperCustom; 6 | import com.pacee1.item.pojo.vo.MyCommentVO; 7 | import com.pacee1.item.service.ItemCommentsService; 8 | import com.pacee1.pojo.PagedGridResult; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.transaction.annotation.Propagation; 11 | import org.springframework.transaction.annotation.Transactional; 12 | import org.springframework.web.bind.annotation.RequestBody; 13 | import org.springframework.web.bind.annotation.RequestParam; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import java.util.HashMap; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | /** 21 | *

商品评价实现

22 | * 23 | * @author : Pace 24 | * @date : 2020-10-21 15:41 25 | **/ 26 | @RestController 27 | public class ItemCommentsServiceImpl implements ItemCommentsService { 28 | 29 | @Autowired 30 | private ItemsCommentsMapperCustom itemsCommentsMapperCustom; 31 | 32 | @Transactional(propagation = Propagation.SUPPORTS) 33 | @Override 34 | public PagedGridResult queryMyComments(@RequestParam("userId") String userId, 35 | @RequestParam(value = "page", required = false) Integer page, 36 | @RequestParam(value = "pageSize", required = false) Integer pageSize) { 37 | PageHelper.startPage(page,pageSize); 38 | List myCommentVOS = itemsCommentsMapperCustom.queryCommentList(userId); 39 | 40 | return setPagedGridResult(myCommentVOS,page); 41 | } 42 | 43 | @Override 44 | public void saveComments(@RequestBody Map map) { 45 | itemsCommentsMapperCustom.saveCommentList(map); 46 | } 47 | 48 | /** 49 | * 封装分页结果 50 | * @param list 51 | * @param page 52 | * @return 53 | */ 54 | private PagedGridResult setPagedGridResult(List list,Integer page){ 55 | PageInfo pageInfo = new PageInfo<>(list); 56 | PagedGridResult result = new PagedGridResult(); 57 | result.setPage(page); 58 | result.setRows(list); 59 | result.setRecords(pageInfo.getTotal()); 60 | result.setTotal(pageInfo.getPages()); 61 | 62 | return result; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /domain/user/foodie-user-web/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | ############################################################ 2 | # 3 | # tomcat 配置 4 | # 5 | ############################################################ 6 | server: 7 | port: 8088 8 | tomcat: 9 | uri-encoding: UTF-8 10 | max-http-header-size: 80KB 11 | ############################################################ 12 | # 13 | # 配置数据源信息 14 | # 15 | ############################################################ 16 | spring: 17 | application: 18 | name: foodie-user-service 19 | profiles: 20 | active: dev 21 | ## 为Feign开启,防止@FeignClient注解重复出现 22 | main: 23 | allow-bean-definition-overriding: true 24 | datasource: # 数据源的相关配置 25 | type: com.zaxxer.hikari.HikariDataSource # 数据源类型:HikariCP 26 | driver-class-name: com.mysql.jdbc.Driver # mysql驱动 27 | url: jdbc:mysql://localhost:3306/foodie?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai 28 | username: root 29 | password: 30 | hikari: 31 | connection-timeout: 30000 # 等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQ 32 | minimum-idle: 5 # 最小连接数 33 | maximum-pool-size: 20 # 最大连接数 34 | auto-commit: true # 自动提交 35 | idle-timeout: 600000 # 连接超时的最大时长(毫秒),超时则被释放(retired),默认:10分钟 36 | pool-name: DateSourceHikariCP # 连接池名字 37 | max-lifetime: 1800000 # 连接的生命时长(毫秒),超时而且没被使用则被释放(retired),默认:30分钟 38 | connection-test-query: SELECT 1 39 | redis: 40 | host: localhost 41 | database: 1 42 | password: 43 | servlet: 44 | multipart: 45 | max-file-size: 512000 # 500kb 46 | max-request-size: 512000 # 500kb 47 | ############################################################ 48 | # 49 | # mybatis 配置 50 | # 51 | ############################################################ 52 | mybatis: 53 | type-aliases-package: com.pacee1.user.pojo # 所有POJO类所在包路径 54 | mapper-locations: classpath:mapper/*.xml # mapper映射文件 55 | configuration: 56 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 控制台打印sql 57 | ############################################################ 58 | # 59 | # mybatis mapper 配置 60 | # 61 | ############################################################ 62 | # 通用 Mapper 配置 63 | mapper: 64 | mappers: com.pacee1.my.mapper.MyMapper 65 | not-empty: false # 当使用动态sql时,如果有name != null,会自动添加name != '' 不需要 66 | identity: MYSQL 67 | # 分页插件配置 68 | pagehelper: 69 | helperDialect: mysql 70 | supportMethodsArguments: true 71 | 72 | # 照片相关配置 73 | pacee1: 74 | image: 75 | faceLocation: /file/image/foodie/faces 76 | serverUrl: http://api.enbuys.com:8088/foodie/faces/ 77 | -------------------------------------------------------------------------------- /domain/auth/foodie-auth-service/src/main/java/com/pacee1/auth/service/impl/JwtService.java: -------------------------------------------------------------------------------- 1 | package com.pacee1.auth.service.impl; 2 | 3 | import com.auth0.jwt.JWT; 4 | import com.auth0.jwt.JWTVerifier; 5 | import com.auth0.jwt.algorithms.Algorithm; 6 | import com.pacee1.auth.service.pojo.Account; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | *

用于生成校验令牌的实现类

14 | * 15 | * @author : Pace 16 | * @date : 2020-12-10 15:17 17 | **/ 18 | @Slf4j 19 | @Service 20 | public class JwtService { 21 | // 生产环境不能这么用 22 | private static final String KEY = "waterbaby"; 23 | private static final String ISSUER = "pacee1"; 24 | 25 | private static final long TOKEN_EXP_TIME = 24 * 3600 * 1000; 26 | private static final String USER_ID = "userid"; 27 | 28 | /** 29 | * 生成Token 30 | * 31 | * @param acct 32 | * @return 33 | */ 34 | public String token(Account acct) { 35 | Date now = new Date(); 36 | // 这里提供了很多种加密算法,生产环境可以用更高等级的加密算法,比如 37 | // 【最常用】采用非对称密钥加密,auth-service只负责生成jwt-token 38 | // 由各个业务方(或网关层)在自己的代码里用key校验token的正确性 39 | // 优点:符合规范,并且节约了一次HTTP Call 40 | // 41 | // 咱这里用了简单的token生成方式,同学们可以试着把上面的场景在本地实现 42 | Algorithm algorithm = Algorithm.HMAC256(KEY); 43 | 44 | String token = JWT.create() 45 | .withIssuer(ISSUER) 46 | .withIssuedAt(now) 47 | .withExpiresAt(new Date(now.getTime() + TOKEN_EXP_TIME)) 48 | .withClaim(USER_ID, acct.getUserId()) 49 | // .withClaim("ROLE", "") 50 | .sign(algorithm); 51 | 52 | log.info("jwt generated, userId={}", acct.getUserId()); 53 | return token; 54 | } 55 | 56 | /** 57 | * 校验Token 58 | * 59 | * @param token 60 | * @param userId 61 | * @return 62 | */ 63 | public boolean verify(String token, String userId) { 64 | log.info("verifying jwt - username={}", userId); 65 | 66 | try { 67 | Algorithm algorithm = Algorithm.HMAC256(KEY); 68 | JWTVerifier verifier = JWT.require(algorithm) 69 | .withIssuer(ISSUER) 70 | .withClaim(USER_ID, userId) 71 | .build(); 72 | 73 | verifier.verify(token); 74 | return true; 75 | } catch (Exception e) { 76 | log.error("auth failed, userId={}", userId); 77 | return false; 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /common/foodie-cloud-common/src/main/java/org/n3r/idworker/utils/Props.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.*; 7 | import java.util.Properties; 8 | 9 | import static java.io.File.separator; 10 | import static org.n3r.idworker.utils.Serializes.closeQuietly; 11 | 12 | public class Props { 13 | static Logger log = LoggerFactory.getLogger(Props.class); 14 | 15 | public static Properties tryProperties(String propertiesFileName, String userHomeBasePath) { 16 | Properties properties = new Properties(); 17 | InputStream is = null; 18 | try { 19 | is = Props.tryResource(propertiesFileName, userHomeBasePath, Silent.ON); 20 | if (is != null) properties.load(is); 21 | } catch (IOException e) { 22 | log.error("load properties error: {}", e.getMessage()); 23 | } finally { 24 | closeQuietly(is); 25 | } 26 | 27 | return properties; 28 | } 29 | 30 | 31 | enum Silent {ON, OFF} 32 | 33 | public static InputStream tryResource(String propertiesFileName, String userHomeBasePath, Silent silent) { 34 | InputStream is = currentDirResource(new File(propertiesFileName)); 35 | if (is != null) return is; 36 | 37 | is = userHomeResource(propertiesFileName, userHomeBasePath); 38 | if (is != null) return is; 39 | 40 | is = classpathResource(propertiesFileName); 41 | if (is != null || silent == Silent.ON) return is; 42 | 43 | throw new RuntimeException("fail to find " + propertiesFileName + " in current dir or classpath"); 44 | } 45 | 46 | private static InputStream userHomeResource(String pathname, String appHome) { 47 | String filePath = System.getProperty("user.home") + separator + appHome; 48 | File dir = new File(filePath); 49 | if (!dir.exists()) return null; 50 | 51 | return currentDirResource(new File(dir, pathname)); 52 | } 53 | 54 | private static InputStream currentDirResource(File file) { 55 | if (!file.exists()) return null; 56 | 57 | try { 58 | return new FileInputStream(file); 59 | } catch (FileNotFoundException e) { 60 | // This should not happened 61 | log.error("read file {} error", file, e); 62 | return null; 63 | } 64 | } 65 | 66 | public static InputStream classpathResource(String resourceName) { 67 | return Props.class.getClassLoader().getResourceAsStream(resourceName); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /platform/gateway/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | INFO 19 | 20 | 21 | 22 | ${CONSOLE_LOG_PATTERN} 23 | utf8 24 | 25 | 26 | 27 | 28 | 29 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /domain/cart/foodie-cart-web/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-cart-web 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-cart-service 19 | ${project.version} 20 | 21 | 22 | ${project.groupId} 23 | foodie-cloud-web-components 24 | ${project.version} 25 | 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-netflix-eureka-client 30 | 31 | 32 | org.springframework.cloud 33 | spring-cloud-starter-config 34 | 35 | 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-starter-sleuth 40 | 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-starter-zipkin 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-maven-plugin 53 | 54 | com.pacee1.cart.CartApplication 55 | 56 | 57 | 58 | 59 | repackage 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /domain/item/foodie-item-web/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie-cloud 7 | com.pacee1 8 | 1.0-SNAPSHOT 9 | ../../../pom.xml 10 | 11 | 4.0.0 12 | 13 | foodie-item-web 14 | 15 | 16 | 17 | ${project.groupId} 18 | foodie-item-service 19 | ${project.version} 20 | 21 | 22 | ${project.groupId} 23 | foodie-cloud-web-components 24 | ${project.version} 25 | 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-netflix-eureka-client 30 | 31 | 32 | org.springframework.cloud 33 | spring-cloud-starter-config 34 | 35 | 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-starter-sleuth 40 | 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-starter-zipkin 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-maven-plugin 53 | 54 | com.pacee1.item.ItemApplication 55 | 56 | 57 | 58 | 59 | repackage 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | --------------------------------------------------------------------------------