├── .gitignore ├── .mvn └── wrapper │ ├── MavenWrapperDownloader.java │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── aop-demo ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── aop │ │ │ ├── AopDemoApplication.java │ │ │ ├── advice │ │ │ ├── PermissionAdvice.java │ │ │ └── PermissionSecondAdvice.java │ │ │ ├── annotation │ │ │ └── PermissionAnnotation.java │ │ │ ├── controller │ │ │ └── PermissionController.java │ │ │ └── service │ │ │ ├── PermissionService.java │ │ │ └── impl │ │ │ └── PermissionServiceImpl.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── aop │ └── AopTest.java ├── elasticSearch-demo ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── es │ │ │ ├── EsDemoApplication.java │ │ │ └── config │ │ │ └── ESConfig.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── es │ ├── AggTest.java │ ├── IndexTest.java │ └── QueryTest.java ├── mongodb-demo ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── mutest │ │ │ └── mongo │ │ │ ├── MongoApplication.java │ │ │ ├── dao │ │ │ ├── MongoDbDao.java │ │ │ └── UserMongoDbDao.java │ │ │ ├── model │ │ │ └── User.java │ │ │ └── service │ │ │ ├── UserService.java │ │ │ └── impl │ │ │ └── UserServiceImpl.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── mutest │ └── mongo │ └── UserTest.java ├── mvnw ├── mvnw.cmd ├── pom.xml ├── quartz-demo ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── quartz │ │ │ └── demo │ │ │ ├── QuartzDemoApplication.java │ │ │ ├── config │ │ │ ├── ExecutorConfig.java │ │ │ └── SchedulerConfig.java │ │ │ ├── controller │ │ │ └── QuartzController.java │ │ │ ├── entity │ │ │ └── Person.java │ │ │ ├── mapper │ │ │ └── PersonMapper.java │ │ │ ├── schedule │ │ │ ├── MajorJob.java │ │ │ └── SimpleJob.java │ │ │ └── utils │ │ │ ├── QuartzUtils.java │ │ │ ├── SpringContextJobUtil.java │ │ │ └── StringUtils.java │ └── resources │ │ ├── application.yml │ │ ├── persons.sql │ │ ├── quartz.properties │ │ └── tables_mysql_innodb.sql │ └── test │ └── java │ └── com │ └── quartz │ └── demo │ ├── MultiQuartzTest.java │ └── SimpleQuartzTest.java ├── rocketmq-demo ├── pom.xml └── src │ └── main │ └── java │ └── rocketmq │ ├── ConsumerTest.java │ └── ProducerTest.java ├── springboot-layui-demo ├── logs │ ├── springboot-demo-sql.log │ └── springboot-demo.log ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── demo │ │ ├── DemoApplication.java │ │ ├── advice │ │ ├── AopAdvice.java │ │ ├── BusinessErrorException.java │ │ ├── BusinessMsgEnum.java │ │ ├── CORSFilter.java │ │ ├── ParamCheckAdvice.java │ │ └── ResponseInfo.java │ │ ├── annotation │ │ └── ParamCheckAnnotation.java │ │ ├── controller │ │ ├── GoodsController.java │ │ └── PersonController.java │ │ ├── dao │ │ ├── GoodsDao.java │ │ └── PersonDao.java │ │ ├── model │ │ ├── Goods.java │ │ └── Person.java │ │ └── service │ │ ├── GoodsService.java │ │ ├── PersonService.java │ │ └── impl │ │ ├── GoodsServiceImpl.java │ │ └── PersonServiceImpl.java │ └── resources │ ├── application.yml │ ├── logback-spring.xml │ ├── mappers │ └── PersonMapper.xml │ └── static │ ├── css │ └── myCss.css │ ├── index.html │ ├── js │ └── lib │ │ └── jquery-2.1.1.min.js │ ├── layui │ ├── css │ │ ├── layui.css │ │ ├── layui.mobile.css │ │ └── modules │ │ │ ├── code.css │ │ │ ├── laydate │ │ │ └── default │ │ │ │ └── laydate.css │ │ │ └── layer │ │ │ └── default │ │ │ ├── icon-ext.png │ │ │ ├── icon.png │ │ │ ├── layer.css │ │ │ ├── loading-0.gif │ │ │ ├── loading-1.gif │ │ │ └── loading-2.gif │ ├── font │ │ ├── iconfont.eot │ │ ├── iconfont.svg │ │ ├── iconfont.ttf │ │ └── iconfont.woff │ ├── images │ │ └── face │ │ │ ├── 0.gif │ │ │ ├── 1.gif │ │ │ ├── 10.gif │ │ │ ├── 11.gif │ │ │ ├── 12.gif │ │ │ ├── 13.gif │ │ │ ├── 14.gif │ │ │ ├── 15.gif │ │ │ ├── 16.gif │ │ │ ├── 17.gif │ │ │ ├── 18.gif │ │ │ ├── 19.gif │ │ │ ├── 2.gif │ │ │ ├── 20.gif │ │ │ ├── 21.gif │ │ │ ├── 22.gif │ │ │ ├── 23.gif │ │ │ ├── 24.gif │ │ │ ├── 25.gif │ │ │ ├── 26.gif │ │ │ ├── 27.gif │ │ │ ├── 28.gif │ │ │ ├── 29.gif │ │ │ ├── 3.gif │ │ │ ├── 30.gif │ │ │ ├── 31.gif │ │ │ ├── 32.gif │ │ │ ├── 33.gif │ │ │ ├── 34.gif │ │ │ ├── 35.gif │ │ │ ├── 36.gif │ │ │ ├── 37.gif │ │ │ ├── 38.gif │ │ │ ├── 39.gif │ │ │ ├── 4.gif │ │ │ ├── 40.gif │ │ │ ├── 41.gif │ │ │ ├── 42.gif │ │ │ ├── 43.gif │ │ │ ├── 44.gif │ │ │ ├── 45.gif │ │ │ ├── 46.gif │ │ │ ├── 47.gif │ │ │ ├── 48.gif │ │ │ ├── 49.gif │ │ │ ├── 5.gif │ │ │ ├── 50.gif │ │ │ ├── 51.gif │ │ │ ├── 52.gif │ │ │ ├── 53.gif │ │ │ ├── 54.gif │ │ │ ├── 55.gif │ │ │ ├── 56.gif │ │ │ ├── 57.gif │ │ │ ├── 58.gif │ │ │ ├── 59.gif │ │ │ ├── 6.gif │ │ │ ├── 60.gif │ │ │ ├── 61.gif │ │ │ ├── 62.gif │ │ │ ├── 63.gif │ │ │ ├── 64.gif │ │ │ ├── 65.gif │ │ │ ├── 66.gif │ │ │ ├── 67.gif │ │ │ ├── 68.gif │ │ │ ├── 69.gif │ │ │ ├── 7.gif │ │ │ ├── 70.gif │ │ │ ├── 71.gif │ │ │ ├── 8.gif │ │ │ └── 9.gif │ ├── lay │ │ └── modules │ │ │ ├── carousel.js │ │ │ ├── code.js │ │ │ ├── colorpicker.js │ │ │ ├── element.js │ │ │ ├── flow.js │ │ │ ├── form.js │ │ │ ├── jquery.js │ │ │ ├── laydate.js │ │ │ ├── layedit.js │ │ │ ├── layer.js │ │ │ ├── laypage.js │ │ │ ├── laytpl.js │ │ │ ├── mobile.js │ │ │ ├── rate.js │ │ │ ├── slider.js │ │ │ ├── table.js │ │ │ ├── tree.js │ │ │ ├── upload.js │ │ │ └── util.js │ ├── layui.all.js │ ├── layui.js │ └── plugin │ │ └── optimizeSelectOption │ │ ├── optimizeSelectOption.css │ │ ├── optimizeSelectOption.js │ │ └── optimizeSelectOption.min.js │ ├── pages │ ├── addPerson.html │ ├── goodsList.html │ └── personsList.html │ └── utils │ └── common.js ├── stream-demo ├── pom.xml └── src │ └── main │ └── java │ └── stream │ ├── model │ └── Person.java │ └── test │ ├── AggregationTest.java │ ├── CollectTest.java │ ├── FilterTest.java │ ├── ForeachTest.java │ ├── MapTest.java │ └── ReduceTest.java └── websocket-demo ├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── mutest │ │ └── websocket │ │ ├── WebSocketApplication.java │ │ ├── config │ │ └── WebSocketConfig.java │ │ ├── handler │ │ └── MyWsHandler.java │ │ ├── job │ │ └── MessageJob.java │ │ ├── service │ │ └── WsService.java │ │ └── utlis │ │ └── WsSessionManager.java └── resources │ └── application.yml └── test └── java └── com └── mutest └── websocket └── WebSocketApplicationTests.java /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.net.*; 18 | import java.io.*; 19 | import java.nio.channels.*; 20 | import java.util.Properties; 21 | 22 | public class MavenWrapperDownloader { 23 | 24 | private static final String WRAPPER_VERSION = "0.5.6"; 25 | /** 26 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 27 | */ 28 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 29 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 30 | 31 | /** 32 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 33 | * use instead of the default one. 34 | */ 35 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 36 | ".mvn/wrapper/maven-wrapper.properties"; 37 | 38 | /** 39 | * Path where the maven-wrapper.jar will be saved to. 40 | */ 41 | private static final String MAVEN_WRAPPER_JAR_PATH = 42 | ".mvn/wrapper/maven-wrapper.jar"; 43 | 44 | /** 45 | * Name of the property which should be used to override the default download url for the wrapper. 46 | */ 47 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 48 | 49 | public static void main(String args[]) { 50 | System.out.println("- Downloader started"); 51 | File baseDirectory = new File(args[0]); 52 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 53 | 54 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 55 | // wrapperUrl parameter. 56 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 57 | String url = DEFAULT_DOWNLOAD_URL; 58 | if (mavenWrapperPropertyFile.exists()) { 59 | FileInputStream mavenWrapperPropertyFileInputStream = null; 60 | try { 61 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 62 | Properties mavenWrapperProperties = new Properties(); 63 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 64 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 65 | } catch (IOException e) { 66 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 67 | } finally { 68 | try { 69 | if (mavenWrapperPropertyFileInputStream != null) { 70 | mavenWrapperPropertyFileInputStream.close(); 71 | } 72 | } catch (IOException e) { 73 | // Ignore ... 74 | } 75 | } 76 | } 77 | System.out.println("- Downloading from: " + url); 78 | 79 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 80 | if (!outputFile.getParentFile().exists()) { 81 | if (!outputFile.getParentFile().mkdirs()) { 82 | System.out.println( 83 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 84 | } 85 | } 86 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 87 | try { 88 | downloadFileFromURL(url, outputFile); 89 | System.out.println("Done"); 90 | System.exit(0); 91 | } catch (Throwable e) { 92 | System.out.println("- Error downloading"); 93 | e.printStackTrace(); 94 | System.exit(1); 95 | } 96 | } 97 | 98 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 99 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 100 | String username = System.getenv("MVNW_USERNAME"); 101 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 102 | Authenticator.setDefault(new Authenticator() { 103 | @Override 104 | protected PasswordAuthentication getPasswordAuthentication() { 105 | return new PasswordAuthentication(username, password); 106 | } 107 | }); 108 | } 109 | URL website = new URL(urlString); 110 | ReadableByteChannel rbc; 111 | rbc = Channels.newChannel(website.openStream()); 112 | FileOutputStream fos = new FileOutputStream(destination); 113 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 114 | fos.close(); 115 | rbc.close(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /aop-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springboot-demo-major 7 | com.mutest 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | aop-demo 13 | 14 | 15 | 8 16 | 8 17 | 18 | 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-aop 24 | 2.0.2.RELEASE 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /aop-demo/src/main/java/com/aop/AopDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.aop; 2 | 3 | import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 7 | 8 | /** 9 | * @author muguozheng 10 | * @version 1.0.0 11 | * @createTime 2021/11/26 14:59 12 | * @description TODO 13 | */ 14 | @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class}) 15 | public class AopDemoApplication { 16 | public static void main(String[] args) { 17 | SpringApplication.run(AopDemoApplication.class, args); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /aop-demo/src/main/java/com/aop/advice/PermissionAdvice.java: -------------------------------------------------------------------------------- 1 | package com.aop.advice; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONObject; 5 | import org.aspectj.lang.ProceedingJoinPoint; 6 | import org.aspectj.lang.annotation.Around; 7 | import org.aspectj.lang.annotation.Aspect; 8 | import org.aspectj.lang.annotation.Pointcut; 9 | import org.springframework.core.annotation.Order; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * @author guozhengMu 14 | * @version 1.0 15 | * @createTime 2020/10/16 11:20 16 | * @description 17 | */ 18 | @Aspect 19 | @Component 20 | @Order(1) 21 | public class PermissionAdvice { 22 | // 定义一个切面 23 | @Pointcut("@annotation(com.aop.annotation.PermissionAnnotation)") 24 | private void permissionCheck() { 25 | } 26 | 27 | @Around("permissionCheck()") 28 | public Object permissionCheckFirst(ProceedingJoinPoint joinPoint) throws Throwable { 29 | System.out.println("===================第一个切面===================:" + System.currentTimeMillis()); 30 | 31 | //获取请求参数,详见接口类 32 | Object[] objects = joinPoint.getArgs(); 33 | Long id = ((JSONObject) objects[0]).getLong("id"); 34 | String name = ((JSONObject) objects[0]).getString("name"); 35 | System.out.println("id1->>>>>>>>>>>>>>>>>>>>>>" + id); 36 | System.out.println("name1->>>>>>>>>>>>>>>>>>>>>>" + name); 37 | 38 | // id小于0则抛出非法id的异常 39 | if (id < 0) { 40 | return JSON.parseObject("{\"message\":\"illegal id\",\"code\":403}"); 41 | } 42 | return joinPoint.proceed(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /aop-demo/src/main/java/com/aop/advice/PermissionSecondAdvice.java: -------------------------------------------------------------------------------- 1 | package com.aop.advice; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONObject; 5 | import org.aspectj.lang.ProceedingJoinPoint; 6 | import org.aspectj.lang.annotation.Around; 7 | import org.aspectj.lang.annotation.Aspect; 8 | import org.aspectj.lang.annotation.Pointcut; 9 | import org.springframework.core.annotation.Order; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * @author guozhengMu 14 | * @version 1.0 15 | * @createTime 2020/10/16 14:16 16 | * @description 17 | */ 18 | 19 | @Aspect 20 | @Component 21 | @Order(0) 22 | public class PermissionSecondAdvice { 23 | @Pointcut("@annotation(com.aop.annotation.PermissionAnnotation)") 24 | private void permissionCheck() { 25 | } 26 | 27 | @Around("permissionCheck()") 28 | public Object permissionCheckSecond(ProceedingJoinPoint joinPoint) throws Throwable { 29 | System.out.println("===================第二个切面===================:" + System.currentTimeMillis()); 30 | 31 | //获取请求参数,详见接口类 32 | Object[] objects = joinPoint.getArgs(); 33 | Long id = ((JSONObject) objects[0]).getLong("id"); 34 | String name = ((JSONObject) objects[0]).getString("name"); 35 | System.out.println("id->>>>>>>>>>>>>>>>>>>>>>" + id); 36 | System.out.println("name->>>>>>>>>>>>>>>>>>>>>>" + name); 37 | 38 | // name不是管理员则抛出异常 39 | if (!name.equals("admin")) { 40 | return JSON.parseObject("{\"message\":\"not admin\",\"code\":403}"); 41 | } 42 | return joinPoint.proceed(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /aop-demo/src/main/java/com/aop/annotation/PermissionAnnotation.java: -------------------------------------------------------------------------------- 1 | package com.aop.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author guozhengMu 7 | * @version 1.0 8 | * @createTime 2020/10/16 11:17 9 | * @description 10 | */ 11 | @Target(ElementType.METHOD) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Documented 14 | public @interface PermissionAnnotation { 15 | } 16 | -------------------------------------------------------------------------------- /aop-demo/src/main/java/com/aop/controller/PermissionController.java: -------------------------------------------------------------------------------- 1 | package com.aop.controller; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONObject; 5 | import com.aop.annotation.PermissionAnnotation; 6 | import org.springframework.web.bind.annotation.RequestBody; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestMethod; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | /** 12 | * @author guozhengMu 13 | * @version 1.0 14 | * @createTime 2020/10/16 11:38 15 | * @description 16 | */ 17 | 18 | @RestController 19 | @RequestMapping(value = "/permission") 20 | public class PermissionController { 21 | 22 | @RequestMapping(value = "/check", method = RequestMethod.POST) 23 | @PermissionAnnotation() 24 | public JSONObject getGroupList(@RequestBody JSONObject request) { 25 | return JSON.parseObject("{\"message\":\"SUCCESS\",\"code\":200}"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /aop-demo/src/main/java/com/aop/service/PermissionService.java: -------------------------------------------------------------------------------- 1 | package com.aop.service; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import org.springframework.stereotype.Service; 5 | import org.springframework.web.bind.annotation.RequestBody; 6 | 7 | /** 8 | * @author muguozheng 9 | * @version 1.0.0 10 | * @createTime 2021/11/26 15:05 11 | * @description TODO 12 | */ 13 | @Service 14 | public interface PermissionService { 15 | JSONObject getGroupList(@RequestBody JSONObject request); 16 | } 17 | -------------------------------------------------------------------------------- /aop-demo/src/main/java/com/aop/service/impl/PermissionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.aop.service.impl; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONObject; 5 | import com.aop.annotation.PermissionAnnotation; 6 | import com.aop.service.PermissionService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.web.bind.annotation.RequestBody; 9 | 10 | /** 11 | * @author muguozheng 12 | * @version 1.0.0 13 | * @createTime 2021/11/26 15:06 14 | * @description TODO 15 | */ 16 | @Service 17 | public class PermissionServiceImpl implements PermissionService { 18 | // todo 用这个注解修饰的方法(也可以修饰类),将被PermissionAdvice切入处理 19 | @PermissionAnnotation() 20 | @Override 21 | public JSONObject getGroupList(@RequestBody JSONObject request) { 22 | System.out.println("原始请求信息:" + request); 23 | return JSON.parseObject("{\"message\":\"SUCCESS\",\"code\":200}"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aop-demo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8085 3 | -------------------------------------------------------------------------------- /aop-demo/src/test/java/aop/AopTest.java: -------------------------------------------------------------------------------- 1 | package aop; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.aop.AopDemoApplication; 5 | import com.aop.service.PermissionService; 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.SpringJUnit4ClassRunner; 11 | 12 | /** 13 | * @author muguozheng 14 | * @version 1.0.0 15 | * @createTime 2021/11/26 15:00 16 | * @description TODO 17 | */ 18 | @RunWith(SpringJUnit4ClassRunner.class) 19 | @SpringBootTest(classes = AopDemoApplication.class) 20 | public class AopTest { 21 | @Autowired 22 | private PermissionService permissionService; 23 | 24 | @Test 25 | public void PermissionTest() { 26 | // 构造入参 27 | JSONObject request = new JSONObject(); 28 | request.put("id", 2); 29 | request.put("name", "hangman"); 30 | System.out.println(permissionService.getGroupList(request)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /elasticSearch-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springboot-demo-major 7 | com.mutest 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | elasticSearch-demo 13 | 14 | 15 | 8 16 | 8 17 | 18 | 19 | 20 | 21 | org.elasticsearch.client 22 | elasticsearch-rest-high-level-client 23 | 7.8.0 24 | 25 | 26 | org.elasticsearch.client 27 | elasticsearch-rest-client 28 | 7.8.0 29 | 30 | 31 | org.elasticsearch 32 | elasticsearch 33 | 7.8.0 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /elasticSearch-demo/src/main/java/com/es/EsDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.es; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * @author guozhengMu 8 | * @version 1.0 9 | * @createTime 2019/3/26 14:15 10 | * @description 启动类 11 | */ 12 | @SpringBootApplication 13 | public class EsDemoApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(EsDemoApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /elasticSearch-demo/src/main/java/com/es/config/ESConfig.java: -------------------------------------------------------------------------------- 1 | package com.es.config; 2 | 3 | import lombok.Data; 4 | import org.apache.http.HttpHost; 5 | import org.elasticsearch.client.RestClient; 6 | import org.elasticsearch.client.RestHighLevelClient; 7 | import org.springframework.boot.context.properties.ConfigurationProperties; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | /** 12 | * @author muguozheng 13 | * @version 1.0.0 14 | * @createTime 2021/6/22 15:48 15 | * @Description es基本操作,请勿执行 16 | */ 17 | @Configuration 18 | @ConfigurationProperties(prefix = "elasticsearch") 19 | @Data 20 | public class ESConfig { 21 | 22 | private String host; 23 | 24 | private Integer port; 25 | 26 | @Bean(destroyMethod = "close") 27 | public RestHighLevelClient client() { 28 | return new RestHighLevelClient(RestClient.builder(new HttpHost(host, port))); 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /elasticSearch-demo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8092 3 | spring: 4 | datasource: 5 | type: com.alibaba.druid.pool.DruidDataSource 6 | driver-class-name: com.mysql.jdbc.Driver 7 | url: jdbc:mysql://localhost:3306?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false 8 | username: root 9 | password: 10 | elasticsearch: 11 | host: xx.xxx.xxx.xxx 12 | port: 9200 -------------------------------------------------------------------------------- /elasticSearch-demo/src/test/java/es/IndexTest.java: -------------------------------------------------------------------------------- 1 | package es; 2 | 3 | import com.es.EsDemoApplication; 4 | import org.elasticsearch.client.IndicesClient; 5 | import org.elasticsearch.client.RequestOptions; 6 | import org.elasticsearch.client.RestHighLevelClient; 7 | import org.elasticsearch.client.indices.CreateIndexRequest; 8 | import org.elasticsearch.client.indices.CreateIndexResponse; 9 | import org.elasticsearch.client.indices.GetIndexRequest; 10 | import org.elasticsearch.client.indices.GetIndexResponse; 11 | import org.junit.Test; 12 | import org.junit.runner.RunWith; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.test.context.SpringBootTest; 15 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 16 | 17 | import java.io.IOException; 18 | import java.util.Map; 19 | 20 | /** 21 | * @author muguozheng 22 | * @version 1.0.0 23 | * @createTime 2021/11/26 17:38 24 | * @description 索引测试 25 | */ 26 | @RunWith(SpringJUnit4ClassRunner.class) 27 | @SpringBootTest(classes = EsDemoApplication.class) 28 | public class IndexTest { 29 | @Autowired 30 | private RestHighLevelClient client; 31 | 32 | private static final String PERSON_INDEX = "person"; 33 | 34 | private static final int START_OFFSET = 0; 35 | 36 | private static final int MAX_COUNT = 2000; 37 | 38 | /** 39 | * 查询索引 40 | */ 41 | @Test 42 | public void queryIndex() throws IOException { 43 | IndicesClient indices = client.indices(); 44 | 45 | GetIndexRequest getRequest = new GetIndexRequest("person"); 46 | GetIndexResponse response = indices.get(getRequest, RequestOptions.DEFAULT); 47 | System.out.println(response.getMappings()); 48 | Map mappings = response.getMappings(); 49 | //iter 提示foreach 50 | for (Object key : mappings.keySet()) { 51 | System.out.println(key + "===" + mappings.get(key)); 52 | } 53 | } 54 | 55 | /** 56 | * 添加索引 57 | * 58 | * @throws IOException e 59 | */ 60 | @Test 61 | public void addIndex() throws IOException { 62 | //1.使用client获取操作索引对象 63 | IndicesClient indices = client.indices(); 64 | //2.具体操作获取返回值 65 | //2.1 设置索引名称 66 | CreateIndexRequest createIndexRequest = new CreateIndexRequest("persons"); 67 | 68 | CreateIndexResponse createIndexResponse = indices.create(createIndexRequest, RequestOptions.DEFAULT); 69 | //3.根据返回值判断结果 70 | System.out.println(createIndexResponse); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /mongodb-demo/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /mongodb-demo/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/mongodb-demo/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /mongodb-demo/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /mongodb-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | springboot-demo-major 7 | com.mutest 8 | 1.0-SNAPSHOT 9 | 10 | 11 | mongodb-demo 12 | 0.0.1-SNAPSHOT 13 | mongodb-demo 14 | Demo project for Spring Boot 15 | 16 | 1.8 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-data-mongodb 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-maven-plugin 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /mongodb-demo/src/main/java/com/mutest/mongo/MongoApplication.java: -------------------------------------------------------------------------------- 1 | package com.mutest.mongo; 2 | 3 | import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 7 | 8 | @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class}) 9 | public class MongoApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(MongoApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /mongodb-demo/src/main/java/com/mutest/mongo/dao/UserMongoDbDao.java: -------------------------------------------------------------------------------- 1 | package com.mutest.mongo.dao; 2 | 3 | import com.mutest.mongo.model.User; 4 | import org.springframework.stereotype.Repository; 5 | 6 | /** 7 | * @author muguozheng 8 | * @version 1.0.0 9 | * @createTime 2022/8/30 16:00 10 | * @description 具体类的mongo操作 11 | */ 12 | @Repository 13 | public class UserMongoDbDao extends MongoDbDao { 14 | @Override 15 | protected Class getEntityClass() { 16 | return User.class; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /mongodb-demo/src/main/java/com/mutest/mongo/model/User.java: -------------------------------------------------------------------------------- 1 | package com.mutest.mongo.model; 2 | 3 | import lombok.Data; 4 | import org.springframework.data.mongodb.core.mapping.Document; 5 | 6 | /** 7 | * @author muguozheng 8 | * @version 1.0.0 9 | * @createTime 2022/8/30 14:21 10 | * @description 对应mongodb的实体类 11 | */ 12 | @Data 13 | @Document("user") 14 | public class User { 15 | private String id; 16 | private String username; 17 | private String password; 18 | private Integer age; 19 | private String city; 20 | private String createTime; 21 | } 22 | -------------------------------------------------------------------------------- /mongodb-demo/src/main/java/com/mutest/mongo/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.mutest.mongo.service; 2 | 3 | import com.mutest.mongo.model.User; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author muguozheng 9 | * @version 1.0.0 10 | * @createTime 2022/8/30 15:58 11 | * @description 服务层 12 | */ 13 | public interface UserService { 14 | void saveUser(User user); 15 | 16 | List queryList(User user); 17 | } 18 | -------------------------------------------------------------------------------- /mongodb-demo/src/main/java/com/mutest/mongo/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.mutest.mongo.service.impl; 2 | 3 | import com.mutest.mongo.dao.UserMongoDbDao; 4 | import com.mutest.mongo.model.User; 5 | import com.mutest.mongo.service.UserService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author muguozheng 13 | * @version 1.0.0 14 | * @createTime 2022/8/30 15:59 15 | * @description mongo测试类 16 | */ 17 | @Service 18 | public class UserServiceImpl implements UserService { 19 | @Autowired 20 | private UserMongoDbDao userMongoDbDao; 21 | 22 | @Override 23 | public void saveUser(User user) { 24 | userMongoDbDao.save(user); 25 | } 26 | 27 | @Override 28 | public List queryList(User user) { 29 | return userMongoDbDao.queryList(user); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /mongodb-demo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8031 3 | 4 | spring: 5 | data: 6 | mongodb: 7 | host: xxx 8 | port: 27017 9 | database: testPlatform 10 | authentication-database: admin 11 | username: muguozheng 12 | password: xxx -------------------------------------------------------------------------------- /mongodb-demo/src/test/java/com/mutest/mongo/UserTest.java: -------------------------------------------------------------------------------- 1 | package com.mutest.mongo; 2 | 3 | import com.mutest.mongo.model.User; 4 | import com.mutest.mongo.service.UserService; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 10 | 11 | import java.time.LocalDateTime; 12 | import java.time.format.DateTimeFormatter; 13 | 14 | /** 15 | * @author muguozheng 16 | * @version 1.0.0 17 | * @createTime 2022/8/30 16:08 18 | * @description mongo测试 19 | */ 20 | @RunWith(SpringJUnit4ClassRunner.class) 21 | @SpringBootTest(classes = MongoApplication.class) 22 | public class UserTest { 23 | @Autowired 24 | private UserService userService; 25 | 26 | @Test 27 | public void insertUserTest() { 28 | User user = new User(); 29 | user.setId("522345"); 30 | user.setUsername("万楚良"); 31 | user.setPassword("12342345"); 32 | user.setAge(19); 33 | user.setCity("北京市"); 34 | user.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); 35 | 36 | userService.saveUser(user); 37 | } 38 | 39 | @Test 40 | public void queryListTest() { 41 | User user = new User(); 42 | user.setCity("北京市"); 43 | user.setAge(19); 44 | 45 | System.out.println(userService.queryList(user)); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.mutest 8 | springboot-demo-major 9 | pom 10 | 1.0-SNAPSHOT 11 | 12 | aop-demo 13 | springboot-layui-demo 14 | elasticSearch-demo 15 | rocketmq-demo 16 | quartz-demo 17 | stream-demo 18 | websocket-demo 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-parent 24 | 2.5.9 25 | 26 | 27 | 28 | 29 | 8 30 | 8 31 | 1.8 32 | 2.8.0 33 | 23.0 34 | 3.17 35 | 0.9.0 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter 42 | 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-test 47 | 2.2.2.RELEASE 48 | test 49 | 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-starter-web 54 | 55 | 56 | 57 | 58 | org.projectlombok 59 | lombok 60 | 61 | 62 | 63 | com.alibaba 64 | fastjson 65 | 1.2.79 66 | 67 | 68 | 69 | org.apache.commons 70 | commons-lang3 71 | 72 | 73 | 74 | 75 | mysql 76 | mysql-connector-java 77 | 8.0.18 78 | runtime 79 | 80 | 81 | 82 | org.mybatis.spring.boot 83 | mybatis-spring-boot-starter 84 | 2.0.1 85 | 86 | 87 | 88 | com.alibaba 89 | druid-spring-boot-starter 90 | 1.1.9 91 | 92 | 93 | 94 | com.github.pagehelper 95 | pagehelper-spring-boot-starter 96 | 1.2.5 97 | 98 | 99 | 100 | junit 101 | junit 102 | test 103 | 104 | 105 | org.springframework 106 | spring-test 107 | 5.2.2.RELEASE 108 | test 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | org.springframework.boot 117 | spring-boot-maven-plugin 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /quartz-demo/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /quartz-demo/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/quartz-demo/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /quartz-demo/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /quartz-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | springboot-demo-major 7 | com.mutest 8 | 1.0-SNAPSHOT 9 | 10 | 11 | com.quartz 12 | demo 13 | 0.0.1-SNAPSHOT 14 | quartz-demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-quartz 24 | 25 | 26 | com.mchange 27 | c3p0 28 | 0.9.5.2 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-maven-plugin 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /quartz-demo/src/main/java/com/quartz/demo/QuartzDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.quartz.demo; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @MapperScan(value = "com.quartz.demo.mapper") 9 | public class QuartzDemoApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(QuartzDemoApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /quartz-demo/src/main/java/com/quartz/demo/config/ExecutorConfig.java: -------------------------------------------------------------------------------- 1 | package com.quartz.demo.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 6 | 7 | import java.util.concurrent.Executor; 8 | import java.util.concurrent.ThreadPoolExecutor; 9 | 10 | /** 11 | * @author muguozheng 12 | * @version 1.0.0 13 | * @createTime 2022/4/12 20:27 14 | * @description 线程池配置 15 | */ 16 | @Configuration 17 | public class ExecutorConfig { 18 | @Bean("asyncExecutor") 19 | public Executor executorInit() { 20 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); 21 | //配置核心线程数 22 | executor.setCorePoolSize(8); 23 | //配置最大线程数 24 | executor.setMaxPoolSize(16); 25 | //配置队列大小 26 | executor.setQueueCapacity(10000); 27 | //配置线程池中的线程的名称前缀 28 | executor.setThreadNamePrefix("thread-"); 29 | // rejection-policy:当pool已经达到max size的时候,如何处理新任务 30 | // CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行 31 | executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); 32 | //执行初始化 33 | executor.initialize(); 34 | return executor; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /quartz-demo/src/main/java/com/quartz/demo/config/SchedulerConfig.java: -------------------------------------------------------------------------------- 1 | package com.quartz.demo.config; 2 | 3 | import org.quartz.Scheduler; 4 | import org.quartz.ee.servlet.QuartzInitializerListener; 5 | import org.springframework.beans.factory.config.PropertiesFactoryBean; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.core.io.ClassPathResource; 9 | import org.springframework.scheduling.quartz.SchedulerFactoryBean; 10 | 11 | import java.io.IOException; 12 | import java.util.Properties; 13 | 14 | /** 15 | * @author muguozheng 16 | * @version 1.0.0 17 | * @createTime 2022/4/19 18:46 18 | * @description Quartz配置 19 | */ 20 | @Configuration 21 | public class SchedulerConfig { 22 | /** 23 | * 读取quartz.properties,将值初始化 24 | * 25 | * @return Properties 26 | * @throws IOException io 27 | */ 28 | @Bean 29 | public Properties quartzProperties() throws IOException { 30 | PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); 31 | propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties")); 32 | propertiesFactoryBean.afterPropertiesSet(); 33 | return propertiesFactoryBean.getObject(); 34 | } 35 | 36 | /** 37 | * 将配置文件的数据加载到SchedulerFactoryBean中 38 | * 39 | * @return SchedulerFactoryBean 40 | * @throws IOException io 41 | */ 42 | @Bean 43 | public SchedulerFactoryBean schedulerFactoryBean() throws IOException { 44 | SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean(); 45 | schedulerFactoryBean.setQuartzProperties(quartzProperties()); 46 | return schedulerFactoryBean; 47 | } 48 | 49 | /** 50 | * 初始化监听器 51 | * 52 | * @return QuartzInitializerListener 53 | */ 54 | @Bean 55 | public QuartzInitializerListener executorListener() { 56 | return new QuartzInitializerListener(); 57 | } 58 | 59 | /** 60 | * 获得Scheduler对象 61 | * 62 | * @return Scheduler 63 | * @throws IOException io 64 | */ 65 | @Bean 66 | public Scheduler scheduler() throws IOException { 67 | return schedulerFactoryBean().getScheduler(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /quartz-demo/src/main/java/com/quartz/demo/controller/QuartzController.java: -------------------------------------------------------------------------------- 1 | package com.quartz.demo.controller; 2 | 3 | import com.quartz.demo.mapper.PersonMapper; 4 | import com.quartz.demo.schedule.MajorJob; 5 | import com.quartz.demo.utils.QuartzUtils; 6 | import org.quartz.*; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import java.util.Date; 13 | 14 | /** 15 | * @author muguozheng 16 | * @version 1.0.0 17 | * @createTime 2022/4/13 15:56 18 | * @description 定时任务控制层 19 | */ 20 | @RestController 21 | @RequestMapping("/quartz") 22 | public class QuartzController { 23 | @Autowired 24 | private PersonMapper personMapper; 25 | 26 | static String jobName = "jobName-1"; 27 | static String triggerName = "triggerName-1"; 28 | static String jobGroupName = "job-group"; 29 | static String triggerGroupName = "trigger-group"; 30 | 31 | /** 32 | * 任务启动 33 | * 34 | * @return string 35 | */ 36 | @RequestMapping(value = "/trigger/start", method = RequestMethod.GET) 37 | public String startJob() { 38 | // 构建定时任务 39 | JobDetail jobDetail = JobBuilder.newJob(MajorJob.class) 40 | .withIdentity(jobName, jobGroupName) 41 | .usingJobData("jobName", "QuartzDemo") 42 | .build(); 43 | // 将mapper放入jobDetail的jobDataMap中 44 | // jobDetail.getJobDataMap().put("personMapper", personMapper); 45 | 46 | Date start = new Date(); 47 | start.setTime(start.getTime() + 10000); 48 | Date end = new Date(); 49 | end.setTime(end.getTime() + 90000); 50 | 51 | Trigger trigger = TriggerBuilder.newTrigger() 52 | .withIdentity(triggerName, triggerGroupName) 53 | .startNow() // 定义开始时间 54 | .endAt(end) // 定义结束时间 55 | .withSchedule(SimpleScheduleBuilder.repeatSecondlyForTotalCount(10, 10)) 56 | .build(); 57 | QuartzUtils.startJob(jobDetail, trigger); 58 | return "启动成功!"; 59 | } 60 | 61 | /** 62 | * 暂停触发器 63 | * 64 | * @return string 65 | */ 66 | @RequestMapping(value = "/trigger/pause", method = RequestMethod.GET) 67 | public String pauseTrigger() { 68 | QuartzUtils.pauseTrigger(triggerName, triggerGroupName); 69 | return "Trigger暂停成功!"; 70 | } 71 | 72 | /** 73 | * 恢复触发器 74 | * 75 | * @return string 76 | */ 77 | @RequestMapping(value = "/trigger/resume", method = RequestMethod.GET) 78 | public String resumeTrigger() { 79 | QuartzUtils.resumeTrigger(triggerName, triggerGroupName); 80 | return "Trigger重启成功!"; 81 | } 82 | 83 | /** 84 | * 关闭触发器 85 | * 86 | * @return string 87 | */ 88 | @RequestMapping(value = "/trigger/shutdown", method = RequestMethod.GET) 89 | public String shutdown() { 90 | QuartzUtils.removeJob(jobName, jobGroupName, triggerName, triggerGroupName); 91 | return "停止成功"; 92 | } 93 | 94 | /** 95 | * 查询触发器状态 96 | * 97 | * @return string 98 | */ 99 | @RequestMapping(value = "/trigger/state", method = RequestMethod.GET) 100 | public String getTriggerState() { 101 | return QuartzUtils.getTriggerState(triggerName, triggerGroupName); 102 | } 103 | 104 | /** 105 | * 查询触发器是否存在 106 | * 107 | * @return true of false 108 | * @throws SchedulerException e 109 | */ 110 | @RequestMapping(value = "/trigger/exists", method = RequestMethod.GET) 111 | public boolean checkTriggerExists() throws SchedulerException { 112 | TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, triggerGroupName); 113 | return QuartzUtils.checkExists(triggerKey); 114 | } 115 | 116 | /** 117 | * 暂停job 118 | * 119 | * @return string 120 | */ 121 | @RequestMapping(value = "/job/pause", method = RequestMethod.GET) 122 | public String pauseJob() { 123 | QuartzUtils.pauseJob(jobName, jobGroupName); 124 | return "JOB暂停成功!"; 125 | } 126 | 127 | /** 128 | * 恢复job 129 | * 130 | * @return string 131 | */ 132 | @RequestMapping(value = "/job/resume", method = RequestMethod.GET) 133 | public String resumeJob() { 134 | QuartzUtils.resumeJob(jobName, jobGroupName); 135 | return "JOB恢复成功!"; 136 | } 137 | 138 | /** 139 | * 查询job是否存在 140 | * 141 | * @return true or false 142 | * @throws SchedulerException e 143 | */ 144 | @RequestMapping(value = "/job/exists", method = RequestMethod.GET) 145 | public boolean checkJobExists() throws SchedulerException { 146 | JobKey jobKey = JobKey.jobKey(jobName, jobGroupName); 147 | return QuartzUtils.checkExists(jobKey); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /quartz-demo/src/main/java/com/quartz/demo/entity/Person.java: -------------------------------------------------------------------------------- 1 | package com.quartz.demo.entity; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author muguozheng 7 | * @version 1.0.0 8 | * @createTime 2022/4/18 16:54 9 | * @description 人员表 10 | */ 11 | @Data 12 | public class Person { 13 | private Long id; 14 | private String name; 15 | private Integer age; 16 | private String sex; 17 | private String address; 18 | private String sect; 19 | private String skill; 20 | private Integer power; 21 | private String createTime; 22 | private String modifyTime; 23 | } 24 | -------------------------------------------------------------------------------- /quartz-demo/src/main/java/com/quartz/demo/mapper/PersonMapper.java: -------------------------------------------------------------------------------- 1 | package com.quartz.demo.mapper; 2 | 3 | import com.quartz.demo.entity.Person; 4 | import org.apache.ibatis.annotations.Select; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author muguozheng 11 | * @version 1.0.0 12 | * @createTime 2022/4/18 16:57 13 | * @description person数据层 14 | */ 15 | @Service("personMapper") 16 | public interface PersonMapper { 17 | @Select("select id,name,age,sex,address,sect,skill,power,create_time createTime,modify_time modifyTime from mytest.persons") 18 | List queryList(); 19 | } 20 | -------------------------------------------------------------------------------- /quartz-demo/src/main/java/com/quartz/demo/schedule/MajorJob.java: -------------------------------------------------------------------------------- 1 | package com.quartz.demo.schedule; 2 | 3 | import com.quartz.demo.entity.Person; 4 | import com.quartz.demo.mapper.PersonMapper; 5 | import com.quartz.demo.utils.SpringContextJobUtil; 6 | import org.quartz.Job; 7 | import org.quartz.JobDataMap; 8 | import org.quartz.JobExecutionContext; 9 | 10 | import java.time.LocalDateTime; 11 | import java.time.format.DateTimeFormatter; 12 | import java.util.List; 13 | 14 | /** 15 | * @author muguozheng 16 | * @version 1.0.0 17 | * @createTime 2022/4/18 16:47 18 | * @description 更复杂一些的job 19 | */ 20 | public class MajorJob implements Job { 21 | @Override 22 | public void execute(JobExecutionContext jobExecutionContext) { 23 | JobDataMap dataMap = jobExecutionContext.getJobDetail().getJobDataMap(); 24 | String jobName = dataMap.getString("jobName"); 25 | // PersonMapper personMapper = (PersonMapper) dataMap.get("personMapper"); 26 | PersonMapper personMapper = (PersonMapper) SpringContextJobUtil.getBean("personMapper"); 27 | List personList = personMapper.queryList(); 28 | 29 | System.out.println(Thread.currentThread().getName() + "--" 30 | + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now()) + "--" 31 | + jobName + "--" + personList); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /quartz-demo/src/main/java/com/quartz/demo/schedule/SimpleJob.java: -------------------------------------------------------------------------------- 1 | package com.quartz.demo.schedule; 2 | 3 | import org.quartz.Job; 4 | import org.quartz.JobExecutionContext; 5 | 6 | import java.time.LocalDateTime; 7 | import java.time.format.DateTimeFormatter; 8 | 9 | /** 10 | * @author muguozheng 11 | * @version 1.0.0 12 | * @createTime 2022/4/12 20:30 13 | * @description 14 | */ 15 | public class SimpleJob implements Job { 16 | @Override 17 | public void execute(JobExecutionContext jobExecutionContext) { 18 | // 创建一个事件,下面仅创建一个输出语句作演示 19 | System.out.println(Thread.currentThread().getName() + "--" 20 | + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now())); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /quartz-demo/src/main/java/com/quartz/demo/utils/QuartzUtils.java: -------------------------------------------------------------------------------- 1 | package com.quartz.demo.utils; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.quartz.*; 6 | import org.quartz.impl.StdSchedulerFactory; 7 | 8 | /** 9 | * @author muguozheng 10 | * @version 1.0.0 11 | * @createTime 2021/12/2 11:23 12 | * @description 定时任务工具方法 13 | */ 14 | @Slf4j 15 | public class QuartzUtils { 16 | static SchedulerFactory schedulerFactory = new StdSchedulerFactory(); 17 | static Scheduler scheduler; 18 | 19 | static { 20 | try { 21 | scheduler = schedulerFactory.getScheduler(); 22 | } catch (SchedulerException e) { 23 | e.printStackTrace(); 24 | } 25 | } 26 | 27 | /** 28 | * 获取定时任务状态 29 | * 30 | * @param triggerName 触发器名称 31 | * @param triggerGroupName 触发器组名 32 | * @return 状态名 33 | */ 34 | public static String getTriggerState(String triggerName, String triggerGroupName) { 35 | try { 36 | TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, triggerGroupName); 37 | Trigger.TriggerState triggerState = scheduler.getTriggerState(triggerKey); 38 | return triggerState.name(); 39 | } catch (SchedulerException e) { 40 | e.printStackTrace(); 41 | } 42 | return null; 43 | } 44 | 45 | /** 46 | * 自行传入任务和触发器方式启动一个任务 47 | * 48 | * @param jobDetail 任务详情 49 | * @param trigger 触发器 50 | */ 51 | public static void startJob(JobDetail jobDetail, Trigger trigger) { 52 | try { 53 | scheduler.scheduleJob(jobDetail, trigger); 54 | scheduler.start(); 55 | System.out.println("当前触发器:" + scheduler.getTriggerGroupNames()); 56 | } catch (SchedulerException e) { 57 | log.error("定时任务异常,jobDetail:{},e:{}", JSON.toJSON(jobDetail), e.getMessage()); 58 | e.printStackTrace(); 59 | } 60 | } 61 | 62 | /** 63 | * 暂停触发器 64 | * 65 | * @param triggerName triggerName 66 | * @param triggerGroupName triggerGroupName 67 | * @return true or false 68 | */ 69 | public static boolean pauseTrigger(String triggerName, String triggerGroupName) { 70 | 71 | try { 72 | TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, triggerGroupName); 73 | // 检查任务状态,只有运行态才允许暂停 74 | String stateName = getTriggerState(triggerName, triggerGroupName); 75 | if (StringUtils.isNull(stateName) || !stateName.equals("NORMAL")) { 76 | System.out.println("当前任务状态非法,state:" + stateName); 77 | return false; 78 | } 79 | scheduler.pauseTrigger(triggerKey); 80 | return true; 81 | } catch (SchedulerException e) { 82 | e.printStackTrace(); 83 | } 84 | return false; 85 | } 86 | 87 | /** 88 | * 恢复触发器运行 89 | * 90 | * @param triggerName triggerName 91 | * @param triggerGroupName triggerGroupName 92 | * @return true or false 93 | */ 94 | public static boolean resumeTrigger(String triggerName, String triggerGroupName) { 95 | 96 | try { 97 | TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, triggerGroupName); 98 | // 检查任务状态,只有暂停状态才允许恢复 99 | String stateName = getTriggerState(triggerName, triggerGroupName); 100 | if (StringUtils.isNull(stateName) || !stateName.equals("PAUSED")) { 101 | System.err.println("当前任务状态非法,state:" + stateName); 102 | return false; 103 | } 104 | scheduler.resumeTrigger(triggerKey); 105 | return true; 106 | } catch (SchedulerException e) { 107 | e.printStackTrace(); 108 | } 109 | return false; 110 | } 111 | 112 | /** 113 | * 暂停job 114 | * 115 | * @param jobName jobName 116 | * @param jobGroupName jobGroupName 117 | * @return true or false 118 | */ 119 | public static boolean pauseJob(String jobName, String jobGroupName) { 120 | 121 | try { 122 | JobKey jobKey = JobKey.jobKey(jobName, jobGroupName); 123 | scheduler.pauseJob(jobKey); 124 | return true; 125 | } catch (SchedulerException e) { 126 | e.printStackTrace(); 127 | } 128 | return false; 129 | } 130 | 131 | /** 132 | * 恢复job 133 | * 134 | * @param jobName jobName 135 | * @param jobGroupName jobGroupName 136 | * @return true or false 137 | */ 138 | public static boolean resumeJob(String jobName, String jobGroupName) { 139 | 140 | try { 141 | JobKey jobKey = JobKey.jobKey(jobName, jobGroupName); 142 | scheduler.resumeJob(jobKey); 143 | return true; 144 | } catch (SchedulerException e) { 145 | e.printStackTrace(); 146 | } 147 | return false; 148 | } 149 | 150 | /** 151 | * 终止并删除触发器和任务 152 | * 153 | * @param jobName 任务名称 154 | * @param jobGroupName 任务组名称 155 | * @param triggerName 触发器名称 156 | * @param triggerGroupName 触发器组名称 157 | * @return true or false 158 | */ 159 | public static boolean removeJob(String jobName, String jobGroupName, String triggerName, String triggerGroupName) { 160 | try { 161 | TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, triggerGroupName); 162 | JobKey jobKey = JobKey.jobKey(jobName, jobGroupName); 163 | Trigger trigger = scheduler.getTrigger(triggerKey); 164 | if (null == trigger) { 165 | return false; 166 | } 167 | scheduler.pauseTrigger(triggerKey); // 停止触发器 168 | scheduler.unscheduleJob(triggerKey); // 解除触发器 169 | scheduler.deleteJob(jobKey); // 删除任务 170 | return true; 171 | } catch (Exception e) { 172 | e.printStackTrace(); 173 | } 174 | return false; 175 | } 176 | 177 | /** 178 | * 检查job是否存在scheduler中 179 | * 180 | * @param jobKey jobKey 181 | * @return true or false 182 | * @throws SchedulerException e 183 | */ 184 | public static boolean checkExists(JobKey jobKey) throws SchedulerException { 185 | return scheduler.checkExists(jobKey); 186 | } 187 | 188 | /** 189 | * 检查trigger是否存在scheduler中 190 | * 191 | * @param triggerKey triggerKey 192 | * @return true or false 193 | * @throws SchedulerException e 194 | */ 195 | public static boolean checkExists(TriggerKey triggerKey) throws SchedulerException { 196 | return scheduler.checkExists(triggerKey); 197 | } 198 | } -------------------------------------------------------------------------------- /quartz-demo/src/main/java/com/quartz/demo/utils/SpringContextJobUtil.java: -------------------------------------------------------------------------------- 1 | package com.quartz.demo.utils; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.Locale; 9 | 10 | /** 11 | * @author muguozheng 12 | * @version 1.0.0 13 | * @createTime 2022/4/19 19:11 14 | * @description bean工具类 15 | */ 16 | @Component 17 | public class SpringContextJobUtil implements ApplicationContextAware { 18 | private static ApplicationContext context; 19 | 20 | @Override 21 | @SuppressWarnings("static-access") 22 | public void setApplicationContext(ApplicationContext contex) throws BeansException { 23 | this.context = contex; 24 | } 25 | 26 | /** 27 | * 根据name获取bean 28 | * 29 | * @param beanName name 30 | * @return bean对象 31 | */ 32 | public static Object getBean(String beanName) { 33 | return context.getBean(beanName); 34 | } 35 | 36 | public static String getMessage(String key) { 37 | return context.getMessage(key, null, Locale.getDefault()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /quartz-demo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8089 3 | 4 | spring: 5 | datasource: 6 | type: com.alibaba.druid.pool.DruidDataSource 7 | driver-class-name: com.mysql.jdbc.Driver 8 | url: jdbc:mysql://localhost:3306?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false 9 | username: root 10 | password: root 11 | 12 | mybatis: 13 | type-aliases-package: com.quartz.demo.entity 14 | configuration: 15 | map-underscore-to-camel-case: true # 驼峰命名规范 16 | -------------------------------------------------------------------------------- /quartz-demo/src/main/resources/persons.sql: -------------------------------------------------------------------------------- 1 | /* 2 | SQLyog v10.2 3 | MySQL - 5.7.36-0ubuntu0.18.04.1 : Database - mytest 4 | ********************************************************************* 5 | */ 6 | 7 | /*!40101 SET NAMES utf8 */; 8 | 9 | /*!40101 SET SQL_MODE=''*/; 10 | 11 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 12 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 13 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 14 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 15 | CREATE DATABASE /*!32312 IF NOT EXISTS*/`mytest` /*!40100 DEFAULT CHARACTER SET utf8 */; 16 | 17 | USE `mytest`; 18 | 19 | /*Table structure for table `persons` */ 20 | 21 | DROP TABLE IF EXISTS `persons`; 22 | 23 | CREATE TABLE `persons` ( 24 | `id` int(10) NOT NULL AUTO_INCREMENT COMMENT 'id', 25 | `name` varchar(10) DEFAULT NULL COMMENT '姓名', 26 | `age` int(10) DEFAULT NULL COMMENT '年龄', 27 | `sex` varchar(5) DEFAULT NULL COMMENT '性别', 28 | `address` varchar(50) DEFAULT NULL COMMENT '住址', 29 | `sect` varchar(10) DEFAULT NULL COMMENT '门派', 30 | `skill` varchar(10) DEFAULT NULL COMMENT '绝技', 31 | `power` int(10) DEFAULT NULL COMMENT '战力值', 32 | `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 33 | `modify_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', 34 | PRIMARY KEY (`id`) 35 | ) ENGINE=InnoDB AUTO_INCREMENT=451 DEFAULT CHARSET=utf8; 36 | 37 | /*Data for the table `persons` */ 38 | 39 | insert into `persons`(`id`,`name`,`age`,`sex`,`address`,`sect`,`skill`,`power`,`create_time`,`modify_time`) values (427,'张无忌',16,'男','昆仑山光明顶','明教','九阳神功',99,'2021-11-26 16:29:38','2021-11-26 16:29:38'),(428,'赵敏',13,'女','大都','朝廷','杂门武功',30,'2021-11-26 16:32:15','2021-11-26 16:32:15'),(429,'周芷若',13,'女','峨眉山','峨嵋派','九阴真经',80,'2021-11-26 16:32:40','2021-11-26 16:32:40'),(430,'小昭',12,'女','昆仑山光明顶','明教','乾坤大挪移',40,'2021-11-26 16:33:27','2021-11-26 16:33:27'),(431,'殷离',12,'女','峨眉山','天鹰教','千蛛万毒手',50,'2021-11-26 16:36:12','2021-11-26 16:36:12'),(432,'杨逍',30,'男','昆仑山光明顶','明教','乾坤大挪移',80,'2021-11-26 17:12:10','2021-11-26 17:12:10'),(433,'范遥',29,'男','昆仑山光明顶','明教','吸星大法',79,'2021-11-26 17:14:03','2021-11-26 17:14:03'),(434,'谢逊',31,'男','冰火岛','明教','七伤拳',79,'2021-11-26 17:15:40','2021-11-26 17:15:40'),(435,'殷天正',40,'男','峨眉山','天鹰教','鹰爪擒拿手',75,'2021-11-26 17:16:49','2021-11-26 17:16:49'),(436,'黛绮丝',35,'女','灵蛇岛','明教','波斯武学',72,'2021-11-26 17:18:48','2021-11-26 17:18:48'),(437,'韦一笑',40,'男','昆仑山光明顶','明教','寒冰绵掌',68,'2021-11-26 17:19:45','2021-11-26 17:19:45'),(438,'宋远桥',41,'男','武当山','武当派','太极功',78,'2021-11-26 17:23:47','2021-11-26 17:23:47'),(439,'俞莲舟',39,'男','武当山','武当派','太极功',75,'2021-11-26 17:24:29','2021-11-26 17:24:29'),(440,'俞岱岩',38,'男','武当山','武当派','太极功',75,'2021-11-26 17:24:55','2021-11-26 17:24:55'),(441,'张松溪',37,'男','武当山','武当派','太极功',75,'2021-11-26 17:25:41','2021-11-26 17:25:41'),(442,'张翠山',36,'男','冰火岛','武当派','太极功',77,'2021-11-26 17:26:10','2021-11-26 17:26:10'),(443,'殷梨亭',33,'男','武当山','武当派','太极功',76,'2021-11-26 17:26:37','2021-11-26 17:26:37'),(444,'莫声谷',30,'男','武当山','武当派','太极功',70,'2021-11-26 17:27:03','2021-11-26 17:27:03'),(445,'空见',50,'男','少林寺','少林派','少林龙爪手',80,'2021-11-26 17:29:06','2021-11-26 17:29:06'),(446,'空闻',49,'男','少林寺','少林派','大力金刚指',80,'2021-11-26 17:30:00','2021-11-26 17:30:00'),(447,'空智',47,'男','少林寺','少林派','少林九阳功',82,'2021-11-26 17:30:56','2021-11-26 17:30:56'),(448,'空性',45,'男','少林寺','少林派','少林七十二绝技',78,'2021-11-26 17:31:57','2021-11-26 17:31:57'),(449,'殷素素',33,'女','冰火岛','天鹰教','杂学',65,'2021-11-26 17:32:53','2021-11-26 17:32:53'),(450,'灭绝师太',33,'女','峨眉山','峨嵋派','峨嵋剑法',80,'2021-11-26 17:33:41','2021-11-26 17:33:41'); 40 | 41 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 42 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 43 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 44 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 45 | -------------------------------------------------------------------------------- /quartz-demo/src/main/resources/quartz.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/quartz-demo/src/main/resources/quartz.properties -------------------------------------------------------------------------------- /quartz-demo/src/test/java/com/quartz/demo/MultiQuartzTest.java: -------------------------------------------------------------------------------- 1 | package com.quartz.demo; 2 | 3 | import com.quartz.demo.schedule.SimpleJob; 4 | import org.junit.Test; 5 | import org.quartz.*; 6 | import org.quartz.impl.StdSchedulerFactory; 7 | 8 | import java.util.concurrent.TimeUnit; 9 | 10 | /** 11 | * @author muguozheng 12 | * @version 1.0.0 13 | * @createTime 2022/4/12 21:02 14 | * @description 多定时任务测试 15 | */ 16 | public class MultiQuartzTest { 17 | 18 | @Test 19 | public void multiJobTest() throws SchedulerException, InterruptedException { 20 | // 1、创建Scheduler(调度器) 21 | SchedulerFactory schedulerFactory = new StdSchedulerFactory(); 22 | Scheduler scheduler = schedulerFactory.getScheduler(); 23 | // 2、创建JobDetail实例,与执行内容类SimpleJob绑定,注意要设置 .storeDurably(),否则报错 24 | JobDetail jobDetail = JobBuilder.newJob(SimpleJob.class) 25 | .withIdentity("job1", "job-group") 26 | .storeDurably() 27 | .build(); 28 | 29 | // 3、分别构建Trigger实例 30 | Trigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger1", "trigger-group") 31 | .startNow()//立即生效 32 | .forJob(jobDetail) 33 | .withSchedule(SimpleScheduleBuilder 34 | .simpleSchedule() 35 | .withIntervalInSeconds(2) //每隔3s执行一次 36 | .repeatForever()) // 永久循环 37 | .build(); 38 | Trigger trigger2 = TriggerBuilder.newTrigger().withIdentity("trigger2", "trigger-group") 39 | .startNow()//立即生效 40 | .forJob(jobDetail) 41 | .withSchedule(SimpleScheduleBuilder.simpleSchedule() 42 | .withIntervalInSeconds(3) //每隔5s执行一次 43 | .repeatForever()).build(); // 永久循环 44 | //4、调度器中添加job 45 | scheduler.addJob(jobDetail, false); 46 | scheduler.scheduleJob(trigger); 47 | scheduler.scheduleJob(trigger2); 48 | // 启动调度器 49 | scheduler.start(); 50 | // 休眠任务执行时长 51 | TimeUnit.SECONDS.sleep(20); 52 | scheduler.shutdown(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /quartz-demo/src/test/java/com/quartz/demo/SimpleQuartzTest.java: -------------------------------------------------------------------------------- 1 | package com.quartz.demo; 2 | 3 | import com.quartz.demo.schedule.SimpleJob; 4 | import org.junit.Test; 5 | import org.quartz.*; 6 | import org.quartz.impl.StdSchedulerFactory; 7 | 8 | import java.util.concurrent.TimeUnit; 9 | 10 | /** 11 | * @author muguozheng 12 | * @version 1.0.0 13 | * @createTime 2022/4/12 20:34 14 | * @description 简单定时任务测试 15 | */ 16 | public class SimpleQuartzTest { 17 | /* 18 | * 基于时间间隔的定时任务 19 | */ 20 | @Test 21 | public void simpleTest() throws SchedulerException, InterruptedException { 22 | // 1、创建Scheduler(调度器) 23 | SchedulerFactory schedulerFactory = new StdSchedulerFactory(); 24 | Scheduler scheduler = schedulerFactory.getScheduler(); 25 | // 2、创建JobDetail实例,并与SimpleJob类绑定(Job执行内容) 26 | JobDetail jobDetail = JobBuilder.newJob(SimpleJob.class) 27 | .withIdentity("job-1", "job-group") 28 | .build(); 29 | // 3、构建Trigger(触发器),定义执行频率和时长 30 | Trigger trigger = TriggerBuilder.newTrigger() 31 | // 指定group和name,这是唯一身份标识 32 | .withIdentity("trigger-1", "trigger-group") 33 | .startNow() //立即生效 34 | .withSchedule(SimpleScheduleBuilder.simpleSchedule() 35 | .withIntervalInSeconds(2) //每隔2s执行一次 36 | .repeatForever()) // 永久执行 37 | .build(); 38 | //4、将Job和Trigger交给Scheduler调度 39 | scheduler.scheduleJob(jobDetail, trigger); 40 | // 5、启动Scheduler 41 | scheduler.start(); 42 | // 休眠,决定调度器运行时间,这里设置30s 43 | TimeUnit.SECONDS.sleep(30); 44 | // 关闭Scheduler 45 | scheduler.shutdown(); 46 | } 47 | 48 | /* 49 | * 基于cron表达式的定时任务 50 | */ 51 | @Test 52 | public void cronTest() throws SchedulerException, InterruptedException { 53 | // 1、创建Scheduler(调度器) 54 | SchedulerFactory schedulerFactory = new StdSchedulerFactory(); 55 | Scheduler scheduler = schedulerFactory.getScheduler(); 56 | // 2、创建JobDetail实例,并与SimpleJob类绑定 57 | JobDetail jobDetail = JobBuilder.newJob(SimpleJob.class) 58 | .withIdentity("job-1", "job-group").build(); 59 | // 3、构建Trigger(触发器),定义执行频率和时长 60 | CronTrigger cronTrigger = TriggerBuilder.newTrigger() 61 | .withIdentity("trigger-1", "trigger-group") 62 | .startNow() //立即生效 63 | .withSchedule(CronScheduleBuilder.cronSchedule("* 30 10 ? * 1/5 *")) 64 | .build(); 65 | 66 | //4、执行 67 | scheduler.scheduleJob(jobDetail, cronTrigger); 68 | scheduler.start(); 69 | // 休眠,决定调度器运行时间,这里设置30s 70 | TimeUnit.SECONDS.sleep(30); 71 | // 关闭Scheduler 72 | scheduler.shutdown(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /rocketmq-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springboot-demo-major 7 | com.mutest 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | rocketmq-demo 13 | 14 | 15 | 8 16 | 8 17 | 18 | 19 | 20 | 21 | org.apache.rocketmq 22 | rocketmq-client 23 | 4.8.0 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /rocketmq-demo/src/main/java/rocketmq/ConsumerTest.java: -------------------------------------------------------------------------------- 1 | package rocketmq; 2 | 3 | import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; 4 | import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; 5 | import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; 6 | import org.apache.rocketmq.client.exception.MQClientException; 7 | import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; 8 | 9 | import java.time.LocalDateTime; 10 | 11 | /** 12 | * @author muguozheng 13 | * @version 1.0.0 14 | * @createTime 2021/12/28 20:11 15 | * @description TODO 16 | */ 17 | public class ConsumerTest { 18 | public static void main(String[] args) throws MQClientException { 19 | 20 | //创建一个消息消费者,并设置一个消息消费者组 21 | DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("test"); 22 | 23 | //指定 NameServer 地址 24 | consumer.setNamesrvAddr("82.157.165.196:9876"); 25 | 26 | // Subscribe one more more topics to consume. 27 | //订阅指定 Topic 下的所有消息 28 | consumer.subscribe("TopicTest", "*"); 29 | 30 | //负载均衡模式,默认 31 | consumer.setMessageModel(MessageModel.CLUSTERING); 32 | // Register callback to execute on arrival of messages fetched from brokers. 33 | // 注册回调函数,处理消息 34 | consumer.registerMessageListener((MessageListenerConcurrently) (msgs, context) -> { 35 | System.out.printf("%s %s Receive New Messages: %s %n", LocalDateTime.now(), Thread.currentThread().getName(), 36 | new String(msgs.get(0).getBody())); 37 | 38 | return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; 39 | }); 40 | 41 | // 启动消费者 42 | consumer.start(); 43 | 44 | System.out.println("消息消费者已启动"); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /rocketmq-demo/src/main/java/rocketmq/ProducerTest.java: -------------------------------------------------------------------------------- 1 | package rocketmq; 2 | 3 | import org.apache.rocketmq.client.producer.DefaultMQProducer; 4 | import org.apache.rocketmq.client.producer.SendResult; 5 | import org.apache.rocketmq.common.message.Message; 6 | import org.apache.rocketmq.remoting.common.RemotingHelper; 7 | 8 | /** 9 | * @author muguozheng 10 | * @version 1.0.0 11 | * @createTime 2021/12/28 19:55 12 | * @description TODO 13 | */ 14 | public class ProducerTest { 15 | 16 | public static void main(String[] args) throws Exception { 17 | //1.创建消息生产者producer,并制定生产者组名 18 | DefaultMQProducer producer = new DefaultMQProducer("test"); 19 | //2.指定Nameserver地址 20 | producer.setNamesrvAddr("82.157.165.196:9876"); 21 | //3.启动producer 22 | producer.start(); 23 | for (int i = 0; i < 10; i++) { 24 | //4.创建消息对象,指定主题Topic、Tag和消息体 25 | /** 26 | * 参数一:消息主题Topic 27 | * 参数二:消息Tag 28 | * 参数三:消息内容 29 | */ 30 | Message msg = new Message("TopicTest", "TagA", "CSL13214282571806", 31 | ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET) /* Message body */ 32 | ); 33 | //5.发送同步消息,将消息发送给其中一个broker 34 | SendResult sendResult = producer.send(msg); 35 | System.out.printf("%s%n", sendResult); 36 | } 37 | //6.关闭生产者producer 38 | producer.shutdown(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /springboot-layui-demo/logs/springboot-demo-sql.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/logs/springboot-demo-sql.log -------------------------------------------------------------------------------- /springboot-layui-demo/logs/springboot-demo.log: -------------------------------------------------------------------------------- 1 | 2021-11-26 16:42:32,314 [main] INFO -[StartupInfoLogger.java:50]- Starting DemoApplication on ZB-PF22EJFG with PID 14672 (D:\Mu\project\mine\springboot-demo-major\springboot-layui-demo\target\classes started by muguozheng in D:\Mu\project\mine\springboot-demo-major) 2 | 2021-11-26 16:42:32,318 [main] INFO -[SpringApplication.java:675]- No active profile set, falling back to default profiles: default 3 | 2021-11-26 16:42:34,404 [main] INFO -[StartupInfoLogger.java:59]- Started DemoApplication in 2.544 seconds (JVM running for 3.123) 4 | 2021-11-26 16:42:47,734 [http-nio-8090-exec-1] INFO -[PersonServiceImpl.java:41]- 查询武侠列表成功--------->,Page{count=true, pageNum=1, pageSize=10, startRow=0, endRow=10, total=5, pages=1, reasonable=false, pageSizeZero=false}[Person(id=431, name=殷离, age=12, sex=女, address=峨眉山, sect=天鹰教, skill=千蛛万毒手, power=50, modifyTime=2021-11-26 16:36:12, createTime=2021-11-26 16:36:12), Person(id=430, name=小昭, age=12, sex=女, address=昆仑山光明顶, sect=明教, skill=乾坤大挪移, power=40, modifyTime=2021-11-26 16:33:27, createTime=2021-11-26 16:33:27), Person(id=429, name=周芷若, age=13, sex=女, address=峨眉山, sect=峨嵋派, skill=九阴真经, power=80, modifyTime=2021-11-26 16:32:40, createTime=2021-11-26 16:32:40), Person(id=428, name=赵敏, age=13, sex=女, address=大都, sect=朝廷, skill=杂门武功, power=30, modifyTime=2021-11-26 16:32:15, createTime=2021-11-26 16:32:15), Person(id=427, name=张无忌, age=16, sex=男, address=昆仑山光明顶, sect=明教, skill=九阳神功, power=100, modifyTime=2021-11-26 16:29:38, createTime=2021-11-26 16:29:38)] 5 | 2021-11-26 16:45:08,827 [main] INFO -[StartupInfoLogger.java:50]- Starting DemoApplication on ZB-PF22EJFG with PID 13496 (D:\Mu\project\mine\springboot-demo-major\springboot-layui-demo\target\classes started by muguozheng in D:\Mu\project\mine\springboot-demo-major) 6 | 2021-11-26 16:45:08,838 [main] INFO -[SpringApplication.java:675]- No active profile set, falling back to default profiles: default 7 | 2021-11-26 16:45:13,917 [main] INFO -[StartupInfoLogger.java:59]- Started DemoApplication in 6.605 seconds (JVM running for 8.776) 8 | 2021-11-26 16:45:21,193 [http-nio-8090-exec-3] INFO -[PersonServiceImpl.java:41]- 查询武侠列表成功--------->,Page{count=true, pageNum=1, pageSize=10, startRow=0, endRow=10, total=5, pages=1, reasonable=false, pageSizeZero=false}[Person(id=431, name=殷离, age=12, sex=女, address=峨眉山, sect=天鹰教, skill=千蛛万毒手, power=50, modifyTime=2021-11-26 16:36:12, createTime=2021-11-26 16:36:12), Person(id=430, name=小昭, age=12, sex=女, address=昆仑山光明顶, sect=明教, skill=乾坤大挪移, power=40, modifyTime=2021-11-26 16:33:27, createTime=2021-11-26 16:33:27), Person(id=429, name=周芷若, age=13, sex=女, address=峨眉山, sect=峨嵋派, skill=九阴真经, power=80, modifyTime=2021-11-26 16:32:40, createTime=2021-11-26 16:32:40), Person(id=428, name=赵敏, age=13, sex=女, address=大都, sect=朝廷, skill=杂门武功, power=30, modifyTime=2021-11-26 16:32:15, createTime=2021-11-26 16:32:15), Person(id=427, name=张无忌, age=16, sex=男, address=昆仑山光明顶, sect=明教, skill=九阳神功, power=100, modifyTime=2021-11-26 16:29:38, createTime=2021-11-26 16:29:38)] 9 | 2021-11-26 16:45:21,303 [http-nio-8090-exec-4] INFO -[PersonServiceImpl.java:41]- 查询武侠列表成功--------->,Page{count=true, pageNum=1, pageSize=10, startRow=0, endRow=10, total=5, pages=1, reasonable=false, pageSizeZero=false}[Person(id=431, name=殷离, age=12, sex=女, address=峨眉山, sect=天鹰教, skill=千蛛万毒手, power=50, modifyTime=2021-11-26 16:36:12, createTime=2021-11-26 16:36:12), Person(id=430, name=小昭, age=12, sex=女, address=昆仑山光明顶, sect=明教, skill=乾坤大挪移, power=40, modifyTime=2021-11-26 16:33:27, createTime=2021-11-26 16:33:27), Person(id=429, name=周芷若, age=13, sex=女, address=峨眉山, sect=峨嵋派, skill=九阴真经, power=80, modifyTime=2021-11-26 16:32:40, createTime=2021-11-26 16:32:40), Person(id=428, name=赵敏, age=13, sex=女, address=大都, sect=朝廷, skill=杂门武功, power=30, modifyTime=2021-11-26 16:32:15, createTime=2021-11-26 16:32:15), Person(id=427, name=张无忌, age=16, sex=男, address=昆仑山光明顶, sect=明教, skill=九阳神功, power=100, modifyTime=2021-11-26 16:29:38, createTime=2021-11-26 16:29:38)] 10 | 2021-11-26 16:45:22,353 [http-nio-8090-exec-5] INFO -[PersonServiceImpl.java:41]- 查询武侠列表成功--------->,Page{count=true, pageNum=1, pageSize=10, startRow=0, endRow=10, total=5, pages=1, reasonable=false, pageSizeZero=false}[Person(id=431, name=殷离, age=12, sex=女, address=峨眉山, sect=天鹰教, skill=千蛛万毒手, power=50, modifyTime=2021-11-26 16:36:12, createTime=2021-11-26 16:36:12), Person(id=430, name=小昭, age=12, sex=女, address=昆仑山光明顶, sect=明教, skill=乾坤大挪移, power=40, modifyTime=2021-11-26 16:33:27, createTime=2021-11-26 16:33:27), Person(id=429, name=周芷若, age=13, sex=女, address=峨眉山, sect=峨嵋派, skill=九阴真经, power=80, modifyTime=2021-11-26 16:32:40, createTime=2021-11-26 16:32:40), Person(id=428, name=赵敏, age=13, sex=女, address=大都, sect=朝廷, skill=杂门武功, power=30, modifyTime=2021-11-26 16:32:15, createTime=2021-11-26 16:32:15), Person(id=427, name=张无忌, age=16, sex=男, address=昆仑山光明顶, sect=明教, skill=九阳神功, power=100, modifyTime=2021-11-26 16:29:38, createTime=2021-11-26 16:29:38)] 11 | -------------------------------------------------------------------------------- /springboot-layui-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springboot-demo-major 7 | com.mutest 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | springboot-layui-demo 13 | 14 | 15 | 8 16 | 8 17 | 18 | 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-aop 24 | 2.0.2.RELEASE 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.demo; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | /** 8 | * @author guozhengMu 9 | * @version 1.0 10 | * @date 2019/3/26 14:15 11 | * @description 启动类 12 | * @modify 13 | */ 14 | @SpringBootApplication 15 | @MapperScan(value = "com.demo.dao") 16 | public class DemoApplication { 17 | 18 | public static void main(String[] args) { 19 | 20 | SpringApplication.run(DemoApplication.class, args); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/advice/AopAdvice.java: -------------------------------------------------------------------------------- 1 | package com.demo.advice; 2 | 3 | import org.aspectj.lang.annotation.Aspect; 4 | import org.aspectj.lang.annotation.Before; 5 | import org.aspectj.lang.annotation.Pointcut; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * @author muguozheng 10 | * @version 1.0.0 11 | * @createTime 2021/6/23 17:59 12 | * @Description TODO 13 | */ 14 | @Aspect 15 | @Component 16 | public class AopAdvice { 17 | // 定义一个切点:所有被GetMapping注解修饰的方法会织入advice 18 | @Pointcut("@annotation(org.springframework.web.bind.annotation.GetMapping)") 19 | private void getAdvicePointcut() {} 20 | 21 | @Pointcut("execution(* com.demo.service.impl..PersonServiceImpl.*(..)))") 22 | private void personAdvicePointcut() {} 23 | 24 | // Before表示logAdvice将在目标方法执行前执行 25 | @Before("getAdvicePointcut()") 26 | public void getAdvice(){ 27 | // 这里只是一个示例,你可以写任何处理逻辑 28 | System.out.println("get请求的advice触发了"); 29 | } 30 | 31 | @Before("personAdvicePointcut()") 32 | public void personAdvice(){ 33 | // 这里只是一个示例,你可以写任何处理逻辑 34 | System.out.println("personServiceImpl的advice触发了"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/advice/BusinessErrorException.java: -------------------------------------------------------------------------------- 1 | package com.demo.advice; 2 | 3 | /** 4 | * @author guozhengMu 5 | * @version 1.0 6 | * @date 2019/8/9 14:27 7 | * @description 8 | * @modify 9 | */ 10 | public class BusinessErrorException extends RuntimeException { 11 | // 程序运行起来,叫做runtime,没有运行前,一般叫做编译期 12 | // 异常至少有两种,编译期异常,运行期异常(throw 13 | 14 | // 序列化id 就像一个密钥 15 | private static final long serialVersionUID = -7480022450501760611L; 16 | 17 | /** 18 | * 异常码 19 | */ 20 | private int code; 21 | 22 | /** 23 | * 异常提示信息 24 | */ 25 | private String message; 26 | 27 | // 和ResponseInfo很像,也是构造方法赋值,但它不能自由赋值了,只接受BusinessMsgEnum的值 28 | public BusinessErrorException(BusinessMsgEnum businessMsgEnum) { 29 | this.code = businessMsgEnum.code; 30 | this.message = businessMsgEnum.msg; 31 | } 32 | 33 | // public BusinessErrorException(int code, String message) { 34 | // this.code = code; 35 | // this.message = message; 36 | // } 37 | 38 | public int getCode() { 39 | return code; 40 | } 41 | 42 | public void setCode(int code) { 43 | this.code = code; 44 | } 45 | 46 | @Override 47 | public String getMessage() { 48 | return message; 49 | } 50 | 51 | public void setMessage(String message) { 52 | this.message = message; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/advice/BusinessMsgEnum.java: -------------------------------------------------------------------------------- 1 | package com.demo.advice; 2 | 3 | // 枚举类一般用于定义 4 | // 比如,性别 public enum SexEnum{ } 5 | // status color 6 | public enum BusinessMsgEnum { 7 | // 枚举类命名规范:全部大写,以下划线分割 8 | /** 9 | * 参数异常 10 | */ 11 | PARMETER_EXCEPTION(101, "参数异常!"), 12 | /** 13 | * 等待超时 14 | */ 15 | SERVICE_TIME_OUT(102, "服务超时!"), 16 | /** 17 | * 参数过大 18 | */ 19 | PARMETER_BIG_EXCEPTION(903, "内容不能超过200字,请重试!"), 20 | /** 21 | * 数据库操作失败 22 | */ 23 | DATABASE_EXCEPTION(509, "数据库操作异常,请联系管理员!"), 24 | /** 25 | * 500 : 一劳永逸的提示也可以在这定义 26 | */ 27 | UNEXPECTED_EXCEPTION(500, "系统发生异常,请联系管理员!"), 28 | // 还可以定义更多的业务异常 29 | ERROR_EXCEPTION(1000, "系统出锅啦!!!"); 30 | /** 31 | * 消息码 32 | */ 33 | public int code; 34 | /** 35 | * 消息内容 36 | */ 37 | public String msg; 38 | 39 | private BusinessMsgEnum(int code, String msg) { 40 | this.code = code; 41 | this.msg = msg; 42 | } 43 | // set get方法 44 | 45 | public int getCode() { 46 | return code; 47 | } 48 | 49 | public void setCode(int code) { 50 | this.code = code; 51 | } 52 | 53 | public String getMsg() { 54 | return msg; 55 | } 56 | 57 | public void setMsg(String msg) { 58 | this.msg = msg; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/advice/CORSFilter.java: -------------------------------------------------------------------------------- 1 | package com.demo.advice; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import javax.servlet.*; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | /** 11 | * @author muguozheng 12 | * @date 2021/5/15 19:58 13 | * @Description 解决跨域问题 14 | * @modify 15 | */ 16 | 17 | @Component 18 | public class CORSFilter implements Filter { 19 | 20 | @Override 21 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 22 | throws IOException, ServletException { 23 | HttpServletResponse res = (HttpServletResponse) response; 24 | res.addHeader("Access-Control-Allow-Credentials", "true"); 25 | res.addHeader("Access-Control-Allow-Origin", "*"); 26 | res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); 27 | res.addHeader("Access-Control-Allow-Headers", "Content-Type,X-CAF-Authorization-Token,sessionToken,X-TOKEN"); 28 | if (((HttpServletRequest) request).getMethod().equals("OPTIONS")) { 29 | response.getWriter().println("ok"); 30 | return; 31 | } 32 | chain.doFilter(request, response); 33 | } 34 | 35 | @Override 36 | public void destroy() { 37 | } 38 | 39 | @Override 40 | public void init(FilterConfig filterConfig) throws ServletException { 41 | } 42 | } 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/advice/ParamCheckAdvice.java: -------------------------------------------------------------------------------- 1 | package com.demo.advice; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import org.aspectj.lang.ProceedingJoinPoint; 5 | import org.aspectj.lang.annotation.Around; 6 | import org.aspectj.lang.annotation.Aspect; 7 | import org.aspectj.lang.annotation.Pointcut; 8 | import org.springframework.stereotype.Component; 9 | 10 | /** 11 | * @author muguozheng 12 | * @version 1.0.0 13 | * @createTime 2021/5/19 14:56 14 | * @Description TODO 15 | */ 16 | 17 | /** 18 | * @Aspect 表示该类是一个AOP处理类 19 | * @Component 表示该类作为一个组件交给Spring容器管理 20 | */ 21 | @Aspect 22 | @Component 23 | public class ParamCheckAdvice { 24 | /** 25 | * 定义一个切面,拦截所有被ParamCheckAnnotation注解修饰的方法 26 | */ 27 | @Pointcut("@annotation(com.demo.annotation.ParamCheckAnnotation)") 28 | private void paramCheck() { 29 | } 30 | 31 | @Around("paramCheck()") //Before After 32 | public ResponseInfo paramCheck(ProceedingJoinPoint joinPoint) throws Throwable { 33 | System.out.println("===================第一个切面===================:" + System.currentTimeMillis()); 34 | 35 | // 拿到请求参数 36 | Object[] objects = joinPoint.getArgs(); 37 | // 从参数中解析出age 38 | Long age = ((JSONObject) objects[0]).getLong("age"); 39 | System.out.println("age->>>>>>>>>>>>>>>>>>>>>>" + age); 40 | 41 | // 年龄小于13则返回异常 42 | if (age < 3) { 43 | return new ResponseInfo(403,"年龄太小莫入江湖"); 44 | } 45 | return (ResponseInfo) joinPoint.proceed(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/advice/ResponseInfo.java: -------------------------------------------------------------------------------- 1 | package com.demo.advice; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author muguozheng 7 | * @version 1.0.0 8 | * @createTime 2021/6/2 18:07 9 | * @Description TODO 10 | */ 11 | @Data 12 | public class ResponseInfo { 13 | // T表示返回值是一个泛型 14 | /** 15 | * 状态码 16 | */ 17 | protected int code; 18 | /** 19 | * 响应信息 20 | */ 21 | protected String msg; 22 | /** 23 | * 返回数据 24 | */ 25 | private T data; 26 | private long count; 27 | 28 | 29 | public ResponseInfo(T data, long count) { 30 | this.data = data; 31 | this.count = count; 32 | } 33 | 34 | /** 35 | * 若没有数据返回,默认状态码为 0,提示信息为“操作成功!” 36 | */ 37 | public ResponseInfo() { 38 | this.code = 0; 39 | this.msg = "操作成功!"; 40 | } 41 | 42 | /** 43 | * 若没有数据返回,可以人为指定状态码和提示信息 44 | * 45 | * @param code 响应码 46 | * @param msg 响应信息 47 | */ 48 | public ResponseInfo(int code, String msg) { 49 | this.code = code; 50 | this.msg = msg; 51 | } 52 | 53 | /** 54 | * 有数据返回时,状态码为 0,默认提示信息为“操作成功!” 55 | * 56 | * @param data 响应数据 57 | */ 58 | public ResponseInfo(T data) { 59 | this.data = data; 60 | this.code = 0; 61 | this.msg = "操作成功!"; 62 | } 63 | 64 | /** 65 | * 有数据返回,状态码为 0,人为指定提示信息 66 | * 67 | * @param data 响应数据 68 | * @param msg 响应信息 69 | */ 70 | public ResponseInfo(T data, String msg) { 71 | this.data = data; 72 | this.code = 0; 73 | this.msg = msg; 74 | } 75 | 76 | // 省略 get 和 set 方法 77 | } 78 | 79 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/annotation/ParamCheckAnnotation.java: -------------------------------------------------------------------------------- 1 | package com.demo.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author muguozheng 7 | * @version 1.0.0 8 | * @createTime 2021/5/19 14:54 9 | * @Description TODO 10 | */ 11 | @Target(ElementType.METHOD) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Documented 14 | public @interface ParamCheckAnnotation { 15 | } 16 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/controller/GoodsController.java: -------------------------------------------------------------------------------- 1 | package com.demo.controller; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.demo.service.GoodsService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.RequestBody; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestMethod; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | /** 12 | * @author muguozheng 13 | * @version 1.0.0 14 | * @createTime 2021/4/26 18:51 15 | * @Description TODO 16 | */ 17 | @RestController 18 | @RequestMapping("/goods") 19 | public class GoodsController { 20 | // 注入实例化的对象,代替我们自己new 21 | @Autowired 22 | private GoodsService goodsService; 23 | 24 | @RequestMapping(value = "/goodsList", method = RequestMethod.GET) 25 | public JSONObject getGoodList(int pageNum, int pageSize) { 26 | 27 | return goodsService.goodsList(pageNum, pageSize); 28 | } 29 | 30 | @RequestMapping(value = "updateGoods", method = RequestMethod.POST) 31 | public JSONObject updateGoods(@RequestBody JSONObject goods) { 32 | return goodsService.updateGoods(goods); 33 | } 34 | } -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/controller/PersonController.java: -------------------------------------------------------------------------------- 1 | package com.demo.controller; 2 | 3 | import com.alibaba.fastjson.JSONArray; 4 | import com.alibaba.fastjson.JSONObject; 5 | import com.demo.advice.ResponseInfo; 6 | import com.demo.annotation.ParamCheckAnnotation; 7 | import com.demo.service.PersonService; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.apache.ibatis.annotations.Param; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.RequestBody; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | /** 17 | * @author muguozheng 18 | * @version 1.0.0 19 | * @createTime 2021/4/26 18:51 20 | * @Description TODO 21 | */ 22 | @RestController 23 | @RequestMapping("/person") 24 | @Slf4j 25 | public class PersonController { 26 | @Autowired 27 | private PersonService personService; 28 | 29 | @RequestMapping(value = "/personsList", method = RequestMethod.GET) 30 | public ResponseInfo getPersonList(int pageNum, int pageSize) { 31 | return personService.personsList(pageNum, pageSize); 32 | } 33 | 34 | @RequestMapping(value = "/updatePerson", method = RequestMethod.POST) 35 | @ParamCheckAnnotation() 36 | public ResponseInfo updatePerson(@RequestBody JSONObject person) { 37 | return personService.updatePerson(person); 38 | } 39 | 40 | @RequestMapping(value = "/updatePersonBatch", method = RequestMethod.POST) 41 | public JSONObject updatePersonBatch(@RequestBody JSONArray personArray) { 42 | return personService.updatePersonBatch(personArray); 43 | } 44 | 45 | @RequestMapping(value = "/addPerson", method = RequestMethod.POST) 46 | @ParamCheckAnnotation() 47 | public ResponseInfo addPerson(@RequestBody JSONObject person) { 48 | return personService.addPerson(person); 49 | } 50 | 51 | @RequestMapping(value = "/searchPerson", method = RequestMethod.POST) 52 | public ResponseInfo searchPerson(@RequestBody JSONObject person) { 53 | return personService.searchPerson(person); 54 | } 55 | 56 | @RequestMapping(value = "/deletePersonById", method = RequestMethod.GET) 57 | public ResponseInfo deletePersonById(@Param("id") Long id) { 58 | return personService.deletePersonById(id); 59 | } 60 | } -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/dao/GoodsDao.java: -------------------------------------------------------------------------------- 1 | package com.demo.dao; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.demo.model.Goods; 5 | import org.apache.ibatis.annotations.*; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author muguozheng 11 | * @version 1.0.0 12 | * @createTime 2021/4/23 14:30 13 | * @Description TODO 14 | */ 15 | @Mapper 16 | public interface GoodsDao { 17 | @Select("SELECT * FROM mytest.goods") 18 | List getGoodsList(); 19 | 20 | @Update("UPDATE mytest.goods SET name=#{name},type=#{type},status=#{status},price=#{price},size=#{size},status=#{status},description=#{description} WHERE id=#{id}") 21 | int updateGoods(JSONObject goods); 22 | } 23 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/dao/PersonDao.java: -------------------------------------------------------------------------------- 1 | package com.demo.dao; 2 | 3 | import com.alibaba.fastjson.JSONArray; 4 | import com.alibaba.fastjson.JSONObject; 5 | import com.demo.model.Person; 6 | import org.apache.ibatis.annotations.Delete; 7 | import org.apache.ibatis.annotations.Param; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author muguozheng 13 | * @version 1.0.0 14 | * @createTime 2021/4/23 14:30 15 | * @Description TODO 16 | */ 17 | public interface PersonDao { 18 | List getPersonsList(); 19 | 20 | int updatePerson(JSONObject person); 21 | 22 | int updatePersonBatch(JSONArray personArray); 23 | 24 | int addPerson(JSONObject person); 25 | 26 | List searchPerson(JSONObject person); 27 | 28 | @Delete("DELETE FROM mytest.persons where id = #{id}") 29 | int deletePersonById(@Param("id") Long id); 30 | } 31 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/model/Goods.java: -------------------------------------------------------------------------------- 1 | package com.demo.model; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author muguozheng 7 | * @version 1.0.0 8 | * @createTime 2021/4/23 13:48 9 | * @Description TODO 10 | */ 11 | @Data 12 | public class Goods { 13 | private Long id; 14 | private String name; 15 | private String type; 16 | private double price; 17 | private int size; 18 | private String status; 19 | private String description; 20 | private String modifyTime; 21 | private String createTime; 22 | } 23 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/model/Person.java: -------------------------------------------------------------------------------- 1 | package com.demo.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | 7 | /** 8 | * @author muguozheng 9 | * @version 1.0.0 10 | * @createTime 2021/4/23 13:48 11 | * @Description TODO 12 | */ 13 | @Data 14 | @Builder 15 | @AllArgsConstructor 16 | public class Person { 17 | private Long id; 18 | private String name; 19 | private Long age; 20 | private String sex; 21 | private String address; 22 | private String sect; 23 | private String skill; 24 | private int power; 25 | private String modifyTime; 26 | private String createTime; 27 | 28 | public Person() { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/service/GoodsService.java: -------------------------------------------------------------------------------- 1 | package com.demo.service; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import org.springframework.stereotype.Service; 5 | 6 | /** 7 | * @author muguozheng 8 | * @version 1.0.0 9 | * @createTime 2021/4/23 14:45 10 | * @Description TODO 11 | */ 12 | @Service 13 | public interface GoodsService { 14 | JSONObject goodsList(int pageNum, int pageSize); 15 | 16 | JSONObject updateGoods(JSONObject goods); 17 | } 18 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/service/PersonService.java: -------------------------------------------------------------------------------- 1 | package com.demo.service; 2 | 3 | import com.alibaba.fastjson.JSONArray; 4 | import com.alibaba.fastjson.JSONObject; 5 | import com.demo.advice.ResponseInfo; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * @author muguozheng 10 | * @version 1.0.0 11 | * @createTime 2021/4/23 14:45 12 | * @Description TODO 13 | */ 14 | @Service 15 | public interface PersonService { 16 | ResponseInfo personsList(int pageNum, int pageSize); 17 | 18 | ResponseInfo updatePerson(JSONObject person); 19 | 20 | ResponseInfo addPerson(JSONObject person); 21 | 22 | JSONObject updatePersonBatch(JSONArray personArray); 23 | 24 | ResponseInfo searchPerson(JSONObject person); 25 | 26 | ResponseInfo deletePersonById(Long id); 27 | } 28 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/service/impl/GoodsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.demo.service.impl; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.github.pagehelper.PageHelper; 5 | import com.github.pagehelper.PageInfo; 6 | import com.demo.dao.GoodsDao; 7 | import com.demo.model.Goods; 8 | import com.demo.service.GoodsService; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | 14 | /** 15 | * @author muguozheng 16 | * @version 1.0.0 17 | * @createTime 2021/4/23 14:45 18 | * @Description TODO 19 | */ 20 | @Service 21 | @Slf4j 22 | public class GoodsServiceImpl implements GoodsService { 23 | @Autowired 24 | private GoodsDao goodDao; 25 | 26 | @Override 27 | public JSONObject goodsList(int pageNum, int pageSize) { 28 | JSONObject result = new JSONObject(); 29 | try { 30 | result.put("code", "200"); 31 | result.put("msg", "chengong"); 32 | PageHelper.startPage(pageNum, pageSize); 33 | PageInfo pageInfo = new PageInfo<>(goodDao.getGoodsList()); 34 | result.put("data", pageInfo.getList()); 35 | log.info("查询商品成功--------->,{}", pageInfo.getList()); 36 | } catch (Exception e) { 37 | result.put("code", "500"); 38 | result.put("msg", "error"); 39 | log.error("获取商品列表失败--------->{}", e.getMessage()); 40 | } 41 | return result; 42 | } 43 | 44 | /** 45 | * 更新商品 46 | * 47 | * @param goods 商品 48 | * @return 49 | */ 50 | public JSONObject updateGoods(JSONObject goods) { 51 | JSONObject result = new JSONObject(); 52 | try { 53 | result.put("code", "0"); 54 | result.put("msg", "success"); 55 | goodDao.updateGoods(goods); 56 | log.info("商品更新成功---->{}", goods); 57 | } catch (Exception e) { 58 | e.printStackTrace(); 59 | result.put("code", "500"); 60 | result.put("msg", "error"); 61 | log.error("更新商品失败--------->{}", e.getMessage()); 62 | } 63 | return result; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/java/com/demo/service/impl/PersonServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.demo.service.impl; 2 | 3 | import com.alibaba.fastjson.JSONArray; 4 | import com.alibaba.fastjson.JSONObject; 5 | import com.github.pagehelper.PageHelper; 6 | import com.github.pagehelper.PageInfo; 7 | import com.demo.advice.BusinessErrorException; 8 | import com.demo.advice.BusinessMsgEnum; 9 | import com.demo.advice.ResponseInfo; 10 | import com.demo.annotation.ParamCheckAnnotation; 11 | import com.demo.dao.PersonDao; 12 | import com.demo.model.Person; 13 | import com.demo.service.PersonService; 14 | import lombok.extern.slf4j.Slf4j; 15 | import org.springframework.stereotype.Service; 16 | 17 | import javax.annotation.Resource; 18 | import java.util.List; 19 | 20 | 21 | /** 22 | * @author muguozheng 23 | * @version 1.0.0 24 | * @createTime 2021/4/23 14:45 25 | * @description TODO 26 | */ 27 | @Service 28 | @Slf4j 29 | public class PersonServiceImpl implements PersonService { 30 | @Resource 31 | private PersonDao personDao; 32 | 33 | // 太冗余,我们寻求一种简洁的处理方式 34 | // 统一的数据封装,我们预先定义好返回的数据格式,用得时候通过构造方法直接放入值即可 35 | @Override 36 | public ResponseInfo personsList(int pageNum, int pageSize) { 37 | 38 | try { 39 | PageHelper.startPage(pageNum, pageSize); 40 | PageInfo pageInfo = new PageInfo<>(personDao.getPersonsList()); 41 | log.info("查询武侠列表成功--------->,{}", pageInfo.getList()); 42 | // 通过有参构造方法直接对实例化的ResponseInfo进行初始化赋值 43 | return new ResponseInfo(pageInfo.getList(), pageInfo.getTotal()); 44 | } catch (Exception e) { 45 | log.error("获取武侠列表失败--------->{}", e.getMessage()); 46 | throw new BusinessErrorException(BusinessMsgEnum.ERROR_EXCEPTION); 47 | } 48 | } 49 | 50 | /** 51 | * 更新武侠 52 | * 53 | * @param person 武侠 54 | * @return 55 | */ 56 | @Override 57 | @ParamCheckAnnotation() 58 | public ResponseInfo updatePerson(JSONObject person) { 59 | JSONObject result = new JSONObject(); 60 | try { 61 | 62 | personDao.updatePerson(person); 63 | log.info("武侠信息更新成功---->{}", person); 64 | return new ResponseInfo(0, "success"); 65 | } catch (Exception e) { 66 | 67 | log.error("更新武侠信息失败--------->{}", e.getMessage()); 68 | return new ResponseInfo(500, "异常异常!"); 69 | } 70 | } 71 | 72 | @Override 73 | @ParamCheckAnnotation() 74 | public ResponseInfo addPerson(JSONObject person) { 75 | try { 76 | 77 | personDao.addPerson(person); 78 | log.info("武侠信息新增成功---->{}", person); 79 | return new ResponseInfo(0, "success"); 80 | } catch (Exception e) { 81 | log.error("武侠信息新增失败--------->{}", e.getMessage()); 82 | return new ResponseInfo(500, "新增武侠异常!"); 83 | } 84 | } 85 | 86 | @Override 87 | public JSONObject updatePersonBatch(JSONArray personArray) { 88 | JSONObject result = new JSONObject(); 89 | try { 90 | result.put("code", "0"); 91 | result.put("msg", "success"); 92 | personDao.updatePersonBatch(personArray); 93 | log.info("武侠信息更新成功---->{}", personArray); 94 | } catch (Exception e) { 95 | e.printStackTrace(); 96 | result.put("code", "500"); 97 | result.put("msg", "error"); 98 | log.error("更新武侠信息失败--------->{}", e.getMessage()); 99 | } 100 | return result; 101 | } 102 | 103 | @Override 104 | public ResponseInfo searchPerson(JSONObject query) { 105 | int pageNum = query.getInteger("pageNum"); 106 | int pageSize = query.getInteger("pageSize"); 107 | 108 | try { 109 | PageHelper.startPage(pageNum, pageSize); 110 | PageInfo pageInfo = new PageInfo<>(personDao.getPersonsList()); 111 | List personList = personDao.searchPerson(query); 112 | log.info("武侠信息查询成功---->{}", personList); 113 | return new ResponseInfo(pageInfo.getList(), pageInfo.getTotal()); 114 | } catch (Exception e) { 115 | log.error("武侠信息查询失败--------->{}", e.getMessage()); 116 | return new ResponseInfo(500, "查询武侠信息异常!"); 117 | } 118 | } 119 | 120 | @Override 121 | public ResponseInfo deletePersonById(Long id) { 122 | 123 | try { 124 | personDao.deletePersonById(id); 125 | log.info("武侠信息查询成功---->{}", id); 126 | return new ResponseInfo(0, "删除武侠成功!"); 127 | } catch (Exception e) { 128 | log.error("武侠信息查询失败--------->{}", e.getMessage()); 129 | return new ResponseInfo(500, "删除武侠异常!"); 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8090 3 | spring: 4 | datasource: 5 | type: com.alibaba.druid.pool.DruidDataSource 6 | driver-class-name: com.mysql.jdbc.Driver 7 | url: jdbc:mysql://localhost:3306?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false 8 | username: root 9 | password: 10 | 11 | mybatis: 12 | type-aliases-package: com.demo.model 13 | configuration: 14 | map-underscore-to-camel-case: true # 驼峰命名规范 15 | # 指定xml文件的路径 16 | mapper-locations: classpath:/mappers/*.xml 17 | 18 | # 日志读取哪个xml文件 19 | logging: 20 | config: classpath:logback-spring.xml 21 | log: 22 | level: 23 | root: error 24 | common: info 25 | sql: info 26 | file: springboot-layui-demo/logs/springboot-demo 27 | maxsize: 30MB -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | %d [%thread] %-5level %logger{50} -[%file:%line]- %msg%n 14 | UTF-8 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | ${logFile}.log 25 | 26 | %d [%thread] %-5level -[%file:%line]- %msg%n 27 | UTF-8 28 | 29 | 30 | ${logFile}-%d{yyyy-MM}-%i.log 31 | ${maxFileSize} 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | ${logFile}-sql.log 42 | 43 | %d [%thread] %msg%n 44 | UTF-8 45 | 46 | 47 | ${logFile}-sql.%d{yyyy-MM}.%i.log 48 | ${maxFileSize} 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/mappers/PersonMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 33 | 34 | 35 | UPDATE 36 | mytest.persons 37 | 38 | name = #{name}, 39 | age = #{age}, 40 | sex = #{sex}, 41 | address = #{address}, 42 | sect = #{sect}, 43 | skill = #{skill}, 44 | power = #{power} 45 | 46 | WHERE 47 | id = #{id} 48 | 49 | 50 | 51 | 52 | UPDATE mytest.persons 53 | 54 | 55 | name=#{item.name}, 56 | 57 | 58 | age=#{item.age}, 59 | 60 | 61 | sex=#{item.sex}, 62 | 63 | 64 | address=#{item.address}, 65 | 66 | 67 | sect=#{item.sect}, 68 | 69 | 70 | skill=#{item.skill}, 71 | 72 | 73 | power=#{item.power}, 74 | 75 | 76 | WHERE 77 | id=#{item.id}; 78 | 79 | 80 | 81 | 82 | INSERT INTO mytest.persons 83 | (name, age, sex, address, sect, skill, power) 84 | VALUES (#{name}, #{age}, #{sex}, #{address}, #{sect}, #{skill}, #{power}) 85 | 86 | 87 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/css/myCss.css: -------------------------------------------------------------------------------- 1 | .layui-btn { 2 | display: inline-block; 3 | height: 38px; 4 | line-height: 38px; 5 | padding: 0 18px; 6 | background-color: #009688; 7 | color: #fff; 8 | white-space: nowrap; 9 | text-align: center; 10 | font-size: 14px; 11 | border: none; 12 | border-radius: 2px; 13 | cursor: pointer 14 | } -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 腾讯官网 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
    14 |
  • 网站设置
  • 15 |
  • 武侠列表
  • 16 |
  • 新增武侠
  • 17 |
  • 商品管理
  • 18 |
  • 系统管理
  • 19 |
20 | 21 |
22 |
23 | 24 |
25 |
26 | 28 |
29 |
30 | 32 |
33 |
34 | 36 |
37 |
内容5
38 |
39 |
40 | 41 | 42 | 43 | 44 | 45 | 90 | 91 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/css/modules/code.css: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.5 MIT License By https://www.layui.com */ 2 | html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none} -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/css/modules/layer/default/icon-ext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/css/modules/layer/default/icon-ext.png -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/css/modules/layer/default/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/css/modules/layer/default/icon.png -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/css/modules/layer/default/loading-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/css/modules/layer/default/loading-0.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/css/modules/layer/default/loading-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/css/modules/layer/default/loading-1.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/css/modules/layer/default/loading-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/css/modules/layer/default/loading-2.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/font/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/font/iconfont.eot -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/font/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/font/iconfont.ttf -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/font/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/font/iconfont.woff -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/0.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/1.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/10.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/11.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/12.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/13.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/14.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/15.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/16.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/17.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/18.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/19.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/2.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/20.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/21.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/21.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/22.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/22.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/23.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/23.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/24.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/25.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/25.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/26.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/26.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/27.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/27.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/28.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/28.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/29.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/29.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/3.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/30.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/30.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/31.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/31.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/32.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/33.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/33.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/34.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/34.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/35.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/35.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/36.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/36.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/37.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/37.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/38.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/38.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/39.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/39.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/4.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/40.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/41.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/41.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/42.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/42.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/43.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/43.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/44.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/44.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/45.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/45.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/46.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/46.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/47.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/47.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/48.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/48.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/49.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/49.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/5.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/50.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/51.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/51.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/52.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/52.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/53.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/53.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/54.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/54.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/55.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/55.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/56.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/56.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/57.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/57.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/58.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/58.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/59.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/59.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/6.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/60.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/60.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/61.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/61.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/62.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/62.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/63.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/63.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/64.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/64.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/65.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/65.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/66.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/66.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/67.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/67.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/68.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/68.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/69.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/69.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/7.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/70.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/70.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/71.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/71.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/8.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/images/face/9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/springboot-layui-demo/src/main/resources/static/layui/images/face/9.gif -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/lay/modules/carousel.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var i=layui.$,n=(layui.hint(),layui.device(),{config:{},set:function(e){var n=this;return n.config=i.extend({},n.config,e),n},on:function(e,i){return layui.onevent.call(this,t,e,i)}}),t="carousel",a="layui-this",l=">*[carousel-item]>*",o="layui-carousel-left",r="layui-carousel-right",d="layui-carousel-prev",s="layui-carousel-next",u="layui-carousel-arrow",c="layui-carousel-ind",m=function(e){var t=this;t.config=i.extend({},t.config,n.config,e),t.render()};m.prototype.config={width:"600px",height:"280px",full:!1,arrow:"hover",indicator:"inside",autoplay:!0,interval:3e3,anim:"",trigger:"click",index:0},m.prototype.render=function(){var e=this,n=e.config;n.elem=i(n.elem),n.elem[0]&&(e.elemItem=n.elem.find(l),n.index<0&&(n.index=0),n.index>=e.elemItem.length&&(n.index=e.elemItem.length-1),n.interval<800&&(n.interval=800),n.full?n.elem.css({position:"fixed",width:"100%",height:"100%",zIndex:9999}):n.elem.css({width:n.width,height:n.height}),n.elem.attr("lay-anim",n.anim),e.elemItem.eq(n.index).addClass(a),e.elemItem.length<=1||(e.indicator(),e.arrow(),e.autoplay(),e.events()))},m.prototype.reload=function(e){var n=this;clearInterval(n.timer),n.config=i.extend({},n.config,e),n.render()},m.prototype.prevIndex=function(){var e=this,i=e.config,n=i.index-1;return n<0&&(n=e.elemItem.length-1),n},m.prototype.nextIndex=function(){var e=this,i=e.config,n=i.index+1;return n>=e.elemItem.length&&(n=0),n},m.prototype.addIndex=function(e){var i=this,n=i.config;e=e||1,n.index=n.index+e,n.index>=i.elemItem.length&&(n.index=0)},m.prototype.subIndex=function(e){var i=this,n=i.config;e=e||1,n.index=n.index-e,n.index<0&&(n.index=i.elemItem.length-1)},m.prototype.autoplay=function(){var e=this,i=e.config;i.autoplay&&(e.timer=setInterval(function(){e.slide()},i.interval))},m.prototype.arrow=function(){var e=this,n=e.config,t=i(['",'"].join(""));n.elem.attr("lay-arrow",n.arrow),n.elem.find("."+u)[0]&&n.elem.find("."+u).remove(),n.elem.append(t),t.on("click",function(){var n=i(this),t=n.attr("lay-type");e.slide(t)})},m.prototype.indicator=function(){var e=this,n=e.config,t=e.elemInd=i(['
    ',function(){var i=[];return layui.each(e.elemItem,function(e){i.push("")}),i.join("")}(),"
"].join(""));n.elem.attr("lay-indicator",n.indicator),n.elem.find("."+c)[0]&&n.elem.find("."+c).remove(),n.elem.append(t),"updown"===n.anim&&t.css("margin-top",-(t.height()/2)),t.find("li").on("hover"===n.trigger?"mouseover":n.trigger,function(){var t=i(this),a=t.index();a>n.index?e.slide("add",a-n.index):a/g,">").replace(/'/g,"'").replace(/"/g,""")),c.html('
  1. '+o.replace(/[\r\t\n]+/g,"
  2. ")+"
"),c.find(">.layui-code-h3")[0]||c.prepend('

'+(c.attr("lay-title")||e.title||"code")+(e.about?'layui.code':"")+"

");var d=c.find(">.layui-code-ol");c.addClass("layui-box layui-code-view"),(c.attr("lay-skin")||e.skin)&&c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),(d.find("li").length/100|0)>0&&d.css("margin-left",(d.find("li").length/100|0)+"px"),(c.attr("lay-height")||e.height)&&d.css("max-height",c.attr("lay-height")||e.height)})})}).addcss("modules/code.css","skincodecss"); -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/lay/modules/flow.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var l=layui.$,o=function(e){},t='';o.prototype.load=function(e){var o,i,n,r,a=this,c=0;e=e||{};var f=l(e.elem);if(f[0]){var m=l(e.scrollElem||document),u=e.mb||50,s=!("isAuto"in e)||e.isAuto,v=e.end||"没有更多了",y=e.scrollElem&&e.scrollElem!==document,d="加载更多",h=l('");f.find(".layui-flow-more")[0]||f.append(h);var p=function(e,t){e=l(e),h.before(e),t=0==t||null,t?h.html(v):h.find("a").html(d),i=t,o=null,n&&n()},g=function(){o=!0,h.find("a").html(t),"function"==typeof e.done&&e.done(++c,p)};if(g(),h.find("a").on("click",function(){l(this);i||o||g()}),e.isLazyimg)var n=a.lazyimg({elem:e.elem+" img",scrollElem:e.scrollElem});return s?(m.on("scroll",function(){var e=l(this),t=e.scrollTop();r&&clearTimeout(r),i||(r=setTimeout(function(){var i=y?e.height():l(window).height(),n=y?e.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-i<=u&&(o||g())},100))}),a):a}},o.prototype.lazyimg=function(e){var o,t=this,i=0;e=e||{};var n=l(e.scrollElem||document),r=e.elem||"img",a=e.scrollElem&&e.scrollElem!==document,c=function(e,l){var o=n.scrollTop(),r=o+l,c=a?function(){return e.offset().top-n.offset().top+o}():e.offset().top;if(c>=o&&c<=r&&!e.attr("src")){var m=e.attr("lay-src");layui.img(m,function(){var l=t.lazyimg.elem.eq(i);e.attr("src",m).removeAttr("lay-src"),l[0]&&f(l),i++})}},f=function(e,o){var f=a?(o||n).height():l(window).height(),m=n.scrollTop(),u=m+f;if(t.lazyimg.elem=l(r),e)c(e,f);else for(var s=0;su)break}};if(f(),!o){var m;n.on("scroll",function(){var e=l(this);m&&clearTimeout(m),m=setTimeout(function(){f(null,e)},50)}),o=!0}return f},e("flow",new o)}); -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/lay/modules/laypage.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.5 MIT License By https://www.layui.com */ 2 | ;layui.define(function(e){"use strict";var a=document,t="getElementById",n="getElementsByTagName",i="laypage",r="layui-disabled",u=function(e){var a=this;a.config=e||{},a.config.index=++s.index,a.render(!0)};u.prototype.type=function(){var e=this.config;if("object"==typeof e.elem)return void 0===e.elem.length?2:3},u.prototype.view=function(){var e=this,a=e.config,t=a.groups="groups"in a?0|a.groups:5;a.layout="object"==typeof a.layout?a.layout:["prev","page","next"],a.count=0|a.count,a.curr=0|a.curr||1,a.limits="object"==typeof a.limits?a.limits:[10,20,30,40,50],a.limit=0|a.limit||10,a.pages=Math.ceil(a.count/a.limit)||1,a.curr>a.pages&&(a.curr=a.pages),t<0?t=1:t>a.pages&&(t=a.pages),a.prev="prev"in a?a.prev:"上一页",a.next="next"in a?a.next:"下一页";var n=a.pages>t?Math.ceil((a.curr+(t>1?1:0))/(t>0?t:1)):1,i={prev:function(){return a.prev?''+a.prev+"":""}(),page:function(){var e=[];if(a.count<1)return"";n>1&&a.first!==!1&&0!==t&&e.push(''+(a.first||1)+"");var i=Math.floor((t-1)/2),r=n>1?a.curr-i:1,u=n>1?function(){var e=a.curr+(t-i-1);return e>a.pages?a.pages:e}():t;for(u-r2&&e.push('');r<=u;r++)r===a.curr?e.push('"+r+""):e.push(''+r+"");return a.pages>t&&a.pages>u&&a.last!==!1&&(u+1…'),0!==t&&e.push(''+(a.last||a.pages)+"")),e.join("")}(),next:function(){return a.next?''+a.next+"":""}(),count:'共 '+a.count+" 条",limit:function(){var e=['"}(),refresh:['','',""].join(""),skip:function(){return['到第','','页',""].join("")}()};return['
',function(){var e=[];return layui.each(a.layout,function(a,t){i[t]&&e.push(i[t])}),e.join("")}(),"
"].join("")},u.prototype.jump=function(e,a){if(e){var t=this,i=t.config,r=e.children,u=e[n]("button")[0],l=e[n]("input")[0],p=e[n]("select")[0],c=function(){var e=0|l.value.replace(/\s|\D/g,"");e&&(i.curr=e,t.render())};if(a)return c();for(var o=0,y=r.length;oi.pages||(i.curr=e,t.render())});p&&s.on(p,"change",function(){var e=this.value;i.curr*e>i.count&&(i.curr=Math.ceil(i.count/e)),i.limit=e,t.render()}),u&&s.on(u,"click",function(){c()})}},u.prototype.skip=function(e){if(e){var a=this,t=e[n]("input")[0];t&&s.on(t,"keyup",function(t){var n=this.value,i=t.keyCode;/^(37|38|39|40)$/.test(i)||(/\D/.test(n)&&(this.value=n.replace(/\D/,"")),13===i&&a.jump(e,!0))})}},u.prototype.render=function(e){var n=this,i=n.config,r=n.type(),u=n.view();2===r?i.elem&&(i.elem.innerHTML=u):3===r?i.elem.html(u):a[t](i.elem)&&(a[t](i.elem).innerHTML=u),i.jump&&i.jump(i,e);var s=a[t]("layui-laypage-"+i.index);n.jump(s),i.hash&&!e&&(location.hash="!"+i.hash+"="+i.curr),n.skip(s)};var s={render:function(e){var a=new u(e);return a.index},index:layui.laypage?layui.laypage.index+1e4:0,on:function(e,a,t){return e.attachEvent?e.attachEvent("on"+a,function(a){a.target=a.srcElement,t.call(e,a)}):e.addEventListener(a,t,!1),this}};e(i,s)}); -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/lay/modules/laytpl.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.5 MIT License By https://www.layui.com */ 2 | ;layui.define(function(e){"use strict";var r={open:"{{",close:"}}"},c={exp:function(e){return new RegExp(e,"g")},query:function(e,c,t){var o=["#([\\s\\S])+?","([^{#}])*?"][e||0];return n((c||"")+r.open+o+r.close+(t||""))},escape:function(e){return String(e||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(e,r){var c="Laytpl Error:";return"object"==typeof console&&console.error(c+e+"\n"+(r||"")),c+e}},n=c.exp,t=function(e){this.tpl=e};t.pt=t.prototype,window.errors=0,t.pt.parse=function(e,t){var o=this,p=e,a=n("^"+r.open+"#",""),l=n(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(n(r.open+"#"),r.open+"# ").replace(n(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(n(r.open+"!(.+?)!"+r.close),function(e){return e=e.replace(n("^"+r.open+"!"),"").replace(n("!"+r.close),"").replace(n(r.open+"|"+r.close),function(e){return e.replace(/(.)/g,"\\$1")})}).replace(/(?="|')/g,"\\").replace(c.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(c.query(1),function(e){var c='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(n(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),c='"+_escape_('),c+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,c.escape)}catch(u){return delete o.cache,c.error(u,p)}},t.pt.render=function(e,r){var n,t=this;return e?(n=t.cache?t.cache(e,c.escape):t.parse(t.tpl,e),r?void r(n):n):c.error("no data")};var o=function(e){return"string"!=typeof e?c.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var c in e)r[c]=e[c]},o.v="1.2.0",e("laytpl",o)}); -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/lay/modules/rate.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var a=layui.jquery,i={config:{},index:layui.rate?layui.rate.index+1e4:0,set:function(e){var i=this;return i.config=a.extend({},i.config,e),i},on:function(e,a){return layui.onevent.call(this,n,e,a)}},l=function(){var e=this,a=e.config;return{setvalue:function(a){e.setvalue.call(e,a)},config:a}},n="rate",t="layui-rate",o="layui-icon-rate",s="layui-icon-rate-solid",u="layui-icon-rate-half",r="layui-icon-rate-solid layui-icon-rate-half",c="layui-icon-rate-solid layui-icon-rate",f="layui-icon-rate layui-icon-rate-half",v=function(e){var l=this;l.index=++i.index,l.config=a.extend({},l.config,i.config,e),l.render()};v.prototype.config={length:5,text:!1,readonly:!1,half:!1,value:0,theme:""},v.prototype.render=function(){var e=this,i=e.config,l=i.theme?'style="color: '+i.theme+';"':"";i.elem=a(i.elem),parseInt(i.value)!==i.value&&(i.half||(i.value=Math.ceil(i.value)-i.value<.5?Math.ceil(i.value):Math.floor(i.value)));for(var n='
    ",u=1;u<=i.length;u++){var r='
  • ";i.half&&parseInt(i.value)!==i.value&&u==Math.ceil(i.value)?n=n+'
  • ":n+=r}n+="
