| | |
| | | package com.ruoyi.demo.controller; |
| | | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.demo.bo.TestTreeAddBo; |
| | | import com.ruoyi.demo.bo.TestTreeEditBo; |
| | | import com.ruoyi.demo.bo.TestTreeQueryBo; |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.validate.AddGroup; |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | | import com.ruoyi.common.core.validate.QueryGroup; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.excel.utils.ExcelUtil; |
| | | import com.ruoyi.common.idempotent.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.demo.domain.bo.TestTreeBo; |
| | | import com.ruoyi.demo.domain.vo.TestTreeVo; |
| | | import com.ruoyi.demo.service.ITestTreeService; |
| | | import com.ruoyi.demo.vo.TestTreeVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotNull; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | |
| | | * 测试树表Controller |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | * @date 2021-07-26 |
| | | */ |
| | | @Api(value = "测试树表控制器", tags = {"测试树表管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/tree") |
| | | public class TestTreeController extends BaseController { |
| | |
| | | /** |
| | | * 查询测试树表列表 |
| | | */ |
| | | @ApiOperation("查询测试树表列表") |
| | | @PreAuthorize("@ss.hasPermi('demo:tree:list')") |
| | | @SaCheckPermission("demo:tree:list") |
| | | @GetMapping("/list") |
| | | public AjaxResult<List<TestTreeVo>> list(@Validated TestTreeQueryBo bo) { |
| | | return AjaxResult.success(iTestTreeService.queryList(bo)); |
| | | public R<List<TestTreeVo>> list(@Validated(QueryGroup.class) TestTreeBo bo) { |
| | | List<TestTreeVo> list = iTestTreeService.queryList(bo); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | /** |
| | | * 导出测试树表列表 |
| | | */ |
| | | @ApiOperation("导出测试树表列表") |
| | | @PreAuthorize("@ss.hasPermi('demo:tree:export')") |
| | | @SaCheckPermission("demo:tree:export") |
| | | @Log(title = "测试树表", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export") |
| | | public AjaxResult<TestTreeVo> export(@Validated TestTreeQueryBo bo) { |
| | | public void export(@Validated TestTreeBo bo, HttpServletResponse response) { |
| | | List<TestTreeVo> list = iTestTreeService.queryList(bo); |
| | | ExcelUtil<TestTreeVo> util = new ExcelUtil<TestTreeVo>(TestTreeVo.class); |
| | | return util.exportExcel(list, "测试树表"); |
| | | ExcelUtil.exportExcel(list, "测试树表", TestTreeVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 获取测试树表详细信息 |
| | | * |
| | | * @param id 测试树ID |
| | | */ |
| | | @ApiOperation("获取测试树表详细信息") |
| | | @PreAuthorize("@ss.hasPermi('demo:tree:query')") |
| | | @SaCheckPermission("demo:tree:query") |
| | | @GetMapping("/{id}") |
| | | public AjaxResult<TestTreeVo> getInfo(@NotNull(message = "主键不能为空") |
| | | @PathVariable("id") Long id) { |
| | | return AjaxResult.success(iTestTreeService.queryById(id)); |
| | | public R<TestTreeVo> getInfo(@NotNull(message = "主键不能为空") |
| | | @PathVariable("id") Long id) { |
| | | return R.ok(iTestTreeService.queryById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 新增测试树表 |
| | | */ |
| | | @ApiOperation("新增测试树表") |
| | | @PreAuthorize("@ss.hasPermi('demo:tree:add')") |
| | | @SaCheckPermission("demo:tree:add") |
| | | @Log(title = "测试树表", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit |
| | | @PostMapping() |
| | | public AjaxResult<Void> add(@Validated @RequestBody TestTreeAddBo bo) { |
| | | return toAjax(iTestTreeService.insertByAddBo(bo) ? 1 : 0); |
| | | public R<Void> add(@Validated(AddGroup.class) @RequestBody TestTreeBo bo) { |
| | | return toAjax(iTestTreeService.insertByBo(bo)); |
| | | } |
| | | |
| | | /** |
| | | * 修改测试树表 |
| | | */ |
| | | @ApiOperation("修改测试树表") |
| | | @PreAuthorize("@ss.hasPermi('demo:tree:edit')") |
| | | @SaCheckPermission("demo:tree:edit") |
| | | @Log(title = "测试树表", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit |
| | | @PutMapping() |
| | | public AjaxResult<Void> edit(@Validated @RequestBody TestTreeEditBo bo) { |
| | | return toAjax(iTestTreeService.updateByEditBo(bo) ? 1 : 0); |
| | | public R<Void> edit(@Validated(EditGroup.class) @RequestBody TestTreeBo bo) { |
| | | return toAjax(iTestTreeService.updateByBo(bo)); |
| | | } |
| | | |
| | | /** |
| | | * 删除测试树表 |
| | | * |
| | | * @param ids 测试树ID串 |
| | | */ |
| | | @ApiOperation("删除测试树表") |
| | | @PreAuthorize("@ss.hasPermi('demo:tree:remove')") |
| | | @Log(title = "测试树表" , businessType = BusinessType.DELETE) |
| | | @SaCheckPermission("demo:tree:remove") |
| | | @Log(title = "测试树表", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ids) { |
| | | return toAjax(iTestTreeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0); |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ids) { |
| | | return toAjax(iTestTreeService.deleteWithValidByIds(Arrays.asList(ids), true)); |
| | | } |
| | | } |