CardCaseController.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package com.izouma.tcg.web.card;
  2. import com.izouma.tcg.dto.GroupDTO;
  3. import com.izouma.tcg.dto.cardCase.CardCaseDTO;
  4. import com.izouma.tcg.dto.cardCase.CardCaseInputDTO;
  5. import com.izouma.tcg.enums.CaseStatus;
  6. import com.izouma.tcg.web.BaseController;
  7. import com.izouma.tcg.domain.card.CardCase;
  8. import com.izouma.tcg.service.card.CardCaseService;
  9. import com.izouma.tcg.dto.PageQuery;
  10. import com.izouma.tcg.exception.BusinessException;
  11. import com.izouma.tcg.repo.card.CardCaseRepo;
  12. import com.izouma.tcg.utils.ObjUtils;
  13. import com.izouma.tcg.utils.excel.ExcelUtils;
  14. import io.swagger.annotations.ApiOperation;
  15. import io.swagger.annotations.Authorization;
  16. import lombok.AllArgsConstructor;
  17. import org.springframework.data.domain.Page;
  18. import org.springframework.data.domain.Pageable;
  19. import org.springframework.security.access.prepost.PreAuthorize;
  20. import org.springframework.web.bind.annotation.*;
  21. import javax.annotation.security.PermitAll;
  22. import javax.servlet.http.HttpServletResponse;
  23. import java.io.IOException;
  24. import java.math.BigDecimal;
  25. import java.time.LocalDateTime;
  26. import java.util.List;
  27. import java.util.Map;
  28. @RestController
  29. @RequestMapping("/cardCase")
  30. @AllArgsConstructor
  31. public class CardCaseController extends BaseController {
  32. private CardCaseService cardCaseService;
  33. private CardCaseRepo cardCaseRepo;
  34. //@PreAuthorize("hasRole('ADMIN')")
  35. @PostMapping("/save")
  36. public CardCase save(@RequestBody CardCaseInputDTO cardCaseInputDTO) {
  37. return cardCaseService.save(cardCaseInputDTO);
  38. }
  39. //@PreAuthorize("hasRole('ADMIN')")
  40. @PostMapping("/all")
  41. public Page<CardCase> all(@RequestBody PageQuery pageQuery) {
  42. return cardCaseService.all(pageQuery);
  43. }
  44. @GetMapping("/getCardCase")
  45. public CardCaseInputDTO getCardCase(Long id) {
  46. return cardCaseService.getCardCaseInputDTO(id);
  47. }
  48. @GetMapping("/get/{id}")
  49. public CardCase get(@PathVariable Long id) {
  50. return cardCaseRepo.findById(id).orElseThrow(new BusinessException("无记录"));
  51. }
  52. @PostMapping("/del/{id}")
  53. public void del(@PathVariable Long id) {
  54. cardCaseRepo.softDelete(id);
  55. }
  56. @GetMapping("/excel")
  57. @ResponseBody
  58. public void excel(HttpServletResponse response, Pageable pageable) throws IOException {
  59. List<CardCaseDTO> data = showCardCasesMA(null, null, null, 103L, pageable).getContent();
  60. ExcelUtils.export(response, data);
  61. }
  62. @PostMapping("/genNew")
  63. @ApiOperation("生成卡箱信息")
  64. public List<GroupDTO> genNew(Integer group, Integer groupCount, boolean special) {
  65. return cardCaseService.genNewCardCase(group, groupCount, special);
  66. }
  67. @GetMapping("/showCasesMA")
  68. @ApiOperation("获取卡箱列表")
  69. public Page<CardCaseDTO> showCardCasesMA(CaseStatus caseStatus, @RequestParam(required = false) Long collectionId,
  70. @RequestParam(required = false) String search, @RequestParam(required = true) Long seriesId, Pageable pageable) {
  71. return cardCaseService.showCardCasesMA(caseStatus, collectionId, search, seriesId, pageable);
  72. }
  73. @GetMapping("/showInfoMA")
  74. @ApiOperation(("获取拼箱详情"))
  75. public Map<String, Object> showCaseInfoMA(Long caseId) {
  76. return cardCaseService.showCaseInfoMA(caseId);
  77. }
  78. @GetMapping("/softDelete")
  79. @ApiOperation(("下架"))
  80. public void softDelete(Long caseId) {
  81. cardCaseService.softDelete(caseId);
  82. }
  83. @GetMapping("/multipleDelete")
  84. @ApiOperation(("批量下架"))
  85. public void multipleDelete(String caseIds) {
  86. cardCaseService.multipleDelete(caseIds);
  87. }
  88. @GetMapping("/revive")
  89. @ApiOperation(("恢复"))
  90. public void revive(Long caseId) {
  91. cardCaseService.revive(caseId);
  92. }
  93. @PostMapping("/cancel")
  94. @ApiOperation(("取消"))
  95. public void cancel(Long caseId) {
  96. cardCaseService.cancel(caseId);
  97. }
  98. @GetMapping("/showRoomCases")
  99. @ApiOperation(("展示直播拼箱"))
  100. public List<CardCaseDTO> showRoomCases(Long roomId, Long storeId) {
  101. return cardCaseService.showRoomCasesMA(roomId, storeId);
  102. }
  103. }