Commit a74f12de by jscat

nyx live:

功能: 添加redis服务
parent 5af3116b
......@@ -99,11 +99,13 @@ public interface Rockwell_keyService {
jscat 20201127
*/
JSONResult Rockwell_keyServiceGetLives(String orderType, int pageNum, int pageCount);
void Rockwell_keyServiceUpdateWatcherToRedis(String sid, String city, Double count);
int Rockwell_keyServiceUpdateWatcherByRedisToDB(Set<Tuple> set);
JSONResult Rockwell_keyServiceGetLivesByRedis(String city, String title, String orderType, int pageNum, int pageCount);
JSONResult Rockwell_keyServiceAddLive(String title, String city, String address, String noteImage, String liveId);
int Rockwell_keyServiceUpdateLive(String title, String liveStatus, String userId);
int Rockwell_keyServiceAddLiveToRedis(String title, String city, String address, String noteImage, String liveId);
void Rockwell_keyServiceUpdateWatcherToRedis(String sid, String city, Double count);
int Rockwell_keyServiceUpdateWatcherByRedisToDB(Set<Tuple> set);
// testing
void Rockwell_keyServiceTest(List<Rockwell_keyT_match> listRockwell_keyT_match);
......
package cn.com.fun.nyxkey.api.service;
import cn.com.fun.nyxkey.api.common.JSONResult;
import cn.com.fun.nyxkey.api.domain.*;
import cn.com.fun.nyxkey.api.domain.*;
import cn.com.fun.nyxkey.api.domain.query.*;
import org.joda.time.DateTime;
import org.springframework.web.multipart.MultipartFile;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* Created by jscat on 2020/12/09.
*/
public interface Rockwell_redisService {
}
......@@ -1112,6 +1112,36 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService {
return jsonResult;
}
public int Rockwell_keyServiceAddLiveToRedis(String title, String city, String address, String noteImage, String liveId)
{
List<Rockwell_keyV_live_info> listRockwell_keyV_live_info = new ArrayList<>();
Rockwell_keyT_liveQuery rockwell_keyT_liveQuery = new Rockwell_keyT_liveQuery();
String keyname = "nyx:live:num_watcher";
String strKeyZset = keyname + ":zset:" + city;
String strKeyHash = keyname + ":hash:" + city;
//step3: 查询数据
rockwell_keyT_liveQuery.setLiveId(liveId);
listRockwell_keyV_live_info = rockwell_keyMapper.getV_live_info(rockwell_keyT_liveQuery);
JSONObject jsonObject = new JSONObject();
for(Rockwell_keyV_live_info rockwell_keyV_live_info : listRockwell_keyV_live_info)
{
jsonObject.put("title", rockwell_keyV_live_info.getTitle());
jsonObject.put("city", rockwell_keyV_live_info.getCity());
jsonObject.put("address", rockwell_keyV_live_info.getAddress());
jsonObject.put("nyxName", rockwell_keyV_live_info.getNyxName());
jsonObject.put("avatarUrl", rockwell_keyV_live_info.getAvatarUrl());
jsonObject.put("noteImage", rockwell_keyV_live_info.getNoteImage());
Double score = Double.valueOf(rockwell_keyV_live_info.getNumWatcher());
jedisUtil.zadd(strKeyZset, score, rockwell_keyV_live_info.getLiveId());
jedisUtil.hset(strKeyHash, rockwell_keyV_live_info.getLiveId(), jsonObject.toJSONString());
}
return 1;
}
public void Rockwell_keyServiceUpdateWatcherToRedis(String sid, String city, Double count)
{
String keyname = "nyx:live:num_watcher:zset:"+city;
......
package cn.com.fun.nyxkey.api.service.impl;
import cn.com.fun.nyxkey.api.common.ExceptionMsg;
import cn.com.fun.nyxkey.api.common.JSONResult;
import cn.com.fun.nyxkey.api.service.*;
import cn.com.fun.nyxkey.api.utils.JedisUtil;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
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.ByteArrayEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
/**
* Created by jscat on 2020/12/09.
*/
@Service
public class Rockwell_redisServiceImpl implements Rockwell_redisService {
private static final Logger LOGGER = LoggerFactory.getLogger(Rockwell_keyServiceImpl.class);
@Autowired
JedisUtil jedisUtil;
}
......@@ -40,8 +40,11 @@ public class HttpRequest {
String result = "";
BufferedReader in = null;
try {
String urlNameString = url + "?" + param;
URL realUrl = new URL(urlNameString);
if(!param.equals(""))
{
url = url + "?" + param;
}
URL realUrl = new URL(url);
// 打开和URL之间的连接
URLConnection connection = realUrl.openConnection();
// 设置通用的请求属性
......
......@@ -44,6 +44,9 @@ public class NyxApiController {
@Autowired
private Rockwell_ossService ossService;
@Autowired
Rockwell_redisService redisService;
//AccessKeyId表示RAM子账号的AccessKeyId;
@Value("${resubmit.interval}")
private int interval;
......@@ -728,7 +731,12 @@ public class NyxApiController {
@RequestParam(value = "liveId", required = false, defaultValue = "0") String liveId
) {
return keyService.Rockwell_keyServiceAddLive(title, city, address, noteImage, liveId);
JSONResult json = keyService.Rockwell_keyServiceAddLive(title, city, address, noteImage, liveId);
if(json.getTotalCount() != 0)
{
keyService.Rockwell_keyServiceAddLiveToRedis(title, city, address, noteImage, liveId);
}
return json;
}
/*
......
......@@ -707,6 +707,9 @@ limitations under the License.
<if test="liveStatus != null and liveStatus != '' ">
AND live_status=#{liveStatus}
</if>
<if test="liveId != null and liveId != '' ">
AND live_id=#{liveId}
</if>
<if test="city != null and city != '' ">
AND city=#{city}
</if>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论