Commit a74f12de by jscat

nyx live:

功能: 添加redis服务
parent 5af3116b
...@@ -49,6 +49,6 @@ public enum ExceptionMsg { ...@@ -49,6 +49,6 @@ public enum ExceptionMsg {
return msg; return msg;
} }
} }
...@@ -99,11 +99,13 @@ public interface Rockwell_keyService { ...@@ -99,11 +99,13 @@ public interface Rockwell_keyService {
jscat 20201127 jscat 20201127
*/ */
JSONResult Rockwell_keyServiceGetLives(String orderType, int pageNum, int pageCount); 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_keyServiceGetLivesByRedis(String city, String title, String orderType, int pageNum, int pageCount);
JSONResult Rockwell_keyServiceAddLive(String title, String city, String address, String noteImage, String liveId); JSONResult Rockwell_keyServiceAddLive(String title, String city, String address, String noteImage, String liveId);
int Rockwell_keyServiceUpdateLive(String title, String liveStatus, String userId); 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 // testing
void Rockwell_keyServiceTest(List<Rockwell_keyT_match> listRockwell_keyT_match); 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 { ...@@ -1112,6 +1112,36 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService {
return jsonResult; 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) public void Rockwell_keyServiceUpdateWatcherToRedis(String sid, String city, Double count)
{ {
String keyname = "nyx:live:num_watcher:zset:"+city; 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 { ...@@ -40,8 +40,11 @@ public class HttpRequest {
String result = ""; String result = "";
BufferedReader in = null; BufferedReader in = null;
try { try {
String urlNameString = url + "?" + param; if(!param.equals(""))
URL realUrl = new URL(urlNameString); {
url = url + "?" + param;
}
URL realUrl = new URL(url);
// 打开和URL之间的连接 // 打开和URL之间的连接
URLConnection connection = realUrl.openConnection(); URLConnection connection = realUrl.openConnection();
// 设置通用的请求属性 // 设置通用的请求属性
......
...@@ -44,6 +44,9 @@ public class NyxApiController { ...@@ -44,6 +44,9 @@ public class NyxApiController {
@Autowired @Autowired
private Rockwell_ossService ossService; private Rockwell_ossService ossService;
@Autowired
Rockwell_redisService redisService;
//AccessKeyId表示RAM子账号的AccessKeyId; //AccessKeyId表示RAM子账号的AccessKeyId;
@Value("${resubmit.interval}") @Value("${resubmit.interval}")
private int interval; private int interval;
...@@ -728,7 +731,12 @@ public class NyxApiController { ...@@ -728,7 +731,12 @@ public class NyxApiController {
@RequestParam(value = "liveId", required = false, defaultValue = "0") String liveId @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. ...@@ -707,6 +707,9 @@ limitations under the License.
<if test="liveStatus != null and liveStatus != '' "> <if test="liveStatus != null and liveStatus != '' ">
AND live_status=#{liveStatus} AND live_status=#{liveStatus}
</if> </if>
<if test="liveId != null and liveId != '' ">
AND live_id=#{liveId}
</if>
<if test="city != null and city != '' "> <if test="city != null and city != '' ">
AND city=#{city} AND city=#{city}
</if> </if>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论