package com.izouma.tcg.web.card; import com.izouma.tcg.dto.GroupDTO; import com.izouma.tcg.dto.cardCase.CardCaseDTO; import com.izouma.tcg.dto.cardCase.CardCaseInputDTO; import com.izouma.tcg.enums.CaseStatus; import com.izouma.tcg.web.BaseController; import com.izouma.tcg.domain.card.CardCase; import com.izouma.tcg.service.card.CardCaseService; import com.izouma.tcg.dto.PageQuery; import com.izouma.tcg.exception.BusinessException; import com.izouma.tcg.repo.card.CardCaseRepo; import com.izouma.tcg.utils.ObjUtils; import com.izouma.tcg.utils.excel.ExcelUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; import java.util.Map; @RestController @RequestMapping("/cardCase") @AllArgsConstructor @Api(value = "拼箱") public class CardCaseController extends BaseController { private CardCaseService cardCaseService; private CardCaseRepo cardCaseRepo; //@PreAuthorize("hasRole('ADMIN')") @PostMapping("/save") public CardCase save(@RequestBody CardCaseInputDTO cardCaseInputDTO) { return cardCaseService.save(cardCaseInputDTO); } //@PreAuthorize("hasRole('ADMIN')") @PostMapping("/all") public Page all(@RequestBody PageQuery pageQuery) { return cardCaseService.all(pageQuery); } @GetMapping("/getCardCase") public CardCaseInputDTO getCardCase(Long id) { return cardCaseService.getCardCaseInputDTO(id); } @GetMapping("/get/{id}") public CardCase get(@PathVariable Long id) { return cardCaseRepo.findById(id).orElseThrow(new BusinessException("无记录")); } @PostMapping("/del/{id}") public void del(@PathVariable Long id) { cardCaseRepo.softDelete(id); } @GetMapping("/excel") @ResponseBody public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException { List data = all(pageQuery).getContent(); ExcelUtils.export(response, data); } @PostMapping("/genNew") @ApiOperation("生成卡箱信息") public List genNew(Integer group, Integer groupCount, boolean special) { return cardCaseService.genNewCardCase(group, groupCount, special); } @GetMapping("/showCasesMA") @ApiOperation("获取卡箱列表") public List showCardCasesMA(CaseStatus caseStatus, @RequestParam(required = false) Long collectionId, @RequestParam(required = false) String search, @RequestParam(required = true) Long seriesId) { return cardCaseService.showCardCasesMA(caseStatus, collectionId, search, seriesId); } @GetMapping("/showInfoMA") @ApiOperation(("获取拼箱详情")) public Map showCaseInfoMA(Long caseId) { return cardCaseService.showCaseInfoMA(caseId); } @GetMapping("/softDelete") @ApiOperation(("下架")) public void softDelete(Long caseId) { cardCaseService.softDelete(caseId); } @GetMapping("/revive") @ApiOperation(("恢复")) public void revive(Long caseId) { cardCaseService.revive(caseId); } }