|
|
@@ -1,37 +1,26 @@
|
|
|
package com.izouma.nineth.web;
|
|
|
|
|
|
-import cn.hutool.core.collection.CollectionUtil;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.izouma.nineth.config.MetaConstants;
|
|
|
-import com.izouma.nineth.domain.MetaGameBoxPoints;
|
|
|
-import com.izouma.nineth.domain.MetaParamsConfig;
|
|
|
import com.izouma.nineth.domain.MetaUserGoldRecord;
|
|
|
-import com.izouma.nineth.dto.*;
|
|
|
+import com.izouma.nineth.dto.PageQuery;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
-import com.izouma.nineth.repo.MetaParamsConfigRepo;
|
|
|
import com.izouma.nineth.repo.MetaUserGoldRecordRepo;
|
|
|
-import com.izouma.nineth.service.MetaParamsConfigService;
|
|
|
import com.izouma.nineth.service.MetaUserGoldRecordService;
|
|
|
import com.izouma.nineth.utils.ObjUtils;
|
|
|
import com.izouma.nineth.utils.excel.ExcelUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
-import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/metaUserGoldRecord")
|
|
|
@AllArgsConstructor
|
|
|
public class MetaUserGoldRecordController extends BaseController {
|
|
|
private MetaUserGoldRecordService metaUserGoldRecordService;
|
|
|
- private MetaUserGoldRecordRepo metaUserGoldRecordRepo;
|
|
|
- private MetaParamsConfigService metaParamsConfigService;
|
|
|
+ private MetaUserGoldRecordRepo metaUserGoldRecordRepo;
|
|
|
|
|
|
//@PreAuthorize("hasRole('ADMIN')")
|
|
|
@PostMapping("/save")
|
|
|
@@ -67,45 +56,5 @@ public class MetaUserGoldRecordController extends BaseController {
|
|
|
List<MetaUserGoldRecord> data = all(pageQuery).getContent();
|
|
|
ExcelUtils.export(response, data);
|
|
|
}
|
|
|
-
|
|
|
- @GetMapping("/excel/top")
|
|
|
- @ResponseBody
|
|
|
- public void excelTop(HttpServletResponse response, PageQuery pageQuery) throws IOException {
|
|
|
- List<MetaGoldTopDTO> data = top(pageQuery).getContent();
|
|
|
- ExcelUtils.export(response, data);
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/goldTop")
|
|
|
- public Page<MetaGoldTopDTO> top(@RequestBody PageQuery pageQuery) {
|
|
|
- String beginTime = metaParamsConfigService.getString(MetaConstants.META_GOLD_TOP_BEGIN_TIME);
|
|
|
- String endTime = metaParamsConfigService.getString(MetaConstants.META_GOLD_TOP_END_TIME);
|
|
|
- List<Map<String, String>> map = metaUserGoldRecordRepo.top(beginTime, endTime);
|
|
|
- JSONArray jsonArray = new JSONArray();
|
|
|
- jsonArray.addAll(map);
|
|
|
- List<MetaGoldTopDTO> metaGoldTopDTOS = jsonArray.toJavaList(MetaGoldTopDTO.class);
|
|
|
- // 当前页
|
|
|
- int page = pageQuery.getPage();
|
|
|
- // pageSize 每页查询多少条数据
|
|
|
- int size = pageQuery.getSize();
|
|
|
- // limit 开始偏移量
|
|
|
- int start = page * size;
|
|
|
- int totalElements = 0;
|
|
|
- if (CollectionUtils.isEmpty(metaGoldTopDTOS)) {
|
|
|
- totalElements = 0;
|
|
|
- return new PageWrapper<>(new ArrayList<MetaGoldTopDTO>(), page,
|
|
|
- size, totalElements).toPage();
|
|
|
- }
|
|
|
- totalElements = metaGoldTopDTOS.size();
|
|
|
- List<MetaGoldTopDTO> newMetaGoldTopDTOS;
|
|
|
- if (metaGoldTopDTOS.size() < start + size) {
|
|
|
- newMetaGoldTopDTOS = metaGoldTopDTOS.subList(start, metaGoldTopDTOS.size());
|
|
|
- return new PageWrapper<>(newMetaGoldTopDTOS, page,
|
|
|
- size, totalElements).toPage();
|
|
|
- }
|
|
|
- newMetaGoldTopDTOS = metaGoldTopDTOS.subList(start, start + size);
|
|
|
- return new PageWrapper<>(newMetaGoldTopDTOS, page,
|
|
|
- size, totalElements).toPage();
|
|
|
-
|
|
|
- }
|
|
|
}
|
|
|
|