StopController.class.php 1.08 KB
<?php
/**
 * 【后台】终止培训计划接口
 * StopController.class.php
 * User: yingcai
 * Date: 2017/8/29
 * Time: 下午6:12
 */

namespace Apicp\Controller\Education;

use Common\Service\EducationService;

class StopController extends \Apicp\Controller\AbstractController
{
    public function Index_post()
    {
        $ed_id = I('ed_id', 0, 'intval');
        // 培训ID是否为空
        if (!$ed_id) {

            E('_EMPTY_ED_ID');
        }

        $education_service = new EducationService();

        // 判断培训是否存在
        $education = $education_service->get($ed_id);
        if (empty($education)) {

            E('_ERR_EDUCATION_NOT_EXIST');
        }

        // 判断培训是否是进行中,进行中的才可以终止
        if (EducationService::EDUCATION_PROCESS_ON_GOING != $education_service->get_ed_status($education)) {

            E('_ERR_EDUCATION_LODING_DELETE');
        }

        // 更改培训状态
        $education_service->update(
            $ed_id,
            ['ed_end_time' => MILLI_TIME]
        );

        return true;
    }
}