package com.ruoyi.tc.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.tc.entity.AssetLc;
import com.ruoyi.tc.entity.request.AssetLcRequest;
import com.ruoyi.tc.service.AssetLcService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 任务流程(AssetLc)表控制层
 *
 * @author makejava
 * @since 2024-11-18 14:46:40
 */
@Api(tags = "任务流程")
@RestController
@RequestMapping("/unit/assetLc")
public class AssetLcController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private AssetLcService assetLcService;

    /**
     * 查询
     *
     * @param req 对象
     * @return 查询结果
     */
    @GetMapping("/page")
    @ApiOperation(value = "分页查询", response = AssetLc.class)
    public AjaxResult queryByPage(AssetLcRequest req) {
        return AjaxResult.success(this.assetLcService.queryByPage(req));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation(value = "通过主键查询单条数据", response = AssetLc.class)
    @GetMapping("{id}")
    public AjaxResult queryById(@PathVariable("id") Integer id) {
        return AjaxResult.success(this.assetLcService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param assetLc 实体
     * @return 新增结果
     */
    @ApiOperation(value = "新增数据")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody @Valid AssetLc assetLc) {
        return AjaxResult.success(this.assetLcService.insert(assetLc));
    }

    /**
     * 编辑数据
     *
     * @param assetLc 实体
     * @return 编辑结果
     */
    @ApiOperation(value = "新增数据")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody @Valid AssetLc assetLc) {
        return AjaxResult.success(this.assetLcService.update(assetLc));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @PostMapping("/deleteById/{id}")
    public AjaxResult deleteById(@PathVariable("id") Integer id) {
        return AjaxResult.success(this.assetLcService.deleteById(id));
    }

}

