This file contains 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 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 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 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 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 io.jsonwebtoken.Claims; | |
import io.jsonwebtoken.Jwts; | |
import io.jsonwebtoken.SignatureAlgorithm; | |
import net.xdclass.xdvideo.domain.User; | |
import java.util.Date; | |
/** | |
* jwt工具类 | |
*/ |
This file contains 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 com.google.gson.Gson; | |
import org.apache.http.HttpEntity; | |
import org.apache.http.HttpResponse; | |
import org.apache.http.client.config.RequestConfig; | |
import org.apache.http.client.methods.CloseableHttpResponse; | |
import org.apache.http.client.methods.HttpGet; | |
import org.apache.http.client.methods.HttpPost; | |
import org.apache.http.entity.StringEntity; | |
import org.apache.http.impl.client.CloseableHttpClient; | |
import org.apache.http.impl.client.HttpClients; |
This file contains 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
@RequestMapping("callback") | |
public void callback(HttpServletRequest request, HttpServletResponse response) throws Exception { | |
InputStream inputStream = request.getInputStream(); | |
//BufferedReader是包装设计模式,性能更搞 | |
BufferedReader in = new BufferedReader(new InputStreamReader(inputStream,"UTF-8")); | |
StringBuffer sb = new StringBuffer(); | |
String line ; | |
while ((line = in.readLine()) != null){ | |
sb.append(line); |
This file contains 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
<?php | |
namespace App\Listeners; | |
use Illuminate\Queue\InteractsWithQueue; | |
use Illuminate\Contracts\Queue\ShouldQueue; | |
use App\Common\Models\UserFollowModel; | |
use Illuminate\Support\Facades\Redis; | |
use App\Common\Models\UserModel; | |
use Log; |
This file contains 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 function fans($userId) | |
{ | |
// 1.1 检查用户是否存在 | |
UserModel::mustExist(['id' => $userId, 'status' => BaseModel::ENABLED], '用户不存在或已被封禁'); | |
// 2.1 查 user_follow 表, 找出跟当前用户相关的记录 | |
$userFollows = UserFollowModel::where(['followed_user_id' => $userId])->paginate(request('pagesize', 20)); | |
// 2.2 查询本次需要查询的 user_id | |
$ids = array_map(function ($item) { |
This file contains 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
try { | |
DB::beginTransaction(); | |
DB::commit(); | |
} catch (Exception $e) { | |
Log::error($e->getMessage()); | |
DB::rollBack(); | |
throw new ExceptionBiz($e->getMessage()); | |
} |