package cn.stylefeng.team.project.modular.filing.controller;

import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.team.project.modular.filing.pojo.businessFlow.add.BusinessFlowAddRequest;
import cn.stylefeng.team.project.modular.filing.pojo.businessFlow.del.BusinessFlowBatchDelRequest;
import cn.stylefeng.team.project.modular.filing.pojo.businessFlow.del.BusinessFlowDelRequest;
import cn.stylefeng.team.project.modular.filing.pojo.businessFlow.edit.BusinessFlowEditRequest;
import cn.stylefeng.team.project.modular.filing.pojo.businessFlow.edit.BusinessFlowUpdateStatusRequest;
import cn.stylefeng.team.project.modular.filing.pojo.businessFlow.query.BusinessFlowDetailRequest;
import cn.stylefeng.team.project.modular.filing.pojo.businessFlow.query.BusinessFlowListRequest;
import cn.stylefeng.team.project.modular.filing.pojo.businessFlow.response.BusinessFlowDetailResponse;
import cn.stylefeng.team.project.modular.filing.pojo.businessFlow.response.BusinessFlowListResponse;
import cn.stylefeng.team.project.modular.filing.service.BusinessFlowService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@ApiResource(name = "业务关联流程")
public class BusinessFlowController {

    @Resource
    private BusinessFlowService businessFlowService;

    @PostResource(name = "添加业务关联流程", path = "/businessFlow/add")
    public ResponseData<Long> add(@RequestBody @Validated BusinessFlowAddRequest businessFlowAddRequest) {
        Long primaryKeyId = businessFlowService.add(businessFlowAddRequest);
        return new SuccessResponseData<>(primaryKeyId);
    }

    @PostResource(name = "删除业务关联流程", path = "/businessFlow/delete")
    public ResponseData<?> delete(@RequestBody @Validated BusinessFlowDelRequest businessFlowDelRequest) {
        businessFlowService.del(businessFlowDelRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "批量删除业务关联流程", path = "/businessFlow/batchDelete")
    public ResponseData<?> batchDelete(@RequestBody @Validated BusinessFlowBatchDelRequest businessFlowBatchDelRequest) {
        businessFlowService.batchDelete(businessFlowBatchDelRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "编辑业务关联流程", path = "/businessFlow/edit")
    public ResponseData<?> edit(@RequestBody @Validated BusinessFlowEditRequest businessFlowEditRequest) {
        businessFlowService.edit(businessFlowEditRequest);
        return new SuccessResponseData<>();
    }

    @GetResource(name = "查看业务关联流程详情", path = "/businessFlow/detail")
    public ResponseData<BusinessFlowDetailResponse> detail(@Validated BusinessFlowDetailRequest businessFlowDetailRequest) {
        return new SuccessResponseData<>(businessFlowService.detail(businessFlowDetailRequest));
    }

    @GetResource(name = "获取业务关联流程列表", path = "/businessFlow/list")
    public ResponseData<List<BusinessFlowListResponse>> list(@Validated BusinessFlowListRequest businessFlowListRequest) {
        return new SuccessResponseData<>(businessFlowService.findList(businessFlowListRequest));
    }

    @PostResource(name = "修改激活状态", path = "/businessFlow/updateStatus")
    public ResponseData<?> updateStatus(@RequestBody @Validated BusinessFlowUpdateStatusRequest businessFlowUpdateStatusRequest) {
        businessFlowService.updateStatus(businessFlowUpdateStatusRequest);
        return new SuccessResponseData<>();
    }

}