/*
 * @Author: baozhoutao@steedos.com
 * @Date: 2022-09-15 13:09:51
 * @LastEditors: 孙浩林 sunhaolin@steedos.com
 * @LastEditTime: 2025-10-03 15:11:56
 * @Description: 
 */
const express = require("express");
const router = express.Router();
const { requireAuthentication } = require("@steedos/auth");
const objectql = require('@steedos/objectql')
const { cc_do } = require('../methods/trace_approve_cc');

router.post('/api/workflow/v2/cc_do', requireAuthentication, async function (req, res) {
    try {
        let userSession = req.user;
        const { instanceId, traceId, approveId, usersId, description } = req.body;
        const approve = await objectql.getSteedosSchema().broker.call('instance.getApprove', {instanceId, traceId, approveId})
        try {
            const result = await cc_do(approve, usersId, description, {userId: userSession.userId})
            res.status(200).send(result);
        } catch (error) {
            console.error(error);
            res.status(200).send({
                error: error.message
            });
        }
    
    } catch (error) {
        console.error(error);
        res.status(200).send({
            error: error.message
        });
    }
});
exports.default = router;