TestIscsController.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package com.ktg.iscs.controller;
  2. import cn.hutool.core.convert.Convert;
  3. import cn.hutool.core.lang.Assert;
  4. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  5. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  6. import com.ktg.common.annotation.Log;
  7. import com.ktg.common.core.controller.BaseController;
  8. import com.ktg.common.enums.BusinessType;
  9. import com.ktg.common.pojo.CommonResult;
  10. import com.ktg.common.utils.poi.ExcelUtil;
  11. import com.ktg.iscs.domain.TestIscs;
  12. import com.ktg.iscs.service.ITestIscsService;
  13. import io.swagger.annotations.Api;
  14. import io.swagger.annotations.ApiOperation;
  15. import io.swagger.v3.oas.annotations.Parameter;
  16. import io.swagger.v3.oas.annotations.Parameters;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.security.access.prepost.PreAuthorize;
  19. import org.springframework.web.bind.annotation.*;
  20. import javax.servlet.http.HttpServletResponse;
  21. import java.util.Arrays;
  22. import java.util.List;
  23. /**
  24. * 测试用Controller
  25. *
  26. * @author cgj
  27. * @date 2024-12-18
  28. */
  29. @Api(tags = "测试用")
  30. @RestController
  31. @RequestMapping("/iscs/iscs")
  32. public class TestIscsController extends BaseController
  33. {
  34. @Autowired
  35. private ITestIscsService testIscsService;
  36. /**
  37. * 查询测试用分页
  38. */
  39. @ApiOperation("查询测试用-分页")
  40. @Parameters({
  41. @Parameter(name = "page", description = "Page"),
  42. @Parameter(name = "testIscs", description = "实体参数")
  43. })
  44. @PreAuthorize("@ss.hasPermi('iscs:iscs:list')")
  45. @GetMapping("/getTestIscsPage")
  46. public CommonResult<Page<TestIscs>> getTestIscsPage(Page<TestIscs> page, TestIscs testIscs)
  47. {
  48. Page<TestIscs> result = testIscsService.page(page, Wrappers.<TestIscs>lambdaQuery()
  49. .orderByDesc(TestIscs::getId));
  50. return CommonResult.success(result);
  51. }
  52. /**
  53. * 导出测试用列表
  54. */
  55. @ApiOperation("导出测试用列表")
  56. @Parameter(name = "testIscs", description = "实体参数")
  57. @PreAuthorize("@ss.hasPermi('iscs:iscs:export')")
  58. @Log(title = "测试用", businessType = BusinessType.EXPORT)
  59. @PostMapping("/exportTestIscs")
  60. public void exportTestIscs(HttpServletResponse response, TestIscs testIscs)
  61. {
  62. Page<TestIscs> page = new Page<>();
  63. page.setSize(-1);
  64. page.setCurrent(1);
  65. List<TestIscs> list = testIscsService.page(page, Wrappers.<TestIscs>lambdaQuery()
  66. .orderByDesc(TestIscs::getId)).getRecords();
  67. ExcelUtil<TestIscs> util = new ExcelUtil<TestIscs>(TestIscs.class);
  68. util.exportExcel(response, list, "测试用数据");
  69. }
  70. /**
  71. * 获取测试用详细信息
  72. */
  73. @ApiOperation("获取测试用详细信息")
  74. @Parameter(name = "id", description = "id")
  75. @PreAuthorize("@ss.hasPermi('iscs:iscs:query')")
  76. @GetMapping(value = "/selectTestIscsById")
  77. public CommonResult<TestIscs> selectTestIscsById(Long id)
  78. {
  79. return CommonResult.success(testIscsService.getById(id));
  80. }
  81. /**
  82. * 新增测试用
  83. */
  84. @ApiOperation("新增测试用")
  85. @PreAuthorize("@ss.hasPermi('iscs:iscs:add')")
  86. @Log(title = "测试用", businessType = BusinessType.INSERT)
  87. @PostMapping("/insertTestIscs")
  88. public CommonResult<Boolean> insertTestIscs(@RequestBody @Parameter(name = "testIscs", description = "新增数据类,放到body") TestIscs testIscs)
  89. {
  90. return CommonResult.success(testIscsService.save(testIscs));
  91. }
  92. /**
  93. * 修改测试用
  94. */
  95. @ApiOperation("修改测试用")
  96. @PreAuthorize("@ss.hasPermi('iscs:iscs:edit')")
  97. @Log(title = "测试用", businessType = BusinessType.UPDATE)
  98. @PostMapping("/updateTestIscs")
  99. public CommonResult<Boolean> updateTestIscs(@RequestBody @Parameter(name = "testIscs", description = "修改数据类,放到body") TestIscs testIscs)
  100. {
  101. return CommonResult.success(testIscsService.updateById(testIscs));
  102. }
  103. /**
  104. * 删除测试用
  105. */
  106. @ApiOperation("删除测试用")
  107. @PreAuthorize("@ss.hasPermi('iscs:iscs:remove')")
  108. @Log(title = "测试用", businessType = BusinessType.DELETE)
  109. @PostMapping("/deleteTestIscsByIds")
  110. public CommonResult<Boolean> deleteTestIscsByIds(String ids)
  111. {
  112. Assert.notBlank(ids, "请选择需要删除的数据!");
  113. Long[] longIds = Convert.toLongArray(ids);
  114. return CommonResult.success(testIscsService.removeBatchByIds(Arrays.asList(longIds)));
  115. }
  116. }