OrderController.class.php 856 Bytes
<?php
/**
 * 【后台】分类排序接口
 * OrderController.class.php
 * @author:daijun
 * @date:2017-08-31
 */

namespace Apicp\Controller\Category;

use Common\Service\CategoryService;

class OrderController extends \Apicp\Controller\AbstractController
{
    /**
     * 分类排序接口
     * @author daijun
     */
    public function Index_post()
    {
        // 获取参数
        $list = I('post.list');

        if (empty($list)) {

            E('_EMPTY_ORDER_PARAMS');
        }

        if (!is_array($list)) {

            E('_EMPTY_ORDER_PARAMS');
        }

        // 实例化分类service
        $cate_service = new CategoryService();

        foreach ($list as $k => $v) {
            // 遍历更新排序字段
            $cate_service->update($v['ca_id'], ['ca_order' => $k + 1]);
        }

        return true;
    }
}