Commit 6e907f15 authored by simon824's avatar simon824
Browse files

1. specified jackson Date format.

2. remove getMapper method,replace with toList()
3. rewrite toList method,support constructCollectionType.
4. parseObject(resp, Map.class) replace to toMap() method
5. rename JacksonSerialize to JsonSerializer

rewrite createArrayNode,createObjectNode method will Affect too many lines ,i will fix it in the next pr.
parent 9a92ab79
Loading
Loading
Loading
Loading
+5 −10
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
 */
package org.apache.dolphinscheduler.alert.template.impl;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import org.apache.dolphinscheduler.alert.template.AlertTemplate;
import org.apache.dolphinscheduler.alert.utils.Constants;
import org.apache.dolphinscheduler.common.enums.ShowType;
@@ -107,18 +109,11 @@ public class DefaultHTMLTemplate implements AlertTemplate {
    private String getTextTypeMessage(String content,boolean showAll){

        if (StringUtils.isNotEmpty(content)){
            List<String> list;
            try {
                list = JSONUtils.toList(content,String.class);
            }catch (Exception e){
                logger.error("json format exception",e);
                return null;
            }

            ArrayNode list = JSONUtils.parseArray(content);
            StringBuilder contents = new StringBuilder(100);
            for (Object obj : list){
            for (JsonNode jsonNode : list){
                contents.append(Constants.TR);
                contents.append(Constants.TD).append(obj).append(Constants.TD_END);
                contents.append(Constants.TD).append(jsonNode.toString()).append(Constants.TD_END);
                contents.append(Constants.TR_END);
            }

+43 −29
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ public class EnterpriseWeChatUtils {

    /**
     * get Enterprise WeChat is enable
     *
     * @return isEnable
     */
    public static boolean isEnable() {
@@ -81,6 +82,7 @@ public class EnterpriseWeChatUtils {

    /**
     * get Enterprise WeChat token info
     *
     * @return token string info
     * @throws IOException the IOException
     */
@@ -99,8 +101,12 @@ public class EnterpriseWeChatUtils {
                response.close();
            }

            Map<String, Object> map = JSONUtils.parseObject(resp, Map.class);
            return map.get("access_token").toString();
            Map<String, String> map = JSONUtils.toMap(resp);
            if (map != null) {
                return map.get("access_token");
            } else {
                return null;
            }
        } finally {
            httpClient.close();
        }
@@ -108,6 +114,7 @@ public class EnterpriseWeChatUtils {

    /**
     * make team single Enterprise WeChat message
     *
     * @param toParty the toParty
     * @param agentId the agentId
     * @param msg     the msg
@@ -121,6 +128,7 @@ public class EnterpriseWeChatUtils {

    /**
     * make team multi Enterprise WeChat message
     *
     * @param toParty the toParty
     * @param agentId the agentId
     * @param msg     the msg
@@ -135,6 +143,7 @@ public class EnterpriseWeChatUtils {

    /**
     * make team single user message
     *
     * @param toUser  the toUser
     * @param agentId the agentId
     * @param msg     the msg
@@ -148,6 +157,7 @@ public class EnterpriseWeChatUtils {

    /**
     * make team multi user message
     *
     * @param toUser  the toUser
     * @param agentId the agentId
     * @param msg     the msg
@@ -162,6 +172,7 @@ public class EnterpriseWeChatUtils {

    /**
     * send Enterprise WeChat
     *
     * @param charset the charset
     * @param data    the data
     * @param token   the token
@@ -194,6 +205,7 @@ public class EnterpriseWeChatUtils {

    /**
     * convert table to markdown style
     *
     * @param title   the title
     * @param content the content
     * @return markdown table content
@@ -223,6 +235,7 @@ public class EnterpriseWeChatUtils {

    /**
     * convert text to markdown style
     *
     * @param title   the title
     * @param content the content
     * @return markdown text
@@ -253,6 +266,7 @@ public class EnterpriseWeChatUtils {

    /**
     * Determine the mardown style based on the show type of the alert
     *
     * @return the markdown alert table/text
     */
    public static String markdownByAlert(AlertData alert) {
+1 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ public class DefaultHTMLTemplateTest{
                "    </head>\n" +
                "    <body style=\"margin:0;padding:0\">\n" +
                "        <table border=\"1px\" cellpadding=\"5px\" cellspacing=\"-10px\">\n" +
                "<tr><td>{mysql service name=mysql200, mysql address=192.168.xx.xx, port=3306, no index of number=80, database client connections=190}</td></tr><tr><td>{mysql service name=mysql210, mysql address=192.168.xx.xx, port=3306, no index of number=10, database client connections=90}</td></tr>        </table>\n" +
                "<tr><td>{\"mysql service name\":\"mysql200\",\"mysql address\":\"192.168.xx.xx\",\"port\":\"3306\",\"no index of number\":\"80\",\"database client connections\":\"190\"}</td></tr><tr><td>{\"mysql service name\":\"mysql210\",\"mysql address\":\"192.168.xx.xx\",\"port\":\"3306\",\"no index of number\":\"10\",\"database client connections\":\"90\"}</td></tr>        </table>\n" +
                "    </body>\n" +
                "</html>";
    }
+4 −0
Original line number Diff line number Diff line
@@ -16,13 +16,17 @@
 */
package org.apache.dolphinscheduler.api.dto;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.Date;

/**
 * schedule parameters
 */
public class ScheduleParam {
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
  private Date startTime;
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
  private Date endTime;
  private String crontab;

+5 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
 */
package org.apache.dolphinscheduler.api.dto.gantt;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -41,16 +43,19 @@ public class Task {
    /**
     * task execution date
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date executionDate;

    /**
     * task iso start
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date isoStart;

    /**
     * task iso end
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date isoEnd;

    /**
Loading