package cn.stylefeng.workflow.design.modular.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.PostResource;
import cn.stylefeng.workflow.design.modular.entity.UserCommonWorkflow;
import cn.stylefeng.workflow.design.modular.pojo.request.UserCommonWorkflowRequest;
import cn.stylefeng.workflow.design.modular.service.UserCommonWorkflowService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@ApiResource(name = "用户常用流程")
public class UserCommonWorkflowController {

    @Resource
    private UserCommonWorkflowService userCommonWorkflowService;

    @PostResource(name = "添加用户常用流程", path = "/userCommonWorkflow/add")
    public ResponseData<UserCommonWorkflow> add(@RequestBody @Validated(UserCommonWorkflowRequest.add.class) UserCommonWorkflowRequest userCommonWorkflowRequest) {
        userCommonWorkflowService.add(userCommonWorkflowRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "删除用户常用流程", path = "/userCommonWorkflow/delete")
    public ResponseData<?> delete(@RequestBody @Validated(UserCommonWorkflowRequest.delete.class) UserCommonWorkflowRequest userCommonWorkflowRequest) {
        userCommonWorkflowService.del(userCommonWorkflowRequest);
        return new SuccessResponseData<>();
    }

}
