记得上下班打卡 | git大法好,push需谨慎

Commit 32d2f2a3 authored by jiangxiulong's avatar jiangxiulong

推荐和预告接口

parent 0ac15854
...@@ -83,16 +83,17 @@ public class KylinPerformancesController { ...@@ -83,16 +83,17 @@ public class KylinPerformancesController {
return ResponseDto.success(result); return ResponseDto.success(result);
} }
@GetMapping("noticeRecommendList") @GetMapping("noticeList")
@ApiOperation("推荐演出/演出预告 列表") @ApiOperation("演出预告列表")
@ApiImplicitParams({ public ResponseDto<HashMap<String, Object>> noticeList() {
@ApiImplicitParam(type = "query", dataType = "Integer", name = "listType", value = "1推荐 2预告", required = true), HashMap<String, Object> result = kylinPerformancesService.noticeList();
}) return ResponseDto.success(result);
public ResponseDto<List<PerformanceVo>> noticeRecommendList( }
@RequestParam Integer listType
) { @GetMapping("recommendList")
List<PerformanceVo> result = new ArrayList(); @ApiOperation("推荐演出列表")
result = kylinPerformancesService.noticeRecommendList(listType); public ResponseDto<List<PerformanceVo>> recommendList() {
List<PerformanceVo> result = kylinPerformancesService.recommendList();
return ResponseDto.success(result); return ResponseDto.success(result);
} }
......
...@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service; ...@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -42,7 +43,7 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM ...@@ -42,7 +43,7 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
Integer page, Integer size, Integer page, Integer size,
String orderBy, String sort String orderBy, String sort
) { ) {
HashMap<String,Object> info = new HashMap<>(); HashMap<String, Object> info = new HashMap<>();
// 排序 分页 // 排序 分页
Sort sortName = null; // 默认开票越早的在上面 Sort sortName = null; // 默认开票越早的在上面
...@@ -50,7 +51,7 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM ...@@ -50,7 +51,7 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
if (!orderBy.isEmpty()) { if (!orderBy.isEmpty()) {
sortName = Sort.by(Sort.Direction.DESC, orderBy); sortName = Sort.by(Sort.Direction.DESC, orderBy);
} }
} else if(sort.equals("ASC")){ } else if (sort.equals("ASC")) {
if (!orderBy.isEmpty()) { if (!orderBy.isEmpty()) {
sortName = Sort.by(Sort.Direction.ASC, orderBy); sortName = Sort.by(Sort.Direction.ASC, orderBy);
} }
...@@ -111,35 +112,62 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM ...@@ -111,35 +112,62 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
List<PerformanceVo> list = mongoTemplate.find(query, PerformanceVo.class, PerformanceVo.class.getSimpleName()); List<PerformanceVo> list = mongoTemplate.find(query, PerformanceVo.class, PerformanceVo.class.getSimpleName());
// 组合数据 // 组合数据
info.put("total",count); info.put("total", count);
info.put("data", list); info.put("data", list);
return info; return info;
} }
public List<PerformanceVo> noticeRecommendList(Integer listType) { public HashMap<String, Object> noticeList() {
// 固定条件 // 固定条件
Query query = new Query(); Query query = new Query();
LocalDateTime nowTime = LocalDateTime.now(); LocalDateTime nowTime = LocalDateTime.now();
String nowTimeStr = nowTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); String nowTimeStr = nowTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
query.addCriteria(Criteria.where("stopSellTime").gte(nowTimeStr)); query.addCriteria(Criteria.where("stopSellTime").gte(nowTimeStr));
query.addCriteria(Criteria.where("statusSell").is(1)); query.addCriteria(Criteria.where("statusSell").is(1));
// 推荐
if (listType.equals(1)) { // 今天的
query.addCriteria(Criteria.where("isRecommend").is(1)); LocalDateTime toDayTime = LocalDateTime.now();
} else if (listType.equals(2)) { String toDayTimeStr = toDayTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDateTime threeDaysLater = nowTime.plusDays(3); LocalDateTime toDayEndTime = toDayTime.plusDays(1);
String toDayEndTimeStr = toDayEndTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
query.addCriteria(Criteria.where("sellTime").gte(toDayTimeStr).lt(toDayEndTimeStr));
List<PerformanceVo> toDayList = mongoTemplate.find(query, PerformanceVo.class, PerformanceVo.class.getSimpleName());
// 三天的
Query queryT = new Query();
LocalDateTime nowTimeT = LocalDateTime.now();
String nowTimeStrT = nowTimeT.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
queryT.addCriteria(Criteria.where("stopSellTime").gte(nowTimeStrT));
queryT.addCriteria(Criteria.where("statusSell").is(1));
LocalDateTime threeDaysLater = toDayTime.plusDays(3);
String threeDaysLaterStr = threeDaysLater.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); String threeDaysLaterStr = threeDaysLater.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
query.addCriteria(Criteria.where("sellTime").gte(nowTimeStr).lt(threeDaysLaterStr).and("statusSell").is(1)); queryT.addCriteria(Criteria.where("sellTime").gte(toDayEndTimeStr).lt(threeDaysLaterStr));
List<PerformanceVo> threeDaysList = mongoTemplate.find(queryT, PerformanceVo.class, PerformanceVo.class.getSimpleName());
HashMap<String, Object> info = new HashMap<>();
info.put("toDayList", toDayList);
info.put("threeDaysList", threeDaysList);
return info;
} }
List<PerformanceVo> list = mongoTemplate.find(query, PerformanceVo.class, PerformanceVo.class.getSimpleName()); public List<PerformanceVo> recommendList() {
// 固定条件
Query query = new Query();
LocalDateTime nowTime = LocalDateTime.now();
String nowTimeStr = nowTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
query.addCriteria(Criteria.where("stopSellTime").gte(nowTimeStr));
query.addCriteria(Criteria.where("statusSell").is(1));
// 推荐
query.addCriteria(Criteria.where("isRecommend").is(1));
List<PerformanceVo> recommendList = mongoTemplate.find(query, PerformanceVo.class, PerformanceVo.class.getSimpleName());
return list; return recommendList;
} }
public HashMap<String, Object> detail(String performancesId) { public HashMap<String, Object> detail(String performancesId) {
HashMap<String,Object> info = new HashMap<>(); HashMap<String, Object> info = new HashMap<>();
PerformanceVo performancesInfo = mongoTemplate.findOne( PerformanceVo performancesInfo = mongoTemplate.findOne(
Query.query(Criteria.where("performancesId").is(performancesId)), Query.query(Criteria.where("performancesId").is(performancesId)),
......
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