|
|
|
package com.ruoyi.tc.controller;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.tc.entity.AssetTask;
|
|
|
|
import com.ruoyi.tc.entity.request.AssetTaskPageRequest;
|
|
|
|
import com.ruoyi.tc.entity.response.AssetTaskIdResponse;
|
|
|
|
import com.ruoyi.tc.service.AssetTaskService;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 任务主表(AssetTask)表控制层
|
|
|
|
*
|
|
|
|
* @author makejava
|
|
|
|
* @since 2024-11-18 13:22:58
|
|
|
|
*/
|
|
|
|
@Api(tags = "任务主表")
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/unit/assetTask")
|
|
|
|
public class AssetTaskController extends BaseController {
|
|
|
|
/**
|
|
|
|
* 服务对象
|
|
|
|
*/
|
|
|
|
@Resource
|
|
|
|
private AssetTaskService assetTaskService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 分页查询
|
|
|
|
*
|
|
|
|
* @param assetTask 筛选条件
|
|
|
|
* @param pageRequest 分页对象
|
|
|
|
* @return 查询结果
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "分页查询", response = AssetTask.class)
|
|
|
|
@GetMapping("/page")
|
|
|
|
public AjaxResult queryByPage(Page<AssetTask> assetTask, AssetTaskPageRequest pageRequest) {
|
|
|
|
return AjaxResult.success(this.assetTaskService.queryByPage(assetTask, pageRequest));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过主键查询单条数据
|
|
|
|
*
|
|
|
|
* @param id 主键
|
|
|
|
* @return 单条数据
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "通过主键查询单条数据", response = AssetTaskIdResponse.class)
|
|
|
|
@GetMapping("{id}")
|
|
|
|
public AjaxResult queryById(@PathVariable("id") Integer id) {
|
|
|
|
return AjaxResult.success(this.assetTaskService.queryById(id));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新增数据
|
|
|
|
*
|
|
|
|
* @param assetTask 实体
|
|
|
|
* @return 新增结果
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "新增数据")
|
|
|
|
@PostMapping("/add")
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public AjaxResult add(@RequestBody @Valid AssetTask assetTask) {
|
|
|
|
this.assetTaskService.insert(assetTask);
|
|
|
|
return AjaxResult.success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 编辑数据
|
|
|
|
*
|
|
|
|
* @param assetTask 实体
|
|
|
|
* @return 编辑结果
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "编辑数据")
|
|
|
|
@PostMapping("/edit")
|
|
|
|
public AjaxResult edit(@RequestBody @Valid AssetTask assetTask) {
|
|
|
|
return AjaxResult.success(this.assetTaskService.update(assetTask));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 删除数据
|
|
|
|
*
|
|
|
|
* @param id 主键
|
|
|
|
* @return 删除是否成功
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "删除数据")
|
|
|
|
@PostMapping("/deleteById/{id}")
|
|
|
|
public AjaxResult deleteById(@PathVariable("id") Integer id) {
|
|
|
|
return AjaxResult.success(this.assetTaskService.deleteById(id));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|