2021-05-30 02:24:10 +08:00
|
|
|
package com.ruoyi.demo.controller;
|
|
|
|
|
|
|
|
import com.ruoyi.common.annotation.Log;
|
2021-07-26 13:13:46 +08:00
|
|
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
2021-05-30 02:24:10 +08:00
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
2021-07-26 13:13:46 +08:00
|
|
|
import com.ruoyi.common.core.validate.AddGroup;
|
|
|
|
import com.ruoyi.common.core.validate.EditGroup;
|
2021-05-30 02:24:10 +08:00
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
2021-07-26 13:13:46 +08:00
|
|
|
import com.ruoyi.demo.domain.bo.TestDemoBo;
|
|
|
|
import com.ruoyi.demo.domain.vo.TestDemoVo;
|
2021-05-30 02:24:10 +08:00
|
|
|
import com.ruoyi.demo.service.ITestDemoService;
|
|
|
|
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.*;
|
|
|
|
|
2021-08-04 19:03:25 +08:00
|
|
|
import javax.servlet.http.HttpServletResponse;
|
2021-05-30 02:24:10 +08:00
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
2021-07-30 19:11:10 +08:00
|
|
|
import java.util.concurrent.TimeUnit;
|
2021-05-30 02:24:10 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 测试单表Controller
|
|
|
|
*
|
|
|
|
* @author Lion Li
|
2021-07-26 13:13:46 +08:00
|
|
|
* @date 2021-07-26
|
2021-05-30 02:24:10 +08:00
|
|
|
*/
|
2021-07-26 13:13:46 +08:00
|
|
|
@Validated
|
2021-05-30 02:24:10 +08:00
|
|
|
@Api(value = "测试单表控制器", tags = {"测试单表管理"})
|
|
|
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/demo/demo")
|
|
|
|
public class TestDemoController extends BaseController {
|
|
|
|
|
|
|
|
private final ITestDemoService iTestDemoService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询测试单表列表
|
|
|
|
*/
|
|
|
|
@ApiOperation("查询测试单表列表")
|
|
|
|
@PreAuthorize("@ss.hasPermi('demo:demo:list')")
|
|
|
|
@GetMapping("/list")
|
2021-07-26 13:13:46 +08:00
|
|
|
public TableDataInfo<TestDemoVo> list(@Validated TestDemoBo bo) {
|
2021-05-30 02:24:10 +08:00
|
|
|
return iTestDemoService.queryPageList(bo);
|
|
|
|
}
|
|
|
|
|
2021-07-21 12:07:12 +08:00
|
|
|
/**
|
|
|
|
* 自定义分页查询
|
|
|
|
*/
|
|
|
|
@ApiOperation("自定义分页查询")
|
|
|
|
@PreAuthorize("@ss.hasPermi('demo:demo:list')")
|
|
|
|
@GetMapping("/page")
|
2021-07-26 13:13:46 +08:00
|
|
|
public TableDataInfo<TestDemoVo> page(@Validated TestDemoBo bo) {
|
2021-07-21 12:07:12 +08:00
|
|
|
return iTestDemoService.customPageList(bo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-05-30 02:24:10 +08:00
|
|
|
* 导出测试单表列表
|
|
|
|
*/
|
|
|
|
@ApiOperation("导出测试单表列表")
|
|
|
|
@PreAuthorize("@ss.hasPermi('demo:demo:export')")
|
|
|
|
@Log(title = "测试单表", businessType = BusinessType.EXPORT)
|
|
|
|
@GetMapping("/export")
|
2021-08-04 19:03:25 +08:00
|
|
|
public void export(@Validated TestDemoBo bo, HttpServletResponse response) {
|
2021-05-30 02:24:10 +08:00
|
|
|
List<TestDemoVo> list = iTestDemoService.queryList(bo);
|
2021-08-04 19:03:25 +08:00
|
|
|
ExcelUtil.exportExcel(list, "测试单表", TestDemoVo.class, response);
|
2021-05-30 02:24:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取测试单表详细信息
|
|
|
|
*/
|
|
|
|
@ApiOperation("获取测试单表详细信息")
|
|
|
|
@PreAuthorize("@ss.hasPermi('demo:demo:query')")
|
|
|
|
@GetMapping("/{id}")
|
|
|
|
public AjaxResult<TestDemoVo> getInfo(@NotNull(message = "主键不能为空")
|
|
|
|
@PathVariable("id") Long id) {
|
|
|
|
return AjaxResult.success(iTestDemoService.queryById(id));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新增测试单表
|
|
|
|
*/
|
|
|
|
@ApiOperation("新增测试单表")
|
|
|
|
@PreAuthorize("@ss.hasPermi('demo:demo:add')")
|
|
|
|
@Log(title = "测试单表", businessType = BusinessType.INSERT)
|
2021-07-30 19:11:10 +08:00
|
|
|
@RepeatSubmit(intervalTime = 2, timeUnit = TimeUnit.SECONDS)
|
2021-05-30 02:24:10 +08:00
|
|
|
@PostMapping()
|
2021-07-26 13:13:46 +08:00
|
|
|
public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody TestDemoBo bo) {
|
|
|
|
return toAjax(iTestDemoService.insertByBo(bo) ? 1 : 0);
|
2021-05-30 02:24:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 修改测试单表
|
|
|
|
*/
|
|
|
|
@ApiOperation("修改测试单表")
|
|
|
|
@PreAuthorize("@ss.hasPermi('demo:demo:edit')")
|
|
|
|
@Log(title = "测试单表", businessType = BusinessType.UPDATE)
|
2021-07-26 13:13:46 +08:00
|
|
|
@RepeatSubmit
|
2021-05-30 02:24:10 +08:00
|
|
|
@PutMapping()
|
2021-07-26 13:13:46 +08:00
|
|
|
public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody TestDemoBo bo) {
|
|
|
|
return toAjax(iTestDemoService.updateByBo(bo) ? 1 : 0);
|
2021-05-30 02:24:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 删除测试单表
|
|
|
|
*/
|
|
|
|
@ApiOperation("删除测试单表")
|
|
|
|
@PreAuthorize("@ss.hasPermi('demo:demo:remove')")
|
|
|
|
@Log(title = "测试单表" , businessType = BusinessType.DELETE)
|
|
|
|
@DeleteMapping("/{ids}")
|
|
|
|
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
|
|
|
|
@PathVariable Long[] ids) {
|
|
|
|
return toAjax(iTestDemoService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
|
|
|
|
}
|
|
|
|
}
|