|
|
@@ -1,69 +0,0 @@
|
|
|
-package com.izouma.ticketExchange.web.gen;
|
|
|
-
|
|
|
-import com.izouma.ticketExchange.web.BaseController;
|
|
|
-import com.izouma.ticketExchange.domain.gen.TestGenCode;
|
|
|
-import com.izouma.ticketExchange.service.gen.TestGenCodeService;
|
|
|
-import com.izouma.ticketExchange.dto.PageQuery;
|
|
|
-import com.izouma.ticketExchange.exception.BusinessException;
|
|
|
-import com.izouma.ticketExchange.repo.gen.TestGenCodeRepo;
|
|
|
-import com.izouma.ticketExchange.utils.ObjUtils;
|
|
|
-import com.izouma.ticketExchange.utils.excel.ExcelUtils;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-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.util.List;
|
|
|
-
|
|
|
-@RestController
|
|
|
-@RequestMapping("/testGenCode")
|
|
|
-public class TestGenCodeController extends BaseController {
|
|
|
- /*generatedStart*/
|
|
|
- @Autowired
|
|
|
- private TestGenCodeService testGenCodeService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private TestGenCodeRepo testGenCodeRepo;
|
|
|
- /*generatedEnd*/
|
|
|
-
|
|
|
- /*generatedStart*/
|
|
|
- @PreAuthorize("hasRole('ADMIN')")
|
|
|
- @PostMapping("/save")
|
|
|
- public TestGenCode save(@RequestBody TestGenCode record) {
|
|
|
- if (record.getId() != null) {
|
|
|
- TestGenCode orig = testGenCodeRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
|
|
|
- ObjUtils.merge(orig, record);
|
|
|
- return testGenCodeRepo.save(record);
|
|
|
- }
|
|
|
- return testGenCodeRepo.save(record);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @PreAuthorize("hasRole('ADMIN')")
|
|
|
- @GetMapping("/all")
|
|
|
- public Page<TestGenCode> all(PageQuery pageQuery) {
|
|
|
- return testGenCodeRepo.findAll(toSpecification(pageQuery,TestGenCode.class), toPageRequest(pageQuery));
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/get/{id}")
|
|
|
- public TestGenCode get(@PathVariable Long id) {
|
|
|
- return testGenCodeRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/del/{id}")
|
|
|
- public void del(@PathVariable Long id) {
|
|
|
- testGenCodeRepo.deleteById(id);
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/excel")
|
|
|
- @ResponseBody
|
|
|
- public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
|
|
|
- List<TestGenCode> data = all(pageQuery).getContent();
|
|
|
- ExcelUtils.export(response, data);
|
|
|
- }
|
|
|
- /*generatedEnd*/
|
|
|
-}
|
|
|
-
|