/*
 * @Author: baozhoutao@steedos.com
 * @Date: 2023-02-11 14:50:02
 * @LastEditors: 孙浩林 sunhaolin@steedos.com
 * @LastEditTime: 2025-12-04 09:45:50
 * @Description: 
 */
const express = require("express");
const router = express.Router();
const { requireAuthentication } = require("@steedos/auth");
const objectql = require('@steedos/objectql')

const { cc_submit } = require('../methods/trace_approve_cc');

router.post('/api/workflow/v2/cc_submit', requireAuthentication, async function (req, res) {
    try {
        let userSession = req.user;
        const { instanceId, traceId, approveId, description } = req.body;
        const approve = await objectql.getSteedosSchema().broker.call('instance.getApprove', { instanceId, traceId, approveId });
        const ccHasEditPermission = false;
        const result = await cc_submit(instanceId, description, approve, ccHasEditPermission, {userId: userSession.userId})

        res.status(200).send(result);
    } catch (error) {
        console.error(error);
        res.status(200).send({
            error: error.message
        });
    }
});

exports.default = router;