SaveController.class.php 1.21 KB
<?php
/**
 * 【考试中心-后台】 编辑试卷分类
 * SaveController.class.php
 * User: 何岳龙
 * Date: 2017年5月25日15:52:08
 */

namespace Apicp\Controller\Category;

class SaveController extends AbstractController
{
    public function Index_post()
    {
        $params = I('post.');

        // 编辑验证false
        $cate_data = $this->cate_service->cate_validation($params, false);

        try {

            $this->cate_service->start_trans();

            // 编辑分类
            $this->cate_service->update($params['ec_id'], $cate_data);
            // 更新试卷表状态
            $this->paper_service->update_by_conds(['ec_id' => $params['ec_id']], ['cate_status' => $params['ec_status']]);

            // 提交事务
            $this->cate_service->commit();
        } catch (\Think\Exception $e) {
            // 事务回滚
            $this->cate_service->rollback();
            E('_ERR_CATE_UPDATE');
            return false;
        } catch (\Exception $e) {
            // 事务回滚
            $this->cate_service->rollback();
            E('_ERR_CATE_UPDATE');
            return false;
        }

        // 返回数据
        $this->_result = [];

        return true;
    }
}