/*
 * Copyright (c) 京北方信息技术股份有限公司 Corporation 2021 . All rights reserved.
 *
 */
package net.northking.cctp.flowable.api.sm;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.northking.cctp.common.db.Pagination;
import net.northking.cctp.common.http.QueryByPage;
import net.northking.cctp.common.http.ResultWrapper;
import net.northking.cctp.flowable.api.sm.service.StateProcessDefApiService;
import net.northking.cctp.flowable.db.entity.SpDefProcess;
import net.northking.cctp.flowable.dto.sm.StateProcessDefDto;
import net.northking.cctp.flowable.sm.StateProcessDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 状态流程活动历史
 *
 * @author : xiusong.xie
 * @version : 1.0
 */
@Api(tags = "状态流程活动历史")
@RequestMapping("/v1")
@RestController
public class StateProcessActHistoryCtrl
{
  /**
   * 资源名称
   */
  private static final String RESOURCE_NAME = "/his/sp";
  /**
   * 日志
   */
  private final static Logger logger = LoggerFactory.getLogger(StateProcessActHistoryCtrl.class);

  private StateProcessDefApiService apiService;


  /**
   * Restful接口-get： 获取状态流程活动历史
   *
   * @param uuid 主键
   * @return 接口数据传输对象
   */
  @ApiOperation(value = "获取：状态流程活动历史")
  @GetMapping(
      value = RESOURCE_NAME + "/{uuid}",
      produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  public ResultWrapper<StateProcessDefinition> findByPK(
      @PathVariable("uuid") String uuid)
  {
    ResultWrapper<StateProcessDefinition> wrapper = new ResultWrapper<>();
    StateProcessDefinition dto = apiService.findByPK(uuid);
    return wrapper.success(dto);
  }


  /**
   * 分页查询
   *
   * @param queryByPage 查询条件
   * @return 数据列表
   */
  @ApiOperation(value = "分页查询列表：状态流程活动历史")
  @PostMapping(value = "/paging/query" + RESOURCE_NAME,
      produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
      consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
  public ResultWrapper<Pagination<StateProcessDefDto>> pagingQuery(
      @RequestBody @Validated QueryByPage<SpDefProcess> queryByPage)
  {
    ResultWrapper<Pagination<StateProcessDefDto>> wrapper = new ResultWrapper<>();
    Pagination<StateProcessDefDto> page = apiService.pagingQuery(queryByPage);

    return wrapper.success(page);
  }
}
