package com.ktg.iscs.controller; import cn.hutool.core.convert.Convert; import cn.hutool.core.lang.Assert; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ktg.common.annotation.Log; import com.ktg.common.core.controller.BaseController; import com.ktg.common.enums.BusinessType; import com.ktg.common.pojo.CommonResult; import com.ktg.common.utils.poi.ExcelUtil; import com.ktg.iscs.domain.TestIscs; import com.ktg.iscs.service.ITestIscsService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.util.Arrays; import java.util.List; /** * 测试用Controller * * @author cgj * @date 2024-12-18 */ @Api(tags = "测试用") @RestController @RequestMapping("/iscs/iscs") public class TestIscsController extends BaseController { @Autowired private ITestIscsService testIscsService; /** * 查询测试用分页 */ @ApiOperation("查询测试用-分页") @Parameters({ @Parameter(name = "page", description = "Page"), @Parameter(name = "testIscs", description = "实体参数") }) @PreAuthorize("@ss.hasPermi('iscs:iscs:list')") @GetMapping("/getTestIscsPage") public CommonResult> getTestIscsPage(Page page, TestIscs testIscs) { Page result = testIscsService.page(page, Wrappers.lambdaQuery() .orderByDesc(TestIscs::getId)); return CommonResult.success(result); } /** * 导出测试用列表 */ @ApiOperation("导出测试用列表") @Parameter(name = "testIscs", description = "实体参数") @PreAuthorize("@ss.hasPermi('iscs:iscs:export')") @Log(title = "测试用", businessType = BusinessType.EXPORT) @PostMapping("/exportTestIscs") public void exportTestIscs(HttpServletResponse response, TestIscs testIscs) { Page page = new Page<>(); page.setSize(-1); page.setCurrent(1); List list = testIscsService.page(page, Wrappers.lambdaQuery() .orderByDesc(TestIscs::getId)).getRecords(); ExcelUtil util = new ExcelUtil(TestIscs.class); util.exportExcel(response, list, "测试用数据"); } /** * 获取测试用详细信息 */ @ApiOperation("获取测试用详细信息") @Parameter(name = "id", description = "id") @PreAuthorize("@ss.hasPermi('iscs:iscs:query')") @GetMapping(value = "/selectTestIscsById") public CommonResult selectTestIscsById(Long id) { return CommonResult.success(testIscsService.getById(id)); } /** * 新增测试用 */ @ApiOperation("新增测试用") @PreAuthorize("@ss.hasPermi('iscs:iscs:add')") @Log(title = "测试用", businessType = BusinessType.INSERT) @PostMapping("/insertTestIscs") public CommonResult insertTestIscs(@RequestBody @Parameter(name = "testIscs", description = "新增数据类,放到body") TestIscs testIscs) { return CommonResult.success(testIscsService.save(testIscs)); } /** * 修改测试用 */ @ApiOperation("修改测试用") @PreAuthorize("@ss.hasPermi('iscs:iscs:edit')") @Log(title = "测试用", businessType = BusinessType.UPDATE) @PostMapping("/updateTestIscs") public CommonResult updateTestIscs(@RequestBody @Parameter(name = "testIscs", description = "修改数据类,放到body") TestIscs testIscs) { return CommonResult.success(testIscsService.updateById(testIscs)); } /** * 删除测试用 */ @ApiOperation("删除测试用") @PreAuthorize("@ss.hasPermi('iscs:iscs:remove')") @Log(title = "测试用", businessType = BusinessType.DELETE) @PostMapping("/deleteTestIscsByIds") public CommonResult deleteTestIscsByIds(String ids) { Assert.notBlank(ids, "请选择需要删除的数据!"); Long[] longIds = Convert.toLongArray(ids); return CommonResult.success(testIscsService.removeBatchByIds(Arrays.asList(longIds))); } }