"+(i.text?''+i.value+"星":"")+"";var c=i.elem,f=c.next("."+t);f[0]&&f.remove(),e.elemTemp=a(n),i.span=e.elemTemp.next("span"),i.setText&&i.setText(i.value),c.html(e.elemTemp),c.addClass("layui-inline"),i.readonly||e.action()},v.prototype.setvalue=function(e){var a=this,i=a.config;i.value=e,a.render()},v.prototype.action=function(){var e=this,i=e.config,l=e.elemTemp,n=l.find("i").width();l.children("li").each(function(e){var t=e+1,v=a(this);v.on("click",function(e){if(i.value=t,i.half){var o=e.pageX-a(this).offset().left;o<=n/2&&(i.value=i.value-.5)}i.text&&l.next("span").text(i.value+"星"),i.choose&&i.choose(i.value),i.setText&&i.setText(i.value)}),v.on("mousemove",function(e){if(l.find("i").each(function(){a(this).addClass(o).removeClass(r)}),l.find("i:lt("+t+")").each(function(){a(this).addClass(s).removeClass(f)}),i.half){var c=e.pageX-a(this).offset().left;c<=n/2&&v.children("i").addClass(u).removeClass(s)}}),v.on("mouseleave",function(){l.find("i").each(function(){a(this).addClass(o).removeClass(r)}),l.find("i:lt("+Math.floor(i.value)+")").each(function(){a(this).addClass(s).removeClass(f)}),i.half&&parseInt(i.value)!==i.value&&l.children("li:eq("+Math.floor(i.value)+")").children("i").addClass(u).removeClass(c)})})},v.prototype.events=function(){var e=this;e.config},i.render=function(e){var a=new v(e);return l.call(a)},e(n,i)}); -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/lay/modules/tree.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var o=layui.$,a=layui.hint(),i="layui-tree-enter",r=function(e){this.options=e},t={arrow:["",""],checkbox:["",""],radio:["",""],branch:["",""],leaf:""};r.prototype.init=function(e){var o=this;e.addClass("layui-box layui-tree"),o.options.skin&&e.addClass("layui-tree-skin-"+o.options.skin),o.tree(e),o.on(e)},r.prototype.tree=function(e,a){var i=this,r=i.options,n=a||r.nodes;layui.each(n,function(a,n){var l=n.children&&n.children.length>0,c=o('
    '),s=o(["
  • ",function(){return l?''+(n.spread?t.arrow[1]:t.arrow[0])+"":""}(),function(){return r.check?''+("checkbox"===r.check?t.checkbox[0]:"radio"===r.check?t.radio[0]:"")+"":""}(),function(){return'"+(''+(l?n.spread?t.branch[1]:t.branch[0]:t.leaf)+"")+(""+(n.name||"未命名")+"")}(),"
  • "].join(""));l&&(s.append(c),i.tree(c,n.children)),e.append(s),"function"==typeof r.click&&i.click(s,n),i.spread(s,n),r.drag&&i.drag(s,n)})},r.prototype.click=function(e,o){var a=this,i=a.options;e.children("a").on("click",function(e){layui.stope(e),i.click(o)})},r.prototype.spread=function(e,o){var a=this,i=(a.options,e.children(".layui-tree-spread")),r=e.children("ul"),n=e.children("a"),l=function(){e.data("spread")?(e.data("spread",null),r.removeClass("layui-show"),i.html(t.arrow[0]),n.find(".layui-icon").html(t.branch[0])):(e.data("spread",!0),r.addClass("layui-show"),i.html(t.arrow[1]),n.find(".layui-icon").html(t.branch[1]))};r[0]&&(i.on("click",l),n.on("dblclick",l))},r.prototype.on=function(e){var a=this,r=a.options,t="layui-tree-drag";e.find("i").on("selectstart",function(e){return!1}),r.drag&&o(document).on("mousemove",function(e){var i=a.move;if(i.from){var r=(i.to,o('
    '));e.preventDefault(),o("."+t)[0]||o("body").append(r);var n=o("."+t)[0]?o("."+t):r;n.addClass("layui-show").html(i.from.elem.children("a").html()),n.css({left:e.pageX+10,top:e.pageY+10})}}).on("mouseup",function(){var e=a.move;e.from&&(e.from.elem.children("a").removeClass(i),e.to&&e.to.elem.children("a").removeClass(i),a.move={},o("."+t).remove())})},r.prototype.move={},r.prototype.drag=function(e,a){var r=this,t=(r.options,e.children("a")),n=function(){var t=o(this),n=r.move;n.from&&(n.to={item:a,elem:e},t.addClass(i))};t.on("mousedown",function(){var o=r.move;o.from={item:a,elem:e}}),t.on("mouseenter",n).on("mousemove",n).on("mouseleave",function(){var e=o(this),a=r.move;a.from&&(delete a.to,e.removeClass(i))})},e("tree",function(e){var i=new r(e=e||{}),t=o(e.elem);return t[0]?void i.init(t):a.error("layui.tree 没有找到"+e.elem+"元素")})}); -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/lay/modules/upload.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.5 MIT License By https://www.layui.com */ 2 | ;layui.define("layer",function(e){"use strict";var i=layui.$,t=layui.layer,n=layui.hint(),a=layui.device(),o={config:{},set:function(e){var t=this;return t.config=i.extend({},t.config,e),t},on:function(e,i){return layui.onevent.call(this,r,e,i)}},l=function(){var e=this;return{upload:function(i){e.upload.call(e,i)},config:e.config}},r="upload",u="layui-upload-file",c="layui-upload-form",f="layui-upload-iframe",s="layui-upload-choose",p=function(e){var t=this;t.config=i.extend({},t.config,o.config,e),t.render()};p.prototype.config={accept:"images",exts:"",auto:!0,bindAction:"",url:"",field:"file",method:"post",data:{},drag:!0,size:0,number:0,multiple:!1},p.prototype.render=function(e){var t=this,e=t.config;e.elem=i(e.elem),e.bindAction=i(e.bindAction),t.file(),t.events()},p.prototype.file=function(){var e=this,t=e.config,n=e.elemFile=i(['"].join("")),o=t.elem.next();(o.hasClass(u)||o.hasClass(c))&&o.remove(),a.ie&&a.ie<10&&t.elem.wrap('
    '),e.isFile()?(e.elemFile=t.elem,t.field=t.elem[0].name):t.elem.after(n),a.ie&&a.ie<10&&e.initIE()},p.prototype.initIE=function(){var e=this,t=e.config,n=i(''),a=i(['
    ',"
    "].join(""));i("#"+f)[0]||i("body").append(n),t.elem.next().hasClass(c)||(e.elemFile.wrap(a),t.elem.next("."+c).append(function(){var e=[];return layui.each(t.data,function(i,t){t="function"==typeof t?t():t,e.push('')}),e.join("")}()))},p.prototype.msg=function(e){return t.msg(e,{icon:2,shift:6})},p.prototype.isFile=function(){var e=this.config.elem[0];if(e)return"input"===e.tagName.toLocaleLowerCase()&&"file"===e.type},p.prototype.preview=function(e){var i=this;window.FileReader&&layui.each(i.chooseFiles,function(i,t){var n=new FileReader;n.readAsDataURL(t),n.onload=function(){e&&e(i,t,this.result)}})},p.prototype.upload=function(e,t){var n,o=this,l=o.config,r=o.elemFile[0],u=function(){var t=0,n=0,a=e||o.files||o.chooseFiles||r.files,u=function(){l.multiple&&t+n===o.fileLength&&"function"==typeof l.allDone&&l.allDone({total:o.fileLength,successful:t,aborted:n})};layui.each(a,function(e,a){var r=new FormData;r.append(l.field,a),layui.each(l.data,function(e,i){i="function"==typeof i?i():i,r.append(e,i)}),i.ajax({url:l.url,type:"post",data:r,contentType:!1,processData:!1,dataType:"json",headers:l.headers||{},success:function(i){t++,d(e,i),u()},error:function(){n++,o.msg("请求上传接口出现异常"),m(e),u()}})})},c=function(){var e=i("#"+f);o.elemFile.parent().submit(),clearInterval(p.timer),p.timer=setInterval(function(){var i,t=e.contents().find("body");try{i=t.text()}catch(n){o.msg("获取上传后的响应信息出现异常"),clearInterval(p.timer),m()}i&&(clearInterval(p.timer),t.html(""),d(0,i))},30)},d=function(e,i){if(o.elemFile.next("."+s).remove(),r.value="","object"!=typeof i)try{i=JSON.parse(i)}catch(t){return i={},o.msg("请对上传接口返回有效JSON")}"function"==typeof l.done&&l.done(i,e||0,function(e){o.upload(e)})},m=function(e){l.auto&&(r.value=""),"function"==typeof l.error&&l.error(e||0,function(e){o.upload(e)})},h=l.exts,v=function(){var i=[];return layui.each(e||o.chooseFiles,function(e,t){i.push(t.name)}),i}(),g={preview:function(e){o.preview(e)},upload:function(e,i){var t={};t[e]=i,o.upload(t)},pushFile:function(){return o.files=o.files||{},layui.each(o.chooseFiles,function(e,i){o.files[e]=i}),o.files},resetFile:function(e,i,t){var n=new File([i],t);o.files=o.files||{},o.files[e]=n}},y=function(){if("choose"!==t&&!l.auto||(l.choose&&l.choose(g),"choose"!==t))return l.before&&l.before(g),a.ie?a.ie>9?u():c():void u()};if(v=0===v.length?r.value.match(/[^\/\\]+\..+/g)||[]||"":v,0!==v.length){switch(l.accept){case"file":if(h&&!RegExp("\\w\\.("+h+")$","i").test(escape(v)))return o.msg("选择的文件中包含不支持的格式"),r.value="";break;case"video":if(!RegExp("\\w\\.("+(h||"avi|mp4|wma|rmvb|rm|flash|3gp|flv")+")$","i").test(escape(v)))return o.msg("选择的视频中包含不支持的格式"),r.value="";break;case"audio":if(!RegExp("\\w\\.("+(h||"mp3|wav|mid")+")$","i").test(escape(v)))return o.msg("选择的音频中包含不支持的格式"),r.value="";break;default:if(layui.each(v,function(e,i){RegExp("\\w\\.("+(h||"jpg|png|gif|bmp|jpeg$")+")","i").test(escape(i))||(n=!0)}),n)return o.msg("选择的图片中包含不支持的格式"),r.value=""}if(o.fileLength=function(){var i=0,t=e||o.files||o.chooseFiles||r.files;return layui.each(t,function(){i++}),i}(),l.number&&o.fileLength>l.number)return o.msg("同时最多只能上传的数量为:"+l.number);if(l.size>0&&!(a.ie&&a.ie<10)){var F;if(layui.each(o.chooseFiles,function(e,i){if(i.size>1024*l.size){var t=l.size/1024;t=t>=1?t.toFixed(2)+"MB":l.size+"KB",r.value="",F=t}}),F)return o.msg("文件不能超过"+F)}y()}},p.prototype.events=function(){var e=this,t=e.config,o=function(i){e.chooseFiles={},layui.each(i,function(i,t){var n=(new Date).getTime();e.chooseFiles[n+"-"+i]=t})},l=function(i,n){var a=e.elemFile,o=i.length>1?i.length+"个文件":(i[0]||{}).name||a[0].value.match(/[^\/\\]+\..+/g)||[]||"";a.next().hasClass(s)&&a.next().remove(),e.upload(null,"choose"),e.isFile()||t.choose||a.after(''+o+"")};t.elem.off("upload.start").on("upload.start",function(){var a=i(this),o=a.attr("lay-data");if(o)try{o=new Function("return "+o)(),e.config=i.extend({},t,o)}catch(l){n.error("Upload element property lay-data configuration item has a syntax error: "+o)}e.config.item=a,e.elemFile[0].click()}),a.ie&&a.ie<10||t.elem.off("upload.over").on("upload.over",function(){var e=i(this);e.attr("lay-over","")}).off("upload.leave").on("upload.leave",function(){var e=i(this);e.removeAttr("lay-over")}).off("upload.drop").on("upload.drop",function(n,a){var r=i(this),u=a.originalEvent.dataTransfer.files||[];r.removeAttr("lay-over"),o(u),t.auto?e.upload(u):l(u)}),e.elemFile.off("upload.change").on("upload.change",function(){var i=this.files||[];o(i),t.auto?e.upload():l(i)}),t.bindAction.off("upload.action").on("upload.action",function(){e.upload()}),t.elem.data("haveEvents")||(e.elemFile.on("change",function(){i(this).trigger("upload.change")}),t.elem.on("click",function(){e.isFile()||i(this).trigger("upload.start")}),t.drag&&t.elem.on("dragover",function(e){e.preventDefault(),i(this).trigger("upload.over")}).on("dragleave",function(e){i(this).trigger("upload.leave")}).on("drop",function(e){e.preventDefault(),i(this).trigger("upload.drop",e)}),t.bindAction.on("click",function(){i(this).trigger("upload.action")}),t.elem.data("haveEvents",!0))},o.render=function(e){var i=new p(e);return l.call(i)},e(r,o)}); -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/lay/modules/util.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(t){"use strict";var e=layui.$,i={fixbar:function(t){var i,a,n="layui-fixbar",r="layui-fixbar-top",o=e(document),l=e("body");t=e.extend({showHeight:200},t),t.bar1=t.bar1===!0?"":t.bar1,t.bar2=t.bar2===!0?"":t.bar2,t.bgcolor=t.bgcolor?"background-color:"+t.bgcolor:"";var c=[t.bar1,t.bar2,""],g=e(['
      ',t.bar1?'
    • '+c[0]+"
    • ":"",t.bar2?'
    • '+c[1]+"
    • ":"",'
    • '+c[2]+"
    • ","
    "].join("")),s=g.find("."+r),u=function(){var e=o.scrollTop();e>=t.showHeight?i||(s.show(),i=1):i&&(s.hide(),i=0)};e("."+n)[0]||("object"==typeof t.css&&g.css(t.css),l.append(g),u(),g.find("li").on("click",function(){var i=e(this),a=i.attr("lay-type");"top"===a&&e("html,body").animate({scrollTop:0},200),t.click&&t.click.call(this,a)}),o.on("scroll",function(){clearTimeout(a),a=setTimeout(function(){u()},100)}))},countdown:function(t,e,i){var a=this,n="function"==typeof e,r=new Date(t).getTime(),o=new Date(!e||n?(new Date).getTime():e).getTime(),l=r-o,c=[Math.floor(l/864e5),Math.floor(l/36e5)%24,Math.floor(l/6e4)%60,Math.floor(l/1e3)%60];n&&(i=e);var g=setTimeout(function(){a.countdown(t,o+1e3,i)},1e3);return i&&i(l>0?c:[0,0,0,0],e,g),l<=0&&clearTimeout(g),g},timeAgo:function(t,e){var i=this,a=[[],[]],n=(new Date).getTime()-new Date(t).getTime();return n>6912e5?(n=new Date(t),a[0][0]=i.digit(n.getFullYear(),4),a[0][1]=i.digit(n.getMonth()+1),a[0][2]=i.digit(n.getDate()),e||(a[1][0]=i.digit(n.getHours()),a[1][1]=i.digit(n.getMinutes()),a[1][2]=i.digit(n.getSeconds())),a[0].join("-")+" "+a[1].join(":")):n>=864e5?(n/1e3/60/60/24|0)+"天前":n>=36e5?(n/1e3/60/60|0)+"小时前":n>=12e4?(n/1e3/60|0)+"分钟前":n<0?"未来":"刚刚"},digit:function(t,e){var i="";t=String(t),e=e||2;for(var a=t.length;a/g,">").replace(/'/g,"'").replace(/"/g,""")}};!function(t,e,i){"$:nomunge";function a(){n=e[l](function(){r.each(function(){var e=t(this),i=e.width(),a=e.height(),n=t.data(this,g);(i!==n.w||a!==n.h)&&e.trigger(c,[n.w=i,n.h=a])}),a()},o[s])}var n,r=t([]),o=t.resize=t.extend(t.resize,{}),l="setTimeout",c="resize",g=c+"-special-event",s="delay",u="throttleWindow";o[s]=250,o[u]=!0,t.event.special[c]={setup:function(){if(!o[u]&&this[l])return!1;var e=t(this);r=r.add(e),t.data(this,g,{w:e.width(),h:e.height()}),1===r.length&&a()},teardown:function(){if(!o[u]&&this[l])return!1;var e=t(this);r=r.not(e),e.removeData(g),r.length||clearTimeout(n)},add:function(e){function a(e,a,r){var o=t(this),l=t.data(this,g)||{};l.w=a!==i?a:o.width(),l.h=r!==i?r:o.height(),n.apply(this,arguments)}if(!o[u]&&this[l])return!1;var n;return t.isFunction(e)?(n=e,a):(n=e.handler,void(e.handler=a))}}}(e,window),t("util",i)}); -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/layui.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.5 MIT License By https://www.layui.com */ 2 | ;!function(e){"use strict";var t=document,o={modules:{},status:{},timeout:10,event:{}},n=function(){this.v="2.4.5"},r=function(){var e=t.currentScript?t.currentScript.src:function(){for(var e,o=t.scripts,n=o.length-1,r=n;r>0;r--)if("interactive"===o[r].readyState){e=o[r].src;break}return e||o[n].src}();return e.substring(0,e.lastIndexOf("/")+1)}(),i=function(t){e.console&&console.error&&console.error("Layui hint: "+t)},a="undefined"!=typeof opera&&"[object Opera]"===opera.toString(),u={layer:"modules/layer",laydate:"modules/laydate",laypage:"modules/laypage",laytpl:"modules/laytpl",layim:"modules/layim",layedit:"modules/layedit",form:"modules/form",upload:"modules/upload",tree:"modules/tree",table:"modules/table",element:"modules/element",rate:"modules/rate",colorpicker:"modules/colorpicker",slider:"modules/slider",carousel:"modules/carousel",flow:"modules/flow",util:"modules/util",code:"modules/code",jquery:"modules/jquery",mobile:"modules/mobile","layui.all":"../layui.all"};n.prototype.cache=o,n.prototype.define=function(e,t){var n=this,r="function"==typeof e,i=function(){var e=function(e,t){layui[e]=t,o.status[e]=!0};return"function"==typeof t&&t(function(n,r){e(n,r),o.callback[n]=function(){t(e)}}),this};return r&&(t=e,e=[]),layui["layui.all"]||!layui["layui.all"]&&layui["layui.mobile"]?i.call(n):(n.use(e,i),n)},n.prototype.use=function(e,n,l){function s(e,t){var n="PLaySTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/;("load"===e.type||n.test((e.currentTarget||e.srcElement).readyState))&&(o.modules[f]=t,d.removeChild(v),function r(){return++m>1e3*o.timeout/4?i(f+" is not a valid module"):void(o.status[f]?c():setTimeout(r,4))}())}function c(){l.push(layui[f]),e.length>1?y.use(e.slice(1),n,l):"function"==typeof n&&n.apply(layui,l)}var y=this,p=o.dir=o.dir?o.dir:r,d=t.getElementsByTagName("head")[0];e="string"==typeof e?[e]:e,window.jQuery&&jQuery.fn.on&&(y.each(e,function(t,o){"jquery"===o&&e.splice(t,1)}),layui.jquery=layui.$=jQuery);var f=e[0],m=0;if(l=l||[],o.host=o.host||(p.match(/\/\/([\s\S]+?)\//)||["//"+location.host+"/"])[0],0===e.length||layui["layui.all"]&&u[f]||!layui["layui.all"]&&layui["layui.mobile"]&&u[f])return c(),y;if(o.modules[f])!function g(){return++m>1e3*o.timeout/4?i(f+" is not a valid module"):void("string"==typeof o.modules[f]&&o.status[f]?c():setTimeout(g,4))}();else{var v=t.createElement("script"),h=(u[f]?p+"lay/":/^\{\/\}/.test(y.modules[f])?"":o.base||"")+(y.modules[f]||f)+".js";h=h.replace(/^\{\/\}/,""),v.async=!0,v.charset="utf-8",v.src=h+function(){var e=o.version===!0?o.v||(new Date).getTime():o.version||"";return e?"?v="+e:""}(),d.appendChild(v),!v.attachEvent||v.attachEvent.toString&&v.attachEvent.toString().indexOf("[native code")<0||a?v.addEventListener("load",function(e){s(e,h)},!1):v.attachEvent("onreadystatechange",function(e){s(e,h)}),o.modules[f]=h}return y},n.prototype.getStyle=function(t,o){var n=t.currentStyle?t.currentStyle:e.getComputedStyle(t,null);return n[n.getPropertyValue?"getPropertyValue":"getAttribute"](o)},n.prototype.link=function(e,n,r){var a=this,u=t.createElement("link"),l=t.getElementsByTagName("head")[0];"string"==typeof n&&(r=n);var s=(r||e).replace(/\.|\//g,""),c=u.id="layuicss-"+s,y=0;return u.rel="stylesheet",u.href=e+(o.debug?"?v="+(new Date).getTime():""),u.media="all",t.getElementById(c)||l.appendChild(u),"function"!=typeof n?a:(function p(){return++y>1e3*o.timeout/100?i(e+" timeout"):void(1989===parseInt(a.getStyle(t.getElementById(c),"width"))?function(){n()}():setTimeout(p,100))}(),a)},o.callback={},n.prototype.factory=function(e){if(layui[e])return"function"==typeof o.callback[e]?o.callback[e]:null},n.prototype.addcss=function(e,t,n){return layui.link(o.dir+"css/"+e,t,n)},n.prototype.img=function(e,t,o){var n=new Image;return n.src=e,n.complete?t(n):(n.onload=function(){n.onload=null,"function"==typeof t&&t(n)},void(n.onerror=function(e){n.onerror=null,"function"==typeof o&&o(e)}))},n.prototype.config=function(e){e=e||{};for(var t in e)o[t]=e[t];return this},n.prototype.modules=function(){var e={};for(var t in u)e[t]=u[t];return e}(),n.prototype.extend=function(e){var t=this;e=e||{};for(var o in e)t[o]||t.modules[o]?i("模块名 "+o+" 已被占用"):t.modules[o]=e[o];return t},n.prototype.router=function(e){var t=this,e=e||location.hash,o={path:[],search:{},hash:(e.match(/[^#](#.*$)/)||[])[1]||""};return/^#\//.test(e)?(e=e.replace(/^#\//,""),o.href="/"+e,e=e.replace(/([^#])(#.*$)/,"$1").split("/")||[],t.each(e,function(e,t){/^\w+=/.test(t)?function(){t=t.split("="),o.search[t[0]]=t[1]}():o.path.push(t)}),o):o},n.prototype.data=function(t,o,n){if(t=t||"layui",n=n||localStorage,e.JSON&&e.JSON.parse){if(null===o)return delete n[t];o="object"==typeof o?o:{key:o};try{var r=JSON.parse(n[t])}catch(i){var r={}}return"value"in o&&(r[o.key]=o.value),o.remove&&delete r[o.key],n[t]=JSON.stringify(r),o.key?r[o.key]:r}},n.prototype.sessionData=function(e,t){return this.data(e,t,sessionStorage)},n.prototype.device=function(t){var o=navigator.userAgent.toLowerCase(),n=function(e){var t=new RegExp(e+"/([^\\s\\_\\-]+)");return e=(o.match(t)||[])[1],e||!1},r={os:function(){return/windows/.test(o)?"windows":/linux/.test(o)?"linux":/iphone|ipod|ipad|ios/.test(o)?"ios":/mac/.test(o)?"mac":void 0}(),ie:function(){return!!(e.ActiveXObject||"ActiveXObject"in e)&&((o.match(/msie\s(\d+)/)||[])[1]||"11")}(),weixin:n("micromessenger")};return t&&!r[t]&&(r[t]=n(t)),r.android=/android/.test(o),r.ios="ios"===r.os,r},n.prototype.hint=function(){return{error:i}},n.prototype.each=function(e,t){var o,n=this;if("function"!=typeof t)return n;if(e=e||[],e.constructor===Object){for(o in e)if(t.call(e[o],o,e[o]))break}else for(o=0;oi?1:rdiv.layui-select-title+ dl, 2 | .select_option_in_layer div.layui-form-select>div.layui-select-title+ dl 3 | /*.layui-table-view .layui-form-select dl*/ 4 | { 5 | /*display: none !important;*/ 6 | visibility: hidden; 7 | } 8 | 9 | .layui-layer.layui-option-layer { 10 | mso-border-shadow: no; 11 | box-shadow: none; 12 | } 13 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/layui/plugin/optimizeSelectOption/optimizeSelectOption.min.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.4 MIT License By https://www.layui.com */ 2 | ;!function(e){"use strict";var t="optimizeSelectOption";window.top.layui?window.top.layui.use("layer",function(){layui.define(["form"],function(n){n(t,e(t))})}):(console.warn("使用插件:"+t+"页面顶层窗口必须引入layui"),layui.define(["form"],function(e){e(t,{msg:"使用插件:"+t+"页面顶层窗口必须引入layui"})}))}(function(e){function t(e,n,o){n=n||window,e=e.length?e.get(0):e;var i={};if(o&&n.top!==n.self){var l=n.frames.frameElement;i=t(l,n.parent,o)}var a=e.getBoundingClientRect();return{top:a.top+(i.top||0),left:a.left+(i.left||0)}}var n="0.1.9",o=layui.$,i=layui.form,l=(layui.layer,layui.cache.modules.optimizeSelectOption.substr(0,layui.cache.modules.optimizeSelectOption.lastIndexOf("/")));layui.link(l+"/optimizeSelectOption.css?v"+n);var a=[".layui-table-view",".layui-layer-content",".select_option_to_layer"];if(window.top.layer._indexTemp=window.top.layer._indexTemp||{},!i.render.plugFlag){var r=i.render;i.render=function(e,t,n){var i,l=this;return n?layui.each(n,function(t,n){n=o(n);var a=n.parent(),s=a.hasClass("layui-form"),u=a.attr("lay-filter");s?"":a.addClass("layui-form"),u?"":a.attr("lay-filter","tablePlug_form_filter_temp_"+(new Date).getTime()+"_"+Math.floor(1e5*Math.random())),i=r.call(l,e,a.attr("lay-filter")),s?"":a.removeClass("layui-form"),u?"":a.attr("lay-filter",null)}):i=r.call(l,e,t),i},i.render.plugFlag=!0}var s=function(){window.top.layer.close(window.top.layer._indexTemp[e])},u={},c=function(n,i){var l=this;return u.name?(console.warn("针对",n,"的显示优化已经存在,请不要重复渲染!"),l):void o(document).on("click",a.map(function(e){return e+" "+i.triggerElem}).join(","),function(n){function l(){var e=t(u,window,!0),n=e.top,o=e.left;return p?n=n-c.outerHeight()+u.outerHeight()-parseFloat(c.css("bottom")):n+=parseFloat(c.css("top")),{top:n,left:o}}layui.stope(n),s();var r=o(this),u=r,c="function"==typeof i.dlElem?i.dlElem(r):u.next(),f=u.parent().prev(),p=u.parent().hasClass("layui-form-selectup"),d=l();u.css({backgroundColor:"transparent"}),window.top.layer._indexTemp[e]=window.top.layer.open({type:1,title:!1,closeBtn:0,shade:0,anim:-1,fixed:u.closest(".layui-layer-content").length||window.top!==window.self,isOutAnim:!1,offset:[d.top+"px",d.left+"px"],area:c.outerWidth()+"px",content:'
    ',skin:"layui-option-layer",success:function(e,t){c.css({top:0,position:"relative"}).appendTo(e.find(".layui-layer-content").css({overflow:"hidden"}).find(".layui-form-selected")),e.width(u.width());var n=window.top.innerHeight-e.outerHeight()-parseFloat(e.css("top"));p&&e.css({top:"auto",bottom:n+"px"}),"function"==typeof i.success&&i.success.call(this,t,e),e.on("mousedown",function(e){layui.stope(e)}),setTimeout(function(){u.parentsUntil(a.join(",")).one("scroll",function(e){s()}),u.parents(a.join(",")).one("scroll",function(e){s()});var e=window;do{var t=e.$||e.layui.$;t&&(t(e.document).one("click",function(e){s()}),t(e.document).one("mousedown",function(e){s()}),t(e).one("resize",function(e){s()}),t(e.document).one("scroll",function(){top!==self&&parent.parent&&s()}))}while(e.self!==e.top&&(e=e.parent))},500)},end:function(){"function"==typeof i.end&&i.end.call(this,f)}})})};return c("layuiSelect",{triggerElem:"div:not(.layui-select-disabled)>.layui-select-title",success:function(e,t){t.find("dl dd").click(function(){s()})},end:function(e){i.render("select",null,e)}}),{version:n,getPosition:t,close:s}}); -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/pages/addPerson.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 更新武侠 6 | 7 | 8 | 9 | 10 |
    11 |
    12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
    20 |
    21 | 22 |
    23 | 25 |
    26 |
    27 | 28 |
    29 | 30 |
    31 | 33 |
    34 |
    35 |
    36 | 37 |
    38 |
    39 | 40 |
    41 | 46 |
    47 |
    48 |
    49 | 50 |
    51 | 53 |
    54 |
    55 |
    56 |
    57 | 58 |
    59 | 60 |
    61 | 63 |
    64 |
    65 |
    66 | 67 |
    68 | 70 |
    71 |
    72 | 73 |
    74 |
    75 |
    76 | 77 |
    78 | 80 |
    81 |
    82 |
    83 |
    84 |
    85 | 86 | 87 |
    88 |
    89 |
    90 |
    91 | 92 | 93 | 94 | 95 | 96 | 97 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /springboot-layui-demo/src/main/resources/static/utils/common.js: -------------------------------------------------------------------------------- 1 | var index; 2 | 3 | function open_form(element, data, title, width, height) { 4 | if (title == null || title == '') { 5 | title = false; 6 | } 7 | if (width == null || width == '') { 8 | width = '100%'; 9 | } 10 | if (height == null || height == '') { 11 | height = '100%'; 12 | } 13 | 14 | index = layer.open({ 15 | type: 1, 16 | title: title, 17 | area: [width, height], 18 | fix: false, //不固定 19 | maxmin: true,//开启最大化最小化按钮 20 | shadeClose: true,//点击阴影处可关闭 21 | shade: 0.4,//背景灰度 22 | // skin: 'layui-layer-rim', //加上边框 23 | content: $(element), 24 | success: function () { 25 | $(element).setForm(data); 26 | layui.form.render(); // 下拉框赋值 27 | } 28 | }); 29 | } 30 | 31 | function checkForm(formId) { 32 | var form = document.getElementById(formId); 33 | var count = 0; 34 | for (var i = 0; i < form.elements.length - 1; i++) { 35 | if (!form.elements[i].value == "") { 36 | count++; 37 | } 38 | } 39 | return count; 40 | } 41 | 42 | function tableReload(tableId, where, contentType, url, method) { 43 | layui.table.reload(tableId, { 44 | where: where, 45 | contentType: contentType, 46 | page: { 47 | curr: 1 //重新从第 1 页开始 48 | }, 49 | url: url 50 | , method: method 51 | }); 52 | } 53 | //这个方法是用来初始化弹层 54 | $.fn.setForm = function (jsonValue) { 55 | var obj = this; 56 | $.each(jsonValue, function (name, ival) { 57 | var $oinput = obj.find("input[name=" + name + "]"); 58 | if ($oinput.attr("type") == "checkbox") { 59 | if (ival !== null) { 60 | var checkboxObj = $("[name=" + name + "]"); 61 | var checkArray = ival.split(";"); 62 | for (var i = 0; i < checkboxObj.length; i++) { 63 | for (var j = 0; j < checkArray.length; j++) { 64 | if (checkboxObj[i].value == checkArray[j]) { 65 | checkboxObj[i].click(); 66 | } 67 | } 68 | } 69 | } 70 | } else if ($oinput.attr("type") == "radio") { 71 | $oinput.each(function () { 72 | var radioObj = $("[name=" + name + "]"); 73 | for (var i = 0; i < radioObj.length; i++) { 74 | if (radioObj[i].value == ival) { 75 | radioObj[i].click(); 76 | } 77 | } 78 | }); 79 | } else if ($oinput.attr("type") == "textarea") { 80 | obj.find("[name=" + name + "]").html(ival); 81 | } else { 82 | obj.find("[name=" + name + "]").val(ival); 83 | } 84 | }) 85 | }; -------------------------------------------------------------------------------- /stream-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springboot-demo-major 7 | com.mutest 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | stream-demo 13 | 14 | 15 | 8 16 | 8 17 | 18 | 19 | -------------------------------------------------------------------------------- /stream-demo/src/main/java/stream/model/Person.java: -------------------------------------------------------------------------------- 1 | package stream.model; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | /** 9 | * @author muguozheng 10 | * @version 1.0.0 11 | * @createTime 2022/9/6 9:54 12 | * @description 实体类 13 | */ 14 | @Data 15 | public class Person { 16 | private String name; // 姓名 17 | private int salary; // 薪资 18 | private int age; // 年龄 19 | private String sex; //性别 20 | private String area; // 地区 21 | 22 | // 构造方法 23 | public Person(String name, int salary, int age, String sex, String area) { 24 | this.name = name; 25 | this.salary = salary; 26 | this.age = age; 27 | this.sex = sex; 28 | this.area = area; 29 | } 30 | 31 | public static List assemblePersonList() { 32 | List personList = new ArrayList<>(); 33 | personList.add(new Person("Tom", 8900, 23, "male", "New York")); 34 | personList.add(new Person("Jack", 7000, 25, "male", "Washington")); 35 | personList.add(new Person("Lily", 7800, 21, "female", "Washington")); 36 | personList.add(new Person("Anni", 8200, 24, "female", "New York")); 37 | personList.add(new Person("Owen", 9500, 25, "male", "New York")); 38 | personList.add(new Person("Alisa", 7900, 26, "female", "New York")); 39 | 40 | return personList; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /stream-demo/src/main/java/stream/test/AggregationTest.java: -------------------------------------------------------------------------------- 1 | package stream.test; 2 | 3 | import stream.model.Person; 4 | 5 | import java.util.*; 6 | 7 | /** 8 | * @author muguozheng 9 | * @version 1.0.0 10 | * @createTime 2022/9/6 10:04 11 | * @description 聚合测试类,包括max、min、sum、count 12 | */ 13 | public class AggregationTest { 14 | public static void main(String[] args) { 15 | findingLongest(); 16 | findingMax(); 17 | maxmumSalary(); 18 | count(); 19 | } 20 | 21 | /** 22 | * 获取String集合中最长的元素。 23 | */ 24 | public static void findingLongest() { 25 | List list = Arrays.asList("adnm", "admmt", "pot", "xbangd", "weoujgsd"); 26 | 27 | Optional max = list.stream().max(Comparator.comparing(String::length)); 28 | System.out.println("最长的字符串:" + max.get()); 29 | } 30 | 31 | /** 32 | * 获取Integer集合中的最大值 33 | */ 34 | public static void findingMax() { 35 | List list = Arrays.asList(7, 6, 9, 4, 11, 6); 36 | 37 | // 自然排序 38 | Optional max = list.stream().max(Integer::compareTo); 39 | // 自定义排序 40 | Optional max2 = list.stream().max((o1, o2) -> o2 - o1); 41 | System.out.println("自然排序的最大值:" + max.get()); 42 | System.out.println("自定义排序的最大值:" + max2.get()); 43 | } 44 | 45 | /** 46 | * 获取员工薪资最高的人 47 | */ 48 | public static void maxmumSalary() { 49 | List personList = Person.assemblePersonList(); 50 | 51 | Optional max = personList.stream().max(Comparator.comparingInt(Person::getSalary)); 52 | System.out.println("员工工资最大值:" + max.get().getSalary()); 53 | } 54 | 55 | public static void count() { 56 | List list = Arrays.asList(7, 6, 4, 8, 2, 11, 9); 57 | 58 | long count = list.stream().filter(x -> x > 6).count(); 59 | System.out.println("list中大于6的元素个数:" + count); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /stream-demo/src/main/java/stream/test/CollectTest.java: -------------------------------------------------------------------------------- 1 | package stream.test; 2 | 3 | import stream.model.Person; 4 | 5 | import java.util.*; 6 | import java.util.stream.Collectors; 7 | 8 | /** 9 | * @author muguozheng 10 | * @version 1.0.0 11 | * @createTime 2022/9/6 14:35 12 | * @description collect测试类 13 | */ 14 | public class CollectTest { 15 | public static void main(String[] args) { 16 | collectTest(); 17 | collectTest2(); 18 | collectTest3(); 19 | } 20 | 21 | public static void collectTest() { 22 | List list = Arrays.asList(1, 6, 3, 4, 6, 7, 9, 6, 20); 23 | List listNew = list.stream().filter(x -> x % 2 == 0).collect(Collectors.toList()); 24 | Set set = list.stream().filter(x -> x % 2 == 0).collect(Collectors.toSet()); 25 | 26 | List personList = Person.assemblePersonList(); 27 | 28 | Map map = personList.stream().filter(p -> p.getSalary() > 8000) 29 | .collect(Collectors.toMap(Person::getName, p -> p)); 30 | System.out.println("toList:" + listNew); 31 | System.out.println("toSet:" + set); 32 | System.out.println("toMap:" + map); 33 | } 34 | 35 | public static void collectTest2() { 36 | List personList = Person.assemblePersonList(); 37 | // 求总数 38 | Long count = personList.stream().collect(Collectors.counting()); 39 | // 求平均工资 40 | Double average = personList.stream().collect(Collectors.averagingDouble(Person::getSalary)); 41 | // 求最高工资 42 | Optional max = personList.stream().map(Person::getSalary).collect(Collectors.maxBy(Integer::compare)); 43 | // 求工资之和 44 | Integer sum = personList.stream().collect(Collectors.summingInt(Person::getSalary)); 45 | // 一次性统计所有信息 46 | DoubleSummaryStatistics collect = personList.stream().collect(Collectors.summarizingDouble(Person::getSalary)); 47 | 48 | System.out.println("员工总数:" + count); 49 | System.out.println("员工平均工资:" + average); 50 | System.out.println("员工工资总和:" + sum); 51 | System.out.println("员工工资所有统计:" + collect); 52 | } 53 | 54 | public static void collectTest3() { 55 | List personList = Person.assemblePersonList(); 56 | // 将员工按薪资是否高于8000分组 57 | Map> part = personList.stream().collect(Collectors.partitioningBy(x -> x.getSalary() > 8000)); 58 | // 将员工按性别分组 59 | Map> group = personList.stream().collect(Collectors.groupingBy(Person::getSex)); 60 | // 将员工先按性别分组,再按地区分组 61 | Map>> group2 = personList.stream().collect(Collectors.groupingBy(Person::getSex, Collectors.groupingBy(Person::getArea))); 62 | System.out.println("员工按薪资是否大于8000分组情况:" + part); 63 | System.out.println("员工按性别分组情况:" + group); 64 | System.out.println("员工按性别、地区:" + group2); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /stream-demo/src/main/java/stream/test/FilterTest.java: -------------------------------------------------------------------------------- 1 | package stream.test; 2 | 3 | import stream.model.Person; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Arrays; 7 | import java.util.List; 8 | import java.util.stream.Collectors; 9 | import java.util.stream.Stream; 10 | 11 | /** 12 | * @author muguozheng 13 | * @version 1.0.0 14 | * @createTime 2022/9/6 9:59 15 | * @description filter测试类 16 | */ 17 | public class FilterTest { 18 | public static void main(String[] args) { 19 | filter(); 20 | filter2(); 21 | } 22 | 23 | public static void filter() { 24 | List list = Arrays.asList(6, 7, 3, 8, 1, 2, 9); 25 | Stream stream = list.stream(); 26 | stream.filter(x -> x > 7).forEach(System.out::println); 27 | } 28 | 29 | public static void filter2() { 30 | List personList = Person.assemblePersonList(); 31 | 32 | List fiterList = personList.stream().filter(x -> x.getSalary() > 8000).map(Person::getName) 33 | .collect(Collectors.toList()); 34 | System.out.print("高于8000的员工姓名:" + fiterList); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /stream-demo/src/main/java/stream/test/ForeachTest.java: -------------------------------------------------------------------------------- 1 | package stream.test; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import java.util.Optional; 6 | 7 | /** 8 | * @author muguozheng 9 | * @version 1.0.0 10 | * @createTime 2022/9/6 9:55 11 | * @description stream遍历匹配测试类 12 | */ 13 | public class ForeachTest { 14 | public static void main(String[] args) { 15 | List list = Arrays.asList(7, 6, 9, 3, 8, 2, 1); 16 | 17 | // 遍历输出符合条件的元素 18 | list.stream().filter(x -> x > 6).forEach(System.out::println); 19 | // 匹配第一个 20 | Optional findFirst = list.stream().filter(x -> x > 6).findFirst(); 21 | // 匹配任意(适用于并行流) 22 | Optional findAny = list.parallelStream().filter(x -> x > 6).findAny(); 23 | // 是否包含符合特定条件的元素 24 | boolean anyMatch = list.stream().anyMatch(x -> x > 6); 25 | System.out.println("匹配第一个值:" + findFirst.get()); 26 | System.out.println("匹配任意一个值:" + findAny.get()); 27 | System.out.println("是否存在大于6的值:" + anyMatch); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /stream-demo/src/main/java/stream/test/MapTest.java: -------------------------------------------------------------------------------- 1 | package stream.test; 2 | 3 | import stream.model.Person; 4 | 5 | import java.util.Arrays; 6 | import java.util.List; 7 | import java.util.stream.Collectors; 8 | 9 | /** 10 | * @author muguozheng 11 | * @version 1.0.0 12 | * @createTime 2022/9/6 10:23 13 | * @description 映射测试类 14 | */ 15 | public class MapTest { 16 | public static void main(String[] args) { 17 | // mapTest(); 18 | // mapTest2(); 19 | // mapTest3(); 20 | // mapTest4(); 21 | mapTest5(); 22 | } 23 | 24 | /** 25 | * 英文字符串数组的元素全部改为大写。整数数组每个元素+3 26 | */ 27 | public static void mapTest() { 28 | String[] strArr = {"abcd", "bcdd", "defde", "fTr"}; 29 | List strList = Arrays.stream(strArr).map(String::toUpperCase).collect(Collectors.toList()); 30 | 31 | List intList = Arrays.asList(1, 3, 5, 7, 9, 11); 32 | List intListNew = intList.stream().map(x -> x + 3).collect(Collectors.toList()); 33 | 34 | System.out.println("每个元素大写:" + strList); 35 | System.out.println("每个元素+3:" + intListNew); 36 | } 37 | 38 | /** 39 | * 将员工的薪资全部增加1000 40 | */ 41 | public static void mapTest2() { 42 | List personList = Person.assemblePersonList(); 43 | // 不改变原来员工集合的方式 44 | List personListNew = personList.stream().map(person -> { 45 | Person personNew = new Person(person.getName(), 0, 0, null, null); 46 | personNew.setSalary(person.getSalary() + 10000); 47 | return personNew; 48 | }).collect(Collectors.toList()); 49 | System.out.println("一次改动前:" + personList.get(0).getName() + "-->" + personList.get(0).getSalary()); 50 | System.out.println("一次改动后:" + personListNew.get(0).getName() + "-->" + personListNew.get(0).getSalary()); 51 | 52 | // 改变原来员工集合的方式 53 | List personListNew2 = personList.stream().map(person -> { 54 | person.setSalary(person.getSalary() + 10000); 55 | return person; 56 | }).collect(Collectors.toList()); 57 | List personListNew3 = personList.stream().peek(person -> person.setSalary(person.getSalary() + 10000)).collect(Collectors.toList()); 58 | System.out.println("二次改动前:" + personList.get(0).getName() + "-->" + personListNew.get(0).getSalary()); 59 | System.out.println("二次改动后:" + personListNew2.get(0).getName() + "-->" + personListNew2.get(0).getSalary()); 60 | System.out.println("二次改动后:" + personListNew3.get(0).getName() + "-->" + personListNew3.get(0).getSalary()); 61 | } 62 | 63 | public static void mapTest3() { 64 | List list = Arrays.asList("m,k,l,a", "1,3,5,7"); 65 | List listNew = list.stream().flatMap(s -> { 66 | // 将每个元素转换成一个stream 67 | String[] split = s.split(","); 68 | return Arrays.stream(split); 69 | }).collect(Collectors.toList()); 70 | 71 | System.out.println("处理前的集合:" + list); 72 | System.out.println("处理后的集合:" + listNew); 73 | } 74 | 75 | public static void mapTest4() { 76 | List stringList = Arrays.asList("mu", "CSDN", "hello", 77 | "world", "quickly"); 78 | stringList.stream().mapToInt(String::length).forEach(System.out::println); 79 | List integerList = Arrays.asList(4, 5, 2, 1, 6, 3); 80 | integerList.stream().mapToInt(x -> x + 1000).forEach(System.out::println); 81 | } 82 | 83 | public static void mapTest5() { 84 | List doubleList = Arrays.asList(1.0, 2.0, 3.0, 4.0, 2.0); 85 | double average = doubleList.stream().mapToDouble(Number::doubleValue).average().getAsDouble(); 86 | double sum = doubleList.stream().mapToDouble(Number::doubleValue).sum(); 87 | double max = doubleList.stream().mapToDouble(Number::doubleValue).max().getAsDouble(); 88 | System.out.println("平均值:" + average + ",总和:" + sum + ",最大值:" + max); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /stream-demo/src/main/java/stream/test/ReduceTest.java: -------------------------------------------------------------------------------- 1 | package stream.test; 2 | 3 | import stream.model.Person; 4 | 5 | import java.util.Arrays; 6 | import java.util.List; 7 | import java.util.Optional; 8 | 9 | /** 10 | * @author muguozheng 11 | * @version 1.0.0 12 | * @createTime 2022/9/6 10:28 13 | * @description 规约测试类 14 | */ 15 | public class ReduceTest { 16 | public static void main(String[] args) { 17 | reduceTest1(); 18 | reduceTest2(); 19 | } 20 | 21 | public static void reduceTest1() { 22 | List list = Arrays.asList(1, 3, 2, 8, 11, 4); 23 | // 求和方式1 24 | Optional sum = list.stream().reduce((x, y) -> x + y); 25 | // 求和方式2 26 | Optional sum2 = list.stream().reduce(Integer::sum); 27 | // 求和方式3 28 | Integer sum3 = list.stream().reduce(0, Integer::sum); 29 | 30 | // 求乘积 31 | Optional product = list.stream().reduce((x, y) -> x * y); 32 | 33 | // 求最大值方式1 34 | Optional max = list.stream().reduce((x, y) -> x > y ? x : y); 35 | // 求最大值写法2 36 | Integer max2 = list.stream().reduce(1, Integer::max); 37 | 38 | System.out.println("list求和:" + sum.get() + "," + sum2.get() + "," + sum3); 39 | System.out.println("list求积:" + product.get()); 40 | System.out.println("list求和:" + max.get() + "," + max2); 41 | } 42 | 43 | public static void reduceTest2() { 44 | List personList = Person.assemblePersonList(); 45 | // 求工资之和方式1: 46 | Optional sumSalary = personList.stream().map(Person::getSalary).reduce(Integer::sum); 47 | // 求工资之和方式2: 48 | Integer sumSalary2 = personList.stream().reduce(0, (sum, p) -> sum += p.getSalary(), (sum1, sum2) -> sum1 + sum2); 49 | // 求工资之和方式3: 50 | Integer sumSalary3 = personList.stream().reduce(0, (sum, p) -> sum += p.getSalary(), Integer::sum); 51 | 52 | // 求最高工资方式1: 53 | Integer maxSalary = personList.stream().reduce(0, (max, p) -> max > p.getSalary() ? max : p.getSalary(), 54 | Integer::max); 55 | // 求最高工资方式2: 56 | Integer maxSalary2 = personList.stream().reduce(0, (max, p) -> max > p.getSalary() ? max : p.getSalary(), 57 | (max1, max2) -> max1 > max2 ? max1 : max2); 58 | // 求最高工资方式3: 59 | Integer maxSalary3 = personList.stream().map(Person::getSalary).reduce(Integer::max).get(); 60 | 61 | System.out.println("工资之和:" + sumSalary.get() + "," + sumSalary2 + "," + sumSalary3); 62 | System.out.println("最高工资:" + maxSalary + "," + maxSalary2 + "," + maxSalary3); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /websocket-demo/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /websocket-demo/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/websocket-demo/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /websocket-demo/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip 18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar 19 | -------------------------------------------------------------------------------- /websocket-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.9 9 | 10 | 11 | com.mutest 12 | websocket-demo 13 | 0.0.1-SNAPSHOT 14 | websocket-demo 15 | websocket demo 16 | 17 | 8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-test 28 | test 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-websocket 33 | 34 | 35 | org.projectlombok 36 | lombok 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-maven-plugin 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /websocket-demo/src/main/java/com/mutest/websocket/WebSocketApplication.java: -------------------------------------------------------------------------------- 1 | package com.mutest.websocket; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 6 | import org.springframework.scheduling.annotation.EnableScheduling; 7 | 8 | @EnableScheduling 9 | @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) 10 | public class WebSocketApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(WebSocketApplication.class, args); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /websocket-demo/src/main/java/com/mutest/websocket/config/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package com.mutest.websocket.config; 2 | 3 | import com.mutest.websocket.handler.MyWsHandler; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.socket.config.annotation.EnableWebSocket; 7 | import org.springframework.web.socket.config.annotation.WebSocketConfigurer; 8 | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; 9 | 10 | /** 11 | * @author muguozheng 12 | * @version 1.0.0 13 | * @createTime 2023/4/7 17:34 14 | * @description websocket config 15 | */ 16 | @Configuration 17 | @EnableWebSocket 18 | public class WebSocketConfig implements WebSocketConfigurer { 19 | @Autowired 20 | private MyWsHandler myWsHandler; 21 | 22 | @Override 23 | public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { 24 | registry 25 | .addHandler(myWsHandler, "myWs") 26 | //允许跨域 27 | .setAllowedOrigins("*"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /websocket-demo/src/main/java/com/mutest/websocket/handler/MyWsHandler.java: -------------------------------------------------------------------------------- 1 | package com.mutest.websocket.handler; 2 | 3 | import com.mutest.websocket.utlis.WsSessionManager; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Component; 6 | import org.springframework.web.socket.BinaryMessage; 7 | import org.springframework.web.socket.CloseStatus; 8 | import org.springframework.web.socket.TextMessage; 9 | import org.springframework.web.socket.WebSocketSession; 10 | import org.springframework.web.socket.handler.AbstractWebSocketHandler; 11 | 12 | import java.time.LocalDateTime; 13 | 14 | /** 15 | * @author muguozheng 16 | * @version 1.0.0 17 | * @createTime 2023/4/8 10:48 18 | * @description ws消息处理类 19 | */ 20 | @Component 21 | @Slf4j 22 | public class MyWsHandler extends AbstractWebSocketHandler { 23 | 24 | 25 | @Override 26 | public void afterConnectionEstablished(WebSocketSession session) { 27 | log.info("建立ws连接"); 28 | WsSessionManager.add(session.getId(), session); 29 | } 30 | 31 | @Override 32 | protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { 33 | log.info("发送文本消息"); 34 | // 获得客户端传来的消息 35 | String payload = message.getPayload(); 36 | log.info("server 接收到消息 " + payload); 37 | session.sendMessage(new TextMessage("server 发送给的消息 " + payload + ",发送时间:" + LocalDateTime.now().toString())); 38 | } 39 | 40 | @Override 41 | protected void handleBinaryMessage(WebSocketSession session, BinaryMessage message) throws Exception { 42 | log.info("发送二进制消息"); 43 | } 44 | 45 | @Override 46 | public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception { 47 | log.error("异常处理"); 48 | WsSessionManager.removeAndClose(session.getId()); 49 | } 50 | 51 | @Override 52 | public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { 53 | log.info("关闭ws连接"); 54 | WsSessionManager.removeAndClose(session.getId()); 55 | } 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /websocket-demo/src/main/java/com/mutest/websocket/job/MessageJob.java: -------------------------------------------------------------------------------- 1 | package com.mutest.websocket.job; 2 | 3 | import com.mutest.websocket.service.WsService; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.scheduling.annotation.Scheduled; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.io.IOException; 10 | import java.time.LocalDateTime; 11 | 12 | /** 13 | * @author muguozheng 14 | * @version 1.0.0 15 | * @createTime 2023/4/8 10:52 16 | * @description 定时生成消息 17 | */ 18 | @Slf4j 19 | @Component 20 | public class MessageJob { 21 | @Autowired 22 | WsService wsService; 23 | 24 | /** 25 | * 每5s发送 26 | */ 27 | @Scheduled(cron = "0/5 * * * * *") 28 | public void run() { 29 | try { 30 | log.info("推送消息===>" + LocalDateTime.now().toString()); 31 | wsService.broadcastMsg("自动生成消息 " + LocalDateTime.now().toString()); 32 | } catch (IOException e) { 33 | e.printStackTrace(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /websocket-demo/src/main/java/com/mutest/websocket/service/WsService.java: -------------------------------------------------------------------------------- 1 | package com.mutest.websocket.service; 2 | 3 | import com.mutest.websocket.utlis.WsSessionManager; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Service; 6 | import org.springframework.web.socket.TextMessage; 7 | import org.springframework.web.socket.WebSocketSession; 8 | 9 | import java.io.IOException; 10 | 11 | /** 12 | * @author muguozheng 13 | * @version 1.0.0 14 | * @createTime 2023/4/8 10:53 15 | * @description ws操作相关服务 16 | */ 17 | @Service 18 | @Slf4j 19 | public class WsService { 20 | /** 21 | * 发送消息 22 | * 23 | * @param session 连接信息 24 | * @param text 消息 25 | */ 26 | public void sendMsg(WebSocketSession session, String text) throws IOException { 27 | session.sendMessage(new TextMessage(text)); 28 | } 29 | 30 | /** 31 | * 广播消息 32 | * 33 | * @param text 消息 34 | */ 35 | public void broadcastMsg(String text) throws IOException { 36 | for (WebSocketSession session : WsSessionManager.SESSION_POOL.values()) { 37 | session.sendMessage(new TextMessage(text)); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /websocket-demo/src/main/java/com/mutest/websocket/utlis/WsSessionManager.java: -------------------------------------------------------------------------------- 1 | package com.mutest.websocket.utlis; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.web.socket.WebSocketSession; 5 | 6 | import java.io.IOException; 7 | import java.util.concurrent.ConcurrentHashMap; 8 | 9 | /** 10 | * @author muguozheng 11 | * @version 1.0.0 12 | * @createTime 2023/4/8 10:50 13 | * @description webSocket session管理器 14 | */ 15 | @Slf4j 16 | public class WsSessionManager { 17 | /** 18 | * 保存连接 session 的地方 19 | */ 20 | public static ConcurrentHashMap SESSION_POOL = new ConcurrentHashMap<>(); 21 | 22 | /** 23 | * 添加 session 24 | * 25 | * @param key key 26 | */ 27 | public static void add(String key, WebSocketSession session) { 28 | // 添加 session 29 | SESSION_POOL.put(key, session); 30 | } 31 | 32 | /** 33 | * 删除 session,会返回删除的 session 34 | * 35 | * @param key key 36 | * @return WebSocketSession 37 | */ 38 | public static WebSocketSession remove(String key) { 39 | // 删除 session 40 | return SESSION_POOL.remove(key); 41 | } 42 | 43 | /** 44 | * 删除并同步关闭连接 45 | * 46 | * @param key key 47 | */ 48 | public static void removeAndClose(String key) { 49 | WebSocketSession session = remove(key); 50 | if (session != null) { 51 | try { 52 | // 关闭连接 53 | session.close(); 54 | } catch (IOException e) { 55 | // todo: 关闭出现异常处理 56 | e.printStackTrace(); 57 | } 58 | } 59 | } 60 | 61 | /** 62 | * 获得 session 63 | * 64 | * @param key key 65 | * @return WebSocketSession 66 | */ 67 | public static WebSocketSession get(String key) { 68 | // 获得 session 69 | return SESSION_POOL.get(key); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /websocket-demo/src/main/resources/application.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkMugz/springboot-demo-major/c9cb339da7d043dc7b60c09dc3c8de0e4d2d1127/websocket-demo/src/main/resources/application.yml -------------------------------------------------------------------------------- /websocket-demo/src/test/java/com/mutest/websocket/WebSocketApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.mutest.websocket; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class WebSocketApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | --------------------------------------------------------------------------------