├── README.md ├── spring-boot-demo ├── src │ ├── main │ │ ├── java │ │ │ ├── com │ │ │ │ └── funtl │ │ │ │ │ └── spring │ │ │ │ │ └── boot │ │ │ │ │ ├── service │ │ │ │ │ ├── TbUserService.java │ │ │ │ │ └── impl │ │ │ │ │ │ └── TbUserServiceImpl.java │ │ │ │ │ ├── mapper │ │ │ │ │ └── TbUserMapper.java │ │ │ │ │ ├── controller │ │ │ │ │ └── HelloController.java │ │ │ │ │ ├── SpringBootDemoApplication.java │ │ │ │ │ └── domain │ │ │ │ │ └── TbUser.java │ │ │ └── tk │ │ │ │ └── mybatis │ │ │ │ └── mapper │ │ │ │ └── MyMapper.java │ │ └── resources │ │ │ ├── jdbc.properties │ │ │ ├── templates │ │ │ └── index.html │ │ │ ├── application.yml │ │ │ ├── mapper │ │ │ └── TbUserMapper.xml │ │ │ ├── banner.txt │ │ │ └── generator │ │ │ └── generatorConfig.xml │ └── test │ │ └── java │ │ └── com │ │ └── funtl │ │ └── spring │ │ └── boot │ │ └── SpringBootDemoApplicationTests.java └── pom.xml ├── .gitattributes ├── spring-security-oauth2 ├── spring-security-oauth2-server │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ ├── com │ │ │ │ │ └── funtl │ │ │ │ │ │ └── oauth2 │ │ │ │ │ │ ├── server │ │ │ │ │ │ ├── service │ │ │ │ │ │ │ ├── TbRoleService.java │ │ │ │ │ │ │ ├── TbUserService.java │ │ │ │ │ │ │ ├── TbPermissionService.java │ │ │ │ │ │ │ └── impl │ │ │ │ │ │ │ │ ├── TbRoleServiceImpl.java │ │ │ │ │ │ │ │ ├── TbPermissionServiceImpl.java │ │ │ │ │ │ │ │ └── TbUserServiceImpl.java │ │ │ │ │ │ ├── mapper │ │ │ │ │ │ │ ├── TbRoleMapper.java │ │ │ │ │ │ │ ├── TbUserMapper.java │ │ │ │ │ │ │ └── TbPermissionMapper.java │ │ │ │ │ │ ├── domain │ │ │ │ │ │ │ ├── TbUser.java │ │ │ │ │ │ │ ├── TbRole.java │ │ │ │ │ │ │ └── TbPermission.java │ │ │ │ │ │ └── config │ │ │ │ │ │ │ ├── WebSecurityConfiguration.java │ │ │ │ │ │ │ ├── service │ │ │ │ │ │ │ └── UserDetailsServiceImpl.java │ │ │ │ │ │ │ └── AuthorizationServerConfiguration.java │ │ │ │ │ │ └── OAuth2ServerApplication.java │ │ │ │ └── tk │ │ │ │ │ └── mybatis │ │ │ │ │ └── mapper │ │ │ │ │ └── MyMapper.java │ │ │ └── resources │ │ │ │ ├── application.yml │ │ │ │ └── tk │ │ │ │ └── mybatis │ │ │ │ └── mapper │ │ │ │ ├── TbUserMapper.xml │ │ │ │ ├── TbRoleMapper.xml │ │ │ │ └── TbPermissionMapper.xml │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── funtl │ │ │ └── oauth2 │ │ │ └── test │ │ │ ├── PasswordEncoderTests.java │ │ │ └── TbPermissionServiceTests.java │ ├── pom.xml │ └── db │ │ ├── oauth2.sql │ │ └── rbac.sql ├── spring-security-oauth2-resource │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ ├── com │ │ │ │ │ └── funtl │ │ │ │ │ │ └── oauth2 │ │ │ │ │ │ ├── resource │ │ │ │ │ │ ├── service │ │ │ │ │ │ │ ├── TbContentCategoryService.java │ │ │ │ │ │ │ ├── impl │ │ │ │ │ │ │ │ ├── TbContentCategoryServiceImpl.java │ │ │ │ │ │ │ │ └── TbContentServiceImpl.java │ │ │ │ │ │ │ └── TbContentService.java │ │ │ │ │ │ ├── mapper │ │ │ │ │ │ │ ├── TbContentMapper.java │ │ │ │ │ │ │ └── TbContentCategoryMapper.java │ │ │ │ │ │ ├── domain │ │ │ │ │ │ │ ├── TbContentCategory.java │ │ │ │ │ │ │ └── TbContent.java │ │ │ │ │ │ ├── config │ │ │ │ │ │ │ └── ResourceServerConfiguration.java │ │ │ │ │ │ ├── controller │ │ │ │ │ │ │ └── TbContentController.java │ │ │ │ │ │ └── dto │ │ │ │ │ │ │ └── ResponseResult.java │ │ │ │ │ │ └── OAuth2ResourceApplication.java │ │ │ │ └── tk │ │ │ │ │ └── mybatis │ │ │ │ │ └── mapper │ │ │ │ │ └── MyMapper.java │ │ │ └── resources │ │ │ │ ├── tk │ │ │ │ └── mybatis │ │ │ │ │ └── mapper │ │ │ │ │ ├── TbContentCategoryMapper.xml │ │ │ │ │ └── TbContentMapper.xml │ │ │ │ └── application.yml │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── funtl │ │ │ └── oauth2 │ │ │ └── test │ │ │ └── TbContentControllerTests.java │ ├── pom.xml │ └── db │ │ └── resource.sql └── pom.xml ├── apache-shardingsphere ├── sharding-jdbc │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── funtl │ │ │ │ │ └── apache │ │ │ │ │ └── shardingsphere │ │ │ │ │ ├── service │ │ │ │ │ ├── api │ │ │ │ │ │ ├── TbOrderService.java │ │ │ │ │ │ └── TbOrderItemService.java │ │ │ │ │ └── impl │ │ │ │ │ │ ├── TbOrderServiceImpl.java │ │ │ │ │ │ └── TbOrderItemServiceImpl.java │ │ │ │ │ ├── mapper │ │ │ │ │ ├── TbOrderMapper.java │ │ │ │ │ └── TbOrderItemMapper.java │ │ │ │ │ ├── ShardingSphereApplication.java │ │ │ │ │ └── domain │ │ │ │ │ ├── TbOrder.java │ │ │ │ │ └── TbOrderItem.java │ │ │ └── resources │ │ │ │ ├── mapper │ │ │ │ ├── TbOrderMapper.xml │ │ │ │ └── TbOrderItemMapper.xml │ │ │ │ └── application.yml │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── funtl │ │ │ └── apache │ │ │ └── shardingsphere │ │ │ └── tests │ │ │ └── ShardingSphereTests.java │ └── pom.xml └── pom.xml ├── spring-cloud-alibaba ├── spring-cloud-alibaba-consumer │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── bootstrap.properties │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── funtl │ │ │ └── spring │ │ │ └── cloud │ │ │ └── alibaba │ │ │ └── consumer │ │ │ ├── service │ │ │ ├── fallback │ │ │ │ └── EchoServiceFallback.java │ │ │ └── EchoService.java │ │ │ ├── SpringCloudConsumerApplication.java │ │ │ ├── configure │ │ │ └── ConsumerConfiguration.java │ │ │ └── controller │ │ │ ├── TestController.java │ │ │ └── TestEchoController.java │ └── pom.xml ├── spring-cloud-alibaba-provider │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── bootstrap.properties │ │ │ ├── bootstrap-prod.properties │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── funtl │ │ │ └── spring │ │ │ └── cloud │ │ │ └── alibaba │ │ │ └── provider │ │ │ ├── SpringCloudProviderApplication.java │ │ │ └── controller │ │ │ └── EchoController.java │ └── pom.xml └── pom.xml ├── spring-cloud-alibaba-dubbo ├── spring-cloud-alibaba-dubbo-consumer │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── bootstrap.properties │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── funtl │ │ │ └── spring │ │ │ └── cloud │ │ │ └── alibaba │ │ │ └── dubbo │ │ │ └── consumer │ │ │ ├── DubboConsumerApplication.java │ │ │ └── controller │ │ │ └── EchoController.java │ └── pom.xml ├── spring-cloud-alibaba-dubbo-provider │ ├── spring-cloud-alibaba-dubbo-provider-api │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── funtl │ │ │ │ └── spring │ │ │ │ └── cloud │ │ │ │ └── alibaba │ │ │ │ └── dubbo │ │ │ │ └── provider │ │ │ │ └── api │ │ │ │ └── EchoService.java │ │ └── pom.xml │ ├── spring-cloud-alibaba-dubbo-provider-service │ │ ├── src │ │ │ └── main │ │ │ │ ├── resources │ │ │ │ └── application.yml │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── funtl │ │ │ │ └── spring │ │ │ │ └── cloud │ │ │ │ └── alibaba │ │ │ │ └── dubbo │ │ │ │ └── provider │ │ │ │ ├── DubboProviderApplication.java │ │ │ │ └── service │ │ │ │ └── EchoServiceImpl.java │ │ └── pom.xml │ └── pom.xml └── pom.xml ├── spring-cloud-alibaba-seata ├── seata-provider │ ├── seata-provider-order-service │ │ ├── src │ │ │ └── main │ │ │ │ ├── resources │ │ │ │ ├── registry.conf │ │ │ │ ├── mapper │ │ │ │ │ └── TbOrderMapper.xml │ │ │ │ ├── application.yml │ │ │ │ └── file.conf │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── funtl │ │ │ │ └── spring │ │ │ │ └── cloud │ │ │ │ └── alibaba │ │ │ │ └── seata │ │ │ │ ├── mapper │ │ │ │ └── TbOrderMapper.java │ │ │ │ ├── service │ │ │ │ └── impl │ │ │ │ │ └── TbOrderServiceImpl.java │ │ │ │ ├── SeataProviderOrderApplication.java │ │ │ │ └── configuration │ │ │ │ └── SeataConfiguration.java │ │ └── pom.xml │ ├── seata-provider-order-item-service │ │ ├── src │ │ │ └── main │ │ │ │ ├── resources │ │ │ │ ├── registry.conf │ │ │ │ ├── mapper │ │ │ │ │ └── TbOrderItemMapper.xml │ │ │ │ ├── application.yml │ │ │ │ └── file.conf │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── funtl │ │ │ │ └── spring │ │ │ │ └── cloud │ │ │ │ └── alibaba │ │ │ │ └── seata │ │ │ │ ├── mapper │ │ │ │ └── TbOrderItemMapper.java │ │ │ │ ├── service │ │ │ │ └── impl │ │ │ │ │ └── TbOrderItemServiceImpl.java │ │ │ │ ├── SeataProviderOrderItemApplication.java │ │ │ │ └── configuration │ │ │ │ └── SeataConfiguration.java │ │ └── pom.xml │ ├── seata-provider-transaction-service │ │ ├── src │ │ │ └── main │ │ │ │ ├── resources │ │ │ │ ├── registry.conf │ │ │ │ ├── application.yml │ │ │ │ └── file.conf │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── funtl │ │ │ │ └── spring │ │ │ │ └── cloud │ │ │ │ └── alibaba │ │ │ │ └── seata │ │ │ │ ├── configuration │ │ │ │ └── SeataConfiguration.java │ │ │ │ ├── SeataProviderTransactionApplication.java │ │ │ │ └── service │ │ │ │ └── impl │ │ │ │ └── SeataProviderTransactionServiceImpl.java │ │ └── pom.xml │ ├── seata-provider-order-api │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── funtl │ │ │ │ └── spring │ │ │ │ └── cloud │ │ │ │ └── alibaba │ │ │ │ └── seata │ │ │ │ ├── service │ │ │ │ └── api │ │ │ │ │ └── TbOrderService.java │ │ │ │ └── domain │ │ │ │ └── TbOrder.java │ │ └── pom.xml │ ├── seata-provider-order-item-api │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── funtl │ │ │ │ └── spring │ │ │ │ └── cloud │ │ │ │ └── alibaba │ │ │ │ └── seata │ │ │ │ ├── service │ │ │ │ └── api │ │ │ │ │ └── TbOrderItemService.java │ │ │ │ └── domain │ │ │ │ └── TbOrderItem.java │ │ └── pom.xml │ ├── seata-provider-transaction-api │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── funtl │ │ │ │ └── spring │ │ │ │ └── cloud │ │ │ │ └── alibaba │ │ │ │ └── seata │ │ │ │ └── service │ │ │ │ └── api │ │ │ │ └── SeataProviderTransactionService.java │ │ └── pom.xml │ └── pom.xml ├── seata-business │ ├── seata-business-transaction-service │ │ ├── src │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── funtl │ │ │ │ │ └── spring │ │ │ │ │ └── cloud │ │ │ │ │ └── alibaba │ │ │ │ │ └── seata │ │ │ │ │ ├── SeataBusinessTransactionApplication.java │ │ │ │ │ └── controller │ │ │ │ │ └── SeataBusinessTransactionController.java │ │ │ │ └── resources │ │ │ │ └── application.yml │ │ └── pom.xml │ └── pom.xml └── pom.xml ├── .gitignore ├── spring-boot-commons ├── commons-mapper │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── tk │ │ │ └── mybatis │ │ │ └── mapper │ │ │ └── MyMapper.java │ └── pom.xml ├── pom.xml └── commons-utils │ ├── pom.xml │ └── src │ └── main │ └── java │ └── com │ └── funtl │ └── spring │ └── boot │ └── commons │ └── utils │ └── id │ └── LeafSnowflakeId.java └── spring-boot-samples-dependencies └── pom.xml /README.md: -------------------------------------------------------------------------------- 1 | # Spring Boot 教学案例 2 | 3 | -------------------------------------------------------------------------------- /spring-boot-demo/src/main/java/com/funtl/spring/boot/service/TbUserService.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.boot.service; 2 | 3 | public interface TbUserService{ 4 | 5 | 6 | } 7 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Windows-specific files that require CRLF: 2 | *.bat eol=crlf 3 | *.txt eol=crlf 4 | 5 | # Unix-specific files that require LF: 6 | *.java eol=lf 7 | *.sh eol=lf -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/service/TbRoleService.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.service; 2 | 3 | public interface TbRoleService { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /apache-shardingsphere/sharding-jdbc/src/main/java/com/funtl/apache/shardingsphere/service/api/TbOrderService.java: -------------------------------------------------------------------------------- 1 | package com.funtl.apache.shardingsphere.service.api; 2 | 3 | public interface TbOrderService { 4 | 5 | 6 | } 7 | -------------------------------------------------------------------------------- /apache-shardingsphere/sharding-jdbc/src/main/java/com/funtl/apache/shardingsphere/service/api/TbOrderItemService.java: -------------------------------------------------------------------------------- 1 | package com.funtl.apache.shardingsphere.service.api; 2 | 3 | public interface TbOrderItemService { 4 | 5 | 6 | } 7 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/java/com/funtl/oauth2/resource/service/TbContentCategoryService.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.resource.service; 2 | 3 | public interface TbContentCategoryService{ 4 | 5 | } 6 | -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-consumer/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=service-consumer-config 2 | spring.cloud.nacos.config.server-addr=192.168.141.132:8848 3 | spring.cloud.nacos.config.file-extension=yaml -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-provider/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=service-provider-config 2 | spring.cloud.nacos.config.server-addr=192.168.141.132:8848 3 | spring.cloud.nacos.config.file-extension=yaml -------------------------------------------------------------------------------- /spring-boot-demo/src/main/resources/jdbc.properties: -------------------------------------------------------------------------------- 1 | jdbc.driverClass=com.mysql.cj.jdbc.Driver 2 | jdbc.connectionURL=jdbc:mysql://192.168.141.130:3306/myshop?useUnicode=true&characterEncoding=utf-8&useSSL=false 3 | jdbc.username=root 4 | jdbc.password=123456 -------------------------------------------------------------------------------- /spring-cloud-alibaba-dubbo/spring-cloud-alibaba-dubbo-consumer/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=dubbo-consumer-config 2 | spring.cloud.nacos.config.server-addr=192.168.141.132:8848 3 | spring.cloud.nacos.config.file-extension=yaml -------------------------------------------------------------------------------- /spring-boot-demo/src/main/java/com/funtl/spring/boot/mapper/TbUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.boot.mapper; 2 | 3 | import com.funtl.spring.boot.domain.TbUser; 4 | import tk.mybatis.mapper.MyMapper; 5 | 6 | public interface TbUserMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-provider/src/main/resources/bootstrap-prod.properties: -------------------------------------------------------------------------------- 1 | spring.profiles.active=prod 2 | spring.application.name=service-provider-config 3 | spring.cloud.nacos.config.server-addr=192.168.141.132:8848 4 | spring.cloud.nacos.config.file-extension=yaml -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-service/src/main/resources/registry.conf: -------------------------------------------------------------------------------- 1 | registry { 2 | type = "file" 3 | 4 | file { 5 | name = "file.conf" 6 | } 7 | } 8 | 9 | config { 10 | type = "file" 11 | 12 | file { 13 | name = "file.conf" 14 | } 15 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-item-service/src/main/resources/registry.conf: -------------------------------------------------------------------------------- 1 | registry { 2 | type = "file" 3 | 4 | file { 5 | name = "file.conf" 6 | } 7 | } 8 | 9 | config { 10 | type = "file" 11 | 12 | file { 13 | name = "file.conf" 14 | } 15 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-transaction-service/src/main/resources/registry.conf: -------------------------------------------------------------------------------- 1 | registry { 2 | type = "file" 3 | 4 | file { 5 | name = "file.conf" 6 | } 7 | } 8 | 9 | config { 10 | type = "file" 11 | 12 | file { 13 | name = "file.conf" 14 | } 15 | } -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/mapper/TbRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.mapper; 2 | 3 | import com.funtl.oauth2.server.domain.TbRole; 4 | import tk.mybatis.mapper.MyMapper; 5 | 6 | public interface TbRoleMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/mapper/TbUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.mapper; 2 | 3 | import com.funtl.oauth2.server.domain.TbUser; 4 | import tk.mybatis.mapper.MyMapper; 5 | 6 | public interface TbUserMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba-dubbo/spring-cloud-alibaba-dubbo-provider/spring-cloud-alibaba-dubbo-provider-api/src/main/java/com/funtl/spring/cloud/alibaba/dubbo/provider/api/EchoService.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.dubbo.provider.api; 2 | 3 | public interface EchoService { 4 | String echo(String string); 5 | } 6 | -------------------------------------------------------------------------------- /apache-shardingsphere/sharding-jdbc/src/main/java/com/funtl/apache/shardingsphere/mapper/TbOrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.funtl.apache.shardingsphere.mapper; 2 | 3 | import com.funtl.apache.shardingsphere.domain.TbOrder; 4 | import tk.mybatis.mapper.MyMapper; 5 | 6 | public interface TbOrderMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/java/com/funtl/oauth2/resource/mapper/TbContentMapper.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.resource.mapper; 2 | 3 | import com.funtl.oauth2.resource.domain.TbContent; 4 | import tk.mybatis.mapper.MyMapper; 5 | 6 | public interface TbContentMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /apache-shardingsphere/sharding-jdbc/src/main/java/com/funtl/apache/shardingsphere/mapper/TbOrderItemMapper.java: -------------------------------------------------------------------------------- 1 | package com.funtl.apache.shardingsphere.mapper; 2 | 3 | import com.funtl.apache.shardingsphere.domain.TbOrderItem; 4 | import tk.mybatis.mapper.MyMapper; 5 | 6 | public interface TbOrderItemMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/service/TbUserService.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.service; 2 | 3 | import com.funtl.oauth2.server.domain.TbUser; 4 | 5 | public interface TbUserService { 6 | default TbUser getByUsername(String username) { 7 | return null; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/java/com/funtl/oauth2/resource/mapper/TbContentCategoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.resource.mapper; 2 | 3 | import com.funtl.oauth2.resource.domain.TbContentCategory; 4 | import tk.mybatis.mapper.MyMapper; 5 | 6 | public interface TbContentCategoryMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ## STS ## 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ## IntelliJ IDEA ## 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ## JRebel ## 19 | rebel.xml 20 | 21 | ## MAC ## 22 | .DS_Store 23 | 24 | ## Other ## 25 | logs/ 26 | temp/ 27 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-service/src/main/java/com/funtl/spring/cloud/alibaba/seata/mapper/TbOrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata.mapper; 2 | 3 | import com.funtl.spring.cloud.alibaba.seata.domain.TbOrder; 4 | import tk.mybatis.mapper.MyMapper; 5 | 6 | public interface TbOrderMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-api/src/main/java/com/funtl/spring/cloud/alibaba/seata/service/api/TbOrderService.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata.service.api; 2 | 3 | import com.funtl.spring.cloud.alibaba.seata.domain.TbOrder; 4 | 5 | public interface TbOrderService { 6 | 7 | void insert(TbOrder order); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-item-service/src/main/java/com/funtl/spring/cloud/alibaba/seata/mapper/TbOrderItemMapper.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata.mapper; 2 | 3 | import com.funtl.spring.cloud.alibaba.seata.domain.TbOrderItem; 4 | import tk.mybatis.mapper.MyMapper; 5 | 6 | public interface TbOrderItemMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-item-api/src/main/java/com/funtl/spring/cloud/alibaba/seata/service/api/TbOrderItemService.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata.service.api; 2 | 3 | import com.funtl.spring.cloud.alibaba.seata.domain.TbOrderItem; 4 | 5 | public interface TbOrderItemService { 6 | 7 | void insert(TbOrderItem orderItem); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/service/TbPermissionService.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.service; 2 | 3 | import com.funtl.oauth2.server.domain.TbPermission; 4 | 5 | import java.util.List; 6 | 7 | public interface TbPermissionService { 8 | default List selectByUserId(Long userId) { 9 | return null; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-demo/src/main/java/com/funtl/spring/boot/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.boot.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloController { 8 | 9 | @GetMapping("/") 10 | public String sayHi() { 11 | return "Hello Spring Boot"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-provider/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | # 服务名 4 | name: service-provider 5 | cloud: 6 | nacos: 7 | discovery: 8 | # 服务注册中心 9 | server-addr: 192.168.141.132:8848 10 | 11 | server: 12 | # 服务端口 13 | port: 8070 14 | 15 | management: 16 | # 端点检查(健康检查) 17 | endpoints: 18 | web: 19 | exposure: 20 | include: "*" -------------------------------------------------------------------------------- /spring-boot-demo/src/main/java/tk/mybatis/mapper/MyMapper.java: -------------------------------------------------------------------------------- 1 | package tk.mybatis.mapper; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * 自己的 Mapper 8 | * 特别注意,该接口不能被扫描到,否则会出错 9 | *

