package cn.stylefeng.workflow.instance.modular.tag.controller;

import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
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.workflow.instance.modular.tag.entity.RuntimeTag;
import cn.stylefeng.workflow.instance.modular.tag.pojo.request.RuntimeTagRequest;
import cn.stylefeng.workflow.instance.modular.tag.service.RuntimeTagService;
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 RuntimeTagController {

    @Resource
    private RuntimeTagService runtimeTagService;

    @PostResource(name = "更新某个流程实例的个人的标签绑定", path = "/runtimeTag/updateUserTag")
    public ResponseData<RuntimeTag> updateUserTag(@RequestBody @Validated(RuntimeTagRequest.add.class) RuntimeTagRequest runtimeTagRequest) {
        runtimeTagService.updateUserTag(runtimeTagRequest);
        return new SuccessResponseData<>();
    }

    @GetResource(name = "获取流程实例个人的标签列表", path = "/runtimeTag/findUserTagList")
    public ResponseData<List<RuntimeTag>> findUserTagList(@Validated(BaseRequest.list.class) RuntimeTagRequest runtimeTagRequest) {
        return new SuccessResponseData<>(runtimeTagService.findUserTagList(runtimeTagRequest));
    }

    @GetResource(name = "用在筛选界面-获取标签列表", path = "/runtimeTag/queryParam/tagList")
    public ResponseData<List<RuntimeTag>> findTagList() {
        return new SuccessResponseData<>(runtimeTagService.queryParamTagList());
    }

}
