CardCaseController.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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.Api;
  15. import io.swagger.annotations.ApiOperation;
  16. import lombok.AllArgsConstructor;
  17. import org.springframework.data.domain.Page;
  18. import org.springframework.security.access.prepost.PreAuthorize;
  19. import org.springframework.web.bind.annotation.*;
  20. import javax.servlet.http.HttpServletResponse;
  21. import java.io.IOException;
  22. import java.math.BigDecimal;
  23. import java.time.LocalDateTime;
  24. import java.util.List;
  25. import java.util.Map;
  26. @RestController
  27. @RequestMapping("/cardCase")
  28. @AllArgsConstructor
  29. @Api(value = "拼箱")
  30. public class CardCaseController extends BaseController {
  31. private CardCaseService cardCaseService;
  32. private CardCaseRepo cardCaseRepo;
  33. //@PreAuthorize("hasRole('ADMIN')")
  34. @PostMapping("/save")
  35. public CardCase save(@RequestBody CardCaseInputDTO cardCaseInputDTO) {
  36. return cardCaseService.save(cardCaseInputDTO);
  37. }
  38. //@PreAuthorize("hasRole('ADMIN')")
  39. @PostMapping("/all")
  40. public Page<CardCase> all(@RequestBody PageQuery pageQuery) {
  41. return cardCaseService.all(pageQuery);
  42. }
  43. @GetMapping("/getCardCase")
  44. public CardCaseInputDTO getCardCase(Long id) {
  45. return cardCaseService.getCardCaseInputDTO(id);
  46. }
  47. @GetMapping("/get/{id}")
  48. public CardCase get(@PathVariable Long id) {
  49. return cardCaseRepo.findById(id).orElseThrow(new BusinessException("无记录"));
  50. }
  51. @PostMapping("/del/{id}")
  52. public void del(@PathVariable Long id) {
  53. cardCaseRepo.softDelete(id);
  54. }
  55. @GetMapping("/excel")
  56. @ResponseBody
  57. public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
  58. List<CardCase> data = all(pageQuery).getContent();
  59. ExcelUtils.export(response, data);
  60. }
  61. @PostMapping("/genNew")
  62. @ApiOperation("生成卡箱信息")
  63. public List<GroupDTO> genNew(Integer group, Integer groupCount, boolean special) {
  64. return cardCaseService.genNewCardCase(group, groupCount, special);
  65. }
  66. @GetMapping("/showCasesMA")
  67. @ApiOperation("获取卡箱列表")
  68. public List<CardCaseDTO> showCardCasesMA(CaseStatus caseStatus, @RequestParam(required = false) Long collectionId,
  69. @RequestParam(required = false) String search, @RequestParam(required = true) Long seriesId) {
  70. return cardCaseService.showCardCasesMA(caseStatus, collectionId, search, seriesId);
  71. }
  72. @GetMapping("/showInfoMA")
  73. @ApiOperation(("获取拼箱详情"))
  74. public Map<String, Object> showCaseInfoMA(Long caseId) {
  75. return cardCaseService.showCaseInfoMA(caseId);
  76. }
  77. @GetMapping("/softDelete")
  78. @ApiOperation(("下架"))
  79. public void softDelete(Long caseId) {
  80. cardCaseService.softDelete(caseId);
  81. }
  82. @GetMapping("/revive")
  83. @ApiOperation(("恢复"))
  84. public void revive(Long caseId) {
  85. cardCaseService.revive(caseId);
  86. }
  87. }