|
@@ -5,6 +5,10 @@ import com.izouma.jiashanxia.domain.User;
|
|
|
import com.izouma.jiashanxia.web.BaseController;
|
|
import com.izouma.jiashanxia.web.BaseController;
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
import org.apache.commons.text.CaseUtils;
|
|
import org.apache.commons.text.CaseUtils;
|
|
|
|
|
+import org.bytedeco.javacv.FFmpegFrameGrabber;
|
|
|
|
|
+import org.bytedeco.javacv.Frame;
|
|
|
|
|
+import org.bytedeco.javacv.FrameGrabber;
|
|
|
|
|
+import org.bytedeco.javacv.Java2DFrameConverter;
|
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
import org.reflections.ReflectionUtils;
|
|
import org.reflections.ReflectionUtils;
|
|
|
import org.reflections.Reflections;
|
|
import org.reflections.Reflections;
|
|
@@ -14,9 +18,13 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
+import javax.imageio.ImageIO;
|
|
|
import java.awt.*;
|
|
import java.awt.*;
|
|
|
import java.awt.font.FontRenderContext;
|
|
import java.awt.font.FontRenderContext;
|
|
|
import java.awt.geom.AffineTransform;
|
|
import java.awt.geom.AffineTransform;
|
|
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
|
|
+import java.io.File;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Method;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
@@ -52,7 +60,8 @@ public class CommonTest {
|
|
|
List<Map<String, String>> entities = new ArrayList<>();
|
|
List<Map<String, String>> entities = new ArrayList<>();
|
|
|
Reflections classReflections = new Reflections(this.getClass().getPackage().getName());
|
|
Reflections classReflections = new Reflections(this.getClass().getPackage().getName());
|
|
|
Set<Class<? extends BaseController>> controllers = classReflections.getSubTypesOf(BaseController.class);
|
|
Set<Class<? extends BaseController>> controllers = classReflections.getSubTypesOf(BaseController.class);
|
|
|
- Set<Class<? extends BaseController>> list = ReflectionUtils.getAll(controllers, ReflectionUtils.withAnnotation(RestController.class));
|
|
|
|
|
|
|
+ Set<Class<? extends BaseController>> list = ReflectionUtils
|
|
|
|
|
+ .getAll(controllers, ReflectionUtils.withAnnotation(RestController.class));
|
|
|
System.out.println(list);
|
|
System.out.println(list);
|
|
|
|
|
|
|
|
for (Class<? extends BaseController> aClass : list) {
|
|
for (Class<? extends BaseController> aClass : list) {
|
|
@@ -62,7 +71,8 @@ public class CommonTest {
|
|
|
GetMapping getMapping = method.getAnnotation(GetMapping.class);
|
|
GetMapping getMapping = method.getAnnotation(GetMapping.class);
|
|
|
System.out.println(getMapping.value()[0]);
|
|
System.out.println(getMapping.value()[0]);
|
|
|
}
|
|
}
|
|
|
- for (Method method : ReflectionUtils.getMethods(aClass, ReflectionUtils.withAnnotation(PostMapping.class))) {
|
|
|
|
|
|
|
+ for (Method method : ReflectionUtils
|
|
|
|
|
+ .getMethods(aClass, ReflectionUtils.withAnnotation(PostMapping.class))) {
|
|
|
PostMapping postMapping = method.getAnnotation(PostMapping.class);
|
|
PostMapping postMapping = method.getAnnotation(PostMapping.class);
|
|
|
System.out.println(postMapping.value()[0]);
|
|
System.out.println(postMapping.value()[0]);
|
|
|
}
|
|
}
|
|
@@ -78,13 +88,15 @@ public class CommonTest {
|
|
|
public void testMeasureText() throws IOException, FontFormatException {
|
|
public void testMeasureText() throws IOException, FontFormatException {
|
|
|
AffineTransform affinetransform = new AffineTransform();
|
|
AffineTransform affinetransform = new AffineTransform();
|
|
|
FontRenderContext frc = new FontRenderContext(affinetransform, true, true);
|
|
FontRenderContext frc = new FontRenderContext(affinetransform, true, true);
|
|
|
- Font font = Font.createFont(Font.TRUETYPE_FONT, this.getClass().getResourceAsStream("/font/SourceHanSansCN-Normal.ttf"));
|
|
|
|
|
|
|
+ Font font = Font.createFont(Font.TRUETYPE_FONT, this.getClass()
|
|
|
|
|
+ .getResourceAsStream("/font/SourceHanSansCN-Normal.ttf"));
|
|
|
System.out.println((int) (font.deriveFont(14f).getStringBounds("aaa", frc).getWidth()));
|
|
System.out.println((int) (font.deriveFont(14f).getStringBounds("aaa", frc).getWidth()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
|
public void testIdNoRegexp() {
|
|
public void testIdNoRegexp() {
|
|
|
- boolean b = Pattern.matches("^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0-2]\\d)|3[0-1])\\d{3}$|^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0-2]\\d)|3[0-1])\\d{3}[0-9xX]$", "32100219950830461X");
|
|
|
|
|
|
|
+ boolean b = Pattern
|
|
|
|
|
+ .matches("^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0-2]\\d)|3[0-1])\\d{3}$|^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0-2]\\d)|3[0-1])\\d{3}[0-9xX]$", "32100219950830461X");
|
|
|
System.out.println(b);
|
|
System.out.println(b);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -94,23 +106,34 @@ public class CommonTest {
|
|
|
Set<Class<? extends Enum>> entitySet = reflections.getSubTypesOf(Enum.class);
|
|
Set<Class<? extends Enum>> entitySet = reflections.getSubTypesOf(Enum.class);
|
|
|
StringBuilder idxJs = new StringBuilder();
|
|
StringBuilder idxJs = new StringBuilder();
|
|
|
for (Class<? extends Enum> entity : entitySet) {
|
|
for (Class<? extends Enum> entity : entitySet) {
|
|
|
- idxJs.append("import ").append(entity.getSimpleName()).append(" from \"./").append(entity.getSimpleName()).append("\";\n");
|
|
|
|
|
|
|
+ idxJs.append("import ").append(entity.getSimpleName()).append(" from \"./").append(entity.getSimpleName())
|
|
|
|
|
+ .append("\";\n");
|
|
|
StringBuilder str = new StringBuilder("export default {\n");
|
|
StringBuilder str = new StringBuilder("export default {\n");
|
|
|
for (Enum enumConstant : entity.getEnumConstants()) {
|
|
for (Enum enumConstant : entity.getEnumConstants()) {
|
|
|
- str.append(" ").append(enumConstant.name()).append(": \"").append(enumConstant.name()).append("\",\n");
|
|
|
|
|
|
|
+ str.append(" ").append(enumConstant.name()).append(": \"").append(enumConstant.name())
|
|
|
|
|
+ .append("\",\n");
|
|
|
}
|
|
}
|
|
|
str.append("}");
|
|
str.append("}");
|
|
|
- Files.write(Paths.get(System.getProperty("user.dir"), "src", "main", "vue", "src", "constants", entity.getSimpleName() + ".js"), str.toString().getBytes(StandardCharsets.UTF_8), CREATE, TRUNCATE_EXISTING);
|
|
|
|
|
- Files.write(Paths.get(System.getProperty("user.dir"), "src", "main", "zmj_mp", "src", "constants", entity.getSimpleName() + ".js"), str.toString().getBytes(StandardCharsets.UTF_8), CREATE, TRUNCATE_EXISTING);
|
|
|
|
|
|
|
+ Files.write(Paths.get(System.getProperty("user.dir"), "src", "main", "vue", "src", "constants", entity
|
|
|
|
|
+ .getSimpleName() + ".js"), str.toString()
|
|
|
|
|
+ .getBytes(StandardCharsets.UTF_8), CREATE, TRUNCATE_EXISTING);
|
|
|
|
|
+ Files.write(Paths.get(System.getProperty("user.dir"), "src", "main", "zmj_mp", "src", "constants", entity
|
|
|
|
|
+ .getSimpleName() + ".js"), str.toString()
|
|
|
|
|
+ .getBytes(StandardCharsets.UTF_8), CREATE, TRUNCATE_EXISTING);
|
|
|
}
|
|
}
|
|
|
idxJs.append("export default {\n");
|
|
idxJs.append("export default {\n");
|
|
|
for (Class<? extends Enum> entity : entitySet) {
|
|
for (Class<? extends Enum> entity : entitySet) {
|
|
|
- idxJs.append(" ").append(entity.getSimpleName()).append(": ").append(entity.getSimpleName()).append(",\n");
|
|
|
|
|
|
|
+ idxJs.append(" ").append(entity.getSimpleName()).append(": ").append(entity.getSimpleName())
|
|
|
|
|
+ .append(",\n");
|
|
|
}
|
|
}
|
|
|
idxJs.append("}");
|
|
idxJs.append("}");
|
|
|
System.out.println(idxJs.toString());
|
|
System.out.println(idxJs.toString());
|
|
|
- Files.write(Paths.get(System.getProperty("user.dir"), "src", "main", "vue", "src", "constants", "index.js"), idxJs.toString().getBytes(StandardCharsets.UTF_8), CREATE, TRUNCATE_EXISTING);
|
|
|
|
|
- Files.write(Paths.get(System.getProperty("user.dir"), "src", "main", "zmj_mp", "src", "constants", "index.js"), idxJs.toString().getBytes(StandardCharsets.UTF_8), CREATE, TRUNCATE_EXISTING);
|
|
|
|
|
|
|
+ Files.write(Paths
|
|
|
|
|
+ .get(System.getProperty("user.dir"), "src", "main", "vue", "src", "constants", "index.js"), idxJs
|
|
|
|
|
+ .toString().getBytes(StandardCharsets.UTF_8), CREATE, TRUNCATE_EXISTING);
|
|
|
|
|
+ Files.write(Paths
|
|
|
|
|
+ .get(System.getProperty("user.dir"), "src", "main", "zmj_mp", "src", "constants", "index.js"), idxJs
|
|
|
|
|
+ .toString().getBytes(StandardCharsets.UTF_8), CREATE, TRUNCATE_EXISTING);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -126,10 +149,13 @@ public class CommonTest {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
|
- public void testEnum() {
|
|
|
|
|
- System.out.println(String.class.getName());
|
|
|
|
|
- System.out.println(String.class.getSimpleName());
|
|
|
|
|
- System.out.println(String.class.getCanonicalName());
|
|
|
|
|
- System.out.println(String.class.getTypeName());
|
|
|
|
|
|
|
+ public void testEnum() throws IOException {
|
|
|
|
|
+ FFmpegFrameGrabber g = new FFmpegFrameGrabber("/Users/drew/Desktop/1.mp4");
|
|
|
|
|
+ g.start();
|
|
|
|
|
+ Frame frame = g.grab();
|
|
|
|
|
+ Java2DFrameConverter converter = new Java2DFrameConverter();
|
|
|
|
|
+ BufferedImage image = converter.convert(frame);
|
|
|
|
|
+ ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
|
|
|
|
|
+ ImageIO.write(image, "jpeg", new File("/Users/drew/Desktop/1.jpg"));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|