<?php
/**
 *
 * @author：llbjj
 * @DateTime：2022/5/6 10:57
 * @Description：
 *
 */

namespace Application\Service\DB\Listset;

use Interop\Container\ContainerInterface;

class Annex extends \Application\Service\DB\AbstractDb
{
    public function __construct($dbAdapter, ContainerInterface $container)
    {
        $this->tableName = 'yikeen_listset_annex';
        parent::__construct($dbAdapter, $container);
    }

    /**
     * Notes:获取operate_id
     * @param
     * @return
     * @author haojinhua
     * @date 2024-07-02
     */
    public function fetchOperateData($cond,$val){
        $cond = [
            'where'=>$cond,
            'columns'=>['id','item_id','itemsig_id','list_type','list_id','operate_id'],
            'order'=>['id']
        ];
        $arr = [];
        $datas = $this->fetchAll($cond);

        if(!empty($datas)){
            foreach($datas as $data){
                $arr[$data['item_id']][$data['list_type']][$data['list_id']][$data['id']] = $data[$val];
            }
        }

        return $arr;
    }


    /**
     * Notes: 获取指定键值下的数据
     * User: lltyy
     * DateTime: 2022/11/17 13:16
     *
     * @param $cond
     * @return array
     */
    public function fetchDataByOperate($cond,$key){
        $arr = [];
        $datas = $this->fetchAll($cond);
        if(!empty($datas)){
            foreach($datas as $data){
                $data_key = $data[$key];
                unset($data[$key]);
                $arr[$data_key][] = $data;
            }
        }
        return $arr;
    }

}