Title: MyMapper

10 | *

Description:

11 | * 12 | * @author Lusifer 13 | * @version 1.0.0 14 | * @date 2018/5/29 0:57 15 | */ 16 | public interface MyMapper extends Mapper, MySqlMapper { 17 | } 18 | -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-consumer/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | # 服务名 4 | name: service-consumer 5 | cloud: 6 | nacos: 7 | discovery: 8 | # 服务注册中心 9 | server-addr: 192.168.141.132:8848 10 | 11 | server: 12 | # 服务端口 13 | port: 8080 14 | 15 | management: 16 | # 端点检查(健康检查) 17 | endpoints: 18 | web: 19 | exposure: 20 | include: "*" 21 | 22 | user: 23 | name: "灶门炭治郎" -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-transaction-api/src/main/java/com/funtl/spring/cloud/alibaba/seata/service/api/SeataProviderTransactionService.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata.service.api; 2 | 3 | import com.funtl.spring.cloud.alibaba.seata.domain.TbOrder; 4 | import com.funtl.spring.cloud.alibaba.seata.domain.TbOrderItem; 5 | 6 | public interface SeataProviderTransactionService { 7 | void createOrder(TbOrder order, TbOrderItem orderItem); 8 | } 9 | -------------------------------------------------------------------------------- /spring-boot-commons/commons-mapper/src/main/java/tk/mybatis/mapper/MyMapper.java: -------------------------------------------------------------------------------- 1 | package tk.mybatis.mapper; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * 自己的 Mapper 8 | * 特别注意,该接口不能被扫描到,否则会出错 9 | *

Title: MyMapper

10 | *

Description:

