├── Fronkend ├── fonts │ └── mui.ttf ├── images │ ├── error.png │ ├── qrcode.png │ ├── success.png │ ├── upload.png │ └── face-default.jpg ├── css │ ├── registLogin │ │ └── arrow.jpg │ └── header.css ├── plugin │ ├── cropper │ │ ├── images │ │ │ └── picture.jpg │ │ └── css │ │ │ └── main.css │ └── v3.1.6 │ │ ├── images │ │ └── picture.jpg │ │ ├── js │ │ └── main.js │ │ ├── index.html │ │ ├── myface-uploader.html │ │ └── css │ │ └── main.css ├── pages │ ├── contact.html │ ├── chatlist.html │ ├── discover.html │ ├── myface.html │ ├── about_me.html │ └── login.html ├── js │ └── app.js └── index.html ├── springboot_mybatis ├── springboot_mybatis.iml ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── mexbo │ │ │ ├── mapper │ │ │ ├── UsersMapper.java │ │ │ ├── ChatMsgMapper.java │ │ │ ├── MyFriendsMapper.java │ │ │ └── FriendsRequestMapper.java │ │ │ ├── mybatis │ │ │ └── GeneratorDisplay.java │ │ │ ├── pojo │ │ │ ├── MyFriends.java │ │ │ ├── FriendsRequest.java │ │ │ ├── ChatMsg.java │ │ │ └── Users.java │ │ │ └── utils │ │ │ └── MyMapper.java │ │ └── resources │ │ ├── log4j.properties │ │ └── mapper │ │ ├── MyFriendsMapper.xml │ │ ├── FriendsRequestMapper.xml │ │ ├── ChatMsgMapper.xml │ │ └── UsersMapper.xml ├── .idea │ ├── encodings.xml │ ├── compiler.xml │ ├── misc.xml │ ├── dataSources.local.xml │ └── dataSources.xml ├── target │ └── classes │ │ └── log4j.properties ├── generatorConfig.xml └── pom.xml ├── Backend ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── mapper │ │ │ │ ├── MyFriendsMapper.xml │ │ │ │ ├── FriendsRequestMapper.xml │ │ │ │ ├── ChatMsgMapper.xml │ │ │ │ └── UsersMapper.xml │ │ └── java │ │ │ ├── com │ │ │ └── mexbo │ │ │ │ ├── mapper │ │ │ │ ├── ChatMsgMapper.java │ │ │ │ ├── MyFriendsMapper.java │ │ │ │ ├── FriendsRequestMapper.java │ │ │ │ └── UsersMapper.java │ │ │ │ ├── service │ │ │ │ ├── UserService.java │ │ │ │ └── impl │ │ │ │ │ └── UserServiceImpl.java │ │ │ │ ├── pojo │ │ │ │ ├── bo │ │ │ │ │ └── UsersBO.java │ │ │ │ ├── vo │ │ │ │ │ └── UsersVO.java │ │ │ │ ├── MyFriends.java │ │ │ │ ├── FriendsRequest.java │ │ │ │ ├── ChatMsg.java │ │ │ │ └── Users.java │ │ │ │ ├── FastdfsImporter.java │ │ │ │ ├── NettyBooter.java │ │ │ │ ├── utils │ │ │ │ ├── MD5Utils.java │ │ │ │ ├── MyMapper.java │ │ │ │ ├── JsonUtils.java │ │ │ │ ├── IMoocJSONResult.java │ │ │ │ └── FastDFSClient.java │ │ │ │ ├── SpringbootMuxinBackendApplication.java │ │ │ │ ├── netty │ │ │ │ ├── WSServer.java │ │ │ │ ├── WSServerInitialzer.java │ │ │ │ └── ChatHandler.java │ │ │ │ ├── SpringUtil.java │ │ │ │ └── controller │ │ │ │ └── UserController.java │ │ │ └── org │ │ │ └── n3r │ │ │ └── idworker │ │ │ ├── WorkerIdStrategy.java │ │ │ ├── InvalidSystemClock.java │ │ │ ├── RandomCodeStrategy.java │ │ │ ├── Test.java │ │ │ ├── DayCode.java │ │ │ ├── Id.java │ │ │ ├── Code.java │ │ │ ├── strategy │ │ │ ├── DayPrefixRandomCodeStrategy.java │ │ │ └── FileLock.java │ │ │ ├── utils │ │ │ ├── Ip.java │ │ │ ├── IPv4Utils.java │ │ │ ├── Props.java │ │ │ ├── Serializes.java │ │ │ ├── Utils.java │ │ │ └── HttpReq.java │ │ │ ├── Sid.java │ │ │ └── IdWorker.java │ └── test │ │ └── java │ │ └── com │ │ └── mexbo │ │ ├── SpringbootMuxinBackendApplicationTests.java │ │ ├── utils │ │ └── FileUtilsTest.java │ │ ├── Controller │ │ └── UserControllerTest.java │ │ └── service │ │ └── impl │ │ └── UserServiceImplTest.java ├── .gitignore └── pom.xml ├── spring-boot-fastDFS ├── target │ └── classes │ │ ├── fdfs_client.conf │ │ ├── application.properties │ │ ├── templates │ │ ├── uploadStatus.html │ │ └── upload.html │ │ └── logback.xml ├── src │ └── main │ │ ├── resources │ │ ├── fdfs_client.conf │ │ ├── application.properties │ │ ├── templates │ │ │ ├── uploadStatus.html │ │ │ └── upload.html │ │ └── logback.xml │ │ └── java │ │ └── com │ │ └── neo │ │ ├── controller │ │ ├── GlobalExceptionHandler.java │ │ └── UploadController.java │ │ ├── FastDFSApplication.java │ │ └── fastdfs │ │ ├── FastDFSFile.java │ │ └── FastDFSClient.java ├── .idea │ ├── encodings.xml │ ├── modules.xml │ ├── misc.xml │ ├── libraries │ │ ├── Maven__ognl_ognl_3_0_8.xml │ │ ├── Maven__org_yaml_snakeyaml_1_17.xml │ │ ├── Maven__org_slf4j_slf4j_api_1_7_25.xml │ │ ├── Maven__com_fasterxml_classmate_1_3_4.xml │ │ ├── Maven__org_codehaus_groovy_groovy_2_4_13.xml │ │ ├── Maven__org_slf4j_jul_to_slf4j_1_7_25.xml │ │ ├── Maven__org_slf4j_jcl_over_slf4j_1_7_25.xml │ │ ├── Maven__org_javassist_javassist_3_21_0_GA.xml │ │ ├── Maven__ch_qos_logback_logback_core_1_1_11.xml │ │ ├── Maven__org_slf4j_log4j_over_slf4j_1_7_25.xml │ │ ├── Maven__ch_qos_logback_logback_classic_1_1_11.xml │ │ ├── Maven__org_thymeleaf_thymeleaf_2_1_6_RELEASE.xml │ │ ├── Maven__org_unbescape_unbescape_1_1_0_RELEASE.xml │ │ ├── Maven__com_fasterxml_jackson_core_jackson_core_2_8_10.xml │ │ ├── Maven__org_jboss_logging_jboss_logging_3_3_1_Final.xml │ │ ├── Maven__javax_validation_validation_api_1_1_0_Final.xml │ │ ├── Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_23.xml │ │ ├── Maven__org_springframework_spring_aop_4_3_13_RELEASE.xml │ │ ├── Maven__org_springframework_spring_web_4_3_13_RELEASE.xml │ │ ├── Maven__org_springframework_spring_core_4_3_13_RELEASE.xml │ │ ├── Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_23.xml │ │ ├── Maven__org_springframework_spring_beans_4_3_13_RELEASE.xml │ │ ├── Maven__com_fasterxml_jackson_core_jackson_databind_2_8_10.xml │ │ ├── Maven__org_hibernate_hibernate_validator_5_3_6_Final.xml │ │ ├── Maven__org_thymeleaf_thymeleaf_spring4_2_1_6_RELEASE.xml │ │ ├── Maven__org_apache_tomcat_tomcat_annotations_api_8_5_23.xml │ │ ├── Maven__org_csource_fastdfs_client_java_1_27_SNAPSHOT.xml │ │ ├── Maven__org_springframework_boot_spring_boot_1_5_9_RELEASE.xml │ │ ├── Maven__org_springframework_spring_webmvc_4_3_13_RELEASE.xml │ │ ├── Maven__com_fasterxml_jackson_core_jackson_annotations_2_8_0.xml │ │ ├── Maven__org_springframework_spring_context_4_3_13_RELEASE.xml │ │ ├── Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_23.xml │ │ ├── Maven__org_springframework_spring_expression_4_3_13_RELEASE.xml │ │ ├── Maven__nz_net_ultraq_thymeleaf_thymeleaf_layout_dialect_1_4_0.xml │ │ ├── Maven__org_springframework_boot_spring_boot_starter_1_5_9_RELEASE.xml │ │ ├── Maven__org_springframework_boot_spring_boot_devtools_1_5_9_RELEASE.xml │ │ ├── Maven__org_springframework_boot_spring_boot_starter_web_1_5_9_RELEASE.xml │ │ ├── Maven__org_springframework_boot_spring_boot_autoconfigure_1_5_9_RELEASE.xml │ │ ├── Maven__org_springframework_boot_spring_boot_starter_tomcat_1_5_9_RELEASE.xml │ │ ├── Maven__org_springframework_boot_spring_boot_starter_logging_1_5_9_RELEASE.xml │ │ └── Maven__org_springframework_boot_spring_boot_starter_thymeleaf_1_5_9_RELEASE.xml │ └── compiler.xml └── pom.xml ├── .gitignore ├── WebChat └── index.html ├── muxin-dev.sql └── README.md /Fronkend/fonts/mui.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awfssv/Springboot_muxin/HEAD/Fronkend/fonts/mui.ttf -------------------------------------------------------------------------------- /Fronkend/images/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awfssv/Springboot_muxin/HEAD/Fronkend/images/error.png -------------------------------------------------------------------------------- /Fronkend/images/qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awfssv/Springboot_muxin/HEAD/Fronkend/images/qrcode.png -------------------------------------------------------------------------------- /Fronkend/images/success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awfssv/Springboot_muxin/HEAD/Fronkend/images/success.png -------------------------------------------------------------------------------- /Fronkend/images/upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awfssv/Springboot_muxin/HEAD/Fronkend/images/upload.png -------------------------------------------------------------------------------- /Fronkend/images/face-default.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awfssv/Springboot_muxin/HEAD/Fronkend/images/face-default.jpg -------------------------------------------------------------------------------- /Fronkend/css/registLogin/arrow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awfssv/Springboot_muxin/HEAD/Fronkend/css/registLogin/arrow.jpg -------------------------------------------------------------------------------- /springboot_mybatis/springboot_mybatis.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Backend/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awfssv/Springboot_muxin/HEAD/Backend/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Fronkend/plugin/cropper/images/picture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awfssv/Springboot_muxin/HEAD/Fronkend/plugin/cropper/images/picture.jpg -------------------------------------------------------------------------------- /Fronkend/plugin/v3.1.6/images/picture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awfssv/Springboot_muxin/HEAD/Fronkend/plugin/v3.1.6/images/picture.jpg -------------------------------------------------------------------------------- /Backend/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awfssv/Springboot_muxin/HEAD/Backend/src/main/resources/application.properties -------------------------------------------------------------------------------- /Backend/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /Fronkend/css/header.css: -------------------------------------------------------------------------------- 1 | .title { 2 | background-color: #c9394a; 3 | } 4 | 5 | .title-color { 6 | color: white; 7 | } 8 | 9 | .mui-bar-tab .mui-tab-item.mui-active { 10 | color: #c9394a; 11 | } 12 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/mapper/ChatMsgMapper.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.mapper; 2 | 3 | import com.mexbo.utils.MyMapper; 4 | import com.mexbo.pojo.ChatMsg; 5 | 6 | public interface ChatMsgMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /spring-boot-fastDFS/target/classes/fdfs_client.conf: -------------------------------------------------------------------------------- 1 | connect_timeout = 60 2 | network_timeout = 60 3 | charset = UTF-8 4 | http.tracker_http_port = 8080 5 | http.anti_steal_token = no 6 | 7 | tracker_server = 47.107.113.43:22122 8 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/resources/fdfs_client.conf: -------------------------------------------------------------------------------- 1 | connect_timeout = 60 2 | network_timeout = 60 3 | charset = UTF-8 4 | http.tracker_http_port = 8080 5 | http.anti_steal_token = no 6 | 7 | tracker_server = 47.107.113.43:22122 8 | -------------------------------------------------------------------------------- /springboot_mybatis/src/main/java/com/mexbo/mapper/UsersMapper.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.mapper; 2 | 3 | import com.imooc.utils.MyMapper; 4 | import com.mexbo.pojo.Users; 5 | 6 | public interface UsersMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/mapper/MyFriendsMapper.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.mapper; 2 | 3 | import com.mexbo.utils.MyMapper; 4 | import com.mexbo.pojo.MyFriends; 5 | 6 | public interface MyFriendsMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/WorkerIdStrategy.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | public interface WorkerIdStrategy { 4 | void initialize(); 5 | 6 | long availableWorkerId(); 7 | 8 | void release(); 9 | } 10 | -------------------------------------------------------------------------------- /springboot_mybatis/src/main/java/com/mexbo/mapper/ChatMsgMapper.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.mapper; 2 | 3 | import com.imooc.utils.MyMapper; 4 | import com.mexbo.pojo.ChatMsg; 5 | 6 | public interface ChatMsgMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /springboot_mybatis/src/main/java/com/mexbo/mapper/MyFriendsMapper.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.mapper; 2 | 3 | import com.imooc.utils.MyMapper; 4 | import com.mexbo.pojo.MyFriends; 5 | 6 | public interface MyFriendsMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/InvalidSystemClock.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | public class InvalidSystemClock extends RuntimeException { 4 | public InvalidSystemClock(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/mapper/FriendsRequestMapper.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.mapper; 2 | 3 | import com.mexbo.utils.MyMapper; 4 | import com.mexbo.pojo.FriendsRequest; 5 | 6 | public interface FriendsRequestMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/RandomCodeStrategy.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | public interface RandomCodeStrategy { 4 | void init(); 5 | 6 | int prefix(); 7 | 8 | int next(); 9 | 10 | void release(); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /springboot_mybatis/src/main/java/com/mexbo/mapper/FriendsRequestMapper.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.mapper; 2 | 3 | import com.imooc.utils.MyMapper; 4 | import com.mexbo.pojo.FriendsRequest; 5 | 6 | public interface FriendsRequestMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/mapper/UsersMapper.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.mapper; 2 | 3 | import com.mexbo.utils.MyMapper; 4 | import com.mexbo.pojo.Users; 5 | import org.springframework.stereotype.Service; 6 | 7 | 8 | public interface UsersMapper extends MyMapper { 9 | } -------------------------------------------------------------------------------- /spring-boot-fastDFS/target/classes/application.properties: -------------------------------------------------------------------------------- 1 | #http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#common-application-properties 2 | #search multipart 3 | spring.http.multipart.max-file-size=10MB 4 | spring.http.multipart.max-request-size=10MB 5 | 6 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#common-application-properties 2 | #search multipart 3 | spring.http.multipart.max-file-size=10MB 4 | spring.http.multipart.max-request-size=10MB 5 | 6 | -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/Test.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | for (int i = 0 ; i < 1000 ; i ++) { 8 | // System.out.println(Sid.nextShort()); 9 | } 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /springboot_mybatis/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/target/classes/templates/uploadStatus.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Spring Boot - Upload Status

6 | 7 |
8 |

9 |

10 | 11 |
12 |

13 |

14 | 15 | 16 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/resources/templates/uploadStatus.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Spring Boot - Upload Status

6 | 7 |
8 |

9 |

10 | 11 |
12 |

13 |

14 | 15 | 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | -------------------------------------------------------------------------------- /Backend/.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 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /spring-boot-fastDFS/target/classes/templates/upload.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Spring Boot file upload example

6 | 7 |
8 |

9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/resources/templates/upload.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Spring Boot file upload example

6 | 7 |
8 |

9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Backend/src/test/java/com/mexbo/SpringbootMuxinBackendApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.mexbo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringbootMuxinBackendApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Backend/src/test/java/com/mexbo/utils/FileUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.utils; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | import static org.junit.Assert.*; 9 | 10 | @RunWith(SpringRunner.class) 11 | @SpringBootTest 12 | public class FileUtilsTest { 13 | @Test 14 | public void TestFastDfs(){ 15 | 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /Fronkend/pages/contact.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Contact

13 | 14 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Fronkend/pages/chatlist.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Chatlist

13 | 14 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Fronkend/pages/discover.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Discover

13 | 14 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Backend/src/test/java/com/mexbo/Controller/UserControllerTest.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.Controller; 2 | 3 | import com.mexbo.controller.UserController; 4 | import com.mexbo.pojo.Users; 5 | import com.mexbo.utils.MD5Utils; 6 | import org.junit.Test; 7 | import org.n3r.idworker.Sid; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | 10 | public class UserControllerTest { 11 | @Autowired 12 | private Sid sid; 13 | 14 | @Test 15 | public void registOrlogin() throws Exception { 16 | 17 | } 18 | } -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__ognl_ognl_3_0_8.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_yaml_snakeyaml_1_17.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.service; 2 | import com.mexbo.pojo.Users; 3 | 4 | public interface UserService { 5 | 6 | /** 7 | * @Description: 判断用户名是否存在 8 | */ 9 | public boolean queryUsernameIsExist(String username); 10 | 11 | /** 12 | * @Description: 查询用户是否存在 13 | */ 14 | public Users queryUserForLogin(String username, String pwd); 15 | 16 | /** 17 | * @Description: 用户注册 18 | */ 19 | public Users saveUser(Users user); 20 | 21 | /** 22 | * @Description: 修改用户记录 23 | */ 24 | public Users updateUserInfo(Users user); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /springboot_mybatis/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__com_fasterxml_classmate_1_3_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /springboot_mybatis/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO,console 2 | # TODO \u53d1\u5e03\u5230\u963f\u91cc\u4e91\u8bb0\u5f97\u6dfb\u52a0\uff0c\u53e6\u5916\u63a7\u5236\u53f0\u4e0d\u8f93\u51fa(\u53ea\u8f93\u51fawarn\u6216\u8005error\u4fe1\u606f) 3 | #INFO,console,dailyFile 4 | 5 | # log4j.logger.org.mybatis = INFO 6 | log4j.logger.com.imooc.mapper=INFO 7 | 8 | log4j.appender.console=org.apache.log4j.ConsoleAppender 9 | log4j.appender.console.encoding=UTF-8 10 | log4j.appender.console.layout=org.apache.log4j.PatternLayout 11 | log4j.appender.console.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%l] - [%p] %m%n -------------------------------------------------------------------------------- /springboot_mybatis/target/classes/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO,console 2 | # TODO \u53d1\u5e03\u5230\u963f\u91cc\u4e91\u8bb0\u5f97\u6dfb\u52a0\uff0c\u53e6\u5916\u63a7\u5236\u53f0\u4e0d\u8f93\u51fa(\u53ea\u8f93\u51fawarn\u6216\u8005error\u4fe1\u606f) 3 | #INFO,console,dailyFile 4 | 5 | # log4j.logger.org.mybatis = INFO 6 | log4j.logger.com.imooc.mapper=INFO 7 | 8 | log4j.appender.console=org.apache.log4j.ConsoleAppender 9 | log4j.appender.console.encoding=UTF-8 10 | log4j.appender.console.layout=org.apache.log4j.PatternLayout 11 | log4j.appender.console.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%l] - [%p] %m%n -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_codehaus_groovy_groovy_2_4_13.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Backend/src/main/resources/mapper/MyFriendsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_slf4j_jcl_over_slf4j_1_7_25.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_javassist_javassist_3_21_0_GA.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /springboot_mybatis/src/main/resources/mapper/MyFriendsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__ch_qos_logback_logback_core_1_1_11.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_slf4j_log4j_over_slf4j_1_7_25.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/pojo/bo/UsersBO.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.pojo.bo; 2 | 3 | public class UsersBO { 4 | private String userId; 5 | private String faceData; 6 | private String nickname; 7 | 8 | public String getUserId() { 9 | return userId; 10 | } 11 | public void setUserId(String userId) { 12 | this.userId = userId; 13 | } 14 | public String getFaceData() { 15 | return faceData; 16 | } 17 | public void setFaceData(String faceData) { 18 | this.faceData = faceData; 19 | } 20 | public String getNickname() { 21 | return nickname; 22 | } 23 | public void setNickname(String nickname) { 24 | this.nickname = nickname; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/FastdfsImporter.java: -------------------------------------------------------------------------------- 1 | package com.mexbo; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.context.annotation.EnableMBeanExport; 5 | import org.springframework.context.annotation.Import; 6 | import org.springframework.jmx.support.RegistrationPolicy; 7 | 8 | import com.github.tobato.fastdfs.FdfsClientConfig; 9 | 10 | /** 11 | * 导入FastDFS-Client组件 12 | * 13 | * @author tobato 14 | * 15 | */ 16 | @Configuration 17 | @Import(FdfsClientConfig.class) 18 | // 解决jmx重复注册bean的问题 19 | @EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING) 20 | public class FastdfsImporter { 21 | // 导入依赖组件 22 | } -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_1_11.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_thymeleaf_thymeleaf_2_1_6_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_unbescape_unbescape_1_1_0_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/NettyBooter.java: -------------------------------------------------------------------------------- 1 | package com.mexbo; 2 | 3 | import com.mexbo.netty.WSServer; 4 | import org.springframework.context.ApplicationListener; 5 | import org.springframework.context.event.ContextRefreshedEvent; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class NettyBooter implements ApplicationListener { 10 | 11 | @Override 12 | public void onApplicationEvent(ContextRefreshedEvent event) { 13 | if (event.getApplicationContext().getParent() == null) { 14 | try { 15 | WSServer.getInstance().start(); 16 | } catch (Exception e) { 17 | e.printStackTrace(); 18 | } 19 | } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Fronkend/plugin/v3.1.6/js/main.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | var $image = $('#image'); 4 | var options = { 5 | aspectRatio: 1 / 1, 6 | preview: '.img-preview', 7 | crop: function(e) {} 8 | }; 9 | 10 | // Cropper 11 | $image.cropper(options); 12 | 13 | // Methods 14 | $('.docs-buttons').on('click', '[data-method]', function() { 15 | var cropper = $image.data('cropper'); 16 | var result; 17 | 18 | result = $image.cropper("getCroppedCanvas"); 19 | 20 | if(result) { 21 | // Bootstrap's Modal 22 | $('#getCroppedCanvasModal').modal().find('.modal-body').html(result); 23 | var base64Url = result.toDataURL(); 24 | console.log(base64Url); 25 | } 26 | 27 | }); 28 | 29 | }); -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/DayCode.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | import org.n3r.idworker.strategy.DayPrefixRandomCodeStrategy; 4 | 5 | public class DayCode { 6 | static RandomCodeStrategy strategy; 7 | 8 | static { 9 | DayPrefixRandomCodeStrategy dayPrefixCodeStrategy = new DayPrefixRandomCodeStrategy("yyMM"); 10 | dayPrefixCodeStrategy.setMinRandomSize(7); 11 | dayPrefixCodeStrategy.setMaxRandomSize(7); 12 | strategy = dayPrefixCodeStrategy; 13 | strategy.init(); 14 | } 15 | 16 | public static synchronized String next() { 17 | return String.format("%d-%04d-%07d", Id.getWorkerId(), strategy.prefix(), strategy.next()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_8_10.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_1_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/utils/MD5Utils.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.utils; 2 | 3 | import java.security.MessageDigest; 4 | import org.apache.commons.codec.binary.Base64; 5 | 6 | public class MD5Utils { 7 | 8 | /** 9 | * @Description: 对字符串进行md5加密 10 | */ 11 | public static String getMD5Str(String strValue) throws Exception { 12 | MessageDigest md5 = MessageDigest.getInstance("MD5"); 13 | String newstr = Base64.encodeBase64String(md5.digest(strValue.getBytes())); 14 | return newstr; 15 | } 16 | 17 | public static void main(String[] args) { 18 | try { 19 | String md5 = getMD5Str("imooc"); 20 | System.out.println(md5); 21 | } catch (Exception e) { 22 | e.printStackTrace(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__javax_validation_validation_api_1_1_0_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_23.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_spring_aop_4_3_13_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_spring_web_4_3_13_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /springboot_mybatis/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_spring_core_4_3_13_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_23.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_spring_beans_4_3_13_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_8_10.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_hibernate_hibernate_validator_5_3_6_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_thymeleaf_thymeleaf_spring4_2_1_6_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Backend/src/main/resources/mapper/FriendsRequestMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_apache_tomcat_tomcat_annotations_api_8_5_23.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_csource_fastdfs_client_java_1_27_SNAPSHOT.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_boot_spring_boot_1_5_9_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_spring_webmvc_4_3_13_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /springboot_mybatis/src/main/resources/mapper/FriendsRequestMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_8_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_spring_context_4_3_13_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_23.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_spring_expression_4_3_13_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__nz_net_ultraq_thymeleaf_thymeleaf_layout_dialect_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/target/classes/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_1_5_9_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_boot_spring_boot_devtools_1_5_9_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_1_5_9_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Backend/src/main/resources/mapper/ChatMsgMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_1_5_9_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_1_5_9_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /springboot_mybatis/src/main/resources/mapper/ChatMsgMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_1_5_9_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/java/com/neo/controller/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import org.springframework.web.bind.annotation.ControllerAdvice; 4 | import org.springframework.web.bind.annotation.ExceptionHandler; 5 | import org.springframework.web.multipart.MultipartException; 6 | import org.springframework.web.servlet.mvc.support.RedirectAttributes; 7 | 8 | @ControllerAdvice 9 | public class GlobalExceptionHandler { 10 | 11 | //https://jira.spring.io/browse/SPR-14651 12 | //4.3.5 supports RedirectAttributes redirectAttributes 13 | @ExceptionHandler(MultipartException.class) 14 | public String handleError1(MultipartException e, RedirectAttributes redirectAttributes) { 15 | 16 | redirectAttributes.addFlashAttribute("message", e.getCause().getMessage()); 17 | return "redirect:/uploadStatus"; 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/SpringbootMuxinBackendApplication.java: -------------------------------------------------------------------------------- 1 | package com.mexbo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import tk.mybatis.spring.annotation.MapperScan; 8 | 9 | @SpringBootApplication 10 | @MapperScan(basePackages="com.mexbo.mapper") 11 | // 扫描 所有需要的包, 包含一些自用的工具类包 所在的路径 12 | @ComponentScan(basePackages= {"com.mexbo", "org.n3r.idworker"}) 13 | public class SpringbootMuxinBackendApplication { 14 | @Bean 15 | public SpringUtil getSpingUtil() { 16 | return new SpringUtil(); 17 | } 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(SpringbootMuxinBackendApplication.class, args); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_thymeleaf_1_5_9_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /springboot_mybatis/.idea/dataSources.local.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #@ 7 | ` 8 | 9 | 10 | master_key 11 | root 12 | *:@ 13 | 14 | 15 | -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/Id.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | import org.n3r.idworker.strategy.DefaultWorkerIdStrategy; 4 | 5 | public class Id { 6 | private static WorkerIdStrategy workerIdStrategy; 7 | private static IdWorker idWorker; 8 | 9 | static { 10 | configure(DefaultWorkerIdStrategy.instance); 11 | } 12 | 13 | public static synchronized void configure(WorkerIdStrategy custom) { 14 | if (workerIdStrategy == custom) return; 15 | 16 | if (workerIdStrategy != null) workerIdStrategy.release(); 17 | workerIdStrategy = custom; 18 | workerIdStrategy.initialize(); 19 | idWorker = new IdWorker(workerIdStrategy.availableWorkerId()); 20 | } 21 | 22 | public static long next() { 23 | return idWorker.nextId(); 24 | } 25 | 26 | public static long getWorkerId() { 27 | return idWorker.getWorkerId(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Backend/src/main/resources/mapper/UsersMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /springboot_mybatis/.idea/dataSources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mysql 6 | true 7 | com.mysql.jdbc.Driver 8 | jdbc:mysql://47.107.113.43:3306/muxin 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /springboot_mybatis/src/main/resources/mapper/UsersMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/Code.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | import org.n3r.idworker.strategy.DefaultRandomCodeStrategy; 4 | 5 | public class Code { 6 | private static RandomCodeStrategy strategy; 7 | 8 | static { 9 | RandomCodeStrategy strategy = new DefaultRandomCodeStrategy(); 10 | strategy.init(); 11 | configure(strategy); 12 | } 13 | 14 | public static synchronized void configure(RandomCodeStrategy custom) { 15 | if (strategy == custom) return; 16 | if (strategy != null) strategy.release(); 17 | 18 | strategy = custom; 19 | } 20 | 21 | /** 22 | * Next Unique code. 23 | * The max length will be 1024-Integer.MAX-Integer.MAX(2147483647) which has 4+10+10+2*1=26 characters. 24 | * The min length will be 0-0. 25 | * 26 | * @return unique string code. 27 | */ 28 | public static synchronized String next() { 29 | long workerId = Id.getWorkerId(); 30 | int prefix = strategy.prefix(); 31 | int next = strategy.next(); 32 | 33 | return String.format("%d-%03d-%06d", workerId, prefix, next); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/netty/WSServer.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.netty; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import io.netty.bootstrap.ServerBootstrap; 6 | import io.netty.channel.ChannelFuture; 7 | import io.netty.channel.EventLoopGroup; 8 | import io.netty.channel.nio.NioEventLoopGroup; 9 | import io.netty.channel.socket.nio.NioServerSocketChannel; 10 | 11 | @Component 12 | public class WSServer { 13 | 14 | private static class SingletionWSServer { 15 | static final WSServer instance = new WSServer(); 16 | } 17 | 18 | public static WSServer getInstance() { 19 | return SingletionWSServer.instance; 20 | } 21 | 22 | private EventLoopGroup mainGroup; 23 | private EventLoopGroup subGroup; 24 | private ServerBootstrap server; 25 | private ChannelFuture future; 26 | 27 | public WSServer() { 28 | mainGroup = new NioEventLoopGroup(); 29 | subGroup = new NioEventLoopGroup(); 30 | server = new ServerBootstrap(); 31 | server.group(mainGroup, subGroup) 32 | .channel(NioServerSocketChannel.class) 33 | .childHandler(new WSServerInitialzer()); 34 | } 35 | 36 | public void start() { 37 | this.future = server.bind(8088); 38 | System.err.println("netty websocket server 启动完毕..."); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/strategy/DayPrefixRandomCodeStrategy.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.strategy; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | public class DayPrefixRandomCodeStrategy extends DefaultRandomCodeStrategy { 7 | private final String dayFormat; 8 | private String lastDay; 9 | 10 | public DayPrefixRandomCodeStrategy(String dayFormat) { 11 | this.dayFormat = dayFormat; 12 | } 13 | 14 | @Override 15 | public void init() { 16 | String day = createDate(); 17 | if (day.equals(lastDay)) 18 | throw new RuntimeException("init failed for day unrolled"); 19 | 20 | lastDay = day; 21 | 22 | availableCodes.clear(); 23 | release(); 24 | 25 | prefixIndex = Integer.parseInt(lastDay); 26 | if (tryUsePrefix()) return; 27 | 28 | throw new RuntimeException("prefix is not available " + prefixIndex); 29 | } 30 | 31 | private String createDate() { 32 | return new SimpleDateFormat(dayFormat).format(new Date()); 33 | } 34 | 35 | @Override 36 | public int next() { 37 | if (!lastDay.equals(createDate())) init(); 38 | 39 | return super.next(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/pojo/vo/UsersVO.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.pojo.vo; 2 | 3 | import java.util.List; 4 | 5 | public class UsersVO { 6 | private String id; 7 | private String username; 8 | private String faceImage; 9 | private String faceImageBig; 10 | private String nickname; 11 | private String qrcode; 12 | 13 | public String getId() { 14 | return id; 15 | } 16 | public void setId(String id) { 17 | this.id = id; 18 | } 19 | public String getUsername() { 20 | return username; 21 | } 22 | public void setUsername(String username) { 23 | this.username = username; 24 | } 25 | public String getFaceImage() { 26 | return faceImage; 27 | } 28 | public void setFaceImage(String faceImage) { 29 | this.faceImage = faceImage; 30 | } 31 | public String getFaceImageBig() { 32 | return faceImageBig; 33 | } 34 | public void setFaceImageBig(String faceImageBig) { 35 | this.faceImageBig = faceImageBig; 36 | } 37 | public String getNickname() { 38 | return nickname; 39 | } 40 | public void setNickname(String nickname) { 41 | this.nickname = nickname; 42 | } 43 | public String getQrcode() { 44 | return qrcode; 45 | } 46 | public void setQrcode(String qrcode) { 47 | this.qrcode = qrcode; 48 | } 49 | } -------------------------------------------------------------------------------- /Fronkend/js/app.js: -------------------------------------------------------------------------------- 1 | window.app = { 2 | /** 3 | * netty服务后端发布的url地址 4 | */ 5 | //nettyServerUrl: 'ws://192.168.43.185:8088/ws', 6 | 7 | /** 8 | * 后端服务发布的url地址 9 | */ 10 | serverUrl: 'http://192.168.3.71:8080', 11 | 12 | /** 13 | * 图片服务器的url地址 14 | */ 15 | imgServerUrl: 'http://192.168.43.185:88/imooc/', 16 | 17 | isNotNull: function(str) { 18 | if (str != null && str != "" && str != undefined) { 19 | return true; 20 | } 21 | return false; 22 | }, 23 | 24 | /** 25 | * 封装消息提示框,默认mui的不支持居中和自定义icon,所以使用h5+ 26 | * @param {Object} msg 27 | * @param {Object} type 28 | */ 29 | showToast: function(msg, type) { 30 | plus.nativeUI.toast(msg, 31 | {icon: "../images/" + type + ".png", verticalAlign: "center"}) 32 | }, 33 | /** 34 | * 保存用户的全局对象 35 | * @param {Object} user 36 | */ 37 | setUserGlobalInfo: function(user) { 38 | var userInfoStr = JSON.stringify(user); 39 | plus.storage.setItem("userInfo", userInfoStr); 40 | }, 41 | 42 | /** 43 | * 获取用户的全局对象 44 | */ 45 | getUserGlobalInfo: function() { 46 | var userInfoStr = plus.storage.getItem("userInfo"); 47 | return JSON.parse(userInfoStr); 48 | }, 49 | /** 50 | * 登出后,移除用户全局对象 51 | */ 52 | userLogout: function() { 53 | plus.storage.removeItem("userInfo"); 54 | }, 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/SpringUtil.java: -------------------------------------------------------------------------------- 1 | package com.mexbo; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | 7 | /** 8 | * @Description: 提供手动获取被spring管理的bean对象 9 | */ 10 | public class SpringUtil implements ApplicationContextAware { 11 | 12 | private static ApplicationContext applicationContext; 13 | 14 | @Override 15 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 16 | if (SpringUtil.applicationContext == null) { 17 | SpringUtil.applicationContext = applicationContext; 18 | } 19 | } 20 | 21 | // 获取applicationContext 22 | public static ApplicationContext getApplicationContext() { 23 | return applicationContext; 24 | } 25 | 26 | // 通过name获取 Bean. 27 | public static Object getBean(String name) { 28 | return getApplicationContext().getBean(name); 29 | } 30 | 31 | // 通过class获取Bean. 32 | public static T getBean(Class clazz) { 33 | return getApplicationContext().getBean(clazz); 34 | } 35 | 36 | // 通过name,以及Clazz返回指定的Bean 37 | public static T getBean(String name, Class clazz) { 38 | return getApplicationContext().getBean(name, clazz); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /springboot_mybatis/src/main/java/com/mexbo/mybatis/GeneratorDisplay.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.mybatis; 2 | 3 | import org.mybatis.generator.api.MyBatisGenerator; 4 | import org.mybatis.generator.config.Configuration; 5 | import org.mybatis.generator.config.xml.ConfigurationParser; 6 | import org.mybatis.generator.internal.DefaultShellCallback; 7 | 8 | import java.io.File; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | 13 | public class GeneratorDisplay { 14 | 15 | public void generator() throws Exception{ 16 | 17 | List warnings = new ArrayList(); 18 | boolean overwrite = true; 19 | //指定 逆向工程配置文件 20 | File configFile = new File("generatorConfig.xml"); 21 | ConfigurationParser cp = new ConfigurationParser(warnings); 22 | Configuration config = cp.parseConfiguration(configFile); 23 | DefaultShellCallback callback = new DefaultShellCallback(overwrite); 24 | MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, 25 | callback, warnings); 26 | myBatisGenerator.generate(null); 27 | 28 | } 29 | 30 | public static void main(String[] args) throws Exception { 31 | try { 32 | GeneratorDisplay generatorSqlmap = new GeneratorDisplay(); 33 | generatorSqlmap.generator(); 34 | } catch (Exception e) { 35 | e.printStackTrace(); 36 | } 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/java/com/neo/FastDFSApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.apache.coyote.http11.AbstractHttp11Protocol; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer; 7 | import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; 8 | import org.springframework.context.annotation.Bean; 9 | 10 | @SpringBootApplication 11 | public class FastDFSApplication { 12 | 13 | public static void main(String[] args) throws Exception { 14 | SpringApplication.run(FastDFSApplication.class, args); 15 | } 16 | 17 | //Tomcat large file upload connection reset 18 | @Bean 19 | public TomcatEmbeddedServletContainerFactory tomcatEmbedded() { 20 | TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory(); 21 | tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> { 22 | if ((connector.getProtocolHandler() instanceof AbstractHttp11Protocol)) { 23 | //-1 means unlimited 24 | ((AbstractHttp11Protocol) connector.getProtocolHandler()).setMaxSwallowSize(-1); 25 | } 26 | }); 27 | return tomcat; 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/java/com/neo/fastdfs/FastDFSFile.java: -------------------------------------------------------------------------------- 1 | package com.neo.fastdfs; 2 | 3 | public class FastDFSFile { 4 | private String name; 5 | 6 | private byte[] content; 7 | 8 | private String ext; 9 | 10 | private String md5; 11 | 12 | private String author; 13 | 14 | public FastDFSFile(String name, byte[] content, String ext, String height, 15 | String width, String author) { 16 | super(); 17 | this.name = name; 18 | this.content = content; 19 | this.ext = ext; 20 | this.author = author; 21 | } 22 | 23 | public FastDFSFile(String name, byte[] content, String ext) { 24 | super(); 25 | this.name = name; 26 | this.content = content; 27 | this.ext = ext; 28 | 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | 39 | public byte[] getContent() { 40 | return content; 41 | } 42 | 43 | public void setContent(byte[] content) { 44 | this.content = content; 45 | } 46 | 47 | public String getExt() { 48 | return ext; 49 | } 50 | 51 | public void setExt(String ext) { 52 | this.ext = ext; 53 | } 54 | 55 | public String getMd5() { 56 | return md5; 57 | } 58 | 59 | public void setMd5(String md5) { 60 | this.md5 = md5; 61 | } 62 | 63 | public String getAuthor() { 64 | return author; 65 | } 66 | 67 | public void setAuthor(String author) { 68 | this.author = author; 69 | } 70 | } -------------------------------------------------------------------------------- /WebChat/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
发送消息:
10 | 11 | 12 | 13 |
接受消息:
14 |
15 | 16 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/pojo/MyFriends.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.pojo; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Table; 5 | 6 | @Table(name = "my_friends") 7 | public class MyFriends { 8 | private String id; 9 | 10 | /** 11 | * 用户id 12 | */ 13 | @Column(name = "my_user_id") 14 | private String myUserId; 15 | 16 | /** 17 | * 用户的好友id 18 | */ 19 | @Column(name = "my_friend_user_id") 20 | private String myFriendUserId; 21 | 22 | /** 23 | * @return id 24 | */ 25 | public String getId() { 26 | return id; 27 | } 28 | 29 | /** 30 | * @param id 31 | */ 32 | public void setId(String id) { 33 | this.id = id; 34 | } 35 | 36 | /** 37 | * 获取用户id 38 | * 39 | * @return my_user_id - 用户id 40 | */ 41 | public String getMyUserId() { 42 | return myUserId; 43 | } 44 | 45 | /** 46 | * 设置用户id 47 | * 48 | * @param myUserId 用户id 49 | */ 50 | public void setMyUserId(String myUserId) { 51 | this.myUserId = myUserId; 52 | } 53 | 54 | /** 55 | * 获取用户的好友id 56 | * 57 | * @return my_friend_user_id - 用户的好友id 58 | */ 59 | public String getMyFriendUserId() { 60 | return myFriendUserId; 61 | } 62 | 63 | /** 64 | * 设置用户的好友id 65 | * 66 | * @param myFriendUserId 用户的好友id 67 | */ 68 | public void setMyFriendUserId(String myFriendUserId) { 69 | this.myFriendUserId = myFriendUserId; 70 | } 71 | } -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/netty/WSServerInitialzer.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.netty; 2 | 3 | import io.netty.channel.ChannelInitializer; 4 | import io.netty.channel.ChannelPipeline; 5 | import io.netty.channel.socket.SocketChannel; 6 | import io.netty.handler.codec.http.HttpObjectAggregator; 7 | import io.netty.handler.codec.http.HttpServerCodec; 8 | import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler; 9 | import io.netty.handler.stream.ChunkedWriteHandler; 10 | 11 | public class WSServerInitialzer extends ChannelInitializer { 12 | 13 | @Override 14 | protected void initChannel(SocketChannel ch) throws Exception { 15 | ChannelPipeline pipeline = ch.pipeline(); 16 | 17 | // websocket 基于http协议,所以要有http编解码器 18 | pipeline.addLast(new HttpServerCodec()); 19 | // 对写大数据流的支持 20 | pipeline.addLast(new ChunkedWriteHandler()); 21 | // 对httpMessage进行聚合,聚合成FullHttpRequest或FullHttpResponse 22 | // 几乎在netty中的编程,都会使用到此hanler 23 | pipeline.addLast(new HttpObjectAggregator(1024*64)); 24 | 25 | // ====================== 以上是用于支持http协议 ====================== 26 | 27 | // ====================== 以下是支持httpWebsocket ====================== 28 | 29 | /** 30 | * websocket 服务器处理的协议,用于指定给客户端连接访问的路由 : /ws 31 | * 本handler会帮你处理一些繁重的复杂的事 32 | * 会帮你处理握手动作: handshaking(close, ping, pong) ping + pong = 心跳 33 | * 对于websocket来讲,都是以frames进行传输的,不同的数据类型对应的frames也不同 34 | */ 35 | pipeline.addLast(new WebSocketServerProtocolHandler("/ws")); 36 | 37 | // 自定义的handler 38 | pipeline.addLast(new ChatHandler()); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /springboot_mybatis/src/main/java/com/mexbo/pojo/MyFriends.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.pojo; 2 | 3 | import javax.persistence.*; 4 | 5 | @Table(name = "my_friends") 6 | public class MyFriends { 7 | @Id 8 | private String id; 9 | 10 | /** 11 | * 用户id 12 | */ 13 | @Column(name = "my_user_id") 14 | private String myUserId; 15 | 16 | /** 17 | * 用户的好友id 18 | */ 19 | @Column(name = "my_friend_user_id") 20 | private String myFriendUserId; 21 | 22 | /** 23 | * @return id 24 | */ 25 | public String getId() { 26 | return id; 27 | } 28 | 29 | /** 30 | * @param id 31 | */ 32 | public void setId(String id) { 33 | this.id = id; 34 | } 35 | 36 | /** 37 | * 获取用户id 38 | * 39 | * @return my_user_id - 用户id 40 | */ 41 | public String getMyUserId() { 42 | return myUserId; 43 | } 44 | 45 | /** 46 | * 设置用户id 47 | * 48 | * @param myUserId 用户id 49 | */ 50 | public void setMyUserId(String myUserId) { 51 | this.myUserId = myUserId; 52 | } 53 | 54 | /** 55 | * 获取用户的好友id 56 | * 57 | * @return my_friend_user_id - 用户的好友id 58 | */ 59 | public String getMyFriendUserId() { 60 | return myFriendUserId; 61 | } 62 | 63 | /** 64 | * 设置用户的好友id 65 | * 66 | * @param myFriendUserId 用户的好友id 67 | */ 68 | public void setMyFriendUserId(String myFriendUserId) { 69 | this.myFriendUserId = myFriendUserId; 70 | } 71 | } -------------------------------------------------------------------------------- /springboot_mybatis/generatorConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 |
33 |
34 |
35 | 36 |
37 |
-------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/utils/MyMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014-2016 abel533@gmail.com 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.mexbo.utils; 26 | 27 | import tk.mybatis.mapper.common.Mapper; 28 | import tk.mybatis.mapper.common.MySqlMapper; 29 | 30 | /** 31 | * 继承自己的MyMapper 32 | * 33 | * @author liuzh 34 | * @since 2015-09-06 21:53 35 | */ 36 | public interface MyMapper extends Mapper, MySqlMapper { 37 | //TODO 38 | //FIXME 特别注意,该接口不能被扫描到,否则会出错 39 | } 40 | -------------------------------------------------------------------------------- /springboot_mybatis/src/main/java/com/mexbo/utils/MyMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014-2016 abel533@gmail.com 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.mexbo.utils; 26 | 27 | import tk.mybatis.mapper.common.Mapper; 28 | import tk.mybatis.mapper.common.MySqlMapper; 29 | 30 | /** 31 | * 继承自己的MyMapper 32 | * 33 | * @author liuzh 34 | * @since 2015-09-06 21:53 35 | */ 36 | public interface MyMapper extends Mapper, MySqlMapper { 37 | //TODO 38 | //FIXME 特别注意,该接口不能被扫描到,否则会出错 39 | } 40 | -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/utils/Ip.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.net.Inet4Address; 8 | import java.net.InetAddress; 9 | import java.net.NetworkInterface; 10 | import java.net.SocketException; 11 | import java.util.Enumeration; 12 | 13 | public class Ip { 14 | static Logger logger = LoggerFactory.getLogger(Ip.class); 15 | 16 | public static String ip; 17 | public static long lip; 18 | 19 | static { 20 | try { 21 | InetAddress localHostLANAddress = getFirstNonLoopbackAddress(); 22 | ip = localHostLANAddress.getHostAddress(); 23 | 24 | byte[] address = localHostLANAddress.getAddress(); 25 | lip = ((address [0] & 0xFFL) << (3*8)) + 26 | ((address [1] & 0xFFL) << (2*8)) + 27 | ((address [2] & 0xFFL) << (1*8)) + 28 | (address [3] & 0xFFL); 29 | } catch (Exception e) { 30 | logger.error("get ipv4 failed ", e); 31 | } 32 | } 33 | 34 | private static InetAddress getFirstNonLoopbackAddress() throws SocketException { 35 | Enumeration en = NetworkInterface.getNetworkInterfaces(); 36 | while (en.hasMoreElements()) { 37 | NetworkInterface i = (NetworkInterface) en.nextElement(); 38 | for (Enumeration en2 = i.getInetAddresses(); en2.hasMoreElements(); ) { 39 | InetAddress addr = (InetAddress) en2.nextElement(); 40 | if (addr.isLoopbackAddress()) continue; 41 | 42 | if (addr instanceof Inet4Address) { 43 | return addr; 44 | } 45 | } 46 | } 47 | return null; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/pom.xml: -------------------------------------------------------------------------------- 1 | 5 | 4.0.0 6 | 7 | com.neo 8 | spring-boot-fastDFS 9 | jar 10 | 1.0 11 | 12 | 13 | org.springframework.boot 14 | spring-boot-starter-parent 15 | 1.5.9.RELEASE 16 | 17 | 18 | 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-thymeleaf 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-devtools 34 | true 35 | 36 | 37 | org.csource 38 | fastdfs-client-java 39 | 1.27-SNAPSHOT 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/pojo/FriendsRequest.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.pojo; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Table; 5 | import java.util.Date; 6 | 7 | @Table(name = "friends_request") 8 | public class FriendsRequest { 9 | private String id; 10 | 11 | @Column(name = "send_user_id") 12 | private String sendUserId; 13 | 14 | @Column(name = "accept_user_id") 15 | private String acceptUserId; 16 | 17 | /** 18 | * 发送请求的事件 19 | */ 20 | @Column(name = "request_date_time") 21 | private Date requestDateTime; 22 | 23 | /** 24 | * @return id 25 | */ 26 | public String getId() { 27 | return id; 28 | } 29 | 30 | /** 31 | * @param id 32 | */ 33 | public void setId(String id) { 34 | this.id = id; 35 | } 36 | 37 | /** 38 | * @return send_user_id 39 | */ 40 | public String getSendUserId() { 41 | return sendUserId; 42 | } 43 | 44 | /** 45 | * @param sendUserId 46 | */ 47 | public void setSendUserId(String sendUserId) { 48 | this.sendUserId = sendUserId; 49 | } 50 | 51 | /** 52 | * @return accept_user_id 53 | */ 54 | public String getAcceptUserId() { 55 | return acceptUserId; 56 | } 57 | 58 | /** 59 | * @param acceptUserId 60 | */ 61 | public void setAcceptUserId(String acceptUserId) { 62 | this.acceptUserId = acceptUserId; 63 | } 64 | 65 | /** 66 | * 获取发送请求的事件 67 | * 68 | * @return request_date_time - 发送请求的事件 69 | */ 70 | public Date getRequestDateTime() { 71 | return requestDateTime; 72 | } 73 | 74 | /** 75 | * 设置发送请求的事件 76 | * 77 | * @param requestDateTime 发送请求的事件 78 | */ 79 | public void setRequestDateTime(Date requestDateTime) { 80 | this.requestDateTime = requestDateTime; 81 | } 82 | } -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/Sid.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | import org.n3r.idworker.strategy.DefaultWorkerIdStrategy; 4 | import org.n3r.idworker.utils.Utils; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | 10 | @Component 11 | public class Sid { 12 | private static WorkerIdStrategy workerIdStrategy; 13 | private static IdWorker idWorker; 14 | 15 | static { 16 | configure(DefaultWorkerIdStrategy.instance); 17 | } 18 | 19 | 20 | public static synchronized void configure(WorkerIdStrategy custom) { 21 | if (workerIdStrategy != null) workerIdStrategy.release(); 22 | workerIdStrategy = custom; 23 | idWorker = new IdWorker(workerIdStrategy.availableWorkerId()) { 24 | @Override 25 | public long getEpoch() { 26 | return Utils.midnightMillis(); 27 | } 28 | }; 29 | } 30 | 31 | /** 32 | * 一天最大毫秒86400000,最大占用27比特 33 | * 27+10+11=48位 最大值281474976710655(15字),YK0XXHZ827(10字) 34 | * 6位(YYMMDD)+15位,共21位 35 | * 36 | * @return 固定21位数字字符串 37 | */ 38 | 39 | public static String next() { 40 | long id = idWorker.nextId(); 41 | String yyMMdd = new SimpleDateFormat("yyMMdd").format(new Date()); 42 | return yyMMdd + String.format("%014d", id); 43 | } 44 | 45 | 46 | /** 47 | * 返回固定16位的字母数字混编的字符串。 48 | */ 49 | public String nextShort() { 50 | long id = idWorker.nextId(); 51 | String yyMMdd = new SimpleDateFormat("yyMMdd").format(new Date()); 52 | return yyMMdd + Utils.padLeft(Utils.encode(id), 10, '0'); 53 | } 54 | 55 | // public static void main(String[] args) { 56 | // String aa = new Sid().nextShort(); 57 | // String bb = new Sid().next(); 58 | // 59 | // System.out.println(aa); 60 | // System.out.println(bb); 61 | // } 62 | } 63 | -------------------------------------------------------------------------------- /springboot_mybatis/src/main/java/com/mexbo/pojo/FriendsRequest.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.pojo; 2 | 3 | import java.util.Date; 4 | import javax.persistence.*; 5 | 6 | @Table(name = "friends_request") 7 | public class FriendsRequest { 8 | @Id 9 | private String id; 10 | 11 | @Column(name = "send_user_id") 12 | private String sendUserId; 13 | 14 | @Column(name = "accept_user_id") 15 | private String acceptUserId; 16 | 17 | /** 18 | * 发送请求的事件 19 | */ 20 | @Column(name = "request_date_time") 21 | private Date requestDateTime; 22 | 23 | /** 24 | * @return id 25 | */ 26 | public String getId() { 27 | return id; 28 | } 29 | 30 | /** 31 | * @param id 32 | */ 33 | public void setId(String id) { 34 | this.id = id; 35 | } 36 | 37 | /** 38 | * @return send_user_id 39 | */ 40 | public String getSendUserId() { 41 | return sendUserId; 42 | } 43 | 44 | /** 45 | * @param sendUserId 46 | */ 47 | public void setSendUserId(String sendUserId) { 48 | this.sendUserId = sendUserId; 49 | } 50 | 51 | /** 52 | * @return accept_user_id 53 | */ 54 | public String getAcceptUserId() { 55 | return acceptUserId; 56 | } 57 | 58 | /** 59 | * @param acceptUserId 60 | */ 61 | public void setAcceptUserId(String acceptUserId) { 62 | this.acceptUserId = acceptUserId; 63 | } 64 | 65 | /** 66 | * 获取发送请求的事件 67 | * 68 | * @return request_date_time - 发送请求的事件 69 | */ 70 | public Date getRequestDateTime() { 71 | return requestDateTime; 72 | } 73 | 74 | /** 75 | * 设置发送请求的事件 76 | * 77 | * @param requestDateTime 发送请求的事件 78 | */ 79 | public void setRequestDateTime(Date requestDateTime) { 80 | this.requestDateTime = requestDateTime; 81 | } 82 | } -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.utils; 2 | 3 | import java.util.List; 4 | 5 | import com.fasterxml.jackson.core.JsonProcessingException; 6 | import com.fasterxml.jackson.databind.JavaType; 7 | import com.fasterxml.jackson.databind.ObjectMapper; 8 | 9 | /** 10 | * @Description: 自定义响应结构, 转换类 11 | */ 12 | public class JsonUtils { 13 | 14 | // 定义jackson对象 15 | private static final ObjectMapper MAPPER = new ObjectMapper(); 16 | 17 | /** 18 | * 将对象转换成json字符串。 19 | *

Title: pojoToJson

20 | *

Description:

21 | * @param data 22 | * @return 23 | */ 24 | public static String objectToJson(Object data) { 25 | try { 26 | String string = MAPPER.writeValueAsString(data); 27 | return string; 28 | } catch (JsonProcessingException e) { 29 | e.printStackTrace(); 30 | } 31 | return null; 32 | } 33 | 34 | /** 35 | * 将json结果集转化为对象 36 | * 37 | * @param jsonData json数据 38 | * @param clazz 对象中的object类型 39 | * @return 40 | */ 41 | public static T jsonToPojo(String jsonData, Class beanType) { 42 | try { 43 | T t = MAPPER.readValue(jsonData, beanType); 44 | return t; 45 | } catch (Exception e) { 46 | e.printStackTrace(); 47 | } 48 | return null; 49 | } 50 | 51 | /** 52 | * 将json数据转换成pojo对象list 53 | *

Title: jsonToList

54 | *

Description:

55 | * @param jsonData 56 | * @param beanType 57 | * @return 58 | */ 59 | public static List jsonToList(String jsonData, Class beanType) { 60 | JavaType javaType = MAPPER.getTypeFactory().constructParametricType(List.class, beanType); 61 | try { 62 | List list = MAPPER.readValue(jsonData, javaType); 63 | return list; 64 | } catch (Exception e) { 65 | e.printStackTrace(); 66 | } 67 | 68 | return null; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /Backend/src/test/java/com/mexbo/service/impl/UserServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.service.impl; 2 | 3 | import com.mexbo.pojo.Users; 4 | import com.mexbo.service.UserService; 5 | import com.mexbo.utils.MD5Utils; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | 12 | @RunWith(SpringRunner.class) 13 | @SpringBootTest 14 | public class UserServiceImplTest { 15 | 16 | @Autowired 17 | private UserService userService; 18 | @Test 19 | public void queryUsernameIsExist() { 20 | boolean usernameIsExist = userService.queryUsernameIsExist("33"); 21 | if (usernameIsExist) { 22 | System.err.println("Found"); 23 | }else{ 24 | System.err.println("Not Found"); 25 | } 26 | } 27 | 28 | @Test 29 | public void queryUserForLogin() throws Exception { 30 | boolean usernameIsExist = userService.queryUsernameIsExist("33"); 31 | Users userResult = null; 32 | if (usernameIsExist) { 33 | // 1.1 登录 34 | userResult = userService.queryUserForLogin("33", MD5Utils.getMD5Str("33")); 35 | if (userResult == null) { 36 | System.err.println("用户名或密码不正确..."); 37 | }else{ 38 | System.err.println("用户名密码正确"); 39 | } 40 | }else{ 41 | System.err.println("用户不存在"); 42 | } 43 | } 44 | 45 | @Test 46 | public void saveUser() throws Exception { 47 | Users user=new Users(); 48 | user.setUsername("33"); 49 | user.setPassword(MD5Utils.getMD5Str("33")); 50 | user.setNickname(user.getUsername()); 51 | user.setFaceImage(""); 52 | user.setFaceImageBig(""); 53 | userService.saveUser(user); 54 | } 55 | 56 | @Test 57 | public void updateUserInfo() { 58 | } 59 | 60 | @Test 61 | public void queryUserById() { 62 | } 63 | } -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/netty/ChatHandler.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.netty; 2 | 3 | import java.time.LocalDateTime; 4 | 5 | import io.netty.channel.ChannelHandlerContext; 6 | import io.netty.channel.SimpleChannelInboundHandler; 7 | import io.netty.channel.group.ChannelGroup; 8 | import io.netty.channel.group.DefaultChannelGroup; 9 | import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; 10 | import io.netty.util.concurrent.GlobalEventExecutor; 11 | 12 | /** 13 | * 14 | * @Description: 处理消息的handler 15 | * TextWebSocketFrame: 在netty中,是用于为websocket专门处理文本的对象,frame是消息的载体 16 | */ 17 | public class ChatHandler extends SimpleChannelInboundHandler { 18 | 19 | // 用于记录和管理所有客户端的channle 20 | private static ChannelGroup clients = 21 | new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); 22 | 23 | @Override 24 | protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame msg) 25 | throws Exception { 26 | // 获取客户端传输过来的消息 27 | String content = msg.text(); 28 | System.out.println("接受到的数据:" + content); 29 | 30 | // for (Channel channel: clients) { 31 | // channel.writeAndFlush( 32 | // new TextWebSocketFrame( 33 | // "[服务器在]" + LocalDateTime.now() 34 | // + "接受到消息, 消息为:" + content)); 35 | // } 36 | // 下面这个方法,和上面的for循环,一致 37 | clients.writeAndFlush( 38 | new TextWebSocketFrame( 39 | "[服务器在]" + LocalDateTime.now() 40 | + "接受到消息, 消息为:" + content)); 41 | 42 | } 43 | 44 | /** 45 | * 当客户端连接服务端之后(打开连接) 46 | * 获取客户端的channle,并且放到ChannelGroup中去进行管理 47 | */ 48 | @Override 49 | public void handlerAdded(ChannelHandlerContext ctx) throws Exception { 50 | clients.add(ctx.channel()); 51 | } 52 | 53 | @Override 54 | public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { 55 | // 当触发handlerRemoved,ChannelGroup会自动移除对应客户端的channel 56 | // clients.remove(ctx.channel()); 57 | System.out.println("客户端断开,channle对应的长id为:" 58 | + ctx.channel().id().asLongText()); 59 | System.out.println("客户端断开,channle对应的短id为:" 60 | + ctx.channel().id().asShortText()); 61 | } 62 | 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.service.impl; 2 | 3 | 4 | import org.n3r.idworker.Sid; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.transaction.annotation.Propagation; 8 | import org.springframework.transaction.annotation.Transactional; 9 | import com.mexbo.mapper.*; 10 | import com.mexbo.service.*; 11 | import com.mexbo.pojo.*; 12 | import tk.mybatis.mapper.entity.Example; 13 | import tk.mybatis.mapper.entity.Example.Criteria; 14 | 15 | @Service 16 | public class UserServiceImpl implements UserService { 17 | 18 | @Autowired 19 | private UsersMapper userMapper; 20 | 21 | @Autowired 22 | private Sid sid; 23 | 24 | @Transactional(propagation = Propagation.SUPPORTS) 25 | @Override 26 | public boolean queryUsernameIsExist(String username) { 27 | 28 | Users user = new Users(); 29 | user.setUsername(username); 30 | 31 | Users result = userMapper.selectOne(user); 32 | 33 | return result != null ? true : false; 34 | } 35 | 36 | @Transactional(propagation = Propagation.SUPPORTS) 37 | @Override 38 | public Users queryUserForLogin(String username, String pwd) { 39 | 40 | Example userExample = new Example(Users.class); 41 | Criteria criteria = userExample.createCriteria(); 42 | 43 | criteria.andEqualTo("username", username); 44 | criteria.andEqualTo("password", pwd); 45 | 46 | Users result = userMapper.selectOneByExample(userExample); 47 | 48 | return result; 49 | } 50 | 51 | @Transactional(propagation = Propagation.REQUIRED) 52 | @Override 53 | public Users saveUser(Users user) { 54 | String userId = sid.nextShort(); 55 | user.setQrcode(""); 56 | user.setId(userId); 57 | userMapper.insert(user); 58 | return user; 59 | } 60 | 61 | @Transactional(propagation = Propagation.REQUIRED) 62 | @Override 63 | public Users updateUserInfo(Users user) { 64 | userMapper.updateByPrimaryKeySelective(user); 65 | return queryUserById(user.getId()); 66 | } 67 | 68 | @Transactional(propagation = Propagation.SUPPORTS) 69 | protected Users queryUserById(String userId) { 70 | return userMapper.selectByPrimaryKey(userId); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/utils/IPv4Utils.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | /** 4 | * This utility provides methods to either convert an IPv4 address to its long format or a 32bit dotted format. 5 | * 6 | * @author Aion 7 | * Created on 22/11/12 8 | */ 9 | public class IPv4Utils { 10 | 11 | /** 12 | * Returns the long format of the provided IP address. 13 | * 14 | * @param ipAddress the IP address 15 | * @return the long format of ipAddress 16 | * @throws IllegalArgumentException if ipAddress is invalid 17 | */ 18 | public static long toLong(String ipAddress) { 19 | if (ipAddress == null || ipAddress.isEmpty()) { 20 | throw new IllegalArgumentException("ip address cannot be null or empty"); 21 | } 22 | String[] octets = ipAddress.split(java.util.regex.Pattern.quote(".")); 23 | if (octets.length != 4) { 24 | throw new IllegalArgumentException("invalid ip address"); 25 | } 26 | long ip = 0; 27 | for (int i = 3; i >= 0; i--) { 28 | long octet = Long.parseLong(octets[3 - i]); 29 | if (octet > 255 || octet < 0) { 30 | throw new IllegalArgumentException("invalid ip address"); 31 | } 32 | ip |= octet << (i * 8); 33 | } 34 | return ip; 35 | } 36 | 37 | /** 38 | * Returns the 32bit dotted format of the provided long ip. 39 | * 40 | * @param ip the long ip 41 | * @return the 32bit dotted format of ip 42 | * @throws IllegalArgumentException if ip is invalid 43 | */ 44 | public static String toString(long ip) { 45 | // if ip is bigger than 255.255.255.255 or smaller than 0.0.0.0 46 | if (ip > 4294967295l || ip < 0) { 47 | throw new IllegalArgumentException("invalid ip"); 48 | } 49 | StringBuilder ipAddress = new StringBuilder(); 50 | for (int i = 3; i >= 0; i--) { 51 | int shift = i * 8; 52 | ipAddress.append((ip & (0xff << shift)) >> shift); 53 | if (i > 0) { 54 | ipAddress.append("."); 55 | } 56 | } 57 | return ipAddress.toString(); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /Fronkend/plugin/v3.1.6/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Cropper 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 |
24 |
25 | 26 |
27 | Picture 28 |
29 |
30 |
31 |
32 |
33 | 34 |
35 |
36 |
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/utils/Props.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.*; 7 | import java.util.Properties; 8 | 9 | import static java.io.File.separator; 10 | import static org.n3r.idworker.utils.Serializes.closeQuietly; 11 | 12 | public class Props { 13 | static Logger log = LoggerFactory.getLogger(Props.class); 14 | 15 | public static Properties tryProperties(String propertiesFileName, String userHomeBasePath) { 16 | Properties properties = new Properties(); 17 | InputStream is = null; 18 | try { 19 | is = Props.tryResource(propertiesFileName, userHomeBasePath, Silent.ON); 20 | if (is != null) properties.load(is); 21 | } catch (IOException e) { 22 | log.error("load properties error: {}", e.getMessage()); 23 | } finally { 24 | closeQuietly(is); 25 | } 26 | 27 | return properties; 28 | } 29 | 30 | 31 | enum Silent {ON, OFF} 32 | 33 | public static InputStream tryResource(String propertiesFileName, String userHomeBasePath, Silent silent) { 34 | InputStream is = currentDirResource(new File(propertiesFileName)); 35 | if (is != null) return is; 36 | 37 | is = userHomeResource(propertiesFileName, userHomeBasePath); 38 | if (is != null) return is; 39 | 40 | is = classpathResource(propertiesFileName); 41 | if (is != null || silent == Silent.ON) return is; 42 | 43 | throw new RuntimeException("fail to find " + propertiesFileName + " in current dir or classpath"); 44 | } 45 | 46 | private static InputStream userHomeResource(String pathname, String appHome) { 47 | String filePath = System.getProperty("user.home") + separator + appHome; 48 | File dir = new File(filePath); 49 | if (!dir.exists()) return null; 50 | 51 | return currentDirResource(new File(dir, pathname)); 52 | } 53 | 54 | private static InputStream currentDirResource(File file) { 55 | if (!file.exists()) return null; 56 | 57 | try { 58 | return new FileInputStream(file); 59 | } catch (FileNotFoundException e) { 60 | // This should not happened 61 | log.error("read file {} error", file, e); 62 | return null; 63 | } 64 | } 65 | 66 | public static InputStream classpathResource(String resourceName) { 67 | return Props.class.getClassLoader().getResourceAsStream(resourceName); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/pojo/ChatMsg.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.pojo; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Table; 5 | import java.util.Date; 6 | 7 | @Table(name = "chat_msg") 8 | public class ChatMsg { 9 | private String id; 10 | 11 | @Column(name = "send_user_id") 12 | private String sendUserId; 13 | 14 | @Column(name = "accept_user_id") 15 | private String acceptUserId; 16 | 17 | private String msg; 18 | 19 | /** 20 | * 消息是否签收状态 21 | 1:签收 22 | 0:未签收 23 | 24 | */ 25 | @Column(name = "sign_flag") 26 | private Integer signFlag; 27 | 28 | /** 29 | * 发送请求的事件 30 | */ 31 | @Column(name = "create_time") 32 | private Date createTime; 33 | 34 | /** 35 | * @return id 36 | */ 37 | public String getId() { 38 | return id; 39 | } 40 | 41 | /** 42 | * @param id 43 | */ 44 | public void setId(String id) { 45 | this.id = id; 46 | } 47 | 48 | /** 49 | * @return send_user_id 50 | */ 51 | public String getSendUserId() { 52 | return sendUserId; 53 | } 54 | 55 | /** 56 | * @param sendUserId 57 | */ 58 | public void setSendUserId(String sendUserId) { 59 | this.sendUserId = sendUserId; 60 | } 61 | 62 | /** 63 | * @return accept_user_id 64 | */ 65 | public String getAcceptUserId() { 66 | return acceptUserId; 67 | } 68 | 69 | /** 70 | * @param acceptUserId 71 | */ 72 | public void setAcceptUserId(String acceptUserId) { 73 | this.acceptUserId = acceptUserId; 74 | } 75 | 76 | /** 77 | * @return msg 78 | */ 79 | public String getMsg() { 80 | return msg; 81 | } 82 | 83 | /** 84 | * @param msg 85 | */ 86 | public void setMsg(String msg) { 87 | this.msg = msg; 88 | } 89 | 90 | /** 91 | * 获取消息是否签收状态 92 | 1:签收 93 | 0:未签收 94 | 95 | * 96 | * @return sign_flag - 消息是否签收状态 97 | 1:签收 98 | 0:未签收 99 | 100 | */ 101 | public Integer getSignFlag() { 102 | return signFlag; 103 | } 104 | /** 105 | * 设置消息是否签收状态 106 | 1:签收 107 | 0:未签收 108 | 109 | * 110 | * @param signFlag 消息是否签收状态 111 | 1:签收 112 | 0:未签收 113 | 114 | */ 115 | public void setSignFlag(Integer signFlag) { 116 | this.signFlag = signFlag; 117 | } 118 | 119 | /** 120 | * 获取发送请求的事件 121 | * 122 | * @return create_time - 发送请求的事件 123 | */ 124 | public Date getCreateTime() { 125 | return createTime; 126 | } 127 | 128 | /** 129 | * 设置发送请求的事件 130 | * 131 | * @param createTime 发送请求的事件 132 | */ 133 | public void setCreateTime(Date createTime) { 134 | this.createTime = createTime; 135 | } 136 | } -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/utils/IMoocJSONResult.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.utils; 2 | 3 | /** 4 | * @Description: 自定义响应数据结构 5 | * 这个类是提供给门户,ios,安卓,微信商城用的 6 | * 门户接受此类数据后需要使用本类的方法转换成对于的数据类型格式(类,或者list) 7 | * 其他自行处理 8 | * 200:表示成功 9 | * 500:表示错误,错误信息在msg字段中 10 | * 501:bean验证错误,不管多少个错误都以map形式返回 11 | * 502:拦截器拦截到用户token出错 12 | * 555:异常抛出信息 13 | */ 14 | public class IMoocJSONResult { 15 | 16 | // 响应业务状态 17 | private Integer status; 18 | 19 | // 响应消息 20 | private String msg; 21 | 22 | // 响应中的数据 23 | private Object data; 24 | 25 | private String ok; // 不使用 26 | 27 | public static IMoocJSONResult build(Integer status, String msg, Object data) { 28 | return new IMoocJSONResult(status, msg, data); 29 | } 30 | 31 | public static IMoocJSONResult ok(Object data) { 32 | return new IMoocJSONResult(data); 33 | } 34 | 35 | public static IMoocJSONResult ok() { 36 | return new IMoocJSONResult(null); 37 | } 38 | 39 | public static IMoocJSONResult errorMsg(String msg) { 40 | return new IMoocJSONResult(500, msg, null); 41 | } 42 | 43 | public static IMoocJSONResult errorMap(Object data) { 44 | return new IMoocJSONResult(501, "error", data); 45 | } 46 | 47 | public static IMoocJSONResult errorTokenMsg(String msg) { 48 | return new IMoocJSONResult(502, msg, null); 49 | } 50 | 51 | public static IMoocJSONResult errorException(String msg) { 52 | return new IMoocJSONResult(555, msg, null); 53 | } 54 | 55 | public IMoocJSONResult() { 56 | 57 | } 58 | 59 | // public static LeeJSONResult build(Integer status, String msg) { 60 | // return new LeeJSONResult(status, msg, null); 61 | // } 62 | 63 | public IMoocJSONResult(Integer status, String msg, Object data) { 64 | this.status = status; 65 | this.msg = msg; 66 | this.data = data; 67 | } 68 | 69 | public IMoocJSONResult(Object data) { 70 | this.status = 200; 71 | this.msg = "OK"; 72 | this.data = data; 73 | } 74 | 75 | public Boolean isOK() { 76 | return this.status == 200; 77 | } 78 | 79 | public Integer getStatus() { 80 | return status; 81 | } 82 | 83 | public void setStatus(Integer status) { 84 | this.status = status; 85 | } 86 | 87 | public String getMsg() { 88 | return msg; 89 | } 90 | 91 | public void setMsg(String msg) { 92 | this.msg = msg; 93 | } 94 | 95 | public Object getData() { 96 | return data; 97 | } 98 | 99 | public void setData(Object data) { 100 | this.data = data; 101 | } 102 | 103 | public String getOk() { 104 | return ok; 105 | } 106 | 107 | public void setOk(String ok) { 108 | this.ok = ok; 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /muxin-dev.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MariaDB Data Transfer 3 | 4 | Source Server : . 5 | Source Server Version : 100122 6 | Source Host : localhost:3306 7 | Source Database : muxin-dev 8 | 9 | Target Server Type : MariaDB 10 | Target Server Version : 100122 11 | File Encoding : 65001 12 | 13 | Date: 2018-07-07 15:39:42 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | 18 | -- ---------------------------- 19 | -- Table structure for chat_msg 20 | -- ---------------------------- 21 | DROP TABLE IF EXISTS `chat_msg`; 22 | CREATE TABLE `chat_msg` ( 23 | `id` varchar(64) NOT NULL, 24 | `send_user_id` varchar(64) NOT NULL, 25 | `accept_user_id` varchar(64) NOT NULL, 26 | `msg` varchar(255) NOT NULL, 27 | `sign_flag` int(1) NOT NULL COMMENT '消息是否签收状态\r\n1:签收\r\n0:未签收\r\n', 28 | `create_time` datetime NOT NULL COMMENT '发送请求的事件', 29 | PRIMARY KEY (`id`) 30 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 31 | 32 | -- ---------------------------- 33 | -- Records of chat_msg 34 | -- ---------------------------- 35 | 36 | -- ---------------------------- 37 | -- Table structure for friends_request 38 | -- ---------------------------- 39 | DROP TABLE IF EXISTS `friends_request`; 40 | CREATE TABLE `friends_request` ( 41 | `id` varchar(64) NOT NULL, 42 | `send_user_id` varchar(64) NOT NULL, 43 | `accept_user_id` varchar(64) NOT NULL, 44 | `request_date_time` datetime NOT NULL COMMENT '发送请求的事件', 45 | PRIMARY KEY (`id`) 46 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 47 | 48 | -- ---------------------------- 49 | -- Records of friends_request 50 | -- ---------------------------- 51 | 52 | -- ---------------------------- 53 | -- Table structure for my_friends 54 | -- ---------------------------- 55 | DROP TABLE IF EXISTS `my_friends`; 56 | CREATE TABLE `my_friends` ( 57 | `id` varchar(64) NOT NULL, 58 | `my_user_id` varchar(64) NOT NULL COMMENT '用户id', 59 | `my_friend_user_id` varchar(64) NOT NULL COMMENT '用户的好友id', 60 | PRIMARY KEY (`id`), 61 | UNIQUE KEY `my_user_id` (`my_user_id`,`my_friend_user_id`) 62 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 63 | 64 | -- ---------------------------- 65 | -- Records of my_friends 66 | -- ---------------------------- 67 | 68 | -- ---------------------------- 69 | -- Table structure for users 70 | -- ---------------------------- 71 | DROP TABLE IF EXISTS `users`; 72 | CREATE TABLE `users` ( 73 | `id` varchar(64) NOT NULL, 74 | `username` varchar(20) NOT NULL COMMENT '用户名,账号,慕信号', 75 | `password` varchar(64) NOT NULL COMMENT '密码', 76 | `face_image` varchar(255) NOT NULL COMMENT '我的头像,如果没有默认给一张', 77 | `face_image_big` varchar(255) NOT NULL, 78 | `nickname` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '昵称', 79 | `qrcode` varchar(255) NOT NULL COMMENT '新用户注册后默认后台生成二维码,并且上传到fastdfs', 80 | `cid` varchar(64) DEFAULT NULL, 81 | PRIMARY KEY (`id`), 82 | UNIQUE KEY `id` (`id`), 83 | UNIQUE KEY `username` (`username`) 84 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 85 | 86 | -- ---------------------------- 87 | -- Records of users 88 | -- ---------------------------- 89 | -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/IdWorker.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | import java.security.SecureRandom; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | public class IdWorker { 9 | protected long epoch = 1288834974657L; 10 | // protected long epoch = 1387886498127L; // 2013-12-24 20:01:38.127 11 | 12 | 13 | protected long workerIdBits = 10L; 14 | protected long maxWorkerId = -1L ^ (-1L << workerIdBits); 15 | protected long sequenceBits = 11L; 16 | 17 | protected long workerIdShift = sequenceBits; 18 | protected long timestampLeftShift = sequenceBits + workerIdBits; 19 | protected long sequenceMask = -1L ^ (-1L << sequenceBits); 20 | 21 | protected long lastMillis = -1L; 22 | 23 | protected final long workerId; 24 | protected long sequence = 0L; 25 | protected Logger logger = LoggerFactory.getLogger(IdWorker.class); 26 | 27 | public IdWorker(long workerId) { 28 | this.workerId = checkWorkerId(workerId); 29 | 30 | logger.debug("worker starting. timestamp left shift {}, worker id {}", timestampLeftShift, workerId); 31 | } 32 | 33 | public long getEpoch() { 34 | return epoch; 35 | } 36 | 37 | private long checkWorkerId(long workerId) { 38 | // sanity check for workerId 39 | if (workerId > maxWorkerId || workerId < 0) { 40 | int rand = new SecureRandom().nextInt((int) maxWorkerId + 1); 41 | logger.warn("worker Id can't be greater than {} or less than 0, use a random {}", maxWorkerId, rand); 42 | return rand; 43 | } 44 | 45 | return workerId; 46 | } 47 | 48 | public synchronized long nextId() { 49 | long timestamp = millisGen(); 50 | 51 | if (timestamp < lastMillis) { 52 | logger.error("clock is moving backwards. Rejecting requests until {}.", lastMillis); 53 | throw new InvalidSystemClock(String.format( 54 | "Clock moved backwards. Refusing to generate id for {} milliseconds", lastMillis - timestamp)); 55 | } 56 | 57 | if (lastMillis == timestamp) { 58 | sequence = (sequence + 1) & sequenceMask; 59 | if (sequence == 0) 60 | timestamp = tilNextMillis(lastMillis); 61 | } else { 62 | sequence = 0; 63 | } 64 | 65 | lastMillis = timestamp; 66 | long diff = timestamp - getEpoch(); 67 | return (diff << timestampLeftShift) | 68 | (workerId << workerIdShift) | 69 | sequence; 70 | } 71 | 72 | protected long tilNextMillis(long lastMillis) { 73 | long millis = millisGen(); 74 | while (millis <= lastMillis) 75 | millis = millisGen(); 76 | 77 | return millis; 78 | } 79 | 80 | protected long millisGen() { 81 | return System.currentTimeMillis(); 82 | } 83 | 84 | public long getLastMillis() { 85 | return lastMillis; 86 | } 87 | 88 | public long getWorkerId() { 89 | return workerId; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /springboot_mybatis/src/main/java/com/mexbo/pojo/ChatMsg.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.pojo; 2 | 3 | import java.util.Date; 4 | import javax.persistence.*; 5 | 6 | @Table(name = "chat_msg") 7 | public class ChatMsg { 8 | @Id 9 | private String id; 10 | 11 | @Column(name = "send_user_id") 12 | private String sendUserId; 13 | 14 | @Column(name = "accept_user_id") 15 | private String acceptUserId; 16 | 17 | private String msg; 18 | 19 | /** 20 | * 消息是否签收状态 21 | 1:签收 22 | 0:未签收 23 | 24 | */ 25 | @Column(name = "sign_flag") 26 | private Integer signFlag; 27 | 28 | /** 29 | * 发送请求的事件 30 | */ 31 | @Column(name = "create_time") 32 | private Date createTime; 33 | 34 | /** 35 | * @return id 36 | */ 37 | public String getId() { 38 | return id; 39 | } 40 | 41 | /** 42 | * @param id 43 | */ 44 | public void setId(String id) { 45 | this.id = id; 46 | } 47 | 48 | /** 49 | * @return send_user_id 50 | */ 51 | public String getSendUserId() { 52 | return sendUserId; 53 | } 54 | 55 | /** 56 | * @param sendUserId 57 | */ 58 | public void setSendUserId(String sendUserId) { 59 | this.sendUserId = sendUserId; 60 | } 61 | 62 | /** 63 | * @return accept_user_id 64 | */ 65 | public String getAcceptUserId() { 66 | return acceptUserId; 67 | } 68 | 69 | /** 70 | * @param acceptUserId 71 | */ 72 | public void setAcceptUserId(String acceptUserId) { 73 | this.acceptUserId = acceptUserId; 74 | } 75 | 76 | /** 77 | * @return msg 78 | */ 79 | public String getMsg() { 80 | return msg; 81 | } 82 | 83 | /** 84 | * @param msg 85 | */ 86 | public void setMsg(String msg) { 87 | this.msg = msg; 88 | } 89 | 90 | /** 91 | * 获取消息是否签收状态 92 | 1:签收 93 | 0:未签收 94 | 95 | * 96 | * @return sign_flag - 消息是否签收状态 97 | 1:签收 98 | 0:未签收 99 | 100 | */ 101 | public Integer getSignFlag() { 102 | return signFlag; 103 | } 104 | 105 | /** 106 | * 设置消息是否签收状态 107 | 1:签收 108 | 0:未签收 109 | 110 | * 111 | * @param signFlag 消息是否签收状态 112 | 1:签收 113 | 0:未签收 114 | 115 | */ 116 | public void setSignFlag(Integer signFlag) { 117 | this.signFlag = signFlag; 118 | } 119 | 120 | /** 121 | * 获取发送请求的事件 122 | * 123 | * @return create_time - 发送请求的事件 124 | */ 125 | public Date getCreateTime() { 126 | return createTime; 127 | } 128 | 129 | /** 130 | * 设置发送请求的事件 131 | * 132 | * @param createTime 发送请求的事件 133 | */ 134 | public void setCreateTime(Date createTime) { 135 | this.createTime = createTime; 136 | } 137 | } -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/java/com/neo/controller/UploadController.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import com.neo.fastdfs.FastDFSClient; 4 | import com.neo.fastdfs.FastDFSFile; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.multipart.MultipartFile; 12 | import org.springframework.web.servlet.mvc.support.RedirectAttributes; 13 | 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | 17 | @Controller 18 | public class UploadController { 19 | private static Logger logger = LoggerFactory.getLogger(UploadController.class); 20 | 21 | @GetMapping("/") 22 | public String index() { 23 | return "upload"; 24 | } 25 | 26 | @PostMapping("/upload") //new annotation since 4.3 27 | public String singleFileUpload(@RequestParam("file") MultipartFile file, 28 | RedirectAttributes redirectAttributes) { 29 | if (file.isEmpty()) { 30 | redirectAttributes.addFlashAttribute("message", "Please select a file to upload"); 31 | return "redirect:uploadStatus"; 32 | } 33 | try { 34 | // Get the file and save it somewhere 35 | String path=saveFile(file); 36 | redirectAttributes.addFlashAttribute("message", 37 | "You successfully uploaded '" + file.getOriginalFilename() + "'"); 38 | redirectAttributes.addFlashAttribute("path", 39 | "file path url '" + path + "'"); 40 | } catch (Exception e) { 41 | logger.error("upload file failed",e); 42 | } 43 | return "redirect:/uploadStatus"; 44 | } 45 | 46 | @GetMapping("/uploadStatus") 47 | public String uploadStatus() { 48 | return "uploadStatus"; 49 | } 50 | 51 | /** 52 | * @param multipartFile 53 | * @return 54 | * @throws IOException 55 | */ 56 | public String saveFile(MultipartFile multipartFile) throws IOException { 57 | String[] fileAbsolutePath={}; 58 | String fileName=multipartFile.getOriginalFilename(); 59 | String ext = fileName.substring(fileName.lastIndexOf(".") + 1); 60 | byte[] file_buff = null; 61 | InputStream inputStream=multipartFile.getInputStream(); 62 | if(inputStream!=null){ 63 | int len1 = inputStream.available(); 64 | file_buff = new byte[len1]; 65 | inputStream.read(file_buff); 66 | } 67 | inputStream.close(); 68 | FastDFSFile file = new FastDFSFile(fileName, file_buff, ext); 69 | try { 70 | fileAbsolutePath = FastDFSClient.upload(file); //upload to fastdfs 71 | } catch (Exception e) { 72 | logger.error("upload file Exception!",e); 73 | } 74 | if (fileAbsolutePath==null) { 75 | logger.error("upload file failed,please upload again!"); 76 | } 77 | String path=FastDFSClient.getTrackerUrl()+fileAbsolutePath[0]+ "/"+fileAbsolutePath[1]; 78 | return path; 79 | } 80 | } -------------------------------------------------------------------------------- /Fronkend/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 18 | 19 | 20 |
21 |

慕信

22 |
23 | 24 | 42 | 43 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.controller; 2 | 3 | import com.mexbo.pojo.Users; 4 | import com.mexbo.pojo.bo.UsersBO; 5 | import com.mexbo.pojo.vo.UsersVO; 6 | import com.mexbo.service.UserService; 7 | import com.mexbo.utils.FastDFSClient; 8 | import com.mexbo.utils.FileUtils; 9 | import com.mexbo.utils.IMoocJSONResult; 10 | import com.mexbo.utils.MD5Utils; 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.springframework.beans.BeanUtils; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.web.bind.annotation.*; 15 | import org.springframework.web.multipart.MultipartFile; 16 | 17 | @RestController 18 | @RequestMapping("User") 19 | public class UserController { 20 | 21 | @Autowired 22 | private UserService userService; 23 | 24 | @Autowired 25 | private FastDFSClient fastDFSClient; 26 | 27 | @PostMapping("/registOrlogin") 28 | public IMoocJSONResult registOrlogin(@RequestBody Users user) throws Exception { 29 | // 0. 判断用户名和密码不能为空 30 | if (StringUtils.isBlank(user.getUsername())|| StringUtils.isBlank(user.getPassword())) { 31 | return IMoocJSONResult.errorMsg("用户名或密码不能为空..."); 32 | } 33 | 34 | // 1. 判断用户名是否存在,如果存在就登录,如果不存在则注册 35 | boolean usernameIsExist = userService.queryUsernameIsExist(user.getUsername()); 36 | Users userResult = null; 37 | if (usernameIsExist) { 38 | // 1.1 登录 39 | userResult = userService.queryUserForLogin(user.getUsername(),MD5Utils.getMD5Str(user.getPassword())); 40 | if (userResult == null) { 41 | return IMoocJSONResult.errorMsg("用户名或密码不正确..."); 42 | } 43 | } else { 44 | // 1.2 注册 45 | user.setNickname(user.getUsername()); 46 | user.setFaceImage(""); 47 | user.setFaceImageBig(""); 48 | user.setPassword(MD5Utils.getMD5Str(user.getPassword())); 49 | userResult = userService.saveUser(user); 50 | } 51 | UsersVO userVO = new UsersVO(); 52 | BeanUtils.copyProperties(userResult, userVO); 53 | 54 | return IMoocJSONResult.ok(userVO); 55 | } 56 | 57 | /** 58 | * @Description: 上传用户头像 59 | */ 60 | @PostMapping("/uploadFaceBase64") 61 | public IMoocJSONResult uploadFaceBase64(@RequestBody UsersBO userBO) throws Exception { 62 | 63 | // 获取前端传过来的base64字符串, 然后转换为文件对象再上传 64 | String base64Data = userBO.getFaceData(); 65 | String userFacePath = "D:\\" + userBO.getUserId() + "userface64.png"; 66 | FileUtils.base64ToFile(userFacePath, base64Data); 67 | 68 | // 上传文件到fastdfs 69 | MultipartFile faceFile = FileUtils.fileToMultipart(userFacePath); 70 | String url = fastDFSClient.uploadBase64(faceFile); 71 | System.out.println(url); 72 | 73 | // "dhawuidhwaiuh3u89u98432.png" 74 | // "dhawuidhwaiuh3u89u98432_80x80.png" 75 | 76 | // 获取缩略图的url 77 | String thump = "_80x80."; 78 | String arr[] = url.split("\\."); 79 | String thumpImgUrl = arr[0] + thump + arr[1]; 80 | 81 | // 更新用户头像 82 | Users user = new Users(); 83 | user.setId(userBO.getUserId()); 84 | user.setFaceImage(thumpImgUrl); 85 | user.setFaceImageBig(url); 86 | 87 | Users result = userService.updateUserInfo(user); 88 | 89 | return IMoocJSONResult.ok(result); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/utils/FastDFSClient.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.utils; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.IOException; 5 | import java.nio.charset.Charset; 6 | 7 | import org.apache.commons.io.FilenameUtils; 8 | import org.apache.commons.lang3.StringUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | import org.springframework.web.multipart.MultipartFile; 12 | 13 | import com.github.tobato.fastdfs.domain.StorePath; 14 | import com.github.tobato.fastdfs.exception.FdfsUnsupportStorePathException; 15 | import com.github.tobato.fastdfs.service.FastFileStorageClient; 16 | 17 | @Component 18 | public class FastDFSClient { 19 | 20 | @Autowired 21 | private FastFileStorageClient storageClient; 22 | 23 | // @Autowired 24 | // private AppConfig appConfig; // 项目参数配置 25 | 26 | /** 27 | * 上传文件 28 | * 29 | * @param file 30 | * 文件对象 31 | * @return 文件访问地址 32 | * @throws IOException 33 | */ 34 | public String uploadFile(MultipartFile file) throws IOException { 35 | StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(), 36 | FilenameUtils.getExtension(file.getOriginalFilename()), null); 37 | 38 | return storePath.getPath(); 39 | } 40 | 41 | public String uploadFile2(MultipartFile file) throws IOException { 42 | StorePath storePath = storageClient.uploadImageAndCrtThumbImage(file.getInputStream(), file.getSize(), 43 | FilenameUtils.getExtension(file.getOriginalFilename()), null); 44 | 45 | return storePath.getPath(); 46 | } 47 | 48 | public String uploadQRCode(MultipartFile file) throws IOException { 49 | StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(), 50 | "png", null); 51 | 52 | return storePath.getPath(); 53 | } 54 | 55 | public String uploadFace(MultipartFile file) throws IOException { 56 | StorePath storePath = storageClient.uploadImageAndCrtThumbImage(file.getInputStream(), file.getSize(), 57 | "png", null); 58 | 59 | return storePath.getPath(); 60 | } 61 | 62 | public String uploadBase64(MultipartFile file) throws IOException { 63 | StorePath storePath = storageClient.uploadImageAndCrtThumbImage(file.getInputStream(), file.getSize(), 64 | "png", null); 65 | 66 | return storePath.getPath(); 67 | } 68 | 69 | /** 70 | * 将一段字符串生成一个文件上传 71 | * 72 | * @param content 73 | * 文件内容 74 | * @param fileExtension 75 | * @return 76 | */ 77 | public String uploadFile(String content, String fileExtension) { 78 | byte[] buff = content.getBytes(Charset.forName("UTF-8")); 79 | ByteArrayInputStream stream = new ByteArrayInputStream(buff); 80 | StorePath storePath = storageClient.uploadFile(stream, buff.length, fileExtension, null); 81 | return storePath.getPath(); 82 | } 83 | 84 | // 封装图片完整URL地址 85 | // private String getResAccessUrl(StorePath storePath) { 86 | // String fileUrl = AppConstants.HTTP_PRODOCOL + appConfig.getResHost() + ":" + appConfig.getFdfsStoragePort() 87 | // + "/" + storePath.getFullPath(); 88 | // return fileUrl; 89 | // } 90 | 91 | /** 92 | * 删除文件 93 | * 94 | * @param fileUrl 95 | * 文件访问地址 96 | * @return 97 | */ 98 | public void deleteFile(String fileUrl) { 99 | if (StringUtils.isEmpty(fileUrl)) { 100 | return; 101 | } 102 | try { 103 | StorePath storePath = StorePath.praseFromUrl(fileUrl); 104 | storageClient.deleteFile(storePath.getGroup(), storePath.getPath()); 105 | } catch (FdfsUnsupportStorePathException e) { 106 | e.getMessage(); 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Backend/src/main/java/com/mexbo/pojo/Users.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.pojo; 2 | 3 | import javax.persistence.Column; 4 | 5 | public class Users { 6 | private String id; 7 | 8 | /** 9 | * 用户名,账号,慕信号 10 | */ 11 | private String username; 12 | 13 | /** 14 | * 密码 15 | */ 16 | private String password; 17 | 18 | /** 19 | * 我的头像,如果没有默认给一张 20 | */ 21 | @Column(name = "face_image") 22 | private String faceImage; 23 | 24 | @Column(name = "face_image_big") 25 | private String faceImageBig; 26 | 27 | /** 28 | * 昵称 29 | */ 30 | private String nickname; 31 | 32 | /** 33 | * 新用户注册后默认后台生成二维码,并且上传到fastdfs 34 | */ 35 | private String qrcode; 36 | 37 | private String cid; 38 | 39 | /** 40 | * @return id 41 | */ 42 | public String getId() { 43 | return id; 44 | } 45 | 46 | /** 47 | * @param id 48 | */ 49 | public void setId(String id) { 50 | this.id = id; 51 | } 52 | 53 | /** 54 | * 获取用户名,账号,慕信号 55 | * 56 | * @return username - 用户名,账号,慕信号 57 | */ 58 | public String getUsername() { 59 | return username; 60 | } 61 | 62 | /** 63 | * 设置用户名,账号,慕信号 64 | * 65 | * @param username 用户名,账号,慕信号 66 | */ 67 | public void setUsername(String username) { 68 | this.username = username; 69 | } 70 | 71 | /** 72 | * 获取密码 73 | * 74 | * @return password - 密码 75 | */ 76 | public String getPassword() { 77 | return password; 78 | } 79 | 80 | /** 81 | * 设置密码 82 | * 83 | * @param password 密码 84 | */ 85 | public void setPassword(String password) { 86 | this.password = password; 87 | } 88 | 89 | /** 90 | * 获取我的头像,如果没有默认给一张 91 | * 92 | * @return face_image - 我的头像,如果没有默认给一张 93 | */ 94 | public String getFaceImage() { 95 | return faceImage; 96 | } 97 | 98 | /** 99 | * 设置我的头像,如果没有默认给一张 100 | * 101 | * @param faceImage 我的头像,如果没有默认给一张 102 | */ 103 | public void setFaceImage(String faceImage) { 104 | this.faceImage = faceImage; 105 | } 106 | 107 | /** 108 | * @return face_image_big 109 | */ 110 | public String getFaceImageBig() { 111 | return faceImageBig; 112 | } 113 | 114 | /** 115 | * @param faceImageBig 116 | */ 117 | public void setFaceImageBig(String faceImageBig) { 118 | this.faceImageBig = faceImageBig; 119 | } 120 | 121 | /** 122 | * 获取昵称 123 | * 124 | * @return nickname - 昵称 125 | */ 126 | public String getNickname() { 127 | return nickname; 128 | } 129 | 130 | /** 131 | * 设置昵称 132 | * 133 | * @param nickname 昵称 134 | */ 135 | public void setNickname(String nickname) { 136 | this.nickname = nickname; 137 | } 138 | 139 | /** 140 | * 获取新用户注册后默认后台生成二维码,并且上传到fastdfs 141 | * 142 | * @return qrcode - 新用户注册后默认后台生成二维码,并且上传到fastdfs 143 | */ 144 | public String getQrcode() { 145 | return qrcode; 146 | } 147 | 148 | /** 149 | * 设置新用户注册后默认后台生成二维码,并且上传到fastdfs 150 | * 151 | * @param qrcode 新用户注册后默认后台生成二维码,并且上传到fastdfs 152 | */ 153 | public void setQrcode(String qrcode) { 154 | this.qrcode = qrcode; 155 | } 156 | 157 | /** 158 | * @return cid 159 | */ 160 | public String getCid() { 161 | return cid; 162 | } 163 | 164 | /** 165 | * @param cid 166 | */ 167 | public void setCid(String cid) { 168 | this.cid = cid; 169 | } 170 | } -------------------------------------------------------------------------------- /Fronkend/pages/myface.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 |

个人头像

16 |
17 |
18 | 19 |
20 |
21 | 22 | 30 | 31 | 36 |
37 | 38 | 39 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/utils/Serializes.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | import java.io.*; 4 | import java.nio.channels.FileChannel; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class Serializes { 9 | 10 | @SuppressWarnings("unchecked") 11 | public static List readObjects(File file) { 12 | ArrayList objects = new ArrayList(); 13 | ObjectInputStream objectReader = null; 14 | FileInputStream fis = null; 15 | try { 16 | fis = new FileInputStream(file); 17 | objectReader = new ObjectInputStream(fis); 18 | while (true) 19 | objects.add((T) objectReader.readObject()); 20 | 21 | } catch (EOFException e) { 22 | } catch (Exception e) { 23 | throw new RuntimeException(e); 24 | } finally { 25 | closeQuietly(objectReader); 26 | closeQuietly(fis); 27 | } 28 | 29 | return objects; 30 | } 31 | 32 | 33 | @SuppressWarnings("unchecked") 34 | public static T readObject(File file) { 35 | ObjectInputStream objectReader = null; 36 | FileInputStream fis = null; 37 | try { 38 | fis = new FileInputStream(file); 39 | objectReader = new ObjectInputStream(fis); 40 | return (T) objectReader.readObject(); 41 | 42 | } catch (EOFException e) { 43 | } catch (Exception e) { 44 | throw new RuntimeException(e); 45 | } finally { 46 | closeQuietly(objectReader); 47 | closeQuietly(fis); 48 | } 49 | 50 | return null; 51 | } 52 | 53 | public static void writeObject(File file, Object object) { 54 | ObjectOutputStream objectOutput = null; 55 | FileOutputStream fos = null; 56 | try { 57 | fos = new FileOutputStream(file); 58 | objectOutput = new ObjectOutputStream(fos); 59 | objectOutput.writeObject(object); 60 | } catch (Exception e) { 61 | throw new RuntimeException(e); 62 | } finally { 63 | closeQuietly(objectOutput); 64 | closeQuietly(fos); 65 | } 66 | } 67 | 68 | public static void writeObject(FileOutputStream fos, Object object) { 69 | FileChannel channel = fos.getChannel(); 70 | if (!channel.isOpen()) throw new RuntimeException("channel is closed"); 71 | 72 | try { 73 | channel.position(0); 74 | ObjectOutputStream objectOutput = new ObjectOutputStream(fos); 75 | objectOutput.writeObject(object); 76 | fos.flush(); 77 | } catch (Exception e) { 78 | throw new RuntimeException(e); 79 | } finally { 80 | } 81 | } 82 | 83 | public static void writeObjects(File file, Object... objects) { 84 | ObjectOutputStream objectOutput = null; 85 | FileOutputStream fos = null; 86 | try { 87 | fos = new FileOutputStream(file); 88 | objectOutput = new ObjectOutputStream(fos); 89 | 90 | for (Object object : objects) 91 | objectOutput.writeObject(object); 92 | } catch (Exception e) { 93 | throw new RuntimeException(e); 94 | } finally { 95 | closeQuietly(objectOutput); 96 | closeQuietly(fos); 97 | } 98 | 99 | } 100 | 101 | public static void closeQuietly(OutputStream os) { 102 | if (os != null) try { 103 | os.close(); 104 | } catch (IOException e) { 105 | // ignore 106 | } 107 | } 108 | 109 | 110 | public static void closeQuietly(InputStream is) { 111 | if (is != null) try { 112 | is.close(); 113 | } catch (IOException e) { 114 | // ignore 115 | } 116 | 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Fronkend/pages/about_me.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 64 | 65 | 66 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/utils/Utils.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | import java.io.*; 4 | import java.sql.Timestamp; 5 | import java.text.SimpleDateFormat; 6 | import java.util.Calendar; 7 | 8 | public class Utils { 9 | 10 | public static final String DOT_IDWORKERS = ".idworkers"; 11 | 12 | public static ClassLoader getClassLoader() { 13 | ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); 14 | return contextClassLoader != null ? contextClassLoader : Utils.class.getClassLoader(); 15 | } 16 | 17 | 18 | public static InputStream classResourceToStream(String resourceName) { 19 | return getClassLoader().getResourceAsStream(resourceName); 20 | } 21 | 22 | 23 | public static String firstLine(String classResourceName) { 24 | InputStream inputStream = null; 25 | try { 26 | inputStream = classResourceToStream(classResourceName); 27 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); 28 | 29 | return bufferedReader.readLine(); 30 | } catch (IOException e) { 31 | return null; 32 | } finally { 33 | if (inputStream != null) try { 34 | inputStream.close(); 35 | } catch (IOException e) { 36 | // ignore 37 | } 38 | } 39 | } 40 | 41 | public static String checkNotEmpty(String param, String name) { 42 | if (param == null || param.isEmpty()) 43 | throw new IllegalArgumentException(name + " is empty"); 44 | 45 | return param; 46 | } 47 | 48 | 49 | public static long midnightMillis() { 50 | // today 51 | Calendar date = Calendar.getInstance(); 52 | // reset hour, minutes, seconds and millis 53 | date.set(Calendar.HOUR_OF_DAY, 0); 54 | date.set(Calendar.MINUTE, 0); 55 | date.set(Calendar.SECOND, 0); 56 | date.set(Calendar.MILLISECOND, 0); 57 | 58 | return date.getTimeInMillis(); 59 | } 60 | 61 | public static void main(String[] args) { 62 | // 2013-12-25 00:00:00.000 63 | System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Timestamp(midnightMillis()))); 64 | System.out.println(encode(281474976710655L)); 65 | } 66 | 67 | public static long decode(String s, String symbols) { 68 | final int B = symbols.length(); 69 | long num = 0; 70 | for (char ch : s.toCharArray()) { 71 | num *= B; 72 | num += symbols.indexOf(ch); 73 | } 74 | return num; 75 | } 76 | 77 | public static String encode(long num) { 78 | return encode(num, defaultRange); 79 | } 80 | 81 | public static String encode(long num, String symbols) { 82 | final int B = symbols.length(); 83 | StringBuilder sb = new StringBuilder(); 84 | while (num != 0) { 85 | sb.append(symbols.charAt((int) (num % B))); 86 | num /= B; 87 | } 88 | return sb.reverse().toString(); 89 | } 90 | 91 | // all un-clearly-recognized letters are skiped. 92 | static String defaultRange = "0123456789ABCDFGHKMNPRSTWXYZ"; 93 | 94 | public static String padLeft(String str, int size, char padChar) { 95 | if (str.length() >= size) return str; 96 | 97 | StringBuilder s = new StringBuilder(); 98 | for (int i = size - str.length(); i > 0; --i) { 99 | s.append(padChar); 100 | } 101 | s.append(str); 102 | 103 | return s.toString(); 104 | } 105 | 106 | public static File createIdWorkerHome() { 107 | String userHome = System.getProperty("user.home"); 108 | File idWorkerHome = new File(userHome + File.separator + DOT_IDWORKERS); 109 | idWorkerHome.mkdirs(); 110 | if (idWorkerHome.isDirectory()) return idWorkerHome; 111 | 112 | throw new RuntimeException("failed to create .idworkers at user home"); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/utils/HttpReq.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.ByteArrayOutputStream; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.UnsupportedEncodingException; 10 | import java.net.*; 11 | 12 | public class HttpReq { 13 | private final String baseUrl; 14 | private String req; 15 | private StringBuilder params = new StringBuilder(); 16 | Logger logger = LoggerFactory.getLogger(HttpReq.class); 17 | 18 | public HttpReq(String baseUrl) { 19 | this.baseUrl = baseUrl; 20 | } 21 | 22 | public static HttpReq get(String baseUrl) { 23 | return new HttpReq(baseUrl); 24 | } 25 | 26 | public HttpReq req(String req) { 27 | this.req = req; 28 | return this; 29 | } 30 | 31 | public HttpReq param(String name, String value) { 32 | if (params.length() > 0) params.append('&'); 33 | try { 34 | params.append(name).append('=').append(URLEncoder.encode(value, "UTF-8")); 35 | } catch (UnsupportedEncodingException e) { 36 | throw new RuntimeException(e); 37 | } 38 | 39 | return this; 40 | } 41 | 42 | public String exec() { 43 | HttpURLConnection http = null; 44 | try { 45 | http = (HttpURLConnection) new URL(baseUrl 46 | + (req == null ? "" : req) 47 | + (params.length() > 0 ? ("?" + params) : "")).openConnection(); 48 | http.setRequestProperty("Accept-Charset", "UTF-8"); 49 | HttpURLConnection.setFollowRedirects(false); 50 | http.setConnectTimeout(5 * 1000); 51 | http.setReadTimeout(5 * 1000); 52 | http.connect(); 53 | 54 | int status = http.getResponseCode(); 55 | String charset = getCharset(http.getHeaderField("Content-Type")); 56 | 57 | if (status == 200) { 58 | return readResponseBody(http, charset); 59 | } else { 60 | logger.warn("non 200 respoonse :" + readErrorResponseBody(http, status, charset)); 61 | return null; 62 | } 63 | } catch (Exception e) { 64 | logger.error("exec error {}", e.getMessage()); 65 | return null; 66 | } finally { 67 | if (http != null) http.disconnect(); 68 | } 69 | 70 | } 71 | 72 | private static String readErrorResponseBody(HttpURLConnection http, int status, String charset) throws IOException { 73 | InputStream errorStream = http.getErrorStream(); 74 | if (errorStream != null) { 75 | String error = toString(charset, errorStream); 76 | return ("STATUS CODE =" + status + "\n\n" + error); 77 | } else { 78 | return ("STATUS CODE =" + status); 79 | } 80 | } 81 | 82 | private static String readResponseBody(HttpURLConnection http, String charset) throws IOException { 83 | InputStream inputStream = http.getInputStream(); 84 | 85 | return toString(charset, inputStream); 86 | } 87 | 88 | private static String toString(String charset, InputStream inputStream) throws IOException { 89 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 90 | byte[] buffer = new byte[1024]; 91 | 92 | int length; 93 | while ((length = inputStream.read(buffer)) != -1) { 94 | baos.write(buffer, 0, length); 95 | } 96 | 97 | return new String(baos.toByteArray(), charset); 98 | } 99 | 100 | private static String getCharset(String contentType) { 101 | if (contentType == null) return "UTF-8"; 102 | 103 | String charset = null; 104 | for (String param : contentType.replace(" ", "").split(";")) { 105 | if (param.startsWith("charset=")) { 106 | charset = param.split("=", 2)[1]; 107 | break; 108 | } 109 | } 110 | 111 | return charset == null ? "UTF-8" : charset; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /springboot_mybatis/src/main/java/com/mexbo/pojo/Users.java: -------------------------------------------------------------------------------- 1 | package com.mexbo.pojo; 2 | 3 | import javax.persistence.*; 4 | 5 | public class Users { 6 | @Id 7 | private String id; 8 | 9 | /** 10 | * 用户名,账号,慕信号 11 | */ 12 | private String username; 13 | 14 | /** 15 | * 密码 16 | */ 17 | private String password; 18 | 19 | /** 20 | * 我的头像,如果没有默认给一张 21 | */ 22 | @Column(name = "face_image") 23 | private String faceImage; 24 | 25 | @Column(name = "face_image_big") 26 | private String faceImageBig; 27 | 28 | /** 29 | * 昵称 30 | */ 31 | private String nickname; 32 | 33 | /** 34 | * 新用户注册后默认后台生成二维码,并且上传到fastdfs 35 | */ 36 | private String qrcode; 37 | 38 | private String cid; 39 | 40 | /** 41 | * @return id 42 | */ 43 | public String getId() { 44 | return id; 45 | } 46 | 47 | /** 48 | * @param id 49 | */ 50 | public void setId(String id) { 51 | this.id = id; 52 | } 53 | 54 | /** 55 | * 获取用户名,账号,慕信号 56 | * 57 | * @return username - 用户名,账号,慕信号 58 | */ 59 | public String getUsername() { 60 | return username; 61 | } 62 | 63 | /** 64 | * 设置用户名,账号,慕信号 65 | * 66 | * @param username 用户名,账号,慕信号 67 | */ 68 | public void setUsername(String username) { 69 | this.username = username; 70 | } 71 | 72 | /** 73 | * 获取密码 74 | * 75 | * @return password - 密码 76 | */ 77 | public String getPassword() { 78 | return password; 79 | } 80 | 81 | /** 82 | * 设置密码 83 | * 84 | * @param password 密码 85 | */ 86 | public void setPassword(String password) { 87 | this.password = password; 88 | } 89 | 90 | /** 91 | * 获取我的头像,如果没有默认给一张 92 | * 93 | * @return face_image - 我的头像,如果没有默认给一张 94 | */ 95 | public String getFaceImage() { 96 | return faceImage; 97 | } 98 | 99 | /** 100 | * 设置我的头像,如果没有默认给一张 101 | * 102 | * @param faceImage 我的头像,如果没有默认给一张 103 | */ 104 | public void setFaceImage(String faceImage) { 105 | this.faceImage = faceImage; 106 | } 107 | 108 | /** 109 | * @return face_image_big 110 | */ 111 | public String getFaceImageBig() { 112 | return faceImageBig; 113 | } 114 | 115 | /** 116 | * @param faceImageBig 117 | */ 118 | public void setFaceImageBig(String faceImageBig) { 119 | this.faceImageBig = faceImageBig; 120 | } 121 | 122 | /** 123 | * 获取昵称 124 | * 125 | * @return nickname - 昵称 126 | */ 127 | public String getNickname() { 128 | return nickname; 129 | } 130 | 131 | /** 132 | * 设置昵称 133 | * 134 | * @param nickname 昵称 135 | */ 136 | public void setNickname(String nickname) { 137 | this.nickname = nickname; 138 | } 139 | 140 | /** 141 | * 获取新用户注册后默认后台生成二维码,并且上传到fastdfs 142 | * 143 | * @return qrcode - 新用户注册后默认后台生成二维码,并且上传到fastdfs 144 | */ 145 | public String getQrcode() { 146 | return qrcode; 147 | } 148 | 149 | /** 150 | * 设置新用户注册后默认后台生成二维码,并且上传到fastdfs 151 | * 152 | * @param qrcode 新用户注册后默认后台生成二维码,并且上传到fastdfs 153 | */ 154 | public void setQrcode(String qrcode) { 155 | this.qrcode = qrcode; 156 | } 157 | 158 | /** 159 | * @return cid 160 | */ 161 | public String getCid() { 162 | return cid; 163 | } 164 | 165 | /** 166 | * @param cid 167 | */ 168 | public void setCid(String cid) { 169 | this.cid = cid; 170 | } 171 | } -------------------------------------------------------------------------------- /springboot_mybatis/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | com.mexbo 8 | springboot_mybatis 9 | 1.0-SNAPSHOT 10 | war 11 | 12 | springboot_mybatis Maven Webapp 13 | 14 | http://www.example.com 15 | 16 | 17 | UTF-8 18 | 1.7 19 | 1.7 20 | 21 | 22 | 23 | 24 | junit 25 | junit 26 | 4.11 27 | test 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-log4j 33 | 1.3.8.RELEASE 34 | 35 | 36 | 37 | 38 | com.alibaba 39 | druid 40 | 1.1.0 41 | 42 | 43 | com.alibaba 44 | druid-spring-boot-starter 45 | 1.1.0 46 | 47 | 48 | 49 | mysql 50 | mysql-connector-java 51 | 8.0.13 52 | 53 | 54 | 55 | 56 | 57 | org.mybatis.spring.boot 58 | mybatis-spring-boot-starter 59 | 1.3.1 60 | 61 | 62 | 63 | tk.mybatis 64 | mapper-spring-boot-starter 65 | 1.2.4 66 | 67 | 68 | 69 | com.github.pagehelper 70 | pagehelper-spring-boot-starter 71 | 1.2.3 72 | 73 | 74 | 75 | 76 | org.mybatis.generator 77 | mybatis-generator-core 78 | 1.3.2 79 | compile 80 | true 81 | 82 | 83 | 84 | 85 | springboot_mybatis 86 | 87 | 88 | 89 | maven-clean-plugin 90 | 3.0.0 91 | 92 | 93 | 94 | maven-resources-plugin 95 | 3.0.2 96 | 97 | 98 | maven-compiler-plugin 99 | 3.7.0 100 | 101 | 102 | maven-surefire-plugin 103 | 2.20.1 104 | 105 | 106 | maven-war-plugin 107 | 3.2.0 108 | 109 | 110 | maven-install-plugin 111 | 2.5.2 112 | 113 | 114 | maven-deploy-plugin 115 | 2.8.2 116 | 117 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /Backend/src/main/java/org/n3r/idworker/strategy/FileLock.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.strategy; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.io.*; 8 | import java.nio.channels.Channels; 9 | import java.nio.channels.ClosedChannelException; 10 | import java.nio.channels.FileChannel; 11 | import java.nio.channels.OverlappingFileLockException; 12 | 13 | /** 14 | * A file lock a la flock/funlock 15 | *

16 | * The given path will be created and opened if it doesn't exist. 17 | */ 18 | public class FileLock { 19 | private final File file; 20 | private FileChannel channel; 21 | private java.nio.channels.FileLock flock = null; 22 | Logger logger = LoggerFactory.getLogger(FileLock.class); 23 | 24 | public FileLock(File file) { 25 | this.file = file; 26 | 27 | try { 28 | file.createNewFile(); // create the file if it doesn't exist 29 | channel = new RandomAccessFile(file, "rw").getChannel(); 30 | } catch (IOException e) { 31 | throw new RuntimeException(e); 32 | } 33 | } 34 | 35 | 36 | /** 37 | * Lock the file or throw an exception if the lock is already held 38 | */ 39 | public void lock() { 40 | try { 41 | synchronized (this) { 42 | logger.trace("Acquiring lock on {}", file.getAbsolutePath()); 43 | flock = channel.lock(); 44 | } 45 | } catch (IOException e) { 46 | throw new RuntimeException(e); 47 | } 48 | } 49 | 50 | /** 51 | * Try to lock the file and return true if the locking succeeds 52 | */ 53 | public boolean tryLock() { 54 | synchronized (this) { 55 | logger.trace("Acquiring lock on {}", file.getAbsolutePath()); 56 | try { 57 | // weirdly this method will return null if the lock is held by another 58 | // process, but will throw an exception if the lock is held by this process 59 | // so we have to handle both cases 60 | flock = channel.tryLock(); 61 | return flock != null; 62 | } catch (OverlappingFileLockException e) { 63 | return false; 64 | } catch (IOException e) { 65 | throw new RuntimeException(e); 66 | } 67 | } 68 | } 69 | 70 | /** 71 | * Unlock the lock if it is held 72 | */ 73 | public void unlock() { 74 | synchronized (this) { 75 | logger.trace("Releasing lock on {}", file.getAbsolutePath()); 76 | if (flock == null) return; 77 | try { 78 | flock.release(); 79 | } catch (ClosedChannelException e) { 80 | // Ignore 81 | } catch (IOException e) { 82 | throw new RuntimeException(e); 83 | } 84 | } 85 | } 86 | 87 | /** 88 | * Destroy this lock, closing the associated FileChannel 89 | */ 90 | public void destroy() { 91 | synchronized (this) { 92 | unlock(); 93 | if (!channel.isOpen()) return; 94 | 95 | try { 96 | channel.close(); 97 | } catch (IOException e) { 98 | throw new RuntimeException(e); 99 | } 100 | } 101 | } 102 | 103 | 104 | @SuppressWarnings("unchecked") 105 | public T readObject() { 106 | try { 107 | InputStream is = Channels.newInputStream(channel); 108 | ObjectInputStream objectReader = new ObjectInputStream(is); 109 | return (T) objectReader.readObject(); 110 | } catch (EOFException e) { 111 | } catch (Exception e) { 112 | throw new RuntimeException(e); 113 | } 114 | 115 | return null; 116 | } 117 | 118 | 119 | public synchronized boolean writeObject(Object object) { 120 | if (!channel.isOpen()) return false; 121 | 122 | try { 123 | channel.position(0); 124 | OutputStream out = Channels.newOutputStream(channel); 125 | ObjectOutputStream objectOutput = new ObjectOutputStream(out); 126 | objectOutput.writeObject(object); 127 | return true; 128 | } catch (Exception e) { 129 | throw new RuntimeException(e); 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /Backend/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.mexbo 7 | springboot_muxin_backend 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | springboot_muxin_backend 12 | springboot backend of muxin 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.1.0.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-webflux 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-test 39 | test 40 | 41 | 42 | io.projectreactor 43 | reactor-test 44 | test 45 | 46 | 47 | 48 | io.netty 49 | netty-all 50 | 4.1.25.Final 51 | 52 | 53 | 54 | mysql 55 | mysql-connector-java 56 | 8.0.13 57 | 58 | 59 | 60 | org.mybatis.spring.boot 61 | mybatis-spring-boot-starter 62 | 1.3.1 63 | 64 | 65 | 66 | tk.mybatis 67 | mapper-spring-boot-starter 68 | 1.2.4 69 | 70 | 71 | 72 | com.github.pagehelper 73 | pagehelper-spring-boot-starter 74 | 1.2.3 75 | 76 | 77 | 78 | commons-codec 79 | commons-codec 80 | 1.11 81 | 82 | 83 | org.apache.commons 84 | commons-lang3 85 | 3.4 86 | 87 | 88 | org.apache.commons 89 | commons-io 90 | 1.3.2 91 | 92 | 93 | 94 | com.github.tobato 95 | fastdfs-client 96 | 1.26.2 97 | 98 | 99 | org.springframework 100 | spring-test 101 | 102 | 103 | 104 | 105 | 106 | 107 | org.springframework.boot 108 | spring-boot-maven-plugin 109 | 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /Fronkend/pages/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 13 | 41 | 42 | 43 | 44 |

45 |
46 |
47 |
48 | 49 |
Netty
50 |
51 | 52 | 风间影月 53 | 54 | 55 |
56 | 57 | 58 |
59 | 60 |
61 | 62 | 63 |
64 |
65 | 68 |
69 |
70 |
71 |
72 |
73 | 74 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/java/com/neo/fastdfs/FastDFSClient.java: -------------------------------------------------------------------------------- 1 | package com.neo.fastdfs; 2 | 3 | import org.csource.common.NameValuePair; 4 | import org.csource.fastdfs.*; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.core.io.ClassPathResource; 7 | import org.springframework.core.io.Resource; 8 | 9 | import java.io.*; 10 | 11 | public class FastDFSClient { 12 | private static org.slf4j.Logger logger = LoggerFactory.getLogger(FastDFSClient.class); 13 | 14 | static { 15 | try { 16 | String filePath = new ClassPathResource("fdfs_client.conf").getFile().getAbsolutePath();; 17 | ClientGlobal.init(filePath); 18 | } catch (Exception e) { 19 | logger.error("FastDFS Client Init Fail!",e); 20 | } 21 | } 22 | 23 | public static String[] upload(FastDFSFile file) { 24 | logger.info("File Name: " + file.getName() + "File Length:" + file.getContent().length); 25 | 26 | NameValuePair[] meta_list = new NameValuePair[1]; 27 | meta_list[0] = new NameValuePair("author", file.getAuthor()); 28 | 29 | long startTime = System.currentTimeMillis(); 30 | String[] uploadResults = null; 31 | StorageClient storageClient=null; 32 | try { 33 | storageClient = getTrackerClient(); 34 | uploadResults = storageClient.upload_file(file.getContent(), file.getExt(), meta_list); 35 | } catch (IOException e) { 36 | logger.error("IO Exception when uploadind the file:" + file.getName(), e); 37 | } catch (Exception e) { 38 | logger.error("Non IO Exception when uploadind the file:" + file.getName(), e); 39 | } 40 | logger.info("upload_file time used:" + (System.currentTimeMillis() - startTime) + " ms"); 41 | 42 | if (uploadResults == null && storageClient!=null) { 43 | logger.error("upload file fail, error code:" + storageClient.getErrorCode()); 44 | } 45 | String groupName = uploadResults[0]; 46 | String remoteFileName = uploadResults[1]; 47 | 48 | logger.info("upload file successfully!!!" + "group_name:" + groupName + ", remoteFileName:" + " " + remoteFileName); 49 | return uploadResults; 50 | } 51 | 52 | public static FileInfo getFile(String groupName, String remoteFileName) { 53 | try { 54 | StorageClient storageClient = getTrackerClient(); 55 | return storageClient.get_file_info(groupName, remoteFileName); 56 | } catch (IOException e) { 57 | logger.error("IO Exception: Get File from Fast DFS failed", e); 58 | } catch (Exception e) { 59 | logger.error("Non IO Exception: Get File from Fast DFS failed", e); 60 | } 61 | return null; 62 | } 63 | 64 | public static InputStream downFile(String groupName, String remoteFileName) { 65 | try { 66 | StorageClient storageClient = getTrackerClient(); 67 | byte[] fileByte = storageClient.download_file(groupName, remoteFileName); 68 | InputStream ins = new ByteArrayInputStream(fileByte); 69 | return ins; 70 | } catch (IOException e) { 71 | logger.error("IO Exception: Get File from Fast DFS failed", e); 72 | } catch (Exception e) { 73 | logger.error("Non IO Exception: Get File from Fast DFS failed", e); 74 | } 75 | return null; 76 | } 77 | 78 | public static void deleteFile(String groupName, String remoteFileName) 79 | throws Exception { 80 | StorageClient storageClient = getTrackerClient(); 81 | int i = storageClient.delete_file(groupName, remoteFileName); 82 | logger.info("delete file successfully!!!" + i); 83 | } 84 | 85 | public static StorageServer[] getStoreStorages(String groupName) 86 | throws IOException { 87 | TrackerClient trackerClient = new TrackerClient(); 88 | TrackerServer trackerServer = trackerClient.getConnection(); 89 | return trackerClient.getStoreStorages(trackerServer, groupName); 90 | } 91 | 92 | public static ServerInfo[] getFetchStorages(String groupName, 93 | String remoteFileName) throws IOException { 94 | TrackerClient trackerClient = new TrackerClient(); 95 | TrackerServer trackerServer = trackerClient.getConnection(); 96 | return trackerClient.getFetchStorages(trackerServer, groupName, remoteFileName); 97 | } 98 | 99 | public static String getTrackerUrl() throws IOException { 100 | return "http://"+getTrackerServer().getInetSocketAddress().getHostString()+":"+ClientGlobal.getG_tracker_http_port()+"/"; 101 | } 102 | 103 | private static StorageClient getTrackerClient() throws IOException { 104 | TrackerServer trackerServer = getTrackerServer(); 105 | StorageClient storageClient = new StorageClient(trackerServer, null); 106 | return storageClient; 107 | } 108 | 109 | private static TrackerServer getTrackerServer() throws IOException { 110 | TrackerClient trackerClient = new TrackerClient(); 111 | TrackerServer trackerServer = trackerClient.getConnection(); 112 | return trackerServer; 113 | } 114 | } -------------------------------------------------------------------------------- /Fronkend/plugin/v3.1.6/myface-uploader.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cropper 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 |

个人头像

35 |
36 | 37 |
38 |
39 | 40 |
41 |
42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /Fronkend/plugin/cropper/css/main.css: -------------------------------------------------------------------------------- 1 | .btn { 2 | padding-left: .75rem; 3 | padding-right: .75rem; 4 | } 5 | 6 | label.btn { 7 | margin-bottom: 0; 8 | } 9 | 10 | .d-flex > .btn { 11 | flex: 1; 12 | } 13 | 14 | .carbonads { 15 | border-radius: .25rem; 16 | border: 1px solid #ccc; 17 | font-size: .875rem; 18 | overflow: hidden; 19 | padding: 1rem; 20 | } 21 | 22 | .carbon-wrap { 23 | overflow: hidden; 24 | } 25 | 26 | .carbon-img { 27 | clear: left; 28 | display: block; 29 | float: left; 30 | } 31 | 32 | .carbon-text, 33 | .carbon-poweredby { 34 | display: block; 35 | margin-left: 140px; 36 | } 37 | 38 | .carbon-text, 39 | .carbon-text:hover, 40 | .carbon-text:focus { 41 | color: #fff; 42 | text-decoration: none; 43 | } 44 | 45 | .carbon-poweredby, 46 | .carbon-poweredby:hover, 47 | .carbon-poweredby:focus { 48 | color: #ddd; 49 | text-decoration: none; 50 | } 51 | 52 | @media (min-width: 768px) { 53 | .carbonads { 54 | float: right; 55 | margin-bottom: -1rem; 56 | margin-top: -1rem; 57 | max-width: 360px; 58 | } 59 | } 60 | 61 | .footer { 62 | font-size: .875rem; 63 | overflow: hidden; 64 | } 65 | 66 | .heart { 67 | color: #ddd; 68 | display: block; 69 | height: 2rem; 70 | line-height: 2rem; 71 | margin-bottom: 0; 72 | margin-top: 1rem; 73 | position: relative; 74 | text-align: center; 75 | width: 100%; 76 | } 77 | 78 | .heart:hover { 79 | color: #ff4136; 80 | } 81 | 82 | .heart::before { 83 | border-top: 1px solid #eee; 84 | content: " "; 85 | display: block; 86 | height: 0; 87 | left: 0; 88 | position: absolute; 89 | right: 0; 90 | top: 50%; 91 | } 92 | 93 | .heart::after { 94 | background-color: #fff; 95 | content: "♥"; 96 | padding-left: .5rem; 97 | padding-right: .5rem; 98 | position: relative; 99 | z-index: 1; 100 | } 101 | 102 | .img-container, 103 | .img-preview { 104 | background-color: #f7f7f7; 105 | text-align: center; 106 | width: 100%; 107 | } 108 | 109 | .img-container { 110 | margin-bottom: 1rem; 111 | max-height: 497px; 112 | min-height: 200px; 113 | } 114 | 115 | @media (min-width: 768px) { 116 | .img-container { 117 | min-height: 497px; 118 | } 119 | } 120 | 121 | .img-container > img { 122 | max-width: 100%; 123 | } 124 | 125 | .docs-preview { 126 | margin-right: -1rem; 127 | } 128 | 129 | .img-preview { 130 | float: left; 131 | margin-bottom: .5rem; 132 | margin-right: .5rem; 133 | overflow: hidden; 134 | } 135 | 136 | .img-preview > img { 137 | max-width: 100%; 138 | } 139 | 140 | .preview-lg { 141 | height: 9rem; 142 | width: 16rem; 143 | } 144 | 145 | .preview-md { 146 | height: 4.5rem; 147 | width: 8rem; 148 | } 149 | 150 | .preview-sm { 151 | height: 2.25rem; 152 | width: 4rem; 153 | } 154 | 155 | .preview-xs { 156 | height: 1.125rem; 157 | margin-right: 0; 158 | width: 2rem; 159 | } 160 | 161 | .docs-data > .input-group { 162 | margin-bottom: .5rem; 163 | } 164 | 165 | .docs-data .input-group-prepend .input-group-text { 166 | min-width: 4rem; 167 | } 168 | 169 | .docs-data .input-group-append .input-group-text { 170 | min-width: 3rem; 171 | } 172 | 173 | .docs-buttons > .btn, 174 | .docs-buttons > .btn-group, 175 | .docs-buttons > .form-control { 176 | margin-bottom: .5rem; 177 | margin-right: .25rem; 178 | } 179 | 180 | .docs-toggles > .btn, 181 | .docs-toggles > .btn-group, 182 | .docs-toggles > .dropdown { 183 | margin-bottom: .5rem; 184 | } 185 | 186 | .docs-tooltip { 187 | display: block; 188 | margin: -.5rem -.75rem; 189 | padding: .5rem .75rem; 190 | } 191 | 192 | .docs-tooltip > .icon { 193 | margin: 0 -.25rem; 194 | vertical-align: top; 195 | } 196 | 197 | .tooltip-inner { 198 | white-space: normal; 199 | } 200 | 201 | .btn-upload .tooltip-inner, 202 | .btn-toggle .tooltip-inner { 203 | white-space: nowrap; 204 | } 205 | 206 | .btn-toggle { 207 | padding: .5rem; 208 | } 209 | 210 | .btn-toggle > .docs-tooltip { 211 | margin: -.5rem; 212 | padding: .5rem; 213 | } 214 | 215 | @media (max-width: 400px) { 216 | .btn-group-crop { 217 | margin-right: -1rem!important; 218 | } 219 | 220 | .btn-group-crop > .btn { 221 | padding-left: .5rem; 222 | padding-right: .5rem; 223 | } 224 | 225 | .btn-group-crop .docs-tooltip { 226 | margin-left: -.5rem; 227 | margin-right: -.5rem; 228 | padding-left: .5rem; 229 | padding-right: .5rem; 230 | } 231 | } 232 | 233 | .docs-options .dropdown-menu { 234 | width: 100%; 235 | } 236 | 237 | .docs-options .dropdown-menu > li { 238 | font-size: .875rem; 239 | padding: .125rem 1rem; 240 | } 241 | 242 | .docs-options .dropdown-menu .form-check-label { 243 | display: block; 244 | } 245 | 246 | .docs-cropped .modal-body { 247 | text-align: center; 248 | } 249 | 250 | .docs-cropped .modal-body > img, 251 | .docs-cropped .modal-body > canvas { 252 | max-width: 100%; 253 | } 254 | -------------------------------------------------------------------------------- /Fronkend/plugin/v3.1.6/css/main.css: -------------------------------------------------------------------------------- 1 | .btn { 2 | padding-left: .75rem; 3 | padding-right: .75rem; 4 | } 5 | 6 | label.btn { 7 | margin-bottom: 0; 8 | } 9 | 10 | .d-flex > .btn { 11 | flex: 1; 12 | } 13 | 14 | .carbonads { 15 | border-radius: .25rem; 16 | border: 1px solid #ccc; 17 | font-size: .875rem; 18 | overflow: hidden; 19 | padding: 1rem; 20 | } 21 | 22 | .carbon-wrap { 23 | overflow: hidden; 24 | } 25 | 26 | .carbon-img { 27 | clear: left; 28 | display: block; 29 | float: left; 30 | } 31 | 32 | .carbon-text, 33 | .carbon-poweredby { 34 | display: block; 35 | margin-left: 140px; 36 | } 37 | 38 | .carbon-text, 39 | .carbon-text:hover, 40 | .carbon-text:focus { 41 | color: #fff; 42 | text-decoration: none; 43 | } 44 | 45 | .carbon-poweredby, 46 | .carbon-poweredby:hover, 47 | .carbon-poweredby:focus { 48 | color: #ddd; 49 | text-decoration: none; 50 | } 51 | 52 | @media (min-width: 768px) { 53 | .carbonads { 54 | float: right; 55 | margin-bottom: -1rem; 56 | margin-top: -1rem; 57 | max-width: 360px; 58 | } 59 | } 60 | 61 | .footer { 62 | font-size: .875rem; 63 | overflow: hidden; 64 | } 65 | 66 | .heart { 67 | color: #ddd; 68 | display: block; 69 | height: 2rem; 70 | line-height: 2rem; 71 | margin-bottom: 0; 72 | margin-top: 1rem; 73 | position: relative; 74 | text-align: center; 75 | width: 100%; 76 | } 77 | 78 | .heart:hover { 79 | color: #ff4136; 80 | } 81 | 82 | .heart::before { 83 | border-top: 1px solid #eee; 84 | content: " "; 85 | display: block; 86 | height: 0; 87 | left: 0; 88 | position: absolute; 89 | right: 0; 90 | top: 50%; 91 | } 92 | 93 | .heart::after { 94 | background-color: #fff; 95 | content: "♥"; 96 | padding-left: .5rem; 97 | padding-right: .5rem; 98 | position: relative; 99 | z-index: 1; 100 | } 101 | 102 | .img-container, 103 | .img-preview { 104 | background-color: #f7f7f7; 105 | text-align: center; 106 | width: 100%; 107 | } 108 | 109 | .img-container { 110 | margin-bottom: 1rem; 111 | max-height: 497px; 112 | min-height: 200px; 113 | } 114 | 115 | @media (min-width: 768px) { 116 | .img-container { 117 | min-height: 497px; 118 | } 119 | } 120 | 121 | .img-container > img { 122 | max-width: 100%; 123 | } 124 | 125 | .docs-preview { 126 | margin-right: -1rem; 127 | } 128 | 129 | .img-preview { 130 | float: left; 131 | margin-bottom: .5rem; 132 | margin-right: .5rem; 133 | overflow: hidden; 134 | } 135 | 136 | .img-preview > img { 137 | max-width: 100%; 138 | } 139 | 140 | .preview-lg { 141 | height: 9rem; 142 | width: 16rem; 143 | } 144 | 145 | .preview-md { 146 | height: 4.5rem; 147 | width: 8rem; 148 | } 149 | 150 | .preview-sm { 151 | height: 2.25rem; 152 | width: 4rem; 153 | } 154 | 155 | .preview-xs { 156 | height: 1.125rem; 157 | margin-right: 0; 158 | width: 2rem; 159 | } 160 | 161 | .docs-data > .input-group { 162 | margin-bottom: .5rem; 163 | } 164 | 165 | .docs-data .input-group-prepend .input-group-text { 166 | min-width: 4rem; 167 | } 168 | 169 | .docs-data .input-group-append .input-group-text { 170 | min-width: 3rem; 171 | } 172 | 173 | .docs-buttons > .btn, 174 | .docs-buttons > .btn-group, 175 | .docs-buttons > .form-control { 176 | margin-bottom: .5rem; 177 | margin-right: .25rem; 178 | } 179 | 180 | .docs-toggles > .btn, 181 | .docs-toggles > .btn-group, 182 | .docs-toggles > .dropdown { 183 | margin-bottom: .5rem; 184 | } 185 | 186 | .docs-tooltip { 187 | display: block; 188 | margin: -.5rem -.75rem; 189 | padding: .5rem .75rem; 190 | } 191 | 192 | .docs-tooltip > .icon { 193 | margin: 0 -.25rem; 194 | vertical-align: top; 195 | } 196 | 197 | .tooltip-inner { 198 | white-space: normal; 199 | } 200 | 201 | .btn-upload .tooltip-inner, 202 | .btn-toggle .tooltip-inner { 203 | white-space: nowrap; 204 | } 205 | 206 | .btn-toggle { 207 | padding: .5rem; 208 | } 209 | 210 | .btn-toggle > .docs-tooltip { 211 | margin: -.5rem; 212 | padding: .5rem; 213 | } 214 | 215 | @media (max-width: 400px) { 216 | .btn-group-crop { 217 | margin-right: -1rem!important; 218 | } 219 | 220 | .btn-group-crop > .btn { 221 | padding-left: .5rem; 222 | padding-right: .5rem; 223 | } 224 | 225 | .btn-group-crop .docs-tooltip { 226 | margin-left: -.5rem; 227 | margin-right: -.5rem; 228 | padding-left: .5rem; 229 | padding-right: .5rem; 230 | } 231 | } 232 | 233 | .docs-options .dropdown-menu { 234 | width: 100%; 235 | } 236 | 237 | .docs-options .dropdown-menu > li { 238 | font-size: .875rem; 239 | padding: .125rem 1rem; 240 | } 241 | 242 | .docs-options .dropdown-menu .form-check-label { 243 | display: block; 244 | } 245 | 246 | .docs-cropped .modal-body { 247 | text-align: center; 248 | } 249 | 250 | .docs-cropped .modal-body > img, 251 | .docs-cropped .modal-body > canvas { 252 | max-width: 100%; 253 | } 254 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Java仿微信全栈 高性能后台+移动客户端 2 | 3 | ## 技术栈 4 | > 前端:MUI H5+ 5 | > 后端:Springboot netty mybatis 6 | 7 | ## 仓库介绍 8 | + Backend 项目后端代码 9 | + Fronkend 项目前端代码 10 | + WebChat 测试netty的前端项目 11 | + spring-boot-fastDFS 测试fasdfs分布式文件服务的项目 12 | + springboot_mybatis 整合springboot和mybatis的项目 13 | 14 | ## 数据库 15 |
数据表设计 16 | 17 | > Table structure for chat_msg 18 | ```sql 19 | DROP TABLE IF EXISTS `chat_msg`; 20 | CREATE TABLE `chat_msg` ( 21 | `id` varchar(64) NOT NULL, 22 | `send_user_id` varchar(64) NOT NULL, 23 | `accept_user_id` varchar(64) NOT NULL, 24 | `msg` varchar(255) NOT NULL, 25 | `sign_flag` int(1) NOT NULL COMMENT '消息是否签收状态\r\n1:签收\r\n0:未签收\r\n', 26 | `create_time` datetime NOT NULL COMMENT '发送请求的事件', 27 | PRIMARY KEY (`id`) 28 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 29 | ``` 30 | > Table structure for friends_request 31 | ```sql 32 | DROP TABLE IF EXISTS `friends_request`; 33 | CREATE TABLE `friends_request` ( 34 | `id` varchar(64) NOT NULL, 35 | `send_user_id` varchar(64) NOT NULL, 36 | `accept_user_id` varchar(64) NOT NULL, 37 | `request_date_time` datetime NOT NULL COMMENT '发送请求的事件', 38 | PRIMARY KEY (`id`) 39 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 40 | ``` 41 | > Table structure for my_friends 42 | ```sql 43 | DROP TABLE IF EXISTS `my_friends`; 44 | CREATE TABLE `my_friends` ( 45 | `id` varchar(64) NOT NULL, 46 | `my_user_id` varchar(64) NOT NULL COMMENT '用户id', 47 | `my_friend_user_id` varchar(64) NOT NULL COMMENT '用户的好友id', 48 | PRIMARY KEY (`id`), 49 | UNIQUE KEY `my_user_id` (`my_user_id`,`my_friend_user_id`) 50 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 51 | ``` 52 | > Table structure for users 53 | ```sql 54 | DROP TABLE IF EXISTS `users`; 55 | CREATE TABLE `users` ( 56 | `id` varchar(64) NOT NULL, 57 | `username` varchar(20) NOT NULL COMMENT '用户名,账号,慕信号', 58 | `password` varchar(64) NOT NULL COMMENT '密码', 59 | `face_image` varchar(255) NOT NULL COMMENT '我的头像,如果没有默认给一张', 60 | `face_image_big` varchar(255) NOT NULL, 61 | `nickname` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '昵称', 62 | `qrcode` varchar(255) NOT NULL COMMENT '新用户注册后默认后台生成二维码,并且上传到fastdfs', 63 | `cid` varchar(64) DEFAULT NULL, 64 | PRIMARY KEY (`id`), 65 | UNIQUE KEY `id` (`id`), 66 | UNIQUE KEY `username` (`username`) 67 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 68 | ``` 69 |
70 | 71 | ## Docker安装fastdfs 72 | 73 |
安装过程 74 | 75 | 76 | * 拉取镜像 77 | ``` 78 | docker pull morunchang/fastdfs 79 | ``` 80 | * 运行tracker 81 | ``` 82 | docker run -d --name tracker --net=host morunchang/fastdfs sh tracker.sh 83 | ``` 84 | * 运行storage 85 | ``` 86 | docker run -d --name storage --net=host -e TRACKER_IP=:22122 -e GROUP_NAME= morunchang/fastdfs sh storage.sh 87 | ``` 88 | > `Nginx`端口应该是默认映射为`8080`吧 89 | 1. 使用的网络模式是–net=host, `` 替换为你机器的Ip即可 90 | 2. `` 是组名,即storage的组 91 | 3. 如果想要增加新的storage服务器,再次运行该命令,注意更换 新组名 92 | 运行完后会自动进入容器内部,输入【exit】退出容器内部 93 | 4. docker ps 查看容器信息 94 | ``` 95 | [root@iZh3cshm0xz7wjZ ~]# docker ps 96 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 97 | ccdf6bbeab48 morunchang/fastdfs "sh storage.sh" 5 seconds ago Up 4 seconds storage 98 | a7253c93bce1 morunchang/fastdfs "sh tracker.sh" About a minute ago Up About a minute tracker 99 | ``` 100 | * 修改nginx的配置,不拦截上传内容 101 | ``` 102 | //1.进入容器内部 103 | docker exec -it storage /bin/bash 104 | 105 | // storage 是 docker ps 中的NAMES 106 | // exit 退出 107 | 108 | root@iZh3cshm0xz7wjZ:/# cd data 109 | root@iZh3cshm0xz7wjZ:/data# ls 110 | fast_data fastdfs fastdfs-nginx-module libfastcommon nginx nginx-1.9.11.tar.gz 111 | 112 | //2.修改nginx配置文件 113 | root@iZh3cshm0xz7wjZ:/# vi /data/nginx/conf/nginx.conf 114 | 115 | //3. 添加修改内容 116 | location /group1/M00 { 117 | proxy_next_upstream http_502 http_504 error timeout invalid_header; 118 | proxy_cache http-cache; 119 | proxy_cache_valid 200 304 12h; 120 | proxy_cache_key $uri$is_args$args; 121 | proxy_pass http://fdfs_group1; 122 | expires 30d; 123 | } 124 | 125 | //4.退出 126 | root@iZh3cshm0xz7wjZ:/data/nginx/conf# exit 127 | exit 128 | 129 | //5. 重启storage服务 130 | [root@iZh3cshm0xz7wjZ ~]# docker restart storage 131 | storage 132 | ``` 133 | 通过spring-boot-fastDFS可以来测试是否安装好fastdfs,我参考的是这篇[博客](https://blog.csdn.net/lizhihaooo/article/details/79261388#commentsedit) 134 | 能上传文件,并通过网址访问就表示成功了 135 | ![img](https://camo.githubusercontent.com/3815b3363efe399dba6c391f11a95218d60d559a/687474703a2f2f34372e3130372e3131332e34333a383038302f6d7578696e2f4d30302f30302f30302f72424135616c7634426e534145476256414143794c6b77714464593035372e706e67) 136 |
137 | 138 | 139 | --------------------------------------------------------------------------------