xiongzhu před 4 roky
rodič
revize
eadd4b5a0b

+ 4 - 0
pom.xml

@@ -266,6 +266,10 @@
             <version>1.6.2</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.fasterxml.jackson.dataformat</groupId>
+            <artifactId>jackson-dataformat-xml</artifactId>
+        </dependency>
     </dependencies>
 
 </project>

+ 20 - 5
src/main/java/com/izouma/awesomeAdmin/config/WebMvcConfig.java

@@ -1,8 +1,15 @@
 package com.izouma.awesomeAdmin.config;
 
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.web.client.RestTemplateBuilder;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.web.client.RestTemplate;
 import org.springframework.web.servlet.config.annotation.CorsRegistry;
 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -12,6 +19,9 @@ import springfox.documentation.builders.RequestHandlerSelectors;
 import springfox.documentation.spi.DocumentationType;
 import springfox.documentation.spring.web.plugins.Docket;
 
+import javax.net.ssl.SSLContext;
+import java.security.cert.X509Certificate;
+
 @Configuration
 public class WebMvcConfig implements WebMvcConfigurer {
     @Value("${storage.local_path}")
@@ -27,15 +37,20 @@ public class WebMvcConfig implements WebMvcConfigurer {
         registry.addResourceHandler("/MP_verify*").addResourceLocations("classpath:/");
     }
 
+    @Bean
+    public RestTemplate restTemplate(RestTemplateBuilder builder) {
+        return builder.build();
+    }
+
     @Bean
     public Docket createApi() {
         return new Docket(DocumentationType.SWAGGER_2)
                 .apiInfo(new ApiInfoBuilder()
-                                 .title("接口文档")
-                                 .version("1.0.0")
-                                 .termsOfServiceUrl("#")
-                                 .description("接口文档")
-                                 .build())
+                        .title("接口文档")
+                        .version("1.0.0")
+                        .termsOfServiceUrl("#")
+                        .description("接口文档")
+                        .build())
                 .select()
                 .apis(RequestHandlerSelectors.basePackage("com.izouma.awesomeAdmin.web"))
                 .paths(PathSelectors.any())

+ 70 - 0
src/main/java/com/izouma/awesomeAdmin/pojo/Action.java

@@ -0,0 +1,70 @@
+package com.izouma.awesomeAdmin.pojo;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Data
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class Action {
+    private String displayText;
+
+    @JsonProperty("postback")
+    private Map<String, String> postbackData;
+
+    @JsonProperty("urlAction")
+    private Map<String, Map<String, String>> urlActionData;
+
+    @JsonProperty("dialerAction")
+    private Map<String, Map<String, String>> dialerActionData;
+
+    @JsonIgnore
+    public String getPostback() {
+        return postbackData.get("data");
+    }
+
+    public void setPostback(String data) {
+        if (data == null) {
+            this.postbackData = null;
+        } else {
+            postbackData = new HashMap<>();
+            postbackData.put("data", data);
+        }
+    }
+
+    public void setUrl(String url) {
+        if (url == null) {
+            urlActionData = null;
+        } else {
+            urlActionData = new HashMap<>();
+            urlActionData.put("openUrl", new HashMap<String, String>() {{
+                put("url", url);
+            }});
+        }
+    }
+
+    @JsonIgnore
+    public String getUrl() {
+        return urlActionData.get("openUrl").get("url");
+    }
+
+    public void setPhoneNumber(String phoneNumber) {
+        if (phoneNumber == null) {
+            dialerActionData = null;
+        } else {
+            dialerActionData = new HashMap<>();
+            dialerActionData.put("dialPhoneNumber", new HashMap<String, String>() {{
+                put("phoneNumber", phoneNumber);
+            }});
+        }
+    }
+
+    @JsonIgnore
+    public String getPhoneNumber() {
+        return dialerActionData.get("dialPhoneNumber").get("phoneNumber");
+    }
+}

+ 25 - 0
src/main/java/com/izouma/awesomeAdmin/pojo/OutboundMessageRequest.java

@@ -0,0 +1,25 @@
+package com.izouma.awesomeAdmin.pojo;
+
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import lombok.Data;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+@XmlRootElement(name = "msg:outboundMessageRequest")
+@XmlAccessorType(XmlAccessType.FIELD)
+@Data
+public class OutboundMessageRequest {
+    @JacksonXmlElementWrapper(useWrapping = false)
+    private List<String> destinationAddress;
+
+    private String contentType;
+
+    @JacksonXmlCData
+    private String bodyText;
+
+    private String contributionID;
+}

+ 57 - 0
src/main/java/com/izouma/awesomeAdmin/pojo/Suggestions.java

@@ -0,0 +1,57 @@
+package com.izouma.awesomeAdmin.pojo;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Data
+@AllArgsConstructor
+@Builder
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class Suggestions {
+    private List<Map<String, Action>> suggestions;
+
+    public Suggestions() {
+        this.suggestions = new ArrayList<>();
+    }
+
+    public Suggestions addReply(String text, String postback) {
+        Action action = new Action();
+        action.setDisplayText(text);
+        action.setPostback(postback);
+        Map<String, Action> map = new HashMap<>();
+        map.put("reply", action);
+        suggestions.add(map);
+        return this;
+    }
+
+    public Suggestions addUrl(String text, String url, String postback) {
+        Action action = new Action();
+        action.setDisplayText(text);
+        action.setPostback(postback);
+        action.setUrl(url);
+        Map<String, Action> map = new HashMap<>();
+        map.put("action", action);
+        suggestions.add(map);
+        return this;
+    }
+
+    public Suggestions addCall(String text, String phone, String postback) {
+        Action action = new Action();
+        action.setDisplayText(text);
+        action.setPostback(postback);
+        action.setPhoneNumber(phone);
+        Map<String, Action> map = new HashMap<>();
+        map.put("action", action);
+        suggestions.add(map);
+        return this;
+    }
+}

+ 17 - 0
src/main/java/com/izouma/awesomeAdmin/utils/AdapterCDATA.java

@@ -0,0 +1,17 @@
+package com.izouma.awesomeAdmin.utils;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+public class AdapterCDATA extends XmlAdapter<String, String> {
+
+    @Override
+    public String marshal(String arg0) throws Exception {
+        return "<![CDATA[" + arg0 + "]]>";
+    }
+
+    @Override
+    public String unmarshal(String arg0) throws Exception {
+        return arg0;
+    }
+
+}

+ 240 - 0
src/main/java/com/izouma/awesomeAdmin/utils/CspUtil.java

@@ -0,0 +1,240 @@
+package com.izouma.awesomeAdmin.utils;
+
+
+import com.fasterxml.jackson.databind.json.JsonMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.izouma.awesomeAdmin.pojo.OutboundMessageRequest;
+import com.izouma.awesomeAdmin.pojo.Suggestions;
+import lombok.SneakyThrows;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.web.client.RestTemplate;
+
+import javax.net.ssl.SSLContext;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
+import java.security.cert.X509Certificate;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.Locale;
+import java.util.UUID;
+
+public class CspUtil {
+    private final static String       username       = "njzm01";
+    private final static String       password       = "mHCSE$EGSxQ@&DuNsM04";
+    private final static String       chatBotId      = "10650511101001400001@botplatform.rcs.chinamobile.com";
+    private final static String       serverRoot     = "https://api.5gcsp.mas.10086.cn/ocsp/developer";
+    private final static String       fileServerRoot = "https://api.5gcsp.mas.10086.cn/ocsp/fileservice";
+    private static       RestTemplate restTemplate;
+
+    private static RestTemplate getRestTemplate() {
+        if (restTemplate == null) {
+            try {
+                TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
+
+                SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom()
+                        .loadTrustMaterial(null, acceptingTrustStrategy)
+                        .build();
+
+                SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);
+
+                CloseableHttpClient httpClient = HttpClients.custom()
+                        .setSSLSocketFactory(csf)
+                        .build();
+
+                HttpComponentsClientHttpRequestFactory requestFactory =
+                        new HttpComponentsClientHttpRequestFactory();
+
+                requestFactory.setHttpClient(httpClient);
+                restTemplate = new RestTemplate(requestFactory);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return restTemplate;
+    }
+
+    public static String getToken() {
+        return DigestUtils.sha256Hex(password);
+    }
+
+    public static String getBasic() {
+        String date = getDate();
+        return Base64.encodeBase64String((username + ":" + DigestUtils.sha256Hex(getToken() + date))
+                .getBytes(StandardCharsets.UTF_8));
+    }
+
+    public static String getDate() {
+        DateTimeFormatter formatter = DateTimeFormatter
+                .ofPattern("EEE, dd MMM yyyy HH:mm:ss z")
+                .withZone(ZoneId.of("GMT+0"))
+                .withLocale(Locale.ENGLISH);
+        return formatter.format(LocalDateTime.now(ZoneOffset.UTC));
+    }
+
+    @SneakyThrows
+    public static void sendTemplate(String templateId, String... tel) {
+        OutboundMessageRequest request = new OutboundMessageRequest();
+        request.setDestinationAddress(Arrays.asList(tel));
+        request.setContentType("static-template");
+        request.setBodyText("{\"templateID\": \"" + templateId + "\"}");
+        request.setContributionID(UUID.randomUUID().toString());
+
+        XmlMapper xmlMapper = new XmlMapper();
+        xmlMapper.writeValueAsString(request);
+        String xmlString = xmlMapper.writeValueAsString(request);
+
+        String url = serverRoot + "/messaging/group/template/outbound/sip:" + chatBotId + "/requests";
+        HttpHeaders headers = new HttpHeaders();
+        headers.add("Authorization", "Basic " + getBasic());
+        headers.add("Date", getDate());
+
+        headers.setContentType(MediaType.APPLICATION_XML);
+        HttpEntity<String> formEntity = new HttpEntity<>(xmlString, headers);
+        ResponseEntity<String> responseEntity = getRestTemplate().postForEntity(url, formEntity, String.class);
+        System.out.println(responseEntity);
+
+    }
+
+    @SneakyThrows
+    public static void sendNormal(String... tel) {
+        OutboundMessageRequest request = new OutboundMessageRequest();
+        request.setDestinationAddress(Arrays.asList(tel));
+        request.setContentType("text/plain");
+        request.setBodyText("hello 5g");
+        request.setContributionID(UUID.randomUUID().toString());
+
+        XmlMapper xmlMapper = new XmlMapper();
+        xmlMapper.writeValueAsString(request);
+        String xmlString = xmlMapper.writeValueAsString(request);
+
+        String url = serverRoot + "/messaging/group/plain/outbound/sip:" + chatBotId + "/requests";
+        HttpHeaders headers = new HttpHeaders();
+        headers.add("Authorization", "Basic " + getBasic());
+        headers.add("Date", getDate());
+
+        headers.setContentType(MediaType.APPLICATION_XML);
+        HttpEntity<String> formEntity = new HttpEntity<>(xmlString, headers);
+        ResponseEntity<String> responseEntity = getRestTemplate().postForEntity(url, formEntity, String.class);
+        System.out.println(responseEntity);
+    }
+
+    @SneakyThrows
+    public static void sendTextWithSuggestion(String... tel) {
+        OutboundMessageRequest request = new OutboundMessageRequest();
+        request.setDestinationAddress(Arrays.asList(tel));
+        request.setContentType("multipart/mixed; boundary=\"next\"");
+        String body = "";
+        body = addTextBody(body, "hello 5g");
+        body = addSuggestionBody(body, new Suggestions()
+                .addReply("回复", "111")
+                .addUrl("百度", "https://www.baidu.com", "222")
+                .addCall("电话", "15077886171", "333"));
+        body += "--next--";
+
+        System.out.println(body);
+
+        request.setBodyText(body);
+        request.setContributionID(UUID.randomUUID().toString());
+
+        XmlMapper xmlMapper = new XmlMapper();
+        xmlMapper.writeValueAsString(request);
+        String xmlString = xmlMapper.writeValueAsString(request);
+
+        String url = serverRoot + "/messaging/group/plain/outbound/sip:" + chatBotId + "/requests";
+        HttpHeaders headers = new HttpHeaders();
+        headers.add("Authorization", "Basic " + getBasic());
+        headers.add("Date", getDate());
+
+        headers.setContentType(MediaType.APPLICATION_XML);
+        HttpEntity<String> formEntity = new HttpEntity<>(xmlString, headers);
+        ResponseEntity<String> responseEntity = getRestTemplate().postForEntity(url, formEntity, String.class);
+        System.out.println(responseEntity);
+    }
+
+    private static String addTextBody(String body, String text) {
+        body += "--next\r\r\n" +
+                "Content-Type: text/plain\r\r\n" +
+                "Content-Disposition: inline; filename=\"Message\"\r\r\n" +
+                "Content-Length: " + text.length() + "\r\r\n" +
+                text + "\r\r\n";
+        return body;
+    }
+
+    @SneakyThrows
+    private static String addSuggestionBody(String body, Suggestions suggestions) {
+        String json = new JsonMapper().writerWithDefaultPrettyPrinter().writeValueAsString(suggestions);
+        body += "--next\r\r\n" +
+                "Content-Type: application/vnd.gsma.botsuggestion.v1.0+json\r\r\n" +
+                "Content-Disposition: inline; filename=\"Chiplist.lst\"\r\r\n" +
+                "Content-Length: " + json.length() + "\r\r\n" +
+                json + "\r\r\n";
+        return body;
+    }
+
+    @SneakyThrows
+    public static void sendCard(String... tel) {
+        OutboundMessageRequest request = new OutboundMessageRequest();
+        request.setDestinationAddress(Arrays.asList(tel));
+        request.setContentType("application/vnd.gsma.botmessage.v1.0+json");
+        String body = "{\r\n" +
+                "    \"message\": {\r\n" +
+                "        \"generalPurposeCard\": {\r\n" +
+                "            \"layout\": {\r\n" +
+                "                \"cardOrientation\": \"VERTICAL\"\r\n" +
+                "            },\r\n" +
+                "            \"content\": {\r\n" +
+                "                \"media\": {\r\n" +
+                "                    \"mediaUrl\": \"https://imt.oss-cn-hangzhou.aliyuncs.com/video/2020-11-25-18-23-23OzQvwzkf.mp4\",\r\n" +
+                "                    \"mediaContentType\": \"video/mp4\",\r\n" +
+                "                    \"mediaFileSize\": 48804366,\r\n" +
+                "                    \"thumbnailUrl\": \"https://imt.oss-cn-hangzhou.aliyuncs.com/image/2020-11-25-18-23-43EUtEUiPZ.png\",\r\n" +
+                "                    \"thumbnailContentType\": \"image/png\",\r\n" +
+                "                    \"thumbnailFileSize\": 274704,\r\n" +
+                "                    \"height\": \"MEDIUM_HEIGHT\"\r\n" +
+                "                },\r\n" +
+                "                \"title\": \"This is a single rich card.\",\r\n" +
+                "                \"description\": \"This is the description of the rich card. It's the first field that will be truncated if it exceeds the maximum width or height of a card.\"\r\n" +
+                "            }\r\n" +
+                "        }\r\n" +
+                "    }\r\n" +
+                "}\r\n";
+
+        System.out.println(body);
+
+        request.setBodyText(body);
+        request.setContributionID(UUID.randomUUID().toString());
+
+        XmlMapper xmlMapper = new XmlMapper();
+        xmlMapper.writeValueAsString(request);
+        String xmlString = xmlMapper.writeValueAsString(request);
+
+        String url = serverRoot + "/messaging/group/plain/outbound/sip:" + chatBotId + "/requests";
+        HttpHeaders headers = new HttpHeaders();
+        headers.add("Authorization", "Basic " + getBasic());
+        headers.add("Date", getDate());
+
+        headers.setContentType(MediaType.APPLICATION_XML);
+        HttpEntity<String> formEntity = new HttpEntity<>(xmlString, headers);
+        ResponseEntity<String> responseEntity = getRestTemplate().postForEntity(url, formEntity, String.class);
+        System.out.println(responseEntity);
+    }
+
+    public static void main(String[] args) throws UnsupportedEncodingException {
+        System.out.println(CspUtil.getBasic());
+        //CspUtil.sendNormal("tel:+8618362933705");
+        CspUtil.sendCard("tel:+8618362933705");
+    }
+}

+ 62 - 16
src/test/java/com/izouma/awesomeAdmin/CommonTest.java

@@ -1,7 +1,12 @@
 package com.izouma.awesomeAdmin;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.json.JsonMapper;
 import com.izouma.awesomeAdmin.domain.BaseEntity;
+import com.izouma.awesomeAdmin.pojo.OutboundMessageRequest;
 import com.izouma.awesomeAdmin.domain.User;
+import com.izouma.awesomeAdmin.pojo.Suggestions;
 import com.izouma.awesomeAdmin.web.BaseController;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.text.CaseUtils;
@@ -14,19 +19,18 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.xml.bind.JAXB;
 import java.awt.*;
 import java.awt.font.FontRenderContext;
 import java.awt.geom.AffineTransform;
 import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
+import java.io.StringWriter;
 import java.lang.reflect.Method;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Paths;
-import java.util.ArrayList;
+import java.util.*;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 import java.util.regex.Pattern;
 
 import static java.nio.file.StandardOpenOption.CREATE;
@@ -53,7 +57,8 @@ public class CommonTest {
         List<Map<String, String>> entities = new ArrayList<>();
         Reflections classReflections = new Reflections(this.getClass().getPackage().getName());
         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);
 
         for (Class<? extends BaseController> aClass : list) {
@@ -63,7 +68,8 @@ public class CommonTest {
                 GetMapping getMapping = method.getAnnotation(GetMapping.class);
                 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);
                 System.out.println(postMapping.value()[0]);
             }
@@ -79,13 +85,15 @@ public class CommonTest {
     public void testMeasureText() throws IOException, FontFormatException {
         AffineTransform affinetransform = new AffineTransform();
         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()));
     }
 
     @Test
     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);
     }
 
