Commit 54210b2e by lenx065@gmail.com

调整数据结构

parent 5c400388
...@@ -15,6 +15,8 @@ public class MatchHomeListByDayResponse { ...@@ -15,6 +15,8 @@ public class MatchHomeListByDayResponse {
private String matchDay; private String matchDay;
private String weekNum;
private List<MatchInfo> matchInfos; private List<MatchInfo> matchInfos;
@Data @Data
...@@ -22,6 +24,7 @@ public class MatchHomeListByDayResponse { ...@@ -22,6 +24,7 @@ public class MatchHomeListByDayResponse {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public static class MatchInfo { public static class MatchInfo {
private String matchId;
// 0足球 1篮球 // 0足球 1篮球
private Integer sportsType; private Integer sportsType;
private String matchShortName; private String matchShortName;
......
...@@ -2,9 +2,11 @@ package com.live.common.domain.request; ...@@ -2,9 +2,11 @@ package com.live.common.domain.request;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
@Data @Data
public class GetMatchListByRequest { @EqualsAndHashCode(callSuper = true)
public class GetMatchListByRequest extends CommonPage {
private String sportsId; private String sportsId;
......
...@@ -117,7 +117,7 @@ public class MatchServiceImpl implements MatchService { ...@@ -117,7 +117,7 @@ public class MatchServiceImpl implements MatchService {
wrapper.eq("source_type", 1); wrapper.eq("source_type", 1);
if (StringUtils.isNotBlank(commonStringId.getSportsId())) { if (StringUtils.isNotBlank(commonStringId.getSportsId())) {
if(commonStringId.getSportsId().equals("-1")){ if (commonStringId.getSportsId().equals("-1")) {
wrapper.eq("hot", 1); wrapper.eq("hot", 1);
} else { } else {
wrapper.eq("sports_id", commonStringId.getSportsId()); wrapper.eq("sports_id", commonStringId.getSportsId());
...@@ -126,48 +126,50 @@ public class MatchServiceImpl implements MatchService { ...@@ -126,48 +126,50 @@ public class MatchServiceImpl implements MatchService {
if (StringUtils.isNotBlank(commonStringId.getMatchTime())) { if (StringUtils.isNotBlank(commonStringId.getMatchTime())) {
wrapper.ge("match_time", commonStringId.getMatchTime() + " 00:00:00"); wrapper.ge("match_time", commonStringId.getMatchTime() + " 00:00:00");
wrapper.le("match_time", commonStringId.getSportsId() + " 23:59:59"); wrapper.le("match_time", commonStringId.getSportsId() + " 23:59:59");
} else {
wrapper.ge("match_time", DateUtil.getYsdStartTime());
} }
//-1 全部 0 展示正在进行 和 未开始 1 正在进行 2未开始 3完场 //-1 全部 0 展示正在进行 和 未开始 1 正在进行 2未开始 3完场
//1正在进行 2未开始 3完场 4 未知 //1正在进行 2未开始 3完场 4 未知
Integer status = commonStringId.getStatus() == null ? 0 : commonStringId.getStatus(); Integer status = commonStringId.getStatus() == null ? 0 : commonStringId.getStatus();
int jumpNum = (commonStringId.getPageNum() - 1) * commonStringId.getPageSize();
long count = 0;
switch (status) { switch (status) {
case -1: case -1:
wrapper.notIn("competition_status", 4); wrapper.notIn("competition_status", 4);
wrapper.orderByDesc("match_time"); wrapper.orderByAsc("match_time");
wrapper.last(String.format(" limit %s,%s", 0, 30)); count = matchMapper.selectCount(wrapper);
wrapper.last(String.format(" limit %s,%s", jumpNum, commonStringId.getPageSize()));
matches = matchMapper.selectList(wrapper); matches = matchMapper.selectList(wrapper);
break; break;
case 1: case 1:
case 2: case 2:
case 3: case 3:
wrapper.eq("competition_status", status); wrapper.eq("competition_status", status);
wrapper.orderByDesc("match_time"); wrapper.orderByAsc("match_time");
wrapper.last(String.format(" limit %s,%s", 0, 30)); count = matchMapper.selectCount(wrapper);
wrapper.last(String.format(" limit %s,%s", jumpNum, commonStringId.getPageSize()));
matches = matchMapper.selectList(wrapper); matches = matchMapper.selectList(wrapper);
break; break;
default: default:
wrapper.in("competition_status", 1, 2); wrapper.in("competition_status", 1, 2);
wrapper.orderByDesc("match_time"); wrapper.orderByAsc("match_time");
wrapper.last(String.format(" limit %s,%s", 0, 30)); count = matchMapper.selectCount(wrapper);
wrapper.last(String.format(" limit %s,%s", jumpNum, commonStringId.getPageSize()));
matches = matchMapper.selectList(wrapper); matches = matchMapper.selectList(wrapper);
break; break;
} }
MatchHomeListByDayResponse response = new MatchHomeListByDayResponse(); Map<String, List<MatchHomeListByDayResponse.MatchInfo>> responseMap = new LinkedHashMap<>();
response.setMatchInfos(new ArrayList<>()); for (Match match : matches) {
for (int i = matches.size() - 1; i >= 0; i--) {
if (i == matches.size() - 1) {
response.setMatchDay(DateUtil.format(matches.get(0).getMatchTime(), DateUtil.YMD_));
}
Match match = matches.get(i);
MatchHomeListByDayResponse.MatchInfo matchInfo = new MatchHomeListByDayResponse.MatchInfo(); MatchHomeListByDayResponse.MatchInfo matchInfo = new MatchHomeListByDayResponse.MatchInfo();
matchInfo.setSubscribed(false); matchInfo.setSubscribed(false);
matchInfo.setMatchId(match.getId());
if (DateUtil.format(match.getMatchTime(), DateUtil.YMD_).equals(response.getMatchDay())) {
try { try {
String phone = CommonMethod.getUserPhone(request); String phone = CommonMethod.getUserPhone(request);
User account = userMapper.selectOne(Wrappers.<User>lambdaQuery() User account = userMapper.selectOne(Wrappers.<User>lambdaQuery()
...@@ -204,18 +206,28 @@ public class MatchServiceImpl implements MatchService { ...@@ -204,18 +206,28 @@ public class MatchServiceImpl implements MatchService {
matchInfo.setMatchTime(DateUtil.format(match.getMatchTime(), DateUtil.HM_)); matchInfo.setMatchTime(DateUtil.format(match.getMatchTime(), DateUtil.HM_));
matchInfo.setSportsType(sports.getSportsId()); matchInfo.setSportsType(sports.getSportsId());
response.getMatchInfos().add(matchInfo); responseMap.computeIfAbsent(DateUtil.format(match.getMatchTime(), DateUtil.YMD_),
m -> new ArrayList<>()).add(matchInfo);
} }
List<MatchHomeListByDayResponse> responses = new ArrayList<>();
for(String key : responseMap.keySet()){
responses.add(MatchHomeListByDayResponse.builder()
.matchDay(key)
.weekNum(DateUtil.returnWeek(DateUtil.getDateByStringYMD(key)))
.matchInfos(responseMap.get(key))
.build());
} }
return ResponseData.successResponse(response); return ResponseData.successResponse(new ResultPage(commonStringId.getPageNum(), commonStringId.getPageSize(),
(int) count, responses));
} }
@Override @Override
public ResponseData<?> getMatchTypeInfoList(HttpServletRequest request) { public ResponseData<?> getMatchTypeInfoList(HttpServletRequest request) {
String key = RedisKeySplicing.requestLock("getMatchTypeInfoList", "0"); String key = RedisKeySplicing.requestLock("getMatchTypeInfoList", "0");
if(redisUtilsService.existsKey(key)){ if (redisUtilsService.existsKey(key)) {
String cacheInfo = redisUtilsService.getCacheStringInfo(key); String cacheInfo = redisUtilsService.getCacheStringInfo(key);
GetMatchTypeInfoListResponse response = JSONObject.toJavaObject(JSONObject.parseObject(cacheInfo), GetMatchTypeInfoListResponse.class); GetMatchTypeInfoListResponse response = JSONObject.toJavaObject(JSONObject.parseObject(cacheInfo), GetMatchTypeInfoListResponse.class);
return ResponseData.successResponse(response); return ResponseData.successResponse(response);
...@@ -250,7 +262,7 @@ public class MatchServiceImpl implements MatchService { ...@@ -250,7 +262,7 @@ public class MatchServiceImpl implements MatchService {
public ResponseData<?> getTeamInfoList(HttpServletRequest request) { public ResponseData<?> getTeamInfoList(HttpServletRequest request) {
String key = RedisKeySplicing.requestLock("getTeamInfoList", "0"); String key = RedisKeySplicing.requestLock("getTeamInfoList", "0");
if(redisUtilsService.existsKey(key)){ if (redisUtilsService.existsKey(key)) {
String cacheInfo = redisUtilsService.getCacheStringInfo(key); String cacheInfo = redisUtilsService.getCacheStringInfo(key);
GetTeamInfoListResponse response = JSONObject.toJavaObject(JSONObject.parseObject(cacheInfo), GetTeamInfoListResponse.class); GetTeamInfoListResponse response = JSONObject.toJavaObject(JSONObject.parseObject(cacheInfo), GetTeamInfoListResponse.class);
return ResponseData.successResponse(response); return ResponseData.successResponse(response);
......
...@@ -239,11 +239,6 @@ public class UserServiceImpl implements UserService { ...@@ -239,11 +239,6 @@ public class UserServiceImpl implements UserService {
.gold(0) .gold(0)
.userId(accountDb.getId()) .userId(accountDb.getId())
.build()); .build());
huanXinIMService.registerUser(HuanXinIMServiceImpl.UserRegistration.builder()
.nickName(accountDb.getUserName())
.password("123456")
.username("live_" + accountDb.getId() + surroundings)
.build());
} }
} }
......
...@@ -33,6 +33,8 @@ public class DateUtil { ...@@ -33,6 +33,8 @@ public class DateUtil {
public final static String MM = "MM"; public final static String MM = "MM";
public final static String YYYY = "yyyy"; public final static String YYYY = "yyyy";
public final static Map<Integer, String> weekMap = new HashMap<>(7);
/** /**
* 返回一个ThreadLocal的sdf,每个线程只会new一次sdf * 返回一个ThreadLocal的sdf,每个线程只会new一次sdf
* *
...@@ -326,6 +328,7 @@ public class DateUtil { ...@@ -326,6 +328,7 @@ public class DateUtil {
/** /**
* 获取多少天以后开始时间 * 获取多少天以后开始时间
*
* @return * @return
*/ */
public static Date getAddDayStartTime(int addDay) { public static Date getAddDayStartTime(int addDay) {
...@@ -340,6 +343,7 @@ public class DateUtil { ...@@ -340,6 +343,7 @@ public class DateUtil {
/** /**
* 获取多少天以后结束时间 * 获取多少天以后结束时间
*
* @return * @return
*/ */
public static Date getAddDayEndTime(int addDay) { public static Date getAddDayEndTime(int addDay) {
...@@ -377,20 +381,24 @@ public class DateUtil { ...@@ -377,20 +381,24 @@ public class DateUtil {
} }
} }
public static void main(String[] args) { public static String returnWeek(Date date) {
// System.out.println(DateUtil.isEffectiveDate(DateUtil.parse(DateUtil.format(new Date(), "HH:mm:ss"), "HH:mm:ss"), DateUtil.parse("00:00:00", "HH:mm:ss"), DateUtil.parse("16:00:00", "HH:mm:ss"))); if(weekMap.size() == 0){
weekMap.put(1, "星期日");
// System.out.println(getYsdStartTime()); weekMap.put(2, "星期一");
weekMap.put(3, "星期二");
weekMap.put(4, "星期三");
weekMap.put(5, "星期四");
weekMap.put(6, "星期五");
weekMap.put(7, "星期六");
}
// System.out.println("25/06/2015".indexOf("/") > 3); Calendar calendar = Calendar.getInstance();
// System.out.println("2015/06/06".indexOf("/") > 3); calendar.setTime(date);
// System.out.println(parse("25/06/2015",DMY)); return weekMap.get(calendar.get(Calendar.DAY_OF_WEEK));
// Map<Date,Integer> map = new HashMap<>(); }
// map.put(getStartTime(),1);
// Integer num = map.get(getStartTime());
// System.out.println(num);
//
public static void main(String[] args) {
System.out.println(returnWeek(getDateByStringYMD("2021-07-23")));
System.out.println("AD" + IdGen.randomLong(3) + String.valueOf(System.currentTimeMillis()).substring(5)); System.out.println("AD" + IdGen.randomLong(3) + String.valueOf(System.currentTimeMillis()).substring(5));
} }
...@@ -423,6 +431,17 @@ public class DateUtil { ...@@ -423,6 +431,17 @@ public class DateUtil {
return 0; return 0;
} }
public static Date getDateByStringYMD(String str) {
SimpleDateFormat sdf = new SimpleDateFormat(YMD_, Locale.ENGLISH);
Date d2 = null;
try {
d2 = sdf.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
return d2;
}
public static Date getEnlishDate(String str) { public static Date getEnlishDate(String str) {
SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy K:m:s a", Locale.ENGLISH); SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy K:m:s a", Locale.ENGLISH);
Date d2 = null; Date d2 = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment