package cn.axzo.workflow.client.feign.manage;

import cn.axzo.workflow.common.model.request.category.CategoryConfigCreateDTO;
import cn.axzo.workflow.common.model.request.category.CategoryConfigSearchDTO;
import cn.axzo.workflow.common.model.request.category.CategoryCreateDTO;
import cn.axzo.workflow.common.model.request.category.CategorySearchDTO;
import cn.axzo.workflow.common.model.request.category.CategoryUpdateDTO;
import cn.axzo.workflow.common.model.response.BpmPageResult;
import cn.axzo.workflow.common.model.response.category.CategoryConfigItemVO;
import cn.axzo.workflow.common.model.response.category.CategoryItemVO;
import cn.azxo.framework.common.model.CommonResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


/**
 * OMS流程业务管理API
 *
 * @author zuoqinbo
 * @version V1.0
 * @date 2023/11/6 16:01
 */

@FeignClient(name = "workflow-engine", url = "${axzo.service.workflow-engine:http://workflow-engine:8080}")
public interface ProcessCategoryApi {

    /**
     * 获取指定业务分类
     *
     * @return
     */
    @GetMapping("/api/process/category/get")
    CommonResponse<CategoryItemVO> get(@RequestParam Long id);

    /**
     * 获取指定业务分类集合
     *
     * @param ids
     * @return
     */
    @GetMapping("/api/process/category/getByIds")
    CommonResponse<List<CategoryItemVO>> getByIds(@RequestParam List<Long> ids);

    /**
     * 获取指定业务分类集合
     *
     * @param values
     * @return
     */
    @GetMapping("/api/process/category/getByValues")
    CommonResponse<List<CategoryItemVO>> getByValues(@RequestParam List<String> values);

    /**
     * 新增业务分类
     *
     * @return
     */
    @PostMapping("/api/process/category/create")
    CommonResponse<CategoryItemVO> create(@Validated @RequestBody CategoryCreateDTO req);

    /**
     * 更新业务分类
     *
     * @return
     */
    @PutMapping("/api/process/category/update")
    CommonResponse<CategoryItemVO> update(@Validated @RequestBody CategoryUpdateDTO dto);

    /**
     * 删除指定业务分类
     *
     * @param id
     * @return
     */
    @DeleteMapping("/api/process/category/delete")
    CommonResponse<Boolean> delete(@RequestParam Long id);

    /**
     * 更新指定分类状态
     *
     * @param id
     * @param state
     * @return
     */
    @PutMapping("/api/process/category/update/state")
    CommonResponse<Boolean> updateState(@RequestParam Long id, @RequestParam Boolean state);

    /**
     * 获取指定业务分类集合
     *
     * @return
     */
    @PostMapping("/api/process/category/list")
    CommonResponse<List<CategoryItemVO>> list(@RequestBody CategorySearchDTO dto);

    /**
     * 搜索业务分类
     *
     * @return
     */
    @PostMapping("/api/process/category/page/search")
    CommonResponse<BpmPageResult<CategoryItemVO>> search(@RequestBody CategorySearchDTO dto);

    /**
     * 业务分类创建黑白名单配置项
     *
     * @param dto
     * @return
     */
    @PostMapping("/api/process/category/config/create")
    CommonResponse<Boolean> createConfig(@RequestBody CategoryConfigCreateDTO dto);

    /**
     * 删除指定分类的配置项数据
     *
     * @param id
     * @return
     */
    @DeleteMapping("/api/process/category/config/delete/{id}")
    CommonResponse<Boolean> deleteConfig(@PathVariable Long id);

    /**
     * 业务分类黑白名单查询
     *
     * @return
     */
    @PostMapping("/api/process/category/config/page/search")
    CommonResponse<BpmPageResult<CategoryConfigItemVO>> configSearch(@RequestBody CategoryConfigSearchDTO dto);

    /**
     * 更新业务分类的配置类型
     *
     * @param id
     * @param configType
     * @return
     */
    @PostMapping("/api/process/category/config/type/update")
    CommonResponse<Boolean> updateCategoryConfigType(@RequestParam Long id, @RequestParam String configType);

    /**
     * 用于业务方判断指定的业务分类的黑白名单配置
     *
     * @param tenantId     租户ID
     * @param categoryCode 业务分类编码
     * @return true: 可以发起创建流程实例, false: 不可用
     */
    @GetMapping("/api/process/category/check/status")
    CommonResponse<Boolean> checkCategoryStatus(@RequestParam Long tenantId, @RequestParam String categoryCode);
}
