package cn.stylefeng.workflow.instance.modular.tag.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.workflow.instance.modular.tag.entity.RuntimeRemark;
import cn.stylefeng.workflow.instance.modular.tag.pojo.request.RuntimeRemarkRequest;
import cn.stylefeng.workflow.instance.modular.tag.service.RuntimeRemarkService;
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 RuntimeRemarkController {

    @Resource
    private RuntimeRemarkService runtimeRemarkService;

    @PostResource(name = "更新流程实例的个人备注", path = "/runtimeRemark/updateUserRemark")
    public ResponseData<RuntimeRemark> updateUserRemark(@RequestBody @Validated(RuntimeRemarkRequest.add.class) RuntimeRemarkRequest runtimeRemarkRequest) {
        runtimeRemarkService.updateUserRemark(runtimeRemarkRequest);
        return new SuccessResponseData<>();
    }

    @GetResource(name = "获取指定流程的个人备注列表", path = "/runtimeRemark/findUserRemarkList")
    public ResponseData<List<RuntimeRemark>> findUserRemarkList(RuntimeRemarkRequest runtimeRemarkRequest) {
        return new SuccessResponseData<>(runtimeRemarkService.findUserRemarkList(runtimeRemarkRequest));
    }

}