11 | * 12 | * @author Lusifer 13 | * @version 1.0.0 14 | * @date 2018/5/29 0:57 15 | */ 16 | public interface MyMapper extends Mapper, MySqlMapper { 17 | } 18 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/mapper/TbPermissionMapper.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.mapper; 2 | 3 | import com.funtl.oauth2.server.domain.TbPermission; 4 | import org.apache.ibatis.annotations.Param; 5 | import tk.mybatis.mapper.MyMapper; 6 | 7 | import java.util.List; 8 | 9 | public interface TbPermissionMapper extends MyMapper { 10 | List selectByUserId(@Param("userId") Long userId); 11 | } -------------------------------------------------------------------------------- /spring-boot-demo/src/main/java/com/funtl/spring/boot/service/impl/TbUserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.boot.service.impl; 2 | 3 | import com.funtl.spring.boot.mapper.TbUserMapper; 4 | import com.funtl.spring.boot.service.TbUserService; 5 | import org.springframework.stereotype.Service; 6 | 7 | import javax.annotation.Resource; 8 | 9 | @Service 10 | public class TbUserServiceImpl implements TbUserService { 11 | 12 | @Resource 13 | private TbUserMapper tbUserMapper; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/java/tk/mybatis/mapper/MyMapper.java: -------------------------------------------------------------------------------- 1 | package tk.mybatis.mapper; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * 自己的 Mapper 8 | * 特别注意,该接口不能被扫描到,否则会出错 9 | *

Title: MyMapper

10 | *

Description:

11 | * 12 | * @author Lusifer 13 | * @version 1.0.0 14 | * @date 2018/5/29 0:57 15 | */ 16 | public interface MyMapper extends Mapper, MySqlMapper { 17 | } 18 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/tk/mybatis/mapper/MyMapper.java: -------------------------------------------------------------------------------- 1 | package tk.mybatis.mapper; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * 自己的 Mapper 8 | * 特别注意,该接口不能被扫描到,否则会出错 9 | *

Title: MyMapper

10 | *

Description:

11 | * 12 | * @author Lusifer 13 | * @version 1.0.0 14 | * @date 2018/5/29 0:57 15 | */ 16 | public interface MyMapper extends Mapper, MySqlMapper { 17 | } 18 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/service/impl/TbRoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.service.impl; 2 | 3 | import org.springframework.stereotype.Service; 4 | import javax.annotation.Resource; 5 | import com.funtl.oauth2.server.mapper.TbRoleMapper; 6 | import com.funtl.oauth2.server.service.TbRoleService; 7 | @Service 8 | public class TbRoleServiceImpl implements TbRoleService{ 9 | 10 | @Resource 11 | private TbRoleMapper tbRoleMapper; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-dubbo/spring-cloud-alibaba-dubbo-provider/spring-cloud-alibaba-dubbo-provider-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: dubbo-provider 4 | main: 5 | allow-bean-definition-overriding: true 6 | 7 | dubbo: 8 | scan: 9 | base-packages: com.funtl.spring.cloud.alibaba.dubbo.provider.service 10 | protocol: 11 | name: dubbo 12 | port: -1 13 | serialization: kryo 14 | registry: 15 | address: nacos://192.168.141.132:8848 16 | provider: 17 | loadbalance: roundrobin -------------------------------------------------------------------------------- /spring-cloud-alibaba-dubbo/spring-cloud-alibaba-dubbo-consumer/src/main/java/com/funtl/spring/cloud/alibaba/dubbo/consumer/DubboConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.dubbo.consumer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DubboConsumerApplication { 8 | public static void main(String[] args) { 9 | SpringApplication.run(DubboConsumerApplication.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /apache-shardingsphere/sharding-jdbc/src/main/java/com/funtl/apache/shardingsphere/service/impl/TbOrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.funtl.apache.shardingsphere.service.impl; 2 | 3 | import com.funtl.apache.shardingsphere.mapper.TbOrderMapper; 4 | import com.funtl.apache.shardingsphere.service.api.TbOrderService; 5 | import org.springframework.stereotype.Service; 6 | 7 | import javax.annotation.Resource; 8 | 9 | @Service 10 | public class TbOrderServiceImpl implements TbOrderService { 11 | 12 | @Resource 13 | private TbOrderMapper tbOrderMapper; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-demo/src/main/java/com/funtl/spring/boot/SpringBootDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.boot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import tk.mybatis.spring.annotation.MapperScan; 6 | 7 | @SpringBootApplication 8 | @MapperScan(basePackages = "com.funtl.spring.boot.mapper") 9 | public class SpringBootDemoApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringBootDemoApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /apache-shardingsphere/sharding-jdbc/src/main/java/com/funtl/apache/shardingsphere/service/impl/TbOrderItemServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.funtl.apache.shardingsphere.service.impl; 2 | 3 | import com.funtl.apache.shardingsphere.mapper.TbOrderItemMapper; 4 | import com.funtl.apache.shardingsphere.service.api.TbOrderItemService; 5 | import org.springframework.stereotype.Service; 6 | 7 | import javax.annotation.Resource; 8 | 9 | @Service 10 | public class TbOrderItemServiceImpl implements TbOrderItemService { 11 | 12 | @Resource 13 | private TbOrderItemMapper tbOrderItemMapper; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-demo/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | Document 9 | 10 | 11 | 李四 12 | 13 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-dubbo/spring-cloud-alibaba-dubbo-provider/spring-cloud-alibaba-dubbo-provider-service/src/main/java/com/funtl/spring/cloud/alibaba/dubbo/provider/DubboProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.dubbo.provider; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DubboProviderApplication { 8 | public static void main(String[] args) { 9 | SpringApplication.run(DubboProviderApplication.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /apache-shardingsphere/sharding-jdbc/src/main/java/com/funtl/apache/shardingsphere/ShardingSphereApplication.java: -------------------------------------------------------------------------------- 1 | package com.funtl.apache.shardingsphere; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import tk.mybatis.spring.annotation.MapperScan; 6 | 7 | @SpringBootApplication 8 | @MapperScan(value = "com.funtl.apache.shardingsphere.mapper") 9 | public class ShardingSphereApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(ShardingSphereApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/java/com/funtl/oauth2/OAuth2ResourceApplication.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import tk.mybatis.spring.annotation.MapperScan; 6 | 7 | @SpringBootApplication 8 | @MapperScan(basePackages = "com.funtl.oauth2.resource.mapper") 9 | public class OAuth2ResourceApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(OAuth2ResourceApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/java/com/funtl/oauth2/resource/service/impl/TbContentCategoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.resource.service.impl; 2 | 3 | import org.springframework.stereotype.Service; 4 | import javax.annotation.Resource; 5 | import com.funtl.oauth2.resource.mapper.TbContentCategoryMapper; 6 | import com.funtl.oauth2.resource.service.TbContentCategoryService; 7 | @Service 8 | public class TbContentCategoryServiceImpl implements TbContentCategoryService{ 9 | 10 | @Resource 11 | private TbContentCategoryMapper tbContentCategoryMapper; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-consumer/src/main/java/com/funtl/spring/cloud/alibaba/consumer/service/fallback/EchoServiceFallback.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.consumer.service.fallback; 2 | 3 | import com.funtl.spring.cloud.alibaba.consumer.service.EchoService; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class EchoServiceFallback implements EchoService { 8 | @Override 9 | public String echo(String string) { 10 | return "你的网络有问题"; 11 | } 12 | 13 | @Override 14 | public String lb() { 15 | return "请联系管理员"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-provider/src/main/java/com/funtl/spring/cloud/alibaba/provider/SpringCloudProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.provider; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | @EnableDiscoveryClient 9 | public class SpringCloudProviderApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(SpringCloudProviderApplication.class, args); 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-transaction-service/src/main/java/com/funtl/spring/cloud/alibaba/seata/configuration/SeataConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata.configuration; 2 | 3 | import io.seata.spring.annotation.GlobalTransactionScanner; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | @Configuration 8 | public class SeataConfiguration { 9 | 10 | @Bean 11 | public GlobalTransactionScanner globalTransactionScanner() { 12 | return new GlobalTransactionScanner("seata-provider-transaction", "tx_group"); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-business/seata-business-transaction-service/src/main/java/com/funtl/spring/cloud/alibaba/seata/SeataBusinessTransactionApplication.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @EnableDiscoveryClient 8 | @SpringBootApplication 9 | public class SeataBusinessTransactionApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(SeataBusinessTransactionApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-transaction-service/src/main/java/com/funtl/spring/cloud/alibaba/seata/SeataProviderTransactionApplication.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @EnableDiscoveryClient 8 | @SpringBootApplication 9 | public class SeataProviderTransactionApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(SeataProviderTransactionApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-consumer/src/main/java/com/funtl/spring/cloud/alibaba/consumer/SpringCloudConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.consumer; 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.openfeign.EnableFeignClients; 7 | 8 | @SpringBootApplication 9 | @EnableDiscoveryClient 10 | @EnableFeignClients 11 | public class SpringCloudConsumerApplication { 12 | public static void main(String[] args) { 13 | SpringApplication.run(SpringCloudConsumerApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-business/seata-business-transaction-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | main: 3 | allow-bean-definition-overriding: true 4 | application: 5 | name: seata-business-transaction 6 | cloud: 7 | nacos: 8 | discovery: 9 | server-addr: 192.168.2.121:8848 10 | sentinel: 11 | transport: 12 | dashboard: localhost:8888 13 | 14 | dubbo: 15 | scan: 16 | base-packages: com.funtl.spring.cloud.alibaba.seata.controller 17 | protocol: 18 | name: dubbo 19 | port: -1 20 | registry: 21 | address: nacos://192.168.2.121:8848 22 | 23 | server: 24 | port: 12001 25 | 26 | management: 27 | endpoints: 28 | web: 29 | exposure: 30 | include: "*" 31 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-dubbo/spring-cloud-alibaba-dubbo-provider/spring-cloud-alibaba-dubbo-provider-service/src/main/java/com/funtl/spring/cloud/alibaba/dubbo/provider/service/EchoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.dubbo.provider.service; 2 | 3 | import com.funtl.spring.cloud.alibaba.dubbo.provider.api.EchoService; 4 | import org.apache.dubbo.config.annotation.Service; 5 | import org.springframework.beans.factory.annotation.Value; 6 | 7 | @Service(version = "1.0.0") 8 | public class EchoServiceImpl implements EchoService { 9 | 10 | @Value("${dubbo.protocol.port}") 11 | private String port; 12 | 13 | @Override 14 | public String echo(String string) { 15 | return "Hello Dubbo " + string + " port:" + port; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-consumer/src/main/java/com/funtl/spring/cloud/alibaba/consumer/service/EchoService.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.consumer.service; 2 | 3 | import com.funtl.spring.cloud.alibaba.consumer.service.fallback.EchoServiceFallback; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | 8 | @FeignClient(value = "service-provider", fallback = EchoServiceFallback.class) 9 | public interface EchoService { 10 | @GetMapping(value = "/echo/{string}") 11 | public String echo(@PathVariable("string") String string); 12 | 13 | @GetMapping(value = "/lb") 14 | public String lb(); 15 | } 16 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-dubbo/spring-cloud-alibaba-dubbo-consumer/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: dubbo-consumer 4 | main: 5 | allow-bean-definition-overriding: true 6 | 7 | dubbo: 8 | scan: 9 | base-packages: com.funtl.spring.cloud.alibaba.dubbo.controller 10 | protocol: 11 | name: dubbo 12 | port: -1 13 | serialization: kryo 14 | registry: 15 | address: nacos://192.168.141.132:8848 16 | server: 17 | port: 8080 18 | 19 | endpoints: 20 | dubbo: 21 | enabled: true 22 | management: 23 | health: 24 | dubbo: 25 | status: 26 | defaults: memory 27 | extras: threadpool 28 | endpoints: 29 | web: 30 | exposure: 31 | include: "*" 32 | 33 | user: 34 | name: "唯我成幸" -------------------------------------------------------------------------------- /apache-shardingsphere/sharding-jdbc/src/main/java/com/funtl/apache/shardingsphere/domain/TbOrder.java: -------------------------------------------------------------------------------- 1 | package com.funtl.apache.shardingsphere.domain; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | import java.io.Serializable; 10 | 11 | @Data 12 | @Table(name = "tb_order") 13 | public class TbOrder implements Serializable { 14 | @Id 15 | @Column(name = "id") 16 | @GeneratedValue(generator = "JDBC") 17 | private Long id; 18 | 19 | @Column(name = "order_id") 20 | private Long orderId; 21 | 22 | @Column(name = "user_id") 23 | private Long userId; 24 | 25 | private static final long serialVersionUID = 1L; 26 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-consumer/src/main/java/com/funtl/spring/cloud/alibaba/consumer/configure/ConsumerConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.consumer.configure; 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 | @Configuration 9 | public class ConsumerConfiguration { 10 | 11 | /** 12 | * 13 | * 14 | * @return 15 | */ 16 | @Bean 17 | @LoadBalanced 18 | public RestTemplate restTemplate() { 19 | return new RestTemplate(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/OAuth2ServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import tk.mybatis.spring.annotation.MapperScan; 6 | 7 | /** 8 | * 认证服务器,用于获取 Token 9 | *

10 | * Description: 11 | *

12 | * 13 | * @author Lusifer 14 | * @version v1.0.0 15 | * @date 2019-04-01 16:06:45 16 | * @see com.funtl.oauth2 17 | */ 18 | @SpringBootApplication 19 | @MapperScan(basePackages = "com.funtl.oauth2.server.mapper") 20 | public class OAuth2ServerApplication { 21 | 22 | public static void main(String[] args) { 23 | SpringApplication.run(OAuth2ServerApplication.class, args); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-api/src/main/java/com/funtl/spring/cloud/alibaba/seata/domain/TbOrder.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata.domain; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | import java.io.Serializable; 10 | 11 | @Data 12 | @Table(name = "tb_order") 13 | public class TbOrder implements Serializable { 14 | @Id 15 | @Column(name = "id") 16 | @GeneratedValue(generator = "JDBC") 17 | private Long id; 18 | 19 | @Column(name = "order_id") 20 | private Integer orderId; 21 | 22 | @Column(name = "user_id") 23 | private Long userId; 24 | 25 | private static final long serialVersionUID = 1L; 26 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-service/src/main/java/com/funtl/spring/cloud/alibaba/seata/service/impl/TbOrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata.service.impl; 2 | 3 | import com.funtl.spring.cloud.alibaba.seata.domain.TbOrder; 4 | import com.funtl.spring.cloud.alibaba.seata.mapper.TbOrderMapper; 5 | import com.funtl.spring.cloud.alibaba.seata.service.api.TbOrderService; 6 | import org.apache.dubbo.config.annotation.Service; 7 | 8 | import javax.annotation.Resource; 9 | 10 | @Service(version = "1.0.0") 11 | public class TbOrderServiceImpl implements TbOrderService { 12 | 13 | @Resource 14 | private TbOrderMapper tbOrderMapper; 15 | 16 | @Override 17 | public void insert(TbOrder order) { 18 | tbOrderMapper.insert(order); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/service/impl/TbPermissionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.service.impl; 2 | 3 | import com.funtl.oauth2.server.domain.TbPermission; 4 | import com.funtl.oauth2.server.mapper.TbPermissionMapper; 5 | import com.funtl.oauth2.server.service.TbPermissionService; 6 | import org.springframework.stereotype.Service; 7 | 8 | import javax.annotation.Resource; 9 | import java.util.List; 10 | 11 | @Service 12 | public class TbPermissionServiceImpl implements TbPermissionService { 13 | 14 | @Resource 15 | private TbPermissionMapper tbPermissionMapper; 16 | 17 | @Override 18 | public List selectByUserId(Long userId) { 19 | return tbPermissionMapper.selectByUserId(userId); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: oauth2-server 4 | datasource: 5 | type: com.zaxxer.hikari.HikariDataSource 6 | driver-class-name: com.mysql.cj.jdbc.Driver 7 | jdbc-url: jdbc:mysql://192.168.141.128:3307/oauth2?useUnicode=true&characterEncoding=utf-8&useSSL=false 8 | username: root 9 | password: 123456 10 | hikari: 11 | minimum-idle: 5 12 | idle-timeout: 600000 13 | maximum-pool-size: 10 14 | auto-commit: true 15 | pool-name: MyHikariCP 16 | max-lifetime: 1800000 17 | connection-timeout: 30000 18 | connection-test-query: SELECT 1 19 | 20 | server: 21 | port: 8080 22 | 23 | mybatis: 24 | type-aliases-package: com.funtl.oauth2.server.domain 25 | mapper-locations: classpath:mapper/*.xml -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-transaction-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | main: 3 | allow-bean-definition-overriding: true 4 | application: 5 | name: seata-provider-transaction 6 | cloud: 7 | nacos: 8 | discovery: 9 | server-addr: 192.168.2.121:8848 10 | sentinel: 11 | transport: 12 | dashboard: localhost:8888 13 | alibaba: 14 | seata: 15 | tx-service-group: tx-group 16 | 17 | dubbo: 18 | scan: 19 | base-packages: com.funtl.spring.cloud.alibaba.seata.service 20 | protocol: 21 | name: dubbo 22 | port: -1 23 | provider: 24 | loadbalance: roundrobin 25 | registry: 26 | address: nacos://192.168.2.121:8848 27 | 28 | #logging: 29 | # level: 30 | # com.funtl.spring.cloud.alibaba.provider.mapper: debug 31 | # io.seata.core: debug -------------------------------------------------------------------------------- /apache-shardingsphere/sharding-jdbc/src/main/java/com/funtl/apache/shardingsphere/domain/TbOrderItem.java: -------------------------------------------------------------------------------- 1 | package com.funtl.apache.shardingsphere.domain; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | import java.io.Serializable; 10 | 11 | @Data 12 | @Table(name = "tb_order_item") 13 | public class TbOrderItem implements Serializable { 14 | @Id 15 | @Column(name = "id") 16 | @GeneratedValue(generator = "JDBC") 17 | private Long id; 18 | 19 | @Column(name = "user_id") 20 | private Long userId; 21 | 22 | @Column(name = "order_id") 23 | private Long orderId; 24 | 25 | @Column(name = "order_item_id") 26 | private Integer orderItemId; 27 | 28 | private static final long serialVersionUID = 1L; 29 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-item-service/src/main/java/com/funtl/spring/cloud/alibaba/seata/service/impl/TbOrderItemServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata.service.impl; 2 | 3 | import com.funtl.spring.cloud.alibaba.seata.domain.TbOrderItem; 4 | import com.funtl.spring.cloud.alibaba.seata.mapper.TbOrderItemMapper; 5 | import com.funtl.spring.cloud.alibaba.seata.service.api.TbOrderItemService; 6 | import org.apache.dubbo.config.annotation.Service; 7 | 8 | import javax.annotation.Resource; 9 | 10 | @Service(version = "1.0.0") 11 | public class TbOrderItemServiceImpl implements TbOrderItemService { 12 | 13 | @Resource 14 | private TbOrderItemMapper tbOrderItemMapper; 15 | 16 | @Override 17 | public void insert(TbOrderItem orderItem) { 18 | tbOrderItemMapper.insert(orderItem); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /apache-shardingsphere/sharding-jdbc/src/main/resources/mapper/TbOrderMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | id, order_id, user_id 14 | 15 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-service/src/main/java/com/funtl/spring/cloud/alibaba/seata/SeataProviderOrderApplication.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata; 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.transaction.annotation.EnableTransactionManagement; 7 | import tk.mybatis.spring.annotation.MapperScan; 8 | 9 | @EnableDiscoveryClient 10 | @EnableTransactionManagement 11 | @SpringBootApplication 12 | @MapperScan(basePackages = "com.funtl.spring.cloud.alibaba.seata.mapper") 13 | public class SeataProviderOrderApplication { 14 | public static void main(String[] args) { 15 | SpringApplication.run(SeataProviderOrderApplication.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/service/impl/TbUserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.service.impl; 2 | 3 | import com.funtl.oauth2.server.domain.TbUser; 4 | import com.funtl.oauth2.server.mapper.TbUserMapper; 5 | import com.funtl.oauth2.server.service.TbUserService; 6 | import org.springframework.stereotype.Service; 7 | import tk.mybatis.mapper.entity.Example; 8 | 9 | import javax.annotation.Resource; 10 | 11 | @Service 12 | public class TbUserServiceImpl implements TbUserService { 13 | 14 | @Resource 15 | private TbUserMapper tbUserMapper; 16 | 17 | @Override 18 | public TbUser getByUsername(String username) { 19 | Example example = new Example(TbUser.class); 20 | example.createCriteria().andEqualTo("username", username); 21 | return tbUserMapper.selectOneByExample(example); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-item-api/src/main/java/com/funtl/spring/cloud/alibaba/seata/domain/TbOrderItem.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata.domain; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | import java.io.Serializable; 10 | 11 | @Data 12 | @Table(name = "tb_order_item") 13 | public class TbOrderItem implements Serializable { 14 | @Id 15 | @Column(name = "id") 16 | @GeneratedValue(generator = "JDBC") 17 | private Long id; 18 | 19 | @Column(name = "user_id") 20 | private Long userId; 21 | 22 | @Column(name = "order_id") 23 | private Long orderId; 24 | 25 | @Column(name = "order_item_id") 26 | private Integer orderItemId; 27 | 28 | private static final long serialVersionUID = 1L; 29 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-item-service/src/main/java/com/funtl/spring/cloud/alibaba/seata/SeataProviderOrderItemApplication.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata; 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.transaction.annotation.EnableTransactionManagement; 7 | import tk.mybatis.spring.annotation.MapperScan; 8 | 9 | @EnableDiscoveryClient 10 | @EnableTransactionManagement 11 | @SpringBootApplication 12 | @MapperScan(basePackages = "com.funtl.spring.cloud.alibaba.seata.mapper") 13 | public class SeataProviderOrderItemApplication { 14 | public static void main(String[] args) { 15 | SpringApplication.run(SeataProviderOrderItemApplication.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-provider/src/main/java/com/funtl/spring/cloud/alibaba/provider/controller/EchoController.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.provider.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | public class EchoController { 10 | 11 | @Value("${server.port}") 12 | private String port; 13 | 14 | @GetMapping(value = "/echo/{string}") 15 | public String echo(@PathVariable("string") String string) { 16 | return "Hello Nacos Provider " + string; 17 | } 18 | 19 | @GetMapping(value = "/lb") 20 | public String lb() { 21 | return "Hello Nacos Provider i am from port:" + port; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-service/src/main/resources/mapper/TbOrderMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | id, order_id, user_id 14 | 15 | -------------------------------------------------------------------------------- /apache-shardingsphere/sharding-jdbc/src/main/resources/mapper/TbOrderItemMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | id, user_id, order_id, order_item_id 15 | 16 | -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-consumer/src/main/java/com/funtl/spring/cloud/alibaba/consumer/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.consumer.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | import org.springframework.web.bind.annotation.RestController; 7 | import org.springframework.web.client.RestTemplate; 8 | 9 | @RestController 10 | public class TestController { 11 | 12 | private final RestTemplate restTemplate; 13 | 14 | @Autowired 15 | public TestController(RestTemplate restTemplate) { 16 | this.restTemplate = restTemplate; 17 | } 18 | 19 | @GetMapping(value = "/echo/{str}") 20 | public String echo(@PathVariable("str") String str) { 21 | return restTemplate.getForObject("http://service-provider/echo/" + str, String.class); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-item-service/src/main/resources/mapper/TbOrderItemMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | id, user_id, order_id, order_item_id 15 | 16 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/test/java/com/funtl/oauth2/test/PasswordEncoderTests.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.test; 2 | 3 | import com.funtl.oauth2.OAuth2ServerApplication; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | /** 11 | * 密码加密测试 12 | *

13 | * Description: 14 | *

15 | * 16 | * @author Lusifer 17 | * @version v1.0.0 18 | * @date 2019-04-03 13:48:06 19 | * @see com.funtl.oauth2.test 20 | */ 21 | @RunWith(SpringRunner.class) 22 | @SpringBootTest(classes = OAuth2ServerApplication.class) 23 | public class PasswordEncoderTests { 24 | 25 | @Test 26 | public void testBCryptPasswordEncoder() { 27 | System.out.println(new BCryptPasswordEncoder().encode("secret")); 28 | System.out.println(new BCryptPasswordEncoder().encode("123456")); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-demo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: spring-boot-demo 4 | thymeleaf: 5 | cache: false 6 | mode: HTML 7 | encoding: UTF-8 8 | servlet: 9 | content-type: text/html 10 | datasource: 11 | type: com.zaxxer.hikari.HikariDataSource 12 | driver-class-name: com.mysql.cj.jdbc.Driver 13 | url: jdbc:mysql://192.168.141.130:3306/myshop?useUnicode=true&characterEncoding=utf-8&useSSL=false 14 | username: root 15 | password: 123456 16 | hikari: 17 | minimum-idle: 5 18 | idle-timeout: 600000 19 | maximum-pool-size: 10 20 | auto-commit: true 21 | pool-name: MyHikariCP 22 | max-lifetime: 1800000 23 | connection-timeout: 30000 24 | connection-test-query: SELECT 1 25 | 26 | mybatis: 27 | type-aliases-package: com.funtl.hello.spring.boot.domain 28 | mapper-locations: classpath:mapper/*.xml 29 | 30 | server: 31 | port: 8088 32 | servlet: 33 | context-path: /boot 34 | 35 | logging: 36 | file: ../logs/spring-boot-hello.log 37 | level.org.springframework.web: DEBUG -------------------------------------------------------------------------------- /spring-cloud-alibaba-dubbo/spring-cloud-alibaba-dubbo-consumer/src/main/java/com/funtl/spring/cloud/alibaba/dubbo/consumer/controller/EchoController.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.dubbo.consumer.controller; 2 | 3 | import com.funtl.spring.cloud.alibaba.dubbo.provider.api.EchoService; 4 | import org.apache.dubbo.config.annotation.Reference; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.cloud.context.config.annotation.RefreshScope; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @RefreshScope 12 | @RestController 13 | public class EchoController { 14 | 15 | @Reference(version = "1.0.0") 16 | private EchoService echoService; 17 | 18 | @Value("${user.name}") 19 | private String username; 20 | 21 | @GetMapping(value = "/echo/{string}") 22 | public String echo(@PathVariable String string) { 23 | return echoService.echo(string) + " " + username; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-demo/src/main/resources/mapper/TbUserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id, username, `password`, phone, email, created, updated 17 | 18 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/domain/TbUser.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.domain; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | import javax.persistence.*; 6 | import lombok.Data; 7 | 8 | @Data 9 | @Table(name = "tb_user") 10 | public class TbUser implements Serializable { 11 | @Id 12 | @Column(name = "id") 13 | @GeneratedValue(generator = "JDBC") 14 | private Long id; 15 | 16 | /** 17 | * 用户名 18 | */ 19 | @Column(name = "username") 20 | private String username; 21 | 22 | /** 23 | * 密码,加密存储 24 | */ 25 | @Column(name = "`password`") 26 | private String password; 27 | 28 | /** 29 | * 注册手机号 30 | */ 31 | @Column(name = "phone") 32 | private String phone; 33 | 34 | /** 35 | * 注册邮箱 36 | */ 37 | @Column(name = "email") 38 | private String email; 39 | 40 | @Column(name = "created") 41 | private Date created; 42 | 43 | @Column(name = "updated") 44 | private Date updated; 45 | 46 | private static final long serialVersionUID = 1L; 47 | } -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/test/java/com/funtl/oauth2/test/TbPermissionServiceTests.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.test; 2 | 3 | import com.funtl.oauth2.OAuth2ServerApplication; 4 | import com.funtl.oauth2.server.service.TbPermissionService; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | /** 12 | * 权限查询测试 13 | *

14 | * Description: 15 | *

16 | * 17 | * @author Lusifer 18 | * @version v1.0.0 19 | * @date 2019-04-04 23:47:25 20 | * @see com.funtl.oauth2.test 21 | */ 22 | @RunWith(SpringRunner.class) 23 | @SpringBootTest(classes = OAuth2ServerApplication.class) 24 | public class TbPermissionServiceTests { 25 | 26 | @Autowired 27 | private TbPermissionService tbPermissionService; 28 | 29 | @Test 30 | public void testSelectByUserId() { 31 | tbPermissionService.selectByUserId(37L).forEach(tbPermission -> System.out.println(tbPermission)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-dubbo/spring-cloud-alibaba-dubbo-provider/spring-cloud-alibaba-dubbo-provider-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-cloud-alibaba-dubbo-provider 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-cloud-alibaba-dubbo-provider-api 13 | http://www.funtl.com 14 | 15 | 16 | 17 | Apache 2.0 18 | https://www.apache.org/licenses/LICENSE-2.0.txt 19 | 20 | 21 | 22 | 23 | 24 | liwemin 25 | Lusifer Lee 26 | lee.lusifer@gmail.com 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /apache-shardingsphere/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-boot-samples 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | apache-shardingsphere 13 | pom 14 | http://www.funtl.com 15 | 16 | 17 | 18 | Apache 2.0 19 | https://www.apache.org/licenses/LICENSE-2.0.txt 20 | 21 | 22 | 23 | 24 | 25 | liwemin 26 | Lusifer Lee 27 | lee.lusifer@gmail.com 28 | 29 | 30 | 31 | 32 | sharding-jdbc 33 | 34 | 35 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/resources/tk/mybatis/mapper/TbUserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id, username, `password`, phone, email, created, updated 17 | 18 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/resources/tk/mybatis/mapper/TbRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id, parent_id, `name`, `enname`, description, created, updated 17 | 18 | -------------------------------------------------------------------------------- /spring-boot-commons/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-boot-samples 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-boot-commons 13 | pom 14 | http://www.funtl.com 15 | 16 | 17 | 18 | Apache 2.0 19 | https://www.apache.org/licenses/LICENSE-2.0.txt 20 | 21 | 22 | 23 | 24 | 25 | liwemin 26 | Lusifer Lee 27 | lee.lusifer@gmail.com 28 | 29 | 30 | 31 | 32 | commons-mapper 33 | commons-utils 34 | 35 | 36 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-business/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-cloud-alibaba-seata 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | seata-business 13 | pom 14 | http://www.funtl.com 15 | 16 | 17 | 18 | Apache 2.0 19 | https://www.apache.org/licenses/LICENSE-2.0.txt 20 | 21 | 22 | 23 | 24 | 25 | liwemin 26 | Lusifer Lee 27 | lee.lusifer@gmail.com 28 | 29 | 30 | 31 | 32 | seata-business-transaction-service 33 | 34 | 35 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-boot-samples 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-cloud-alibaba-seata 13 | pom 14 | http://www.funtl.com 15 | 16 | 17 | 18 | Apache 2.0 19 | https://www.apache.org/licenses/LICENSE-2.0.txt 20 | 21 | 22 | 23 | 24 | 25 | liwemin 26 | Lusifer Lee 27 | lee.lusifer@gmail.com 28 | 29 | 30 | 31 | 32 | seata-provider 33 | seata-business 34 | 35 | 36 | -------------------------------------------------------------------------------- /spring-cloud-alibaba/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-boot-samples 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-cloud-alibaba 13 | pom 14 | http://www.funtl.com 15 | 16 | 17 | spring-cloud-alibaba-provider 18 | spring-cloud-alibaba-consumer 19 | 20 | 21 | 22 | 23 | Apache 2.0 24 | https://www.apache.org/licenses/LICENSE-2.0.txt 25 | 26 | 27 | 28 | 29 | 30 | liwemin 31 | Lusifer Lee 32 | lee.lusifer@gmail.com 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/domain/TbRole.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.domain; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | @Data 13 | @Table(name = "tb_role") 14 | public class TbRole implements Serializable { 15 | @Id 16 | @Column(name = "id") 17 | @GeneratedValue(generator = "JDBC") 18 | private Long id; 19 | 20 | /** 21 | * 父角色 22 | */ 23 | @Column(name = "parent_id") 24 | private Long parentId; 25 | 26 | /** 27 | * 角色名称 28 | */ 29 | @Column(name = "`name`") 30 | private String name; 31 | 32 | /** 33 | * 角色英文名称 34 | */ 35 | @Column(name = "`enname`") 36 | private String enname; 37 | 38 | /** 39 | * 备注 40 | */ 41 | @Column(name = "description") 42 | private String description; 43 | 44 | @Column(name = "created") 45 | private Date created; 46 | 47 | @Column(name = "updated") 48 | private Date updated; 49 | 50 | private static final long serialVersionUID = 1L; 51 | } -------------------------------------------------------------------------------- /spring-security-oauth2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-boot-samples 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-security-oauth2 13 | pom 14 | http://www.funtl.com 15 | 16 | 17 | spring-security-oauth2-server 18 | spring-security-oauth2-resource 19 | 20 | 21 | 22 | 23 | Apache 2.0 24 | https://www.apache.org/licenses/LICENSE-2.0.txt 25 | 26 | 27 | 28 | 29 | 30 | liwemin 31 | Lusifer Lee 32 | lee.lusifer@gmail.com 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-dubbo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-boot-samples 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-cloud-alibaba-dubbo 13 | pom 14 | http://www.funtl.com 15 | 16 | 17 | spring-cloud-alibaba-dubbo-provider 18 | spring-cloud-alibaba-dubbo-consumer 19 | 20 | 21 | 22 | 23 | Apache 2.0 24 | https://www.apache.org/licenses/LICENSE-2.0.txt 25 | 26 | 27 | 28 | 29 | 30 | liwemin 31 | Lusifer Lee 32 | lee.lusifer@gmail.com 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/domain/TbPermission.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.domain; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | @Data 13 | @Table(name = "tb_permission") 14 | public class TbPermission implements Serializable { 15 | @Id 16 | @Column(name = "id") 17 | @GeneratedValue(generator = "JDBC") 18 | private Long id; 19 | 20 | /** 21 | * 父权限 22 | */ 23 | @Column(name = "parent_id") 24 | private Long parentId; 25 | 26 | /** 27 | * 权限名称 28 | */ 29 | @Column(name = "`name`") 30 | private String name; 31 | 32 | /** 33 | * 权限英文名称 34 | */ 35 | @Column(name = "`enname`") 36 | private String enname; 37 | 38 | /** 39 | * 备注 40 | */ 41 | @Column(name = "description") 42 | private String description; 43 | 44 | @Column(name = "created") 45 | private Date created; 46 | 47 | @Column(name = "updated") 48 | private Date updated; 49 | 50 | private static final long serialVersionUID = 1L; 51 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-consumer/src/main/java/com/funtl/spring/cloud/alibaba/consumer/controller/TestEchoController.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.consumer.controller; 2 | 3 | import com.funtl.spring.cloud.alibaba.consumer.service.EchoService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.cloud.context.config.annotation.RefreshScope; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @RefreshScope 12 | @RestController 13 | public class TestEchoController { 14 | 15 | @Autowired 16 | private EchoService echoService; 17 | 18 | @Value("${user.name}") 19 | private String username; 20 | 21 | @GetMapping(value = "/feign/echo/{str}") 22 | public String echo(@PathVariable String str) { 23 | return echoService.echo(str); 24 | } 25 | 26 | @GetMapping(value = "/feign/echo") 27 | public String echo() { 28 | return echoService.echo(username); 29 | } 30 | 31 | @GetMapping(value = "/lb") 32 | public String lb() { 33 | return echoService.lb(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/resources/tk/mybatis/mapper/TbContentCategoryMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | id, parent_id, `name`, `status`, sort_order, is_parent, created, updated 18 | 19 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/java/com/funtl/oauth2/resource/service/TbContentService.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.resource.service; 2 | 3 | import com.funtl.oauth2.resource.domain.TbContent; 4 | 5 | import java.util.List; 6 | 7 | public interface TbContentService { 8 | 9 | /** 10 | * 根据 ID 获取 11 | * 12 | * @param id ID 13 | * @return {@link TbContent} 14 | */ 15 | default TbContent getById(Long id) { 16 | return null; 17 | } 18 | 19 | /** 20 | * 获取全部数据 21 | * 22 | * @return {@link List} 23 | */ 24 | default List selectAll() { 25 | return null; 26 | } 27 | 28 | /** 29 | * 新增 30 | * 31 | * @param tbContent {@link TbContent} 32 | * @return int 数据库受影响行数 33 | */ 34 | default int insert(TbContent tbContent) { 35 | return 0; 36 | } 37 | 38 | /** 39 | * 编辑 40 | * 41 | * @param tbContent {@link TbContent} 42 | * @return int 数据库受影响行数 43 | */ 44 | default int update(TbContent tbContent) { 45 | return 0; 46 | } 47 | 48 | /** 49 | * 删除 50 | * 51 | * @param id ID 52 | * @return int 数据库受影响行数 53 | */ 54 | default int delete(Long id) { 55 | return 0; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/java/com/funtl/oauth2/resource/service/impl/TbContentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.resource.service.impl; 2 | 3 | import com.funtl.oauth2.resource.domain.TbContent; 4 | import com.funtl.oauth2.resource.mapper.TbContentMapper; 5 | import com.funtl.oauth2.resource.service.TbContentService; 6 | import org.springframework.stereotype.Service; 7 | 8 | import javax.annotation.Resource; 9 | import java.util.List; 10 | 11 | @Service 12 | public class TbContentServiceImpl implements TbContentService { 13 | 14 | @Resource 15 | private TbContentMapper tbContentMapper; 16 | 17 | @Override 18 | public TbContent getById(Long id) { 19 | return tbContentMapper.selectByPrimaryKey(id); 20 | } 21 | 22 | @Override 23 | public List selectAll() { 24 | return tbContentMapper.selectAll(); 25 | } 26 | 27 | @Override 28 | public int insert(TbContent tbContent) { 29 | return tbContentMapper.insert(tbContent); 30 | } 31 | 32 | @Override 33 | public int update(TbContent tbContent) { 34 | return tbContentMapper.updateByPrimaryKey(tbContent); 35 | } 36 | 37 | @Override 38 | public int delete(Long id) { 39 | return tbContentMapper.deleteByPrimaryKey(id); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-dubbo/spring-cloud-alibaba-dubbo-provider/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-cloud-alibaba-dubbo 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-cloud-alibaba-dubbo-provider 13 | pom 14 | http://www.funtl.com 15 | 16 | 17 | spring-cloud-alibaba-dubbo-provider-api 18 | spring-cloud-alibaba-dubbo-provider-service 19 | 20 | 21 | 22 | 23 | Apache 2.0 24 | https://www.apache.org/licenses/LICENSE-2.0.txt 25 | 26 | 27 | 28 | 29 | 30 | liwemin 31 | Lusifer Lee 32 | lee.lusifer@gmail.com 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /spring-boot-commons/commons-utils/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-boot-commons 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | commons-utils 13 | jar 14 | http://www.funtl.com 15 | 2018-Now 16 | 17 | 18 | 19 | Apache 2.0 20 | https://www.apache.org/licenses/LICENSE-2.0.txt 21 | 22 | 23 | 24 | 25 | 26 | liwemin 27 | Lusifer Lee 28 | lee.lusifer@gmail.com 29 | 30 | 31 | 32 | 33 | 34 | com.squareup.okhttp3 35 | okhttp 36 | 37 | 38 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: oauth2-resource 4 | datasource: 5 | type: com.zaxxer.hikari.HikariDataSource 6 | driver-class-name: com.mysql.cj.jdbc.Driver 7 | url: jdbc:mysql://192.168.141.128:3307/oauth2_resource?useUnicode=true&characterEncoding=utf-8&useSSL=false 8 | username: root 9 | password: 123456 10 | hikari: 11 | minimum-idle: 5 12 | idle-timeout: 600000 13 | maximum-pool-size: 10 14 | auto-commit: true 15 | pool-name: MyHikariCP 16 | max-lifetime: 1800000 17 | connection-timeout: 30000 18 | connection-test-query: SELECT 1 19 | 20 | security: 21 | oauth2: 22 | client: 23 | client-id: client 24 | client-secret: secret 25 | access-token-uri: http://localhost:8080/oauth/token 26 | user-authorization-uri: http://localhost:8080/oauth/authorize 27 | resource: 28 | token-info-uri: http://localhost:8080/oauth/check_token 29 | 30 | server: 31 | port: 8081 32 | servlet: 33 | context-path: /contents 34 | 35 | mybatis: 36 | type-aliases-package: com.funtl.oauth2.resource.domain 37 | mapper-locations: classpath:mapper/*.xml 38 | 39 | logging: 40 | level: 41 | root: INFO 42 | org.springframework.web: INFO 43 | org.springframework.security: INFO 44 | org.springframework.security.oauth2: INFO 45 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-business/seata-business-transaction-service/src/main/java/com/funtl/spring/cloud/alibaba/seata/controller/SeataBusinessTransactionController.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata.controller; 2 | 3 | import com.funtl.spring.cloud.alibaba.seata.domain.TbOrder; 4 | import com.funtl.spring.cloud.alibaba.seata.domain.TbOrderItem; 5 | import com.funtl.spring.cloud.alibaba.seata.service.api.SeataProviderTransactionService; 6 | import org.apache.dubbo.config.annotation.Reference; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @RestController 12 | @RequestMapping(value = "transaction") 13 | public class SeataBusinessTransactionController { 14 | 15 | @Reference(version = "1.0.0") 16 | private SeataProviderTransactionService transactionService; 17 | 18 | @GetMapping(value = "create/order") 19 | public String createOrder() { 20 | TbOrder order = new TbOrder(); 21 | order.setOrderId(1); 22 | order.setUserId(1L); 23 | 24 | TbOrderItem orderItem = new TbOrderItem(); 25 | orderItem.setUserId(1L); 26 | orderItem.setOrderId(1L); 27 | orderItem.setOrderItemId(1); 28 | 29 | transactionService.createOrder(order, orderItem); 30 | return "ok"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-commons/commons-utils/src/main/java/com/funtl/spring/boot/commons/utils/id/LeafSnowflakeId.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.boot.commons.utils.id; 2 | 3 | import com.funtl.spring.boot.commons.utils.net.OkHttpClientUtil; 4 | 5 | import java.io.IOException; 6 | import java.text.ParseException; 7 | import java.util.Objects; 8 | 9 | /** 10 | * 通过 Leaf 获取雪花 ID 11 | *

12 | * Description: 13 | *

14 | * 15 | * @author Lusifer 16 | * @version v1.0.0 17 | * @date 2019-12-26 03:45:16 18 | * @see com.funtl.spring.boot.commons.utils.id 19 | */ 20 | public class LeafSnowflakeId { 21 | 22 | /** 23 | * 注意我这里写死了获取 Leaf 地址,只是为了方便演示 24 | */ 25 | private static final String LEAF_HOST = "http://192.168.2.121:8080/api/snowflake/get/id"; 26 | 27 | /** 28 | * 生成 ID 29 | * 30 | * @return {@code Long} 雪花 ID 31 | */ 32 | public static Long genId() { 33 | try { 34 | String string = Objects.requireNonNull(OkHttpClientUtil.getInstance().getData(LEAF_HOST).body()).string(); 35 | return Long.valueOf(string); 36 | } catch (IOException e) { 37 | return 0L; 38 | } 39 | } 40 | 41 | /** 42 | * 测试 43 | * 44 | * @param args 45 | * @throws ParseException 46 | */ 47 | public static void main(String[] args) throws ParseException { 48 | for (int i = 0; i < 100; i++) { 49 | System.out.println(LeafSnowflakeId.genId()); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-transaction-service/src/main/java/com/funtl/spring/cloud/alibaba/seata/service/impl/SeataProviderTransactionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata.service.impl; 2 | 3 | import com.funtl.spring.cloud.alibaba.seata.domain.TbOrder; 4 | import com.funtl.spring.cloud.alibaba.seata.domain.TbOrderItem; 5 | import com.funtl.spring.cloud.alibaba.seata.service.api.SeataProviderTransactionService; 6 | import com.funtl.spring.cloud.alibaba.seata.service.api.TbOrderItemService; 7 | import com.funtl.spring.cloud.alibaba.seata.service.api.TbOrderService; 8 | import io.seata.spring.annotation.GlobalTransactional; 9 | import org.apache.dubbo.config.annotation.Reference; 10 | import org.apache.dubbo.config.annotation.Service; 11 | 12 | @Service(version = "1.0.0") 13 | public class SeataProviderTransactionServiceImpl implements SeataProviderTransactionService { 14 | 15 | @Reference(version = "1.0.0") 16 | private TbOrderService orderService; 17 | 18 | @Reference(version = "1.0.0") 19 | private TbOrderItemService orderItemService; 20 | 21 | @Override 22 | @GlobalTransactional 23 | public void createOrder(TbOrder order, TbOrderItem orderItem) { 24 | orderService.insert(order); 25 | orderItemService.insert(orderItem); 26 | 27 | // 抛出异常用以测试分布式事务是否回滚 28 | if (order.getUserId().equals(1L)) { 29 | throw new RuntimeException("Exception for seata."); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/java/com/funtl/oauth2/resource/domain/TbContentCategory.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.resource.domain; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | import javax.persistence.*; 6 | import lombok.Data; 7 | 8 | @Data 9 | @Table(name = "tb_content_category") 10 | public class TbContentCategory implements Serializable { 11 | /** 12 | * 类目ID 13 | */ 14 | @Id 15 | @Column(name = "id") 16 | @GeneratedValue(generator = "JDBC") 17 | private Long id; 18 | 19 | /** 20 | * 父类目ID=0时,代表的是一级的类目 21 | */ 22 | @Column(name = "parent_id") 23 | private Long parentId; 24 | 25 | /** 26 | * 分类名称 27 | */ 28 | @Column(name = "`name`") 29 | private String name; 30 | 31 | /** 32 | * 状态。可选值:1(正常),2(删除) 33 | */ 34 | @Column(name = "`status`") 35 | private Integer status; 36 | 37 | /** 38 | * 排列序号,表示同级类目的展现次序,如数值相等则按名称次序排列。取值范围:大于零的整数 39 | */ 40 | @Column(name = "sort_order") 41 | private Integer sortOrder; 42 | 43 | /** 44 | * 该类目是否为父类目,1为true,0为false 45 | */ 46 | @Column(name = "is_parent") 47 | private Boolean isParent; 48 | 49 | /** 50 | * 创建时间 51 | */ 52 | @Column(name = "created") 53 | private Date created; 54 | 55 | /** 56 | * 创建时间 57 | */ 58 | @Column(name = "updated") 59 | private Date updated; 60 | 61 | private static final long serialVersionUID = 1L; 62 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-cloud-alibaba-seata 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | seata-provider 13 | pom 14 | http://www.funtl.com 15 | 16 | 17 | 18 | Apache 2.0 19 | https://www.apache.org/licenses/LICENSE-2.0.txt 20 | 21 | 22 | 23 | 24 | 25 | liwemin 26 | Lusifer Lee 27 | lee.lusifer@gmail.com 28 | 29 | 30 | 31 | 32 | seata-provider-order-api 33 | seata-provider-order-item-api 34 | seata-provider-transaction-api 35 | seata-provider-order-service 36 | seata-provider-order-item-service 37 | seata-provider-transaction-service 38 | 39 | 40 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/resources/tk/mybatis/mapper/TbContentMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | id, category_id, title, sub_title, title_desc, url, pic, pic2, content, created, 21 | updated 22 | 23 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | main: 3 | allow-bean-definition-overriding: true 4 | application: 5 | name: seata-provider-order 6 | cloud: 7 | nacos: 8 | discovery: 9 | server-addr: 192.168.2.121:8848 10 | sentinel: 11 | transport: 12 | dashboard: localhost:8888 13 | alibaba: 14 | seata: 15 | tx-service-group: tx-group 16 | datasource: 17 | type: com.zaxxer.hikari.HikariDataSource 18 | driver-class-name: com.mysql.cj.jdbc.Driver 19 | jdbc-url: jdbc:mysql://192.168.2.121:3336/db_order?useUnicode=true&characterEncoding=utf-8&serverTimezone=Hongkong&useSSL=false 20 | username: root 21 | password: 123456 22 | hikari: 23 | minimum-idle: 5 24 | idle-timeout: 600000 25 | maximum-pool-size: 10 26 | auto-commit: true 27 | pool-name: MyHikariCP 28 | max-lifetime: 1800000 29 | connection-timeout: 30000 30 | connection-test-query: SELECT 1 31 | 32 | dubbo: 33 | scan: 34 | base-packages: com.funtl.spring.cloud.alibaba.seata.service 35 | protocol: 36 | name: dubbo 37 | port: -1 38 | provider: 39 | loadbalance: roundrobin 40 | registry: 41 | address: nacos://192.168.2.121:8848 42 | 43 | mybatis: 44 | type-aliases-package: com.funtl.spring.cloud.alibaba.provider.domain 45 | mapper-locations: classpath:mapper/*.xml 46 | 47 | #logging: 48 | # level: 49 | # com.funtl.spring.cloud.alibaba.provider.mapper: debug 50 | # io.seata.core: debug -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-item-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | main: 3 | allow-bean-definition-overriding: true 4 | application: 5 | name: seata-provider-order-item 6 | cloud: 7 | nacos: 8 | discovery: 9 | server-addr: 192.168.2.121:8848 10 | sentinel: 11 | transport: 12 | dashboard: localhost:8888 13 | alibaba: 14 | seata: 15 | tx-service-group: tx-group 16 | datasource: 17 | type: com.zaxxer.hikari.HikariDataSource 18 | driver-class-name: com.mysql.cj.jdbc.Driver 19 | jdbc-url: jdbc:mysql://192.168.2.121:3346/db_order_item?useUnicode=true&characterEncoding=utf-8&serverTimezone=Hongkong&useSSL=false 20 | username: root 21 | password: 123456 22 | hikari: 23 | minimum-idle: 5 24 | idle-timeout: 600000 25 | maximum-pool-size: 10 26 | auto-commit: true 27 | pool-name: MyHikariCP 28 | max-lifetime: 1800000 29 | connection-timeout: 30000 30 | connection-test-query: SELECT 1 31 | 32 | dubbo: 33 | scan: 34 | base-packages: com.funtl.spring.cloud.alibaba.seata.service 35 | protocol: 36 | name: dubbo 37 | port: -1 38 | provider: 39 | loadbalance: roundrobin 40 | registry: 41 | address: nacos://192.168.2.121:8848 42 | 43 | mybatis: 44 | type-aliases-package: com.funtl.spring.cloud.alibaba.provider.domain 45 | mapper-locations: classpath:mapper/*.xml 46 | 47 | #logging: 48 | # level: 49 | # com.funtl.spring.cloud.alibaba.provider.mapper: debug 50 | # io.seata.core: debug -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/java/com/funtl/oauth2/resource/domain/TbContent.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.resource.domain; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | import javax.persistence.*; 6 | import lombok.Data; 7 | 8 | @Data 9 | @Table(name = "tb_content") 10 | public class TbContent implements Serializable { 11 | @Id 12 | @Column(name = "id") 13 | @GeneratedValue(generator = "JDBC") 14 | private Long id; 15 | 16 | /** 17 | * 内容类目ID 18 | */ 19 | @Column(name = "category_id") 20 | private Long categoryId; 21 | 22 | /** 23 | * 内容标题 24 | */ 25 | @Column(name = "title") 26 | private String title; 27 | 28 | /** 29 | * 子标题 30 | */ 31 | @Column(name = "sub_title") 32 | private String subTitle; 33 | 34 | /** 35 | * 标题描述 36 | */ 37 | @Column(name = "title_desc") 38 | private String titleDesc; 39 | 40 | /** 41 | * 链接 42 | */ 43 | @Column(name = "url") 44 | private String url; 45 | 46 | /** 47 | * 图片绝对路径 48 | */ 49 | @Column(name = "pic") 50 | private String pic; 51 | 52 | /** 53 | * 图片2 54 | */ 55 | @Column(name = "pic2") 56 | private String pic2; 57 | 58 | /** 59 | * 内容 60 | */ 61 | @Column(name = "content") 62 | private String content; 63 | 64 | @Column(name = "created") 65 | private Date created; 66 | 67 | @Column(name = "updated") 68 | private Date updated; 69 | 70 | private static final long serialVersionUID = 1L; 71 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-service/src/main/resources/file.conf: -------------------------------------------------------------------------------- 1 | transport { 2 | type = "TCP" 3 | server = "NIO" 4 | heartbeat = true 5 | enable-client-batch-send-request = true 6 | thread-factory { 7 | boss-thread-prefix = "NettyBoss" 8 | worker-thread-prefix = "NettyServerNIOWorker" 9 | server-executor-thread-prefix = "NettyServerBizHandler" 10 | share-boss-worker = false 11 | client-selector-thread-prefix = "NettyClientSelector" 12 | client-selector-thread-size = 1 13 | client-worker-thread-prefix = "NettyClientWorkerThread" 14 | boss-thread-size = 1 15 | worker-thread-size = 8 16 | } 17 | shutdown { 18 | wait = 3 19 | } 20 | serialization = "seata" 21 | compressor = "none" 22 | } 23 | service { 24 | vgroup_mapping.tx_group = "default" 25 | default.grouplist = "192.168.2.121:8091" 26 | enableDegrade = false 27 | disableGlobalTransaction = false 28 | } 29 | 30 | client { 31 | rm { 32 | async.commit.buffer.limit = 10000 33 | lock { 34 | retry.internal = 10 35 | retry.times = 30 36 | retry.policy.branch-rollback-on-conflict = true 37 | } 38 | report.retry.count = 5 39 | table.meta.check.enable = false 40 | report.success.enable = true 41 | } 42 | tm { 43 | commit.retry.count = 5 44 | rollback.retry.count = 5 45 | } 46 | undo { 47 | data.validation = true 48 | log.serialization = "jackson" 49 | log.table = "undo_log" 50 | } 51 | log { 52 | exceptionRate = 100 53 | } 54 | support { 55 | spring.datasource.autoproxy = false 56 | } 57 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-item-service/src/main/resources/file.conf: -------------------------------------------------------------------------------- 1 | transport { 2 | type = "TCP" 3 | server = "NIO" 4 | heartbeat = true 5 | enable-client-batch-send-request = true 6 | thread-factory { 7 | boss-thread-prefix = "NettyBoss" 8 | worker-thread-prefix = "NettyServerNIOWorker" 9 | server-executor-thread-prefix = "NettyServerBizHandler" 10 | share-boss-worker = false 11 | client-selector-thread-prefix = "NettyClientSelector" 12 | client-selector-thread-size = 1 13 | client-worker-thread-prefix = "NettyClientWorkerThread" 14 | boss-thread-size = 1 15 | worker-thread-size = 8 16 | } 17 | shutdown { 18 | wait = 3 19 | } 20 | serialization = "seata" 21 | compressor = "none" 22 | } 23 | service { 24 | vgroup_mapping.tx_group = "default" 25 | default.grouplist = "192.168.2.121:8091" 26 | enableDegrade = false 27 | disableGlobalTransaction = false 28 | } 29 | 30 | client { 31 | rm { 32 | async.commit.buffer.limit = 10000 33 | lock { 34 | retry.internal = 10 35 | retry.times = 30 36 | retry.policy.branch-rollback-on-conflict = true 37 | } 38 | report.retry.count = 5 39 | table.meta.check.enable = false 40 | report.success.enable = true 41 | } 42 | tm { 43 | commit.retry.count = 5 44 | rollback.retry.count = 5 45 | } 46 | undo { 47 | data.validation = true 48 | log.serialization = "jackson" 49 | log.table = "undo_log" 50 | } 51 | log { 52 | exceptionRate = 100 53 | } 54 | support { 55 | spring.datasource.autoproxy = false 56 | } 57 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-transaction-service/src/main/resources/file.conf: -------------------------------------------------------------------------------- 1 | transport { 2 | type = "TCP" 3 | server = "NIO" 4 | heartbeat = true 5 | enable-client-batch-send-request = true 6 | thread-factory { 7 | boss-thread-prefix = "NettyBoss" 8 | worker-thread-prefix = "NettyServerNIOWorker" 9 | server-executor-thread-prefix = "NettyServerBizHandler" 10 | share-boss-worker = false 11 | client-selector-thread-prefix = "NettyClientSelector" 12 | client-selector-thread-size = 1 13 | client-worker-thread-prefix = "NettyClientWorkerThread" 14 | boss-thread-size = 1 15 | worker-thread-size = 8 16 | } 17 | shutdown { 18 | wait = 3 19 | } 20 | serialization = "seata" 21 | compressor = "none" 22 | } 23 | service { 24 | vgroup_mapping.tx_group = "default" 25 | default.grouplist = "192.168.2.121:8091" 26 | enableDegrade = false 27 | disableGlobalTransaction = false 28 | } 29 | 30 | client { 31 | rm { 32 | async.commit.buffer.limit = 10000 33 | lock { 34 | retry.internal = 10 35 | retry.times = 30 36 | retry.policy.branch-rollback-on-conflict = true 37 | } 38 | report.retry.count = 5 39 | table.meta.check.enable = false 40 | report.success.enable = true 41 | } 42 | tm { 43 | commit.retry.count = 5 44 | rollback.retry.count = 5 45 | } 46 | undo { 47 | data.validation = true 48 | log.serialization = "jackson" 49 | log.table = "undo_log" 50 | } 51 | log { 52 | exceptionRate = 100 53 | } 54 | support { 55 | spring.datasource.autoproxy = false 56 | } 57 | } -------------------------------------------------------------------------------- /spring-boot-demo/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ${AnsiColor.BRIGHT_RED} 2 | //////////////////////////////////////////////////////////////////// 3 | // _ooOoo_ // 4 | // o8888888o // 5 | // 88" . "88 // 6 | // (| ^_^ |) // 7 | // O\ = /O // 8 | // ____/`---'\____ // 9 | // .' \\| |// `. // 10 | // / \\||| : |||// \ // 11 | // / _||||| -:- |||||- \ // 12 | // | | \\\ - /// | | // 13 | // | \_| ''\---/'' | | // 14 | // \ .-\__ `-` ___/-. / // 15 | // ___`. .' /--.--\ `. . ___ // 16 | // ."" '< `.___\_<|>_/___.' >'"". // 17 | // | | : `- \`.;`\ _ /`;.`/ - ` : | | // 18 | // \ \ `-. \_ __\ /__ _/ .-` / / // 19 | // ========`-.____`-.___\_____/___.-`____.-'======== // 20 | // `=---=' // 21 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // 22 | // 佛祖保佑 永不宕机 永无BUG // 23 | //////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/resources/tk/mybatis/mapper/TbPermissionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id, parent_id, `name`, `enname`, description, created, updated 17 | 18 | 33 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/java/com/funtl/oauth2/resource/config/ResourceServerConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.resource.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 5 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 6 | import org.springframework.security.config.http.SessionCreationPolicy; 7 | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; 8 | import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; 9 | 10 | @Configuration 11 | @EnableResourceServer 12 | @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, jsr250Enabled = true) 13 | public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter { 14 | 15 | @Override 16 | public void configure(HttpSecurity http) throws Exception { 17 | http 18 | .exceptionHandling() 19 | .and() 20 | .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) 21 | .and() 22 | .authorizeRequests() 23 | .antMatchers("/").hasAuthority("SystemContent") 24 | .antMatchers("/view/**").hasAuthority("SystemContentView") 25 | .antMatchers("/insert/**").hasAuthority("SystemContentInsert") 26 | .antMatchers("/update/**").hasAuthority("SystemContentUpdate") 27 | .antMatchers("/delete/**").hasAuthority("SystemContentDelete"); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | seata-provider 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | seata-provider-order-api 13 | jar 14 | http://www.funtl.com 15 | 2018-Now 16 | 17 | 18 | 19 | Apache 2.0 20 | https://www.apache.org/licenses/LICENSE-2.0.txt 21 | 22 | 23 | 24 | 25 | 26 | liwemin 27 | Lusifer Lee 28 | lee.lusifer@gmail.com 29 | 30 | 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter 36 | provided 37 | 38 | 39 | javax.persistence 40 | javax.persistence-api 41 | provided 42 | 43 | 44 | org.projectlombok 45 | lombok 46 | provided 47 | 48 | 49 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-item-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | seata-provider 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | seata-provider-order-item-api 13 | jar 14 | http://www.funtl.com 15 | 2018-Now 16 | 17 | 18 | 19 | Apache 2.0 20 | https://www.apache.org/licenses/LICENSE-2.0.txt 21 | 22 | 23 | 24 | 25 | 26 | liwemin 27 | Lusifer Lee 28 | lee.lusifer@gmail.com 29 | 30 | 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter 36 | provided 37 | 38 | 39 | javax.persistence 40 | javax.persistence-api 41 | provided 42 | 43 | 44 | org.projectlombok 45 | lombok 46 | provided 47 | 48 | 49 | -------------------------------------------------------------------------------- /apache-shardingsphere/sharding-jdbc/src/test/java/com/funtl/apache/shardingsphere/tests/ShardingSphereTests.java: -------------------------------------------------------------------------------- 1 | package com.funtl.apache.shardingsphere.tests; 2 | 3 | import com.funtl.apache.shardingsphere.domain.TbOrder; 4 | import com.funtl.apache.shardingsphere.domain.TbOrderItem; 5 | import com.funtl.apache.shardingsphere.mapper.TbOrderItemMapper; 6 | import com.funtl.apache.shardingsphere.mapper.TbOrderMapper; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | 15 | @SpringBootTest 16 | @RunWith(SpringRunner.class) 17 | public class ShardingSphereTests { 18 | 19 | @Resource 20 | private TbOrderMapper tbOrderMapper; 21 | 22 | @Resource 23 | private TbOrderItemMapper tbOrderItemMapper; 24 | 25 | @Test 26 | public void testInsertOrder() { 27 | TbOrder tbOrder = new TbOrder(); 28 | tbOrder.setOrderId(1L); 29 | tbOrder.setUserId(1L); 30 | 31 | tbOrderMapper.insert(tbOrder); 32 | } 33 | 34 | @Test 35 | public void testInsertOrderItem() { 36 | TbOrderItem tbOrderItem = new TbOrderItem(); 37 | tbOrderItem.setUserId(2L); 38 | tbOrderItem.setOrderId(2L); 39 | tbOrderItem.setOrderItemId(2); 40 | 41 | tbOrderItemMapper.insert(tbOrderItem); 42 | } 43 | 44 | @Test 45 | public void testSelectAll() { 46 | List tbOrders = tbOrderMapper.selectAll(); 47 | tbOrders.forEach(tbOrder -> { 48 | System.out.println(tbOrder); 49 | }); 50 | 51 | List tbOrderItems = tbOrderItemMapper.selectAll(); 52 | tbOrderItems.forEach(tbOrderItem -> { 53 | System.out.println(tbOrderItem); 54 | }); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/config/WebSecurityConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.config; 2 | 3 | import com.funtl.oauth2.server.config.service.UserDetailsServiceImpl; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 7 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 8 | import org.springframework.security.config.annotation.web.builders.WebSecurity; 9 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 10 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 11 | import org.springframework.security.core.userdetails.UserDetailsService; 12 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 13 | 14 | @Configuration 15 | @EnableWebSecurity 16 | @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, jsr250Enabled = true) 17 | public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter { 18 | 19 | @Bean 20 | public BCryptPasswordEncoder passwordEncoder() { 21 | // 设置默认的加密方式 22 | return new BCryptPasswordEncoder(); 23 | } 24 | 25 | @Bean 26 | @Override 27 | public UserDetailsService userDetailsService() { 28 | return new UserDetailsServiceImpl(); 29 | } 30 | 31 | @Override 32 | protected void configure(AuthenticationManagerBuilder auth) throws Exception { 33 | // 使用自定义认证与授权 34 | auth.userDetailsService(userDetailsService()); 35 | } 36 | 37 | @Override 38 | public void configure(WebSecurity web) throws Exception { 39 | // 将 check_token 暴露出去,否则资源服务器访问时报 403 错误 40 | web.ignoring().antMatchers("/oauth/check_token"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-boot-demo/src/main/resources/generator/generatorConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
47 |
48 |
-------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-service/src/main/java/com/funtl/spring/cloud/alibaba/seata/configuration/SeataConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata.configuration; 2 | 3 | import com.zaxxer.hikari.HikariDataSource; 4 | import io.seata.rm.datasource.DataSourceProxy; 5 | import io.seata.spring.annotation.GlobalTransactionScanner; 6 | import org.apache.ibatis.session.SqlSessionFactory; 7 | import org.mybatis.spring.SqlSessionFactoryBean; 8 | import org.mybatis.spring.transaction.SpringManagedTransactionFactory; 9 | import org.springframework.boot.context.properties.ConfigurationProperties; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | import org.springframework.context.annotation.Primary; 13 | import org.springframework.core.io.support.PathMatchingResourcePatternResolver; 14 | 15 | import javax.sql.DataSource; 16 | 17 | @Configuration 18 | public class SeataConfiguration { 19 | 20 | @Bean 21 | @ConfigurationProperties(prefix = "spring.datasource") 22 | public DataSource druidDataSource() { 23 | HikariDataSource hikariDataSource = new HikariDataSource(); 24 | return hikariDataSource; 25 | } 26 | 27 | @Primary 28 | @Bean("dataSource") 29 | public DataSourceProxy dataSource(DataSource hikariDataSource) { 30 | return new DataSourceProxy(hikariDataSource); 31 | } 32 | 33 | @Bean 34 | public SqlSessionFactory sqlSessionFactory(DataSourceProxy dataSourceProxy) throws Exception { 35 | SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); 36 | sqlSessionFactoryBean.setDataSource(dataSourceProxy); 37 | sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver() 38 | .getResources("classpath*:/mapper/*.xml")); 39 | sqlSessionFactoryBean.setTransactionFactory(new SpringManagedTransactionFactory()); 40 | return sqlSessionFactoryBean.getObject(); 41 | } 42 | 43 | @Bean 44 | public GlobalTransactionScanner globalTransactionScanner() { 45 | return new GlobalTransactionScanner("seata-provider-order", "tx_group"); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-item-service/src/main/java/com/funtl/spring/cloud/alibaba/seata/configuration/SeataConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.cloud.alibaba.seata.configuration; 2 | 3 | import com.zaxxer.hikari.HikariDataSource; 4 | import io.seata.rm.datasource.DataSourceProxy; 5 | import io.seata.spring.annotation.GlobalTransactionScanner; 6 | import org.apache.ibatis.session.SqlSessionFactory; 7 | import org.mybatis.spring.SqlSessionFactoryBean; 8 | import org.mybatis.spring.transaction.SpringManagedTransactionFactory; 9 | import org.springframework.boot.context.properties.ConfigurationProperties; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | import org.springframework.context.annotation.Primary; 13 | import org.springframework.core.io.support.PathMatchingResourcePatternResolver; 14 | 15 | import javax.sql.DataSource; 16 | 17 | @Configuration 18 | public class SeataConfiguration { 19 | 20 | @Bean 21 | @ConfigurationProperties(prefix = "spring.datasource") 22 | public DataSource druidDataSource() { 23 | HikariDataSource hikariDataSource = new HikariDataSource(); 24 | return hikariDataSource; 25 | } 26 | 27 | @Primary 28 | @Bean("dataSource") 29 | public DataSourceProxy dataSource(DataSource hikariDataSource) { 30 | return new DataSourceProxy(hikariDataSource); 31 | } 32 | 33 | @Bean 34 | public SqlSessionFactory sqlSessionFactory(DataSourceProxy dataSourceProxy) throws Exception { 35 | SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); 36 | sqlSessionFactoryBean.setDataSource(dataSourceProxy); 37 | sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver() 38 | .getResources("classpath*:/mapper/*.xml")); 39 | sqlSessionFactoryBean.setTransactionFactory(new SpringManagedTransactionFactory()); 40 | return sqlSessionFactoryBean.getObject(); 41 | } 42 | 43 | @Bean 44 | public GlobalTransactionScanner globalTransactionScanner() { 45 | return new GlobalTransactionScanner("seata-provider-order-item", "tx_group"); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-transaction-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | seata-provider 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | seata-provider-transaction-api 13 | jar 14 | http://www.funtl.com 15 | 2018-Now 16 | 17 | 18 | 19 | Apache 2.0 20 | https://www.apache.org/licenses/LICENSE-2.0.txt 21 | 22 | 23 | 24 | 25 | 26 | liwemin 27 | Lusifer Lee 28 | lee.lusifer@gmail.com 29 | 30 | 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter 36 | provided 37 | 38 | 39 | javax.persistence 40 | javax.persistence-api 41 | provided 42 | 43 | 44 | org.projectlombok 45 | lombok 46 | provided 47 | 48 | 49 | 50 | 51 | com.funtl 52 | seata-provider-order-api 53 | ${project.parent.version} 54 | 55 | 56 | com.funtl 57 | seata-provider-order-item-api 58 | ${project.parent.version} 59 | 60 | 61 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/config/service/UserDetailsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.config.service; 2 | 3 | import com.funtl.oauth2.server.domain.TbPermission; 4 | import com.funtl.oauth2.server.domain.TbUser; 5 | import com.funtl.oauth2.server.service.TbPermissionService; 6 | import com.funtl.oauth2.server.service.TbUserService; 7 | import org.assertj.core.util.Lists; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.security.core.GrantedAuthority; 10 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 11 | import org.springframework.security.core.userdetails.User; 12 | import org.springframework.security.core.userdetails.UserDetails; 13 | import org.springframework.security.core.userdetails.UserDetailsService; 14 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 15 | import org.springframework.stereotype.Service; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | * 自定义用户认证与授权 21 | *

22 | * Description: 23 | *

24 | * 25 | * @author Lusifer 26 | * @version v1.0.0 27 | * @date 2019-04-04 23:57:04 28 | * @see com.funtl.oauth2.server.config 29 | */ 30 | @Service 31 | public class UserDetailsServiceImpl implements UserDetailsService { 32 | 33 | @Autowired 34 | private TbUserService tbUserService; 35 | 36 | @Autowired 37 | private TbPermissionService tbPermissionService; 38 | 39 | @Override 40 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 41 | TbUser tbUser = tbUserService.getByUsername(username); 42 | List grantedAuthorities = Lists.newArrayList(); 43 | if (tbUser != null) { 44 | // 获取用户授权 45 | List tbPermissions = tbPermissionService.selectByUserId(tbUser.getId()); 46 | 47 | // 声明用户授权 48 | tbPermissions.forEach(tbPermission -> { 49 | if (tbPermission != null && tbPermission.getEnname() != null) { 50 | GrantedAuthority grantedAuthority = new SimpleGrantedAuthority(tbPermission.getEnname()); 51 | grantedAuthorities.add(grantedAuthority); 52 | } 53 | }); 54 | } 55 | return new User(tbUser.getUsername(), tbUser.getPassword(), grantedAuthorities); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /apache-shardingsphere/sharding-jdbc/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | main: 3 | allow-bean-definition-overriding: true 4 | application: 5 | name: sharding-jdbc 6 | shardingsphere: 7 | props: 8 | sql: 9 | show: true 10 | datasource: 11 | names: ds0,ds1 12 | ds0: 13 | type: com.zaxxer.hikari.HikariDataSource 14 | driver-class-name: com.mysql.jdbc.Driver 15 | jdbc-url: jdbc:mysql://192.168.2.121:3310/myshop_0?useUnicode=true&characterEncoding=utf-8&serverTimezone=Hongkong&useSSL=false 16 | username: root 17 | password: '123456' 18 | hikari: 19 | minimum-idle: 5 20 | idle-timeout: 600000 21 | maximum-pool-size: 10 22 | auto-commit: true 23 | pool-name: MyHikariCP 24 | max-lifetime: 1800000 25 | connection-timeout: 30000 26 | connection-test-query: SELECT 1 27 | ds1: 28 | type: com.zaxxer.hikari.HikariDataSource 29 | driver-class-name: com.mysql.jdbc.Driver 30 | jdbc-url: jdbc:mysql://192.168.2.121:3311/myshop_1?useUnicode=true&characterEncoding=utf-8&serverTimezone=Hongkong&useSSL=false 31 | username: root 32 | password: '123456' 33 | hikari: 34 | minimum-idle: 5 35 | idle-timeout: 600000 36 | maximum-pool-size: 10 37 | auto-commit: true 38 | pool-name: MyHikariCP 39 | max-lifetime: 1800000 40 | connection-timeout: 30000 41 | connection-test-query: SELECT 1 42 | sharding: 43 | binding-tables: tb_order,tb_order_item 44 | default-database-strategy: 45 | inline: 46 | algorithm-expression: ds$->{user_id % 2} 47 | sharding-column: user_id 48 | tables: 49 | tb_order: 50 | actual-data-nodes: ds$->{0..1}.tb_order_$->{0..1} 51 | table-strategy: 52 | inline: 53 | algorithm-expression: tb_order_$->{order_id % 2} 54 | sharding-column: order_id 55 | tb_order_item: 56 | actual-data-nodes: ds$->{0..1}.tb_order_item_$->{0..1} 57 | table-strategy: 58 | inline: 59 | algorithm-expression: tb_order_item_$->{order_id % 2} 60 | sharding-column: order_id 61 | 62 | mybatis: 63 | type-aliases-package: com.funtl.apache.shardingsphere.domain 64 | mapper-locations: classpath:mapper/*.xml -------------------------------------------------------------------------------- /spring-boot-commons/commons-mapper/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-boot-commons 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | commons-mapper 13 | jar 14 | http://www.funtl.com 15 | 2018-Now 16 | 17 | 18 | 19 | Apache 2.0 20 | https://www.apache.org/licenses/LICENSE-2.0.txt 21 | 22 | 23 | 24 | 25 | 26 | liwemin 27 | Lusifer Lee 28 | lee.lusifer@gmail.com 29 | 30 | 31 | 32 | 33 | 34 | 35 | com.zaxxer 36 | HikariCP 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-jdbc 41 | 42 | 43 | org.apache.tomcat 44 | tomcat-jdbc 45 | 46 | 47 | 48 | 49 | mysql 50 | mysql-connector-java 51 | 52 | 53 | tk.mybatis 54 | mapper-spring-boot-starter 55 | 56 | 57 | com.github.pagehelper 58 | pagehelper-spring-boot-starter 59 | 60 | 61 | 62 | 63 | org.projectlombok 64 | lombok 65 | 66 | 67 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/src/main/java/com/funtl/oauth2/server/config/AuthorizationServerConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.server.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.boot.jdbc.DataSourceBuilder; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.context.annotation.Primary; 8 | import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer; 9 | import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter; 10 | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; 11 | import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; 12 | import org.springframework.security.oauth2.provider.ClientDetailsService; 13 | import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService; 14 | import org.springframework.security.oauth2.provider.token.TokenStore; 15 | import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore; 16 | 17 | import javax.sql.DataSource; 18 | 19 | @Configuration 20 | @EnableAuthorizationServer 21 | public class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter { 22 | 23 | @Bean 24 | @Primary 25 | @ConfigurationProperties(prefix = "spring.datasource") 26 | public DataSource dataSource() { 27 | // 配置数据源(注意,我使用的是 HikariCP 连接池),以上注解是指定数据源,否则会有冲突 28 | return DataSourceBuilder.create().build(); 29 | } 30 | 31 | @Bean 32 | public TokenStore tokenStore() { 33 | // 基于 JDBC 实现,令牌保存到数据 34 | return new JdbcTokenStore(dataSource()); 35 | } 36 | 37 | @Bean 38 | public ClientDetailsService jdbcClientDetails() { 39 | // 基于 JDBC 实现,需要事先在数据库配置客户端信息 40 | return new JdbcClientDetailsService(dataSource()); 41 | } 42 | 43 | @Override 44 | public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { 45 | // 设置令牌 46 | endpoints.tokenStore(tokenStore()); 47 | } 48 | 49 | @Override 50 | public void configure(ClientDetailsServiceConfigurer clients) throws Exception { 51 | // 读取客户端配置 52 | clients.withClientDetails(jdbcClientDetails()); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-provider/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-cloud-alibaba 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-cloud-alibaba-provider 13 | http://www.funtl.com 14 | 15 | 16 | 17 | Apache 2.0 18 | https://www.apache.org/licenses/LICENSE-2.0.txt 19 | 20 | 21 | 22 | 23 | 24 | liwemin 25 | Lusifer Lee 26 | lee.lusifer@gmail.com 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-actuator 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-test 43 | test 44 | 45 | 46 | 47 | 48 | com.alibaba.cloud 49 | spring-cloud-starter-alibaba-sentinel 50 | 51 | 52 | com.alibaba.cloud 53 | spring-cloud-starter-alibaba-nacos-config 54 | 55 | 56 | com.alibaba.cloud 57 | spring-cloud-starter-alibaba-nacos-discovery 58 | 59 | 60 | 61 | 62 | 63 | 64 | org.springframework.boot 65 | spring-boot-maven-plugin 66 | 67 | com.funtl.spring.cloud.alibaba.provider.SpringCloudProviderApplication 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /spring-cloud-alibaba/spring-cloud-alibaba-consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-cloud-alibaba 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-cloud-alibaba-consumer 13 | http://www.funtl.com 14 | 15 | 16 | 17 | Apache 2.0 18 | https://www.apache.org/licenses/LICENSE-2.0.txt 19 | 20 | 21 | 22 | 23 | 24 | liwemin 25 | Lusifer Lee 26 | lee.lusifer@gmail.com 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-actuator 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-test 43 | test 44 | 45 | 46 | 47 | 48 | org.springframework.cloud 49 | spring-cloud-starter-openfeign 50 | 51 | 52 | com.alibaba.cloud 53 | spring-cloud-starter-alibaba-sentinel 54 | 55 | 56 | com.alibaba.cloud 57 | spring-cloud-starter-alibaba-nacos-config 58 | 59 | 60 | com.alibaba.cloud 61 | spring-cloud-starter-alibaba-nacos-discovery 62 | 63 | 64 | 65 | 66 | 67 | 68 | org.springframework.boot 69 | spring-boot-maven-plugin 70 | 71 | com.funtl.spring.cloud.alibaba.consumer.SpringCloudConsumerApplication 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /spring-boot-demo/src/test/java/com/funtl/spring/boot/SpringBootDemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.boot; 2 | 3 | import com.funtl.spring.boot.domain.TbUser; 4 | import com.funtl.spring.boot.mapper.TbUserMapper; 5 | import com.github.pagehelper.PageHelper; 6 | import com.github.pagehelper.PageInfo; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.test.annotation.Rollback; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | import org.springframework.transaction.annotation.Transactional; 14 | import tk.mybatis.mapper.entity.Example; 15 | 16 | import java.util.Date; 17 | import java.util.List; 18 | 19 | @RunWith(SpringRunner.class) 20 | @SpringBootTest 21 | @Transactional 22 | @Rollback 23 | public class SpringBootDemoApplicationTests { 24 | 25 | /** 26 | * 注入 DAO 27 | */ 28 | @Autowired 29 | private TbUserMapper tbUserMapper; 30 | 31 | /** 32 | * 查询 33 | */ 34 | @Test 35 | public void testSelectAll() { 36 | List tbUsers = tbUserMapper.selectAll(); 37 | tbUsers.forEach(tbUser -> { 38 | System.out.println(tbUser); 39 | }); 40 | } 41 | 42 | /** 43 | * 条件查询 44 | */ 45 | @Test 46 | public void testSelectCondition() { 47 | Example example = new Example(TbUser.class); 48 | example.createCriteria().andEqualTo("username", "zhangsan"); 49 | List tbUsers = tbUserMapper.selectByExample(example); 50 | tbUsers.forEach(tbUser -> { 51 | System.out.println(tbUser); 52 | }); 53 | } 54 | 55 | /** 56 | * 新增 57 | */ 58 | @Test 59 | public void testInsert() { 60 | TbUser tbUser = new TbUser(); 61 | tbUser.setUsername("Lusifer"); 62 | tbUser.setPassword("123456"); 63 | tbUser.setPhone("15888888888"); 64 | tbUser.setEmail("topsale@vip.qq.com"); 65 | tbUser.setCreated(new Date()); 66 | tbUser.setUpdated(new Date()); 67 | 68 | tbUserMapper.insert(tbUser); 69 | } 70 | 71 | /** 72 | * 更新 73 | */ 74 | @Test 75 | public void testUpdate() { 76 | TbUser tbUser = tbUserMapper.selectByPrimaryKey(37L); 77 | tbUser.setUsername("Happy"); 78 | 79 | tbUserMapper.updateByPrimaryKey(tbUser); 80 | } 81 | 82 | /** 83 | * 修改 84 | */ 85 | @Test 86 | public void testDelete() { 87 | tbUserMapper.deleteByPrimaryKey(37L); 88 | } 89 | 90 | /** 91 | * 分页 92 | */ 93 | @Test 94 | public void testPage() { 95 | Example example = new Example(TbUser.class); 96 | example.createCriteria().andLike("username", "z%"); 97 | 98 | PageHelper.startPage(1, 5); 99 | PageInfo pageInfo = new PageInfo<>(tbUserMapper.selectByExample(example)); 100 | System.out.println(pageInfo.getTotal()); 101 | System.out.println(pageInfo.getPages()); 102 | pageInfo.getList().forEach(tbUser -> { 103 | System.out.println(tbUser); 104 | }); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-security-oauth2 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-security-oauth2-server 13 | http://www.funtl.com 14 | 15 | 16 | 17 | Apache 2.0 18 | https://www.apache.org/licenses/LICENSE-2.0.txt 19 | 20 | 21 | 22 | 23 | 24 | liwemin 25 | Lusifer Lee 26 | lee.lusifer@gmail.com 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-actuator 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-test 43 | 44 | 45 | 46 | 47 | org.springframework.cloud 48 | spring-cloud-starter-oauth2 49 | 50 | 51 | 52 | 53 | com.zaxxer 54 | HikariCP 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-starter-jdbc 59 | 60 | 61 | 62 | org.apache.tomcat 63 | tomcat-jdbc 64 | 65 | 66 | 67 | 68 | mysql 69 | mysql-connector-java 70 | 71 | 72 | tk.mybatis 73 | mapper-spring-boot-starter 74 | 75 | 76 | 77 | 78 | org.projectlombok 79 | lombok 80 | 81 | 82 | 83 | 84 | 85 | 86 | org.springframework.boot 87 | spring-boot-maven-plugin 88 | 89 | com.funtl.oauth2.OAuth2ServerApplication 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/java/com/funtl/oauth2/resource/controller/TbContentController.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.resource.controller; 2 | 3 | import com.funtl.oauth2.resource.domain.TbContent; 4 | import com.funtl.oauth2.resource.dto.ResponseResult; 5 | import com.funtl.oauth2.resource.service.TbContentService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.http.HttpStatus; 8 | import org.springframework.web.bind.annotation.DeleteMapping; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.PostMapping; 12 | import org.springframework.web.bind.annotation.PutMapping; 13 | import org.springframework.web.bind.annotation.RequestBody; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import java.util.List; 17 | 18 | @RestController 19 | public class TbContentController { 20 | 21 | @Autowired 22 | private TbContentService tbContentService; 23 | 24 | /** 25 | * 获取全部资源 26 | * 27 | * @return 28 | */ 29 | @GetMapping("/") 30 | public ResponseResult> selectAll() { 31 | return new ResponseResult<>(Integer.valueOf(HttpStatus.OK.value()), HttpStatus.OK.toString(), tbContentService.selectAll()); 32 | } 33 | 34 | /** 35 | * 获取资源详情 36 | * 37 | * @param id 38 | * @return 39 | */ 40 | @GetMapping("/view/{id}") 41 | public ResponseResult getById(@PathVariable Long id) { 42 | return new ResponseResult<>(Integer.valueOf(HttpStatus.OK.value()), HttpStatus.OK.toString(), tbContentService.getById(id)); 43 | } 44 | 45 | /** 46 | * 新增资源 47 | * 48 | * @param tbContent 49 | * @return 50 | */ 51 | @PostMapping("/insert") 52 | public ResponseResult insert(@RequestBody TbContent tbContent) { 53 | int count = tbContentService.insert(tbContent); 54 | 55 | if (count > 0) { 56 | return new ResponseResult<>(Integer.valueOf(HttpStatus.OK.value()), HttpStatus.OK.toString(), count); 57 | } else { 58 | return new ResponseResult<>(Integer.valueOf(HttpStatus.BAD_REQUEST.value()), HttpStatus.BAD_REQUEST.toString()); 59 | } 60 | } 61 | 62 | /** 63 | * 更新资源 64 | * 65 | * @param tbContent 66 | * @return 67 | */ 68 | @PutMapping("/update") 69 | public ResponseResult update(@RequestBody TbContent tbContent) { 70 | int count = tbContentService.update(tbContent); 71 | 72 | if (count > 0) { 73 | return new ResponseResult<>(Integer.valueOf(HttpStatus.OK.value()), HttpStatus.OK.toString(), count); 74 | } else { 75 | return new ResponseResult<>(Integer.valueOf(HttpStatus.BAD_REQUEST.value()), HttpStatus.BAD_REQUEST.toString()); 76 | } 77 | } 78 | 79 | /** 80 | * 删除资源 81 | * 82 | * @param id 83 | * @return 84 | */ 85 | @DeleteMapping("/delete/{id}") 86 | public ResponseResult delete(@PathVariable Long id) { 87 | int count = tbContentService.delete(id); 88 | 89 | if (count > 0) { 90 | return new ResponseResult<>(Integer.valueOf(HttpStatus.OK.value()), HttpStatus.OK.toString(), count); 91 | } else { 92 | return new ResponseResult<>(Integer.valueOf(HttpStatus.BAD_REQUEST.value()), HttpStatus.BAD_REQUEST.toString()); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-security-oauth2 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-security-oauth2-resource 13 | http://www.funtl.com 14 | 15 | 16 | 17 | Apache 2.0 18 | https://www.apache.org/licenses/LICENSE-2.0.txt 19 | 20 | 21 | 22 | 23 | 24 | liwemin 25 | Lusifer Lee 26 | lee.lusifer@gmail.com 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-actuator 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-test 43 | test 44 | 45 | 46 | 47 | 48 | org.springframework.cloud 49 | spring-cloud-starter-oauth2 50 | 51 | 52 | 53 | 54 | com.zaxxer 55 | HikariCP 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-starter-jdbc 60 | 61 | 62 | 63 | org.apache.tomcat 64 | tomcat-jdbc 65 | 66 | 67 | 68 | 69 | mysql 70 | mysql-connector-java 71 | 72 | 73 | tk.mybatis 74 | mapper-spring-boot-starter 75 | 76 | 77 | 78 | 79 | org.projectlombok 80 | lombok 81 | 82 | 83 | 84 | 85 | 86 | 87 | org.springframework.boot 88 | spring-boot-maven-plugin 89 | 90 | com.funtl.oauth2.OAuth2ResourceApplication 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-dubbo/spring-cloud-alibaba-dubbo-provider/spring-cloud-alibaba-dubbo-provider-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-cloud-alibaba-dubbo-provider 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-cloud-alibaba-dubbo-provider-service 13 | http://www.funtl.com 14 | 15 | 16 | 17 | Apache 2.0 18 | https://www.apache.org/licenses/LICENSE-2.0.txt 19 | 20 | 21 | 22 | 23 | 24 | liwemin 25 | Lusifer Lee 26 | lee.lusifer@gmail.com 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-actuator 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-test 43 | test 44 | 45 | 46 | 47 | 48 | org.apache.dubbo 49 | dubbo 50 | 51 | 52 | com.alibaba.nacos 53 | nacos-client 54 | 55 | 56 | org.apache.dubbo 57 | dubbo-registry-nacos 58 | 59 | 60 | org.apache.dubbo 61 | dubbo-spring-boot-starter 62 | 63 | 64 | org.apache.dubbo 65 | dubbo-serialization-kryo 66 | 67 | 68 | commons-logging 69 | commons-logging 70 | 71 | 72 | 73 | 74 | com.alibaba.spring 75 | spring-context-support 76 | 77 | 78 | 79 | 80 | com.funtl 81 | spring-cloud-alibaba-dubbo-provider-api 82 | ${project.parent.version} 83 | 84 | 85 | 86 | 87 | 88 | 89 | org.springframework.boot 90 | spring-boot-maven-plugin 91 | 92 | com.funtl.spring.cloud.alibaba.dubbo.provider.DubboProviderApplication 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-business/seata-business-transaction-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | seata-business 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | seata-business-transaction-service 13 | jar 14 | http://www.funtl.com 15 | 2018-Now 16 | 17 | 18 | 19 | Apache 2.0 20 | https://www.apache.org/licenses/LICENSE-2.0.txt 21 | 22 | 23 | 24 | 25 | 26 | liwemin 27 | Lusifer Lee 28 | lee.lusifer@gmail.com 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-actuator 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | 49 | 50 | com.alibaba.cloud 51 | spring-cloud-starter-alibaba-sentinel 52 | 53 | 54 | com.alibaba.cloud 55 | spring-cloud-starter-alibaba-nacos-discovery 56 | 57 | 58 | 59 | 60 | org.apache.dubbo 61 | dubbo 62 | 63 | 64 | com.alibaba.nacos 65 | nacos-client 66 | 67 | 68 | org.apache.dubbo 69 | dubbo-registry-nacos 70 | 71 | 72 | org.apache.dubbo 73 | dubbo-spring-boot-starter 74 | 75 | 76 | com.alibaba.spring 77 | spring-context-support 78 | 79 | 80 | 81 | 82 | com.funtl 83 | seata-provider-transaction-api 84 | ${project.parent.version} 85 | 86 | 87 | 88 | 89 | 90 | 91 | org.springframework.boot 92 | spring-boot-maven-plugin 93 | 94 | com.funtl.spring.cloud.alibaba.seata.SeataBusinessTransactionApplication 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /apache-shardingsphere/sharding-jdbc/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | apache-shardingsphere 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | sharding-jdbc 13 | jar 14 | http://www.funtl.com 15 | 2018-Now 16 | 17 | 18 | 19 | Apache 2.0 20 | https://www.apache.org/licenses/LICENSE-2.0.txt 21 | 22 | 23 | 24 | 25 | 26 | liwemin 27 | Lusifer Lee 28 | lee.lusifer@gmail.com 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | 46 | com.zaxxer 47 | HikariCP 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-starter-jdbc 52 | 53 | 54 | org.apache.tomcat 55 | tomcat-jdbc 56 | 57 | 58 | 59 | 60 | mysql 61 | mysql-connector-java 62 | 63 | 5.1.48 64 | 65 | 66 | tk.mybatis 67 | mapper-spring-boot-starter 68 | 69 | 70 | com.github.pagehelper 71 | pagehelper-spring-boot-starter 72 | 73 | 74 | 75 | 76 | org.apache.shardingsphere 77 | sharding-jdbc-spring-boot-starter 78 | 4.0.0-RC3 79 | 80 | 81 | 82 | 83 | com.funtl 84 | commons-mapper 85 | ${project.parent.version} 86 | 87 | 88 | 89 | 90 | 91 | 92 | org.springframework.boot 93 | spring-boot-maven-plugin 94 | 95 | com.funtl.apache.shardingsphere.ShardingSphereApplication 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-transaction-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | seata-provider 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | seata-provider-transaction-service 13 | jar 14 | http://www.funtl.com 15 | 2018-Now 16 | 17 | 18 | 19 | Apache 2.0 20 | https://www.apache.org/licenses/LICENSE-2.0.txt 21 | 22 | 23 | 24 | 25 | 26 | liwemin 27 | Lusifer Lee 28 | lee.lusifer@gmail.com 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | 46 | com.alibaba.cloud 47 | spring-cloud-starter-alibaba-sentinel 48 | 49 | 50 | com.alibaba.cloud 51 | spring-cloud-starter-alibaba-nacos-discovery 52 | 53 | 54 | 55 | 56 | org.apache.dubbo 57 | dubbo 58 | 59 | 60 | com.alibaba.nacos 61 | nacos-client 62 | 63 | 64 | org.apache.dubbo 65 | dubbo-registry-nacos 66 | 67 | 68 | org.apache.dubbo 69 | dubbo-spring-boot-starter 70 | 71 | 72 | com.alibaba.spring 73 | spring-context-support 74 | 75 | 76 | 77 | 78 | io.seata 79 | seata-spring-boot-starter 80 | 81 | 82 | 83 | 84 | com.funtl 85 | seata-provider-transaction-api 86 | ${project.parent.version} 87 | 88 | 89 | 90 | 91 | 92 | 93 | org.springframework.boot 94 | spring-boot-maven-plugin 95 | 96 | com.funtl.spring.cloud.alibaba.seata.SeataProviderTransactionApplication 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/main/java/com/funtl/oauth2/resource/dto/ResponseResult.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.resource.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 通用的返回对象 9 | *

10 | * Description: 11 | *

12 | * 13 | * @author Lusifer 14 | * @version v1.0.0 15 | * @date 2019-04-07 00:09:49 16 | * @see com.funtl.oauth2.resource.dto 17 | */ 18 | @Data 19 | public class ResponseResult implements Serializable { 20 | private static final long serialVersionUID = 8486468806063544444L; 21 | 22 | /** 23 | * 状态码 24 | */ 25 | private Integer state; 26 | 27 | /** 28 | * 消息 29 | */ 30 | private String message; 31 | 32 | /** 33 | * 返回对象 34 | */ 35 | private T data; 36 | 37 | public ResponseResult() { 38 | super(); 39 | } 40 | 41 | public ResponseResult(Integer state) { 42 | super(); 43 | this.state = state; 44 | } 45 | 46 | public ResponseResult(Integer state, String message) { 47 | super(); 48 | this.state = state; 49 | this.message = message; 50 | } 51 | 52 | public ResponseResult(Integer state, Throwable throwable) { 53 | super(); 54 | this.state = state; 55 | this.message = throwable.getMessage(); 56 | } 57 | 58 | public ResponseResult(Integer state, T data) { 59 | super(); 60 | this.state = state; 61 | this.data = data; 62 | } 63 | 64 | public ResponseResult(Integer state, String message, T data) { 65 | super(); 66 | this.state = state; 67 | this.message = message; 68 | this.data = data; 69 | } 70 | 71 | public Integer getState() { 72 | return state; 73 | } 74 | 75 | public void setState(Integer state) { 76 | this.state = state; 77 | } 78 | 79 | public String getMessage() { 80 | return message; 81 | } 82 | 83 | public void setMessage(String message) { 84 | this.message = message; 85 | } 86 | 87 | public T getData() { 88 | return data; 89 | } 90 | 91 | public void setData(T data) { 92 | this.data = data; 93 | } 94 | 95 | @Override 96 | public int hashCode() { 97 | final int prime = 31; 98 | int result = 1; 99 | result = prime * result + ((data == null) ? 0 : data.hashCode()); 100 | result = prime * result + ((message == null) ? 0 : message.hashCode()); 101 | result = prime * result + ((state == null) ? 0 : state.hashCode()); 102 | return result; 103 | } 104 | 105 | @Override 106 | public boolean equals(Object obj) { 107 | if (this == obj) { 108 | return true; 109 | } 110 | if (obj == null) { 111 | return false; 112 | } 113 | if (getClass() != obj.getClass()) { 114 | return false; 115 | } 116 | ResponseResult other = (ResponseResult) obj; 117 | if (data == null) { 118 | if (other.data != null) { 119 | return false; 120 | } 121 | } else if (!data.equals(other.data)) { 122 | return false; 123 | } 124 | if (message == null) { 125 | if (other.message != null) { 126 | return false; 127 | } 128 | } else if (!message.equals(other.message)) { 129 | return false; 130 | } 131 | if (state == null) { 132 | if (other.state != null) { 133 | return false; 134 | } 135 | } else if (!state.equals(other.state)) { 136 | return false; 137 | } 138 | return true; 139 | } 140 | 141 | @Override 142 | public String toString() { 143 | return "ResponseResult [state=" + state + ", message=" + message + ", data=" + data + "]"; 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /spring-boot-demo/src/main/java/com/funtl/spring/boot/domain/TbUser.java: -------------------------------------------------------------------------------- 1 | package com.funtl.spring.boot.domain; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.GeneratedValue; 5 | import javax.persistence.Id; 6 | import javax.persistence.Table; 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | @Table(name = "tb_user") 11 | public class TbUser implements Serializable { 12 | @Id 13 | @Column(name = "id") 14 | @GeneratedValue(generator = "JDBC") 15 | private Long id; 16 | 17 | /** 18 | * 用户名 19 | */ 20 | @Column(name = "username") 21 | private String username; 22 | 23 | /** 24 | * 密码,加密存储 25 | */ 26 | @Column(name = "`password`") 27 | private String password; 28 | 29 | /** 30 | * 注册手机号 31 | */ 32 | @Column(name = "phone") 33 | private String phone; 34 | 35 | /** 36 | * 注册邮箱 37 | */ 38 | @Column(name = "email") 39 | private String email; 40 | 41 | @Column(name = "created") 42 | private Date created; 43 | 44 | @Column(name = "updated") 45 | private Date updated; 46 | 47 | private static final long serialVersionUID = 1L; 48 | 49 | /** 50 | * @return id 51 | */ 52 | public Long getId() { 53 | return id; 54 | } 55 | 56 | /** 57 | * @param id 58 | */ 59 | public void setId(Long id) { 60 | this.id = id; 61 | } 62 | 63 | /** 64 | * 获取用户名 65 | * 66 | * @return username - 用户名 67 | */ 68 | public String getUsername() { 69 | return username; 70 | } 71 | 72 | /** 73 | * 设置用户名 74 | * 75 | * @param username 用户名 76 | */ 77 | public void setUsername(String username) { 78 | this.username = username; 79 | } 80 | 81 | /** 82 | * 获取密码,加密存储 83 | * 84 | * @return password - 密码,加密存储 85 | */ 86 | public String getPassword() { 87 | return password; 88 | } 89 | 90 | /** 91 | * 设置密码,加密存储 92 | * 93 | * @param password 密码,加密存储 94 | */ 95 | public void setPassword(String password) { 96 | this.password = password; 97 | } 98 | 99 | /** 100 | * 获取注册手机号 101 | * 102 | * @return phone - 注册手机号 103 | */ 104 | public String getPhone() { 105 | return phone; 106 | } 107 | 108 | /** 109 | * 设置注册手机号 110 | * 111 | * @param phone 注册手机号 112 | */ 113 | public void setPhone(String phone) { 114 | this.phone = phone; 115 | } 116 | 117 | /** 118 | * 获取注册邮箱 119 | * 120 | * @return email - 注册邮箱 121 | */ 122 | public String getEmail() { 123 | return email; 124 | } 125 | 126 | /** 127 | * 设置注册邮箱 128 | * 129 | * @param email 注册邮箱 130 | */ 131 | public void setEmail(String email) { 132 | this.email = email; 133 | } 134 | 135 | /** 136 | * @return created 137 | */ 138 | public Date getCreated() { 139 | return created; 140 | } 141 | 142 | /** 143 | * @param created 144 | */ 145 | public void setCreated(Date created) { 146 | this.created = created; 147 | } 148 | 149 | /** 150 | * @return updated 151 | */ 152 | public Date getUpdated() { 153 | return updated; 154 | } 155 | 156 | /** 157 | * @param updated 158 | */ 159 | public void setUpdated(Date updated) { 160 | this.updated = updated; 161 | } 162 | 163 | @Override 164 | public String toString() { 165 | return "TbUser{" + 166 | "id=" + id + 167 | ", username='" + username + '\'' + 168 | ", password='" + password + '\'' + 169 | ", phone='" + phone + '\'' + 170 | ", email='" + email + '\'' + 171 | ", created=" + created + 172 | ", updated=" + updated + 173 | '}'; 174 | } 175 | } -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | seata-provider 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | seata-provider-order-service 13 | jar 14 | http://www.funtl.com 15 | 2018-Now 16 | 17 | 18 | 19 | Apache 2.0 20 | https://www.apache.org/licenses/LICENSE-2.0.txt 21 | 22 | 23 | 24 | 25 | 26 | liwemin 27 | Lusifer Lee 28 | lee.lusifer@gmail.com 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | 46 | com.alibaba.cloud 47 | spring-cloud-starter-alibaba-sentinel 48 | 49 | 50 | com.alibaba.cloud 51 | spring-cloud-starter-alibaba-nacos-discovery 52 | 53 | 54 | 55 | 56 | org.apache.dubbo 57 | dubbo 58 | 59 | 60 | com.alibaba.nacos 61 | nacos-client 62 | 63 | 64 | org.apache.dubbo 65 | dubbo-registry-nacos 66 | 67 | 68 | org.apache.dubbo 69 | dubbo-spring-boot-starter 70 | 71 | 72 | com.alibaba.spring 73 | spring-context-support 74 | 75 | 76 | 77 | 78 | io.seata 79 | seata-spring-boot-starter 80 | 81 | 82 | 83 | 84 | com.funtl 85 | seata-provider-order-api 86 | ${project.parent.version} 87 | 88 | 89 | com.funtl 90 | commons-mapper 91 | ${project.parent.version} 92 | 93 | 94 | 95 | 96 | 97 | 98 | org.springframework.boot 99 | spring-boot-maven-plugin 100 | 101 | com.funtl.spring.cloud.alibaba.seata.SeataProviderOrderApplication 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-seata/seata-provider/seata-provider-order-item-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | seata-provider 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | seata-provider-order-item-service 13 | jar 14 | http://www.funtl.com 15 | 2018-Now 16 | 17 | 18 | 19 | Apache 2.0 20 | https://www.apache.org/licenses/LICENSE-2.0.txt 21 | 22 | 23 | 24 | 25 | 26 | liwemin 27 | Lusifer Lee 28 | lee.lusifer@gmail.com 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | 46 | com.alibaba.cloud 47 | spring-cloud-starter-alibaba-sentinel 48 | 49 | 50 | com.alibaba.cloud 51 | spring-cloud-starter-alibaba-nacos-discovery 52 | 53 | 54 | 55 | 56 | org.apache.dubbo 57 | dubbo 58 | 59 | 60 | com.alibaba.nacos 61 | nacos-client 62 | 63 | 64 | org.apache.dubbo 65 | dubbo-registry-nacos 66 | 67 | 68 | org.apache.dubbo 69 | dubbo-spring-boot-starter 70 | 71 | 72 | com.alibaba.spring 73 | spring-context-support 74 | 75 | 76 | 77 | 78 | io.seata 79 | seata-spring-boot-starter 80 | 81 | 82 | 83 | 84 | com.funtl 85 | seata-provider-order-item-api 86 | ${project.parent.version} 87 | 88 | 89 | com.funtl 90 | commons-mapper 91 | ${project.parent.version} 92 | 93 | 94 | 95 | 96 | 97 | 98 | org.springframework.boot 99 | spring-boot-maven-plugin 100 | 101 | com.funtl.spring.cloud.alibaba.seata.SeataProviderOrderItemApplication 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /spring-boot-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-boot-samples 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-boot-demo 13 | http://www.funtl.com 14 | 15 | 16 | 17 | Apache 2.0 18 | https://www.apache.org/licenses/LICENSE-2.0.txt 19 | 20 | 21 | 22 | 23 | 24 | liwemin 25 | Lusifer Lee 26 | lee.lusifer@gmail.com 27 | 28 | 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-web 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | 43 | com.zaxxer 44 | HikariCP 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-starter-jdbc 49 | 50 | 51 | 52 | org.apache.tomcat 53 | tomcat-jdbc 54 | 55 | 56 | 57 | 58 | 59 | mysql 60 | mysql-connector-java 61 | 62 | 63 | 64 | tk.mybatis 65 | mapper-spring-boot-starter 66 | 67 | 68 | 69 | com.github.pagehelper 70 | pagehelper-spring-boot-starter 71 | 72 | 73 | 74 | org.projectlombok 75 | lombok 76 | 77 | 78 | 79 | 80 | 81 | 82 | org.mybatis.generator 83 | mybatis-generator-maven-plugin 84 | 1.3.7 85 | 86 | ${basedir}/src/main/resources/generator/generatorConfig.xml 87 | true 88 | true 89 | 90 | 91 | 92 | mysql 93 | mysql-connector-java 94 | ${mysql.version} 95 | 96 | 97 | tk.mybatis 98 | mapper 99 | 4.1.5 100 | 101 | 102 | 103 | 104 | 105 | org.springframework.boot 106 | spring-boot-maven-plugin 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /spring-cloud-alibaba-dubbo/spring-cloud-alibaba-dubbo-consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.funtl 8 | spring-cloud-alibaba-dubbo 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-cloud-alibaba-dubbo-consumer 13 | http://www.funtl.com 14 | 15 | 16 | 17 | Apache 2.0 18 | https://www.apache.org/licenses/LICENSE-2.0.txt 19 | 20 | 21 | 22 | 23 | 24 | liwemin 25 | Lusifer Lee 26 | lee.lusifer@gmail.com 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-actuator 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-test 43 | test 44 | 45 | 46 | 47 | 48 | com.alibaba.cloud 49 | spring-cloud-starter-alibaba-sentinel 50 | 51 | 52 | com.alibaba.cloud 53 | spring-cloud-starter-alibaba-nacos-config 54 | 55 | 56 | com.alibaba.cloud 57 | spring-cloud-starter-alibaba-nacos-discovery 58 | 59 | 60 | 61 | 62 | org.apache.dubbo 63 | dubbo 64 | 65 | 66 | com.alibaba.nacos 67 | nacos-client 68 | 69 | 70 | org.apache.dubbo 71 | dubbo-registry-nacos 72 | 73 | 74 | org.apache.dubbo 75 | dubbo-spring-boot-starter 76 | 77 | 78 | org.apache.dubbo 79 | dubbo-serialization-kryo 80 | 81 | 82 | commons-logging 83 | commons-logging 84 | 85 | 86 | 87 | 88 | com.alibaba.spring 89 | spring-context-support 90 | 91 | 92 | 93 | 94 | com.funtl 95 | spring-cloud-alibaba-dubbo-provider-api 96 | ${project.parent.version} 97 | 98 | 99 | 100 | 101 | 102 | 103 | org.springframework.boot 104 | spring-boot-maven-plugin 105 | 106 | com.funtl.spring.cloud.alibaba.dubbo.consumer.DubboConsumerApplication 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/db/resource.sql: -------------------------------------------------------------------------------- 1 | /* 2 | SQLyog v12.2.6 (64 bit) 3 | MySQL - 8.0.15 : Database - oauth2_resource 4 | ********************************************************************* 5 | */ 6 | 7 | /*!40101 SET NAMES utf8 */; 8 | 9 | /*!40101 SET SQL_MODE=''*/; 10 | 11 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 12 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 13 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 14 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 15 | CREATE DATABASE /*!32312 IF NOT EXISTS*/`oauth2_resource` /*!40100 DEFAULT CHARACTER SET utf8 */; 16 | 17 | USE `oauth2_resource`; 18 | 19 | /*Table structure for table `tb_content` */ 20 | 21 | DROP TABLE IF EXISTS `tb_content`; 22 | 23 | CREATE TABLE `tb_content` ( 24 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 25 | `category_id` bigint(20) NOT NULL COMMENT '内容类目ID', 26 | `title` varchar(200) DEFAULT NULL COMMENT '内容标题', 27 | `sub_title` varchar(100) DEFAULT NULL COMMENT '子标题', 28 | `title_desc` varchar(500) DEFAULT NULL COMMENT '标题描述', 29 | `url` varchar(500) DEFAULT NULL COMMENT '链接', 30 | `pic` varchar(300) DEFAULT NULL COMMENT '图片绝对路径', 31 | `pic2` varchar(300) DEFAULT NULL COMMENT '图片2', 32 | `content` text COMMENT '内容', 33 | `created` datetime DEFAULT NULL, 34 | `updated` datetime DEFAULT NULL, 35 | PRIMARY KEY (`id`), 36 | KEY `category_id` (`category_id`), 37 | KEY `updated` (`updated`) 38 | ) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8; 39 | 40 | /*Data for the table `tb_content` */ 41 | 42 | insert into `tb_content`(`id`,`category_id`,`title`,`sub_title`,`title_desc`,`url`,`pic`,`pic2`,`content`,`created`,`updated`) values 43 | (28,89,'标题','子标题','标题说明','http://www.jd.com',NULL,NULL,NULL,'2019-04-07 00:56:09','2019-04-07 00:56:11'), 44 | (29,89,'ad2','ad2','ad2','http://www.baidu.com',NULL,NULL,NULL,'2019-04-07 00:56:13','2019-04-07 00:56:15'), 45 | (30,89,'ad3','ad3','ad3','http://www.sina.com.cn',NULL,NULL,NULL,'2019-04-07 00:56:17','2019-04-07 00:56:19'), 46 | (31,89,'ad4','ad4','ad4','http://www.funtl.com',NULL,NULL,NULL,'2019-04-07 00:56:22','2019-04-07 00:56:25'); 47 | 48 | /*Table structure for table `tb_content_category` */ 49 | 50 | DROP TABLE IF EXISTS `tb_content_category`; 51 | 52 | CREATE TABLE `tb_content_category` ( 53 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '类目ID', 54 | `parent_id` bigint(20) DEFAULT NULL COMMENT '父类目ID=0时,代表的是一级的类目', 55 | `name` varchar(50) DEFAULT NULL COMMENT '分类名称', 56 | `status` int(1) DEFAULT '1' COMMENT '状态。可选值:1(正常),2(删除)', 57 | `sort_order` int(4) DEFAULT NULL COMMENT '排列序号,表示同级类目的展现次序,如数值相等则按名称次序排列。取值范围:大于零的整数', 58 | `is_parent` tinyint(1) DEFAULT '1' COMMENT '该类目是否为父类目,1为true,0为false', 59 | `created` datetime DEFAULT NULL COMMENT '创建时间', 60 | `updated` datetime DEFAULT NULL COMMENT '创建时间', 61 | PRIMARY KEY (`id`), 62 | KEY `parent_id` (`parent_id`,`status`) USING BTREE, 63 | KEY `sort_order` (`sort_order`) 64 | ) ENGINE=InnoDB AUTO_INCREMENT=98 DEFAULT CHARSET=utf8 COMMENT='内容分类'; 65 | 66 | /*Data for the table `tb_content_category` */ 67 | 68 | insert into `tb_content_category`(`id`,`parent_id`,`name`,`status`,`sort_order`,`is_parent`,`created`,`updated`) values 69 | (30,0,'LeeShop',1,1,1,'2015-04-03 16:51:38','2015-04-03 16:51:40'), 70 | (86,30,'首页',1,1,1,'2015-06-07 15:36:07','2015-06-07 15:36:07'), 71 | (87,30,'列表页面',1,1,1,'2015-06-07 15:36:16','2015-06-07 15:36:16'), 72 | (88,30,'详细页面',1,1,1,'2015-06-07 15:36:27','2015-06-07 15:36:27'), 73 | (89,86,'大广告',1,1,0,'2015-06-07 15:36:38','2015-06-07 15:36:38'), 74 | (90,86,'小广告',1,1,0,'2015-06-07 15:36:45','2015-06-07 15:36:45'), 75 | (91,86,'商城快报',1,1,0,'2015-06-07 15:36:55','2015-06-07 15:36:55'), 76 | (92,87,'边栏广告',1,1,0,'2015-06-07 15:37:07','2015-06-07 15:37:07'), 77 | (93,87,'页头广告',1,1,0,'2015-06-07 15:37:17','2015-06-07 15:37:17'), 78 | (94,87,'页脚广告',1,1,0,'2015-06-07 15:37:31','2015-06-07 15:37:31'), 79 | (95,88,'边栏广告',1,1,0,'2015-06-07 15:37:56','2015-06-07 15:37:56'), 80 | (96,86,'中广告',1,1,1,'2015-07-25 18:58:52','2015-07-25 18:58:52'), 81 | (97,96,'中广告1',1,1,0,'2015-07-25 18:59:43','2015-07-25 18:59:43'); 82 | 83 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 84 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 85 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 86 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 87 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/db/oauth2.sql: -------------------------------------------------------------------------------- 1 | /* 2 | SQLyog v12.2.6 (64 bit) 3 | MySQL - 8.0.15 : Database - oauth2 4 | ********************************************************************* 5 | */ 6 | 7 | 8 | /*!40101 SET NAMES utf8 */; 9 | 10 | /*!40101 SET SQL_MODE=''*/; 11 | 12 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 13 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 14 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 15 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 16 | CREATE DATABASE /*!32312 IF NOT EXISTS*/`oauth2` /*!40100 DEFAULT CHARACTER SET utf8 */; 17 | 18 | USE `oauth2`; 19 | 20 | /*Table structure for table `clientdetails` */ 21 | 22 | DROP TABLE IF EXISTS `clientdetails`; 23 | 24 | CREATE TABLE `clientdetails` ( 25 | `appId` varchar(128) NOT NULL, 26 | `resourceIds` varchar(256) DEFAULT NULL, 27 | `appSecret` varchar(256) DEFAULT NULL, 28 | `scope` varchar(256) DEFAULT NULL, 29 | `grantTypes` varchar(256) DEFAULT NULL, 30 | `redirectUrl` varchar(256) DEFAULT NULL, 31 | `authorities` varchar(256) DEFAULT NULL, 32 | `access_token_validity` int(11) DEFAULT NULL, 33 | `refresh_token_validity` int(11) DEFAULT NULL, 34 | `additionalInformation` varchar(4096) DEFAULT NULL, 35 | `autoApproveScopes` varchar(256) DEFAULT NULL, 36 | PRIMARY KEY (`appId`) 37 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 38 | 39 | /*Table structure for table `oauth_access_token` */ 40 | 41 | DROP TABLE IF EXISTS `oauth_access_token`; 42 | 43 | CREATE TABLE `oauth_access_token` ( 44 | `token_id` varchar(256) DEFAULT NULL, 45 | `token` blob, 46 | `authentication_id` varchar(128) NOT NULL, 47 | `user_name` varchar(256) DEFAULT NULL, 48 | `client_id` varchar(256) DEFAULT NULL, 49 | `authentication` blob, 50 | `refresh_token` varchar(256) DEFAULT NULL, 51 | PRIMARY KEY (`authentication_id`) 52 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 53 | 54 | /*Table structure for table `oauth_approvals` */ 55 | 56 | DROP TABLE IF EXISTS `oauth_approvals`; 57 | 58 | CREATE TABLE `oauth_approvals` ( 59 | `userId` varchar(256) DEFAULT NULL, 60 | `clientId` varchar(256) DEFAULT NULL, 61 | `scope` varchar(256) DEFAULT NULL, 62 | `status` varchar(10) DEFAULT NULL, 63 | `expiresAt` timestamp NULL DEFAULT NULL, 64 | `lastModifiedAt` timestamp NULL DEFAULT NULL 65 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 66 | 67 | /*Table structure for table `oauth_client_details` */ 68 | 69 | DROP TABLE IF EXISTS `oauth_client_details`; 70 | 71 | CREATE TABLE `oauth_client_details` ( 72 | `client_id` varchar(128) NOT NULL, 73 | `resource_ids` varchar(256) DEFAULT NULL, 74 | `client_secret` varchar(256) DEFAULT NULL, 75 | `scope` varchar(256) DEFAULT NULL, 76 | `authorized_grant_types` varchar(256) DEFAULT NULL, 77 | `web_server_redirect_uri` varchar(256) DEFAULT NULL, 78 | `authorities` varchar(256) DEFAULT NULL, 79 | `access_token_validity` int(11) DEFAULT NULL, 80 | `refresh_token_validity` int(11) DEFAULT NULL, 81 | `additional_information` varchar(4096) DEFAULT NULL, 82 | `autoapprove` varchar(256) DEFAULT NULL, 83 | PRIMARY KEY (`client_id`) 84 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 85 | 86 | /*Table structure for table `oauth_client_token` */ 87 | 88 | DROP TABLE IF EXISTS `oauth_client_token`; 89 | 90 | CREATE TABLE `oauth_client_token` ( 91 | `token_id` varchar(256) DEFAULT NULL, 92 | `token` blob, 93 | `authentication_id` varchar(128) NOT NULL, 94 | `user_name` varchar(256) DEFAULT NULL, 95 | `client_id` varchar(256) DEFAULT NULL, 96 | PRIMARY KEY (`authentication_id`) 97 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 98 | 99 | /*Table structure for table `oauth_code` */ 100 | 101 | DROP TABLE IF EXISTS `oauth_code`; 102 | 103 | CREATE TABLE `oauth_code` ( 104 | `code` varchar(256) DEFAULT NULL, 105 | `authentication` blob 106 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 107 | 108 | /*Table structure for table `oauth_refresh_token` */ 109 | 110 | DROP TABLE IF EXISTS `oauth_refresh_token`; 111 | 112 | CREATE TABLE `oauth_refresh_token` ( 113 | `token_id` varchar(256) DEFAULT NULL, 114 | `token` blob, 115 | `authentication` blob 116 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 117 | 118 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 119 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 120 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 121 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 122 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-server/db/rbac.sql: -------------------------------------------------------------------------------- 1 | /* 2 | SQLyog v12.2.6 (64 bit) 3 | MySQL - 8.0.15 : Database - oauth2 4 | ********************************************************************* 5 | */ 6 | 7 | /*!40101 SET NAMES utf8 */; 8 | 9 | /*!40101 SET SQL_MODE=''*/; 10 | 11 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 12 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 13 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 14 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 15 | CREATE DATABASE /*!32312 IF NOT EXISTS*/`oauth2` /*!40100 DEFAULT CHARACTER SET utf8 */; 16 | 17 | USE `oauth2`; 18 | 19 | /*Table structure for table `tb_permission` */ 20 | 21 | DROP TABLE IF EXISTS `tb_permission`; 22 | 23 | CREATE TABLE `tb_permission` ( 24 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 25 | `parent_id` bigint(20) DEFAULT NULL COMMENT '父权限', 26 | `name` varchar(64) NOT NULL COMMENT '权限名称', 27 | `enname` varchar(64) NOT NULL COMMENT '权限英文名称', 28 | `url` varchar(255) NOT NULL COMMENT '授权路径', 29 | `description` varchar(200) DEFAULT NULL COMMENT '备注', 30 | `created` datetime NOT NULL, 31 | `updated` datetime NOT NULL, 32 | PRIMARY KEY (`id`) 33 | ) ENGINE=InnoDB AUTO_INCREMENT=49 DEFAULT CHARSET=utf8 COMMENT='权限表'; 34 | 35 | /*Data for the table `tb_permission` */ 36 | 37 | insert into `tb_permission`(`id`,`parent_id`,`name`,`enname`,`url`,`description`,`created`,`updated`) values 38 | (37,0,'系统管理','System','/',NULL,'2019-04-04 23:22:54','2019-04-04 23:22:56'), 39 | (38,37,'用户管理','SystemUser','/users/',NULL,'2019-04-04 23:25:31','2019-04-04 23:25:33'), 40 | (39,38,'查看用户','SystemUserView','/users/view/**',NULL,'2019-04-04 15:30:30','2019-04-04 15:30:43'), 41 | (40,38,'新增用户','SystemUserInsert','/users/insert/**',NULL,'2019-04-04 15:30:31','2019-04-04 15:30:44'), 42 | (41,38,'编辑用户','SystemUserUpdate','/users/update/**',NULL,'2019-04-04 15:30:32','2019-04-04 15:30:45'), 43 | (42,38,'删除用户','SystemUserDelete','/users/delete/**',NULL,'2019-04-04 15:30:48','2019-04-04 15:30:45'), 44 | (44,37,'内容管理','SystemContent','/contents/',NULL,'2019-04-06 18:23:58','2019-04-06 18:24:00'), 45 | (45,44,'查看内容','SystemContentView','/contents/view/**',NULL,'2019-04-06 23:49:39','2019-04-06 23:49:41'), 46 | (46,44,'新增内容','SystemContentInsert','/contents/insert/**',NULL,'2019-04-06 23:51:00','2019-04-06 23:51:02'), 47 | (47,44,'编辑内容','SystemContentUpdate','/contents/update/**',NULL,'2019-04-06 23:51:04','2019-04-06 23:51:06'), 48 | (48,44,'删除内容','SystemContentDelete','/contents/delete/**',NULL,'2019-04-06 23:51:08','2019-04-06 23:51:10'); 49 | 50 | /*Table structure for table `tb_role` */ 51 | 52 | DROP TABLE IF EXISTS `tb_role`; 53 | 54 | CREATE TABLE `tb_role` ( 55 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 56 | `parent_id` bigint(20) DEFAULT NULL COMMENT '父角色', 57 | `name` varchar(64) NOT NULL COMMENT '角色名称', 58 | `enname` varchar(64) NOT NULL COMMENT '角色英文名称', 59 | `description` varchar(200) DEFAULT NULL COMMENT '备注', 60 | `created` datetime NOT NULL, 61 | `updated` datetime NOT NULL, 62 | PRIMARY KEY (`id`) 63 | ) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8 COMMENT='角色表'; 64 | 65 | /*Data for the table `tb_role` */ 66 | 67 | insert into `tb_role`(`id`,`parent_id`,`name`,`enname`,`description`,`created`,`updated`) values 68 | (37,0,'超级管理员','admin',NULL,'2019-04-04 23:22:03','2019-04-04 23:22:05'); 69 | 70 | /*Table structure for table `tb_role_permission` */ 71 | 72 | DROP TABLE IF EXISTS `tb_role_permission`; 73 | 74 | CREATE TABLE `tb_role_permission` ( 75 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 76 | `role_id` bigint(20) NOT NULL COMMENT '角色 ID', 77 | `permission_id` bigint(20) NOT NULL COMMENT '权限 ID', 78 | PRIMARY KEY (`id`) 79 | ) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8 COMMENT='角色权限表'; 80 | 81 | /*Data for the table `tb_role_permission` */ 82 | 83 | insert into `tb_role_permission`(`id`,`role_id`,`permission_id`) values 84 | (37,37,37), 85 | (38,37,38), 86 | (39,37,39), 87 | (40,37,40), 88 | (41,37,41), 89 | (42,37,42), 90 | (43,37,44), 91 | (44,37,45), 92 | (45,37,46), 93 | (46,37,47), 94 | (47,37,48); 95 | 96 | /*Table structure for table `tb_user` */ 97 | 98 | DROP TABLE IF EXISTS `tb_user`; 99 | 100 | CREATE TABLE `tb_user` ( 101 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 102 | `username` varchar(50) NOT NULL COMMENT '用户名', 103 | `password` varchar(64) NOT NULL COMMENT '密码,加密存储', 104 | `phone` varchar(20) DEFAULT NULL COMMENT '注册手机号', 105 | `email` varchar(50) DEFAULT NULL COMMENT '注册邮箱', 106 | `created` datetime NOT NULL, 107 | `updated` datetime NOT NULL, 108 | PRIMARY KEY (`id`), 109 | UNIQUE KEY `username` (`username`) USING BTREE, 110 | UNIQUE KEY `phone` (`phone`) USING BTREE, 111 | UNIQUE KEY `email` (`email`) USING BTREE 112 | ) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8 COMMENT='用户表'; 113 | 114 | /*Data for the table `tb_user` */ 115 | 116 | insert into `tb_user`(`id`,`username`,`password`,`phone`,`email`,`created`,`updated`) values 117 | (37,'admin','$2a$10$9ZhDOBp.sRKat4l14ygu/.LscxrMUcDAfeVOEPiYwbcRkoB09gCmi','15888888888','lee.lusifer@gmail.com','2019-04-04 23:21:27','2019-04-04 23:21:29'); 118 | 119 | /*Table structure for table `tb_user_role` */ 120 | 121 | DROP TABLE IF EXISTS `tb_user_role`; 122 | 123 | CREATE TABLE `tb_user_role` ( 124 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 125 | `user_id` bigint(20) NOT NULL COMMENT '用户 ID', 126 | `role_id` bigint(20) NOT NULL COMMENT '角色 ID', 127 | PRIMARY KEY (`id`) 128 | ) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8 COMMENT='用户角色表'; 129 | 130 | /*Data for the table `tb_user_role` */ 131 | 132 | insert into `tb_user_role`(`id`,`user_id`,`role_id`) values 133 | (37,37,37); 134 | 135 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 136 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 137 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 138 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 139 | -------------------------------------------------------------------------------- /spring-security-oauth2/spring-security-oauth2-resource/src/test/java/com/funtl/oauth2/test/TbContentControllerTests.java: -------------------------------------------------------------------------------- 1 | package com.funtl.oauth2.test; 2 | 3 | import com.funtl.oauth2.OAuth2ResourceApplication; 4 | import com.funtl.oauth2.resource.domain.TbContent; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.codehaus.jackson.map.ObjectMapper; 7 | import org.codehaus.jackson.map.ObjectWriter; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.http.MediaType; 15 | import org.springframework.test.context.junit4.SpringRunner; 16 | import org.springframework.test.web.servlet.MockMvc; 17 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; 18 | import org.springframework.test.web.servlet.result.MockMvcResultHandlers; 19 | 20 | /** 21 | * 资源访问测试 22 | *

23 | * Description: 24 | *

25 | * 26 | * @author Lusifer 27 | * @version v1.0.0 28 | * @date 2019-04-07 01:38:30 29 | * @see com.funtl.oauth2.test 30 | */ 31 | @Slf4j 32 | @RunWith(SpringRunner.class) 33 | @SpringBootTest(classes = OAuth2ResourceApplication.class) 34 | @AutoConfigureMockMvc 35 | public class TbContentControllerTests { 36 | 37 | @Autowired 38 | private MockMvc mockMvc; 39 | 40 | /** 41 | * 获取全部资源 42 | */ 43 | @Test 44 | public void testSelectAll() throws Exception { 45 | int status = this.mockMvc 46 | .perform(MockMvcRequestBuilders 47 | .get("/") 48 | .header("Authorization", "Bearer 91317816-5036-4b76-86b7-05d96d55774d")) 49 | .andDo(MockMvcResultHandlers.print()) 50 | .andReturn().getResponse().getStatus(); 51 | if (status == 200) { 52 | log.info("请求成功"); 53 | } else { 54 | log.info("请求失败,状态码为:{}", status); 55 | } 56 | 57 | Assert.assertEquals(status, 200); 58 | } 59 | 60 | /** 61 | * 获取资源详情 62 | */ 63 | @Test 64 | public void testGetById() throws Exception { 65 | int status = this.mockMvc 66 | .perform(MockMvcRequestBuilders 67 | .get("/view/28") 68 | .header("Authorization", "Bearer 91317816-5036-4b76-86b7-05d96d55774d")) 69 | .andDo(MockMvcResultHandlers.print()) 70 | .andReturn().getResponse().getStatus(); 71 | if (status == 200) { 72 | log.info("请求成功"); 73 | } else { 74 | log.info("请求失败,状态码为:{}", status); 75 | } 76 | 77 | Assert.assertEquals(status, 200); 78 | } 79 | 80 | /** 81 | * 新增资源 82 | */ 83 | @Test 84 | public void testInsert() throws Exception { 85 | // 由于请求参数使用了 @RequestBody 注解,故需要将参数封装成 JSON 格式 86 | TbContent tbContent = new TbContent(); 87 | tbContent.setCategoryId(89L); 88 | tbContent.setTitle("来自 SpringMock 的新增测试"); 89 | ObjectMapper objectMapper = new ObjectMapper(); 90 | ObjectWriter objectWriter = objectMapper.writer().withDefaultPrettyPrinter(); 91 | String jsonParams = objectWriter.writeValueAsString(tbContent); 92 | 93 | // 模拟请求 94 | int status = this.mockMvc 95 | .perform(MockMvcRequestBuilders 96 | .post("/insert") 97 | .header("Authorization", "Bearer 91317816-5036-4b76-86b7-05d96d55774d") 98 | // 设置使用 JSON 方式传参 99 | .contentType(MediaType.APPLICATION_JSON) 100 | // 设置 JSON 参数内容 101 | .content(jsonParams)) 102 | .andDo(MockMvcResultHandlers.print()) 103 | .andReturn().getResponse().getStatus(); 104 | if (status == 200) { 105 | log.info("请求成功"); 106 | } else { 107 | log.info("请求失败,状态码为:{}", status); 108 | } 109 | 110 | Assert.assertEquals(status, 200); 111 | } 112 | 113 | /** 114 | * 更新资源 115 | * 116 | * @throws Exception 117 | */ 118 | @Test 119 | public void testUpdate() throws Exception { 120 | // 由于请求参数使用了 @RequestBody 注解,故需要将参数封装成 JSON 格式 121 | TbContent tbContent = new TbContent(); 122 | tbContent.setId(43L); 123 | tbContent.setCategoryId(89L); 124 | tbContent.setTitle("来自 SpringMock 的编辑测试"); 125 | ObjectMapper objectMapper = new ObjectMapper(); 126 | ObjectWriter objectWriter = objectMapper.writer().withDefaultPrettyPrinter(); 127 | String jsonParams = objectWriter.writeValueAsString(tbContent); 128 | 129 | // 模拟请求 130 | int status = this.mockMvc 131 | .perform(MockMvcRequestBuilders 132 | .put("/update") 133 | .header("Authorization", "Bearer 91317816-5036-4b76-86b7-05d96d55774d") 134 | // 设置使用 JSON 方式传参 135 | .contentType(MediaType.APPLICATION_JSON) 136 | // 设置 JSON 参数内容 137 | .content(jsonParams)) 138 | .andDo(MockMvcResultHandlers.print()) 139 | .andReturn().getResponse().getStatus(); 140 | if (status == 200) { 141 | log.info("请求成功"); 142 | } else { 143 | log.info("请求失败,状态码为:{}", status); 144 | } 145 | 146 | Assert.assertEquals(status, 200); 147 | } 148 | 149 | /** 150 | * 删除资源 151 | * 152 | * @throws Exception 153 | */ 154 | @Test 155 | public void testDelete() throws Exception { 156 | int status = this.mockMvc 157 | .perform(MockMvcRequestBuilders 158 | .delete("/delete/43") 159 | .header("Authorization", "Bearer 91317816-5036-4b76-86b7-05d96d55774d")) 160 | .andDo(MockMvcResultHandlers.print()) 161 | .andReturn().getResponse().getStatus(); 162 | if (status == 200) { 163 | log.info("请求成功"); 164 | } else { 165 | log.info("请求失败,状态码为:{}", status); 166 | } 167 | 168 | Assert.assertEquals(status, 200); 169 | } 170 | 171 | 172 | } 173 | -------------------------------------------------------------------------------- /spring-boot-samples-dependencies/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.funtl 7 | spring-boot-samples-dependencies 8 | 1.0.0-SNAPSHOT 9 | pom 10 | http://www.funtl.com 11 | 12 | 13 | 2.7.4.1 14 | Hoxton.RELEASE 15 | 2.1.1.RELEASE 16 | 2.1.5 17 | 1.2.13 18 | 1.0.0 19 | 1.0.5 20 | 4.0.0-RC3 21 | 22 | 4.2.2 23 | 24 | 25 | 26 | 27 | Apache 2.0 28 | https://www.apache.org/licenses/LICENSE-2.0.txt 29 | 30 | 31 | 32 | 33 | 34 | liwemin 35 | Lusifer Lee 36 | lee.lusifer@gmail.com 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.cloud 45 | spring-cloud-dependencies 46 | ${spring-cloud.version} 47 | pom 48 | import 49 | 50 | 51 | com.alibaba.cloud 52 | spring-cloud-alibaba-dependencies 53 | ${spring-cloud-alibaba.verion} 54 | pom 55 | import 56 | 57 | 58 | 59 | 60 | org.apache.dubbo 61 | dubbo 62 | ${dubbo.version} 63 | 64 | 65 | org.apache.dubbo 66 | dubbo-registry-nacos 67 | ${dubbo.version} 68 | 69 | 70 | org.apache.dubbo 71 | dubbo-spring-boot-starter 72 | ${dubbo.version} 73 | 74 | 75 | org.apache.dubbo 76 | dubbo-serialization-kryo 77 | ${dubbo.version} 78 | 79 | 80 | com.alibaba.spring 81 | spring-context-support 82 | ${alibaba-spring-context-support.version} 83 | 84 | 85 | 86 | 87 | org.apache.shardingsphere 88 | sharding-jdbc-spring-boot-starter 89 | ${apache-sharding-sphere.version} 90 | 91 | 92 | org.apache.shardingsphere 93 | sharding-jdbc-spring-namespace 94 | ${apache-sharding-sphere.version} 95 | 96 | 97 | org.apache.shardingsphere 98 | sharding-transaction-base-seata-at 99 | ${apache-sharding-sphere.version} 100 | 101 | 102 | 103 | 104 | io.seata 105 | seata-spring-boot-starter 106 | ${alibaba-seata.version} 107 | 108 | 109 | 110 | 111 | tk.mybatis 112 | mapper-spring-boot-starter 113 | ${spring-boot-mapper.version} 114 | 115 | 116 | com.github.pagehelper 117 | pagehelper-spring-boot-starter 118 | ${spring-boot-pagehelper.version} 119 | 120 | 121 | com.squareup.okhttp3 122 | okhttp 123 | ${okhttp3.version} 124 | 125 | 126 | 127 | 128 | 129 | 130 | alimaven 131 | aliyun maven 132 | http://maven.aliyun.com/nexus/content/groups/public/ 133 | 134 | false 135 | 136 | 137 | 138 | 139 | spring-milestone 140 | Spring Milestone 141 | https://repo.spring.io/milestone 142 | 143 | false 144 | 145 | 146 | 147 | spring-snapshot 148 | Spring Snapshot 149 | https://repo.spring.io/snapshot 150 | 151 | true 152 | 153 | 154 | 155 | 156 | 157 | 158 | alimaven 159 | aliyun maven 160 | http://maven.aliyun.com/nexus/content/groups/public/ 161 | 162 | false 163 | 164 | 165 | 166 | 167 | spring-milestone 168 | Spring Milestone 169 | https://repo.spring.io/milestone 170 | 171 | false 172 | 173 | 174 | 175 | spring-snapshot 176 | Spring Snapshot 177 | https://repo.spring.io/snapshot 178 | 179 | true 180 | 181 | 182 | 183 | 184 | 185 | --------------------------------------------------------------------------------