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

Commit 32d2f2a3 authored by jiangxiulong's avatar jiangxiulong

推荐和预告接口

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