| | |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | | import com.ruoyi.common.core.validate.QueryGroup; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.ValidatorUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.demo.domain.bo.TestDemoBo; |
| | | import com.ruoyi.demo.domain.vo.TestDemoVo; |
| | | import com.ruoyi.demo.service.ITestDemoService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | |
| | | return iTestDemoService.queryPageList(bo); |
| | | } |
| | | |
| | | /** |
| | | * 自定义分页查询 |
| | | */ |
| | | @ApiOperation("自定义分页查询") |
| | | @PreAuthorize("@ss.hasPermi('demo:demo:list')") |
| | | @GetMapping("/page") |
| | | public TableDataInfo<TestDemoVo> page(@Validated TestDemoBo bo) { |
| | | return iTestDemoService.customPageList(bo); |
| | | } |
| | | /** |
| | | * 自定义分页查询 |
| | | */ |
| | | @ApiOperation("自定义分页查询") |
| | | @PreAuthorize("@ss.hasPermi('demo:demo:list')") |
| | | @GetMapping("/page") |
| | | public TableDataInfo<TestDemoVo> page(@Validated(QueryGroup.class) TestDemoBo bo) { |
| | | return iTestDemoService.customPageList(bo); |
| | | } |
| | | |
| | | /** |
| | | /** |
| | | * 导出测试单表列表 |
| | | */ |
| | | @ApiOperation("导出测试单表列表") |
| | | @PreAuthorize("@ss.hasPermi('demo:demo:export')") |
| | | @Log(title = "测试单表", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export") |
| | | @PostMapping("/export") |
| | | public void export(@Validated TestDemoBo bo, HttpServletResponse response) { |
| | | List<TestDemoVo> list = iTestDemoService.queryList(bo); |
| | | // 测试雪花id导出 |
| | | // 测试雪花id导出 |
| | | // for (TestDemoVo vo : list) { |
| | | // vo.setId(1234567891234567893L); |
| | | // } |
| | | ExcelUtil.exportExcel(list, "测试单表", TestDemoVo.class, response); |
| | | ExcelUtil.exportExcel(list, "测试单表", TestDemoVo.class, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("获取测试单表详细信息") |
| | | @PreAuthorize("@ss.hasPermi('demo:demo:query')") |
| | | @GetMapping("/{id}") |
| | | public AjaxResult<TestDemoVo> getInfo(@NotNull(message = "主键不能为空") |
| | | @PathVariable("id") Long id) { |
| | | public AjaxResult<TestDemoVo> getInfo(@ApiParam("测试ID") |
| | | @NotNull(message = "主键不能为空") |
| | | @PathVariable("id") Long id) { |
| | | return AjaxResult.success(iTestDemoService.queryById(id)); |
| | | } |
| | | |
| | |
| | | @Log(title = "测试单表", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS, message = "不允许重复提交") |
| | | @PostMapping() |
| | | public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody TestDemoBo bo) { |
| | | public AjaxResult<Void> add(@RequestBody TestDemoBo bo) { |
| | | // 使用校验工具对标 @Validated(AddGroup.class) 注解 |
| | | // 用于在非 Controller 的地方校验对象 |
| | | ValidatorUtils.validate(bo, AddGroup.class); |
| | | return toAjax(iTestDemoService.insertByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | |
| | | */ |
| | | @ApiOperation("删除测试单表") |
| | | @PreAuthorize("@ss.hasPermi('demo:demo:remove')") |
| | | @Log(title = "测试单表" , businessType = BusinessType.DELETE) |
| | | @Log(title = "测试单表", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ids) { |
| | | public AjaxResult<Void> remove(@ApiParam("测试ID串") |
| | | @NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ids) { |
| | | return toAjax(iTestDemoService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0); |
| | | } |
| | | } |