forked from fanruan/finekit
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.9 KiB
66 lines
1.9 KiB
package com.fanruan.api.decision; |
|
|
|
import com.fanruan.api.log.LogKit; |
|
import com.fanruan.api.util.StringKit; |
|
import com.fr.base.Base64; |
|
import com.fr.base.ServerConfig; |
|
import com.fr.decision.webservice.utils.DecisionServiceConstants; |
|
import com.fr.stable.StringUtils; |
|
|
|
import java.awt.Image; |
|
/** |
|
* @author richie |
|
* @version 10.0 |
|
* Created by richie on 2019-09-19 |
|
* 常规工具类 |
|
*/ |
|
public class CommonKit { |
|
|
|
/** |
|
* 这个方法用于判断从前端返回服务器端的密码是否有被修改过 |
|
* |
|
* @param password 从前端返回的密码文本 |
|
* @return 如果密码没有被修改过就返回true,否则就返回false |
|
*/ |
|
public static boolean isDefaultPasswordHolderString(String password) { |
|
return DecisionServiceConstants.DEFAULT_PASSWORD.equals(password); |
|
} |
|
|
|
/** |
|
* 获取默认密码占位符 |
|
* |
|
* @return 默认密码占位符 |
|
*/ |
|
public static String fetchDefaultPasswordHolderString() { |
|
return DecisionServiceConstants.DEFAULT_PASSWORD; |
|
} |
|
|
|
/** |
|
* 将base64编码的字符串转为常规的字符串 |
|
* |
|
* @param encodeStr base64编码的字符串 |
|
* @return 常规字符串 |
|
*/ |
|
public static String getBase64DecodeStr(String encodeStr) { |
|
try { |
|
if (StringUtils.isNotEmpty(encodeStr)) { |
|
return new String(Base64.decode(encodeStr), ServerConfig.getInstance().getServerCharset()); |
|
} |
|
} catch (Exception e) { |
|
LogKit.error(e.getMessage(), e); |
|
} |
|
|
|
return StringKit.EMPTY; |
|
} |
|
|
|
/** |
|
* 将图片对象用指定的格式输出成base64编码表示的字符串 |
|
* |
|
* @param im 图片对象 |
|
* @param format 要输出的格式 |
|
* @return 表示图片的base64编码的字符串 |
|
*/ |
|
public static String encode(Image im, String format) { |
|
return Base64.encode(im, format); |
|
} |
|
}
|
|
|