CodingAir cloud service development platform is online! Address: [http://codingair.com] (http://codingair.com)

Welcome everyone to give us a free trial! (Test account: 823143047@qq.com (my mailbox) Password: 123456, you can also register yourself!)

Description

Some platform-created and more commonly used tool methods are placed in this class.


/**
 * General tools
 * User: zhouzhipeng
 * Date: 2018/7/29:22:26
 */
Public class CommonUtils {

/**
     * Multi-line string
     * Into the parentheses, use /* ....* / form comments
     *
     * @return
     */
    Public static String S();

/**
     * sql operation
     * @param sqlTemplate
     * @param contexts
     * @param <T>
     * @return
     */
    Public static <T> T sql(String sqlTemplate, Map<String, Object>... contexts) ;

/**
     * sql operation
     *
     * @param <T>
     * @param sqlTemplate
     * @return
     */
    Public static <T> T sql(String sqlTemplate);

/**
     * Convert json-formatted strings to fastjson's json objects
     *
     * @param strTemplate json string
     * @param context template context parameter
     * @return fastjson's json object
     */
    Public static JSONObject jsonObj(String strTemplate, HashMap<String, Object> context)

/**
     * Convert json-formatted strings to fastjson's json objects
     *
     * @param jsonStr json string
     * @return fastjson's json object
     */
    Public static JSONObject jsonObj(String jsonStr)
  

/**
     * json path query
     *
     * @param jsonStr
     * @return
     */
    Public static <T> T jsonPath(String jsonStr, String path)

/**
     * base64 encoding
     * @param src original text
     * @return ciphertext
     */
    Public static String base64Encode(String src)

/**
     * base64 decoding
     * @param base64Str ciphertext
     * @return original
     */
    Public static String base64Decode(String base64Str)

/**
     * base64 decoding
     * @param base64Str ciphertext
     * @return original byte array
     */
    Public static byte[] base64DecodeBytes(String base64Str)

/**
     * Set the cache value
     * @param name
     * @param value
     * @param ttl
     */
    Public static void set(String name, String value, long ttl)

/**
     * Query cache value
     * @param name
     * @return
     */
    Public static String get(String name)

}
Last modified: 2019年3月29日

Author

Comments

Write a Reply or Comment

Your email address will not be published.