package ink.wgink.module.activiti.controller.api;

import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.activiti.pojo.dtos.ActivitiProcdefDTO;
import ink.wgink.module.activiti.service.activiti.IActivitiProcdefService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.result.SuccessResultList;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName: ActivitiProcdefController
 * @Description: 流程定义
 * @Author: wanggeng
 * @Date: 2021/12/7 10:14 PM
 * @Version: 1.0
 */
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "流程定义接口")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/activiti/procdef")
public class ActivitiProcdefController extends DefaultBaseController {

    @Autowired
    private IActivitiProcdefService activitiProcdefService;

    @ApiOperation(value = "删除流程", notes = "删除流程接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deploymentId", value = "部署ID", paramType = "path")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @DeleteMapping("delete/{deploymentId}")
    public SuccessResult delete(@PathVariable("deploymentId") String deploymentId) {
        activitiProcdefService.delete(deploymentId);
        return new SuccessResult();
    }

    @ApiOperation(value = "部署分页列表", notes = "部署分页列表接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "Integer", defaultValue = "1"),
            @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "Integer", defaultValue = "20"),
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("listpage")
    public SuccessResultList<List<ActivitiProcdefDTO>> listPage(ListPage page) {
        return activitiProcdefService.listPage(page.getPage(), page.getRows());
    }

}
