EditController.class.php 1.07 KB
<?php
/**
 * 【后台】员工激励编辑接口
 * EditController.class.php
 * @author:daijun
 * @date:2017-08-31
 */

namespace Apicp\Controller\Incentives;

use Common\Service\IncentivesService;

class EditController extends \Apicp\Controller\AbstractController
{
    /**
     * 员工激励编辑接口
     * @author daijun
     */
    public function Index_post()
    {
        // 获取参数
        $params = I('post.');

        $incentives_serv = new IncentivesService();

        // 传入参数验证
        $check = $incentives_serv->check_edit_data($params);

        if (!$check) {

            return false;
        }

        $medal = '';
        if (!empty($params['medal'])) {

            $medal = implode(';', $params['medal']);
        }

        // 组织数据
        $update_data = [
            'sr_medal' => $medal,
            'sr_score' => intval($params['score']),
            'sr_credit' => (int)$params['credit'],
        ];

        // 更新激励数据
        $incentives_serv->update($params['sr_id'], $update_data);

        return true;
    }
}