@@ -95,23 +103,34 @@ public class CommonTest {
         Set<Class<? extends Enum>> entitySet = reflections.getSubTypesOf(Enum.class);
         StringBuilder idxJs = new StringBuilder();
         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");
             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("}");
-            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");
         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("}");
         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
@@ -133,4 +152,31 @@ public class CommonTest {
         System.out.println(String.class.getCanonicalName());
         System.out.println(String.class.getTypeName());
     }
-}
+
+    @Test
+    public void testXml() {
+        StringWriter sw = new StringWriter();
+        OutboundMessageRequest request = new OutboundMessageRequest();
+        request.setDestinationAddress(new ArrayList<String>() {{
+            add("tel:+8618362933705");
+        }});
+        request.setContentType("static-template");
+        request.setBodyText("{\"templateID\": \"102A77EB865E24AA1BB3D\"}");
+        request.setContributionID(UUID.randomUUID().toString());
+
+        JAXB.marshal(request, sw);
+        String xmlString = sw.toString();
+        System.out.println(xmlString);
+    }
+
+    @Test
+    public void testJackson() throws JsonProcessingException {
+        JsonMapper jsonMapper = new JsonMapper();
+
+        Suggestions suggestions = new Suggestions()
+                .addReply("回复", "111")
+                .addUrl("百度", "https://www.baidu.com", "222")
+                .addCall("电话", "15077886171", "333");
+        System.out.println(jsonMapper.writerWithDefaultPrettyPrinter().writeValueAsString(suggestions));
+    }
+}

+ 14 - 0
src/test/java/com/izouma/awesomeAdmin/RestTest.java

@@ -0,0 +1,14 @@
+package com.izouma.awesomeAdmin;
+
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.client.RestTemplate;
+
+public class RestTest extends ApplicationTests {
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Test
+    public void rest() {
+    }
+}