This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.w3c.dom.Entity; | |
import org.w3c.dom.Node; | |
import org.w3c.dom.NodeList; | |
import javax.xml.parsers.DocumentBuilder; | |
import javax.xml.parsers.DocumentBuilderFactory; | |
import javax.xml.transform.OutputKeys; | |
import javax.xml.transform.Transformer; | |
import javax.xml.transform.TransformerFactory; | |
import javax.xml.transform.dom.DOMSource; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.security.MessageDigest; | |
import java.util.UUID; | |
/** | |
* 常用工具类的封装,md5,uuid等 | |
*/ | |
public class CommonUtils { | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.InetAddress; | |
import java.net.UnknownHostException; | |
import javax.servlet.http.HttpServletRequest; | |
public class IpUtils { | |
public static String getIpAddr(HttpServletRequest request) { | |
String ipAddress = null; | |
try { | |
ipAddress = request.getHeader("x-forwarded-for"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Date(data.updated).toLocaleString(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String decrypt(String encrypted) { | |
String KEY = ")O[NB]6,YF}+efcaj{+oESb9d8>Z'e9M"; | |
String IV = "L+\\~f4,Ir)b$=pkf"; | |
try { | |
IvParameterSpec iv = new IvParameterSpec(IV.getBytes("UTF-8")); | |
SecretKeySpec skeySpec = new SecretKeySpec(KEY.getBytes("UTF-8"), "AES"); | |
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); | |
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 创建 Map | |
Map<String, String> map = new HashMap<>(); | |
// 添加元素 | |
map.put("1", "张三"); | |
map.put("2", "李四"); | |
map.put("3", "王五"); | |
// 获取存放键值的集合 | |
// Map 并没有 iterator 方法,所以不能 map.iterator() 获取迭代器 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ReloadSystem { | |
public static void reloadSystem() { | |
ProcessBuilder processBuilder = new ProcessBuilder(); | |
processBuilder.command("bash", "-c", "bash ~/tieba-demo/Tieba/reload.sh"); | |
try { | |
Process process = processBuilder.start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 项目名 | |
PRONAME="demo" | |
#echo $PRONAME | |
# 项目所在路径 | |
PROPATH='/root/tieba-demo/Tieba/' | |
nohup git pull origin master >/dev/null 2>&1 | |
#git pull origin master | |
cd $PROPATH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Insert("INSERT IGNORE INTO t_user " + | |
"(email, password, salt, is_active) " + | |
"VALUES (#{email}, #{password}, #{salt}, 1)") | |
int addUser(TUser user); | |
//重点是 IGNORE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Insert("INSERT INTO t_email_link VALUES (#{email}, #{link}, DATE_ADD(CURDATE(), INTERVAL 2 DAY))" + | |
"ON DUPLICATE KEY UPDATE link=#{link}, exp=DATE_ADD(CURDATE(), INTERVAL 2 DAY)") | |
void saveEmailAndChangePasswordLink(@Param("email") String email, @Param("link") String link); | |
//重点是 ON DUPLICATE KEY UPDATE |