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

Commit 01be469f authored by 胡佳晨's avatar 胡佳晨

Merge remote-tracking branch 'origin/dev' into dev

parents bdedcb0a b662ab3d
...@@ -96,17 +96,44 @@ public class KylinPerformancesController { ...@@ -96,17 +96,44 @@ public class KylinPerformancesController {
return ResponseDto.success(result); return ResponseDto.success(result);
} }
@SneakyThrows @GetMapping(value = "search")
@ApiOperation("演出搜索")
@ApiImplicitParams({
@ApiImplicitParam(type = "query", dataType = "String", name = "title", value = "演出名称", required = true),
@ApiImplicitParam(type = "query", dataType = "int", name = "page", value = "页码"),
@ApiImplicitParam(type = "query", dataType = "int", name = "size", value = "每页数量")
})
public ResponseDto<HashMap> performancesSearch(
@RequestParam String title,
@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int size
) {
HashMap result = null;
result = kylinPerformancesService.performancesSearch(title, page, size);
return ResponseDto.success(result);
}
@GetMapping(value = "calendar") @GetMapping(value = "calendar")
@ApiOperation("演出日历") @ApiOperation("演出日历")
@ApiImplicitParam(type = "query", dataType = "String", name = "yearMonth", value = "年月 2021-01", required = true) @ApiImplicitParams({
public ResponseDto<List> performanceList(@RequestParam String yearMonth) throws ParseException { @ApiImplicitParam(type = "query", dataType = "String", name = "yearMonth", value = "年月 2021-01", required = true),
@ApiImplicitParam(type = "query", dataType = "String", name = "cityName", value = "城市名称", required = true)
})
public ResponseDto<List> performanceCalendar(@RequestParam String yearMonth, @RequestParam String cityName) throws ParseException {
List result = null; List result = null;
try { result = kylinPerformancesService.performanceCalendar(yearMonth, cityName);
result = kylinPerformancesService.performanceCalendar(yearMonth); return ResponseDto.success(result);
} catch (ParseException e) { }
e.printStackTrace();
} @GetMapping(value = "calendarPerformances")
@ApiOperation("演出日历-演出列表")
@ApiImplicitParams({
@ApiImplicitParam(type = "query", dataType = "String", name = "yearMonthDay", value = "年月日 2021-01-01", required = true),
@ApiImplicitParam(type = "query", dataType = "String", name = "cityName", value = "城市名称", required = true)
})
public ResponseDto<List> calendarPerformances(@RequestParam String yearMonthDay, @RequestParam String cityName) {
List result = null;
result = kylinPerformancesService.calendarPerformances(yearMonthDay, cityName);
return ResponseDto.success(result); return ResponseDto.success(result);
} }
......
...@@ -344,14 +344,20 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM ...@@ -344,14 +344,20 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
return list; return list;
} }
public List performanceCalendar(String yearMonth) throws ParseException { public List performanceCalendar(String yearMonth, String cityName) throws ParseException {
Document queryObject = new Document();
if (!cityName.isEmpty()) {
queryObject.put("cityName", Pattern.compile(cityName, Pattern.CASE_INSENSITIVE));
}
Query query = new BasicQuery(queryObject);
// 处理成正常格式 // 处理成正常格式
yearMonth = yearMonth.concat("-01 00:00:00"); yearMonth = yearMonth.concat("-01 00:00:00");
// 获取此月开始结束时间 // 获取此月开始结束时间
String monthStart = DateUtil.getMonthFirst(yearMonth); String monthStart = DateUtil.getMonthFirst(yearMonth);
String monthEnd = DateUtil.getMonthLast(yearMonth); String monthEnd = DateUtil.getMonthLast(yearMonth);
Query query = Query.query(Criteria.where("timeStart").gte(monthStart).lte(monthEnd)); query.addCriteria(Criteria.where("timeStart").gte(monthStart).lte(monthEnd));
query.fields().include("timeStart"); query.fields().include("timeStart");
List<KylinPerformanceVo> list = mongoTemplate.find(query, KylinPerformanceVo.class, KylinPerformanceVo.class.getSimpleName()); List<KylinPerformanceVo> list = mongoTemplate.find(query, KylinPerformanceVo.class, KylinPerformanceVo.class.getSimpleName());
...@@ -369,4 +375,42 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM ...@@ -369,4 +375,42 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
return newList; return newList;
} }
public List calendarPerformances(String yearMonthDay, String cityName) {
Document queryObject = new Document();
queryObject.put("cityName", Pattern.compile(cityName, Pattern.CASE_INSENSITIVE));
Query query = new BasicQuery(queryObject);
String yearMonthDayEnd = yearMonthDay.concat(" 23:59:59");
query.addCriteria(Criteria.where("timeStart").gte(yearMonthDay).lte(yearMonthDayEnd));
query.fields().exclude("details");
query.fields().exclude("noticeImage");
List<KylinPerformanceVo> list = mongoTemplate.find(query, KylinPerformanceVo.class, KylinPerformanceVo.class.getSimpleName());
return list;
}
public HashMap performancesSearch(String title, int page, int size) {
Document queryObject = new Document();
queryObject.put("title", Pattern.compile(title, Pattern.CASE_INSENSITIVE));
Query query = new BasicQuery(queryObject);
long count = mongoTemplate.count(query, KylinPerformanceVo.class, KylinPerformanceVo.class.getSimpleName());
query.fields().exclude("details");
query.fields().exclude("noticeImage");
Sort sortName = Sort.by(Sort.Direction.ASC, "timeStart");
Pageable pageable = PageRequest.of(page - 1, size, sortName);
query.with(pageable);
List<KylinPerformanceVo> list = mongoTemplate.find(query, KylinPerformanceVo.class, KylinPerformanceVo.class.getSimpleName());
HashMap info = new HashMap();
info.put("total", count);
info.put("list", list);
return info;
}
} }
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