package cn.stylefeng.workflow.design.modular.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.design.modular.entity.FlowUserComment;
import cn.stylefeng.workflow.design.modular.pojo.request.FlowUserCommentRequest;
import cn.stylefeng.workflow.design.modular.service.FlowUserCommentService;
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 FlowUserCommentController {

    @Resource
    private FlowUserCommentService flowUserCommentService;

    @GetResource(name = "获取用户常用审批意见列表", path = "/flowUserComment/list")
    public ResponseData<List<FlowUserComment>> list(FlowUserCommentRequest flowUserCommentRequest) {
        return new SuccessResponseData<>(flowUserCommentService.findList(flowUserCommentRequest));
    }

    @PostResource(name = "编辑用户常用审批意见", path = "/flowUserComment/updateTotal")
    public ResponseData<?> updateTotal(@RequestBody @Validated(BaseRequest.edit.class) FlowUserCommentRequest flowUserCommentRequest) {
        flowUserCommentService.updateTotal(flowUserCommentRequest);
        return new SuccessResponseData<>();
    }

}
