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

namespace Application\Service\DB\Tmp;

use Interop\Container\ContainerInterface;

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

    /**
     * Notes: 获取指定条件下的黑/白名单数据
     * User: lltyy
     * DateTime: 2023/4/25 10:16
     *
     * @param $where
     * @return array
     */
    public function wordNameData($where){
        $data = [
            'white_word' => [],//白名单
            'black_word' => [],//黑名单
            'black_white_word' => []//黑名单下白名单
        ];
        //获取黑/白名单数据
        $wordCond = [
            'where'=>$where,
            'columns'=>['word_name','word_type']
        ];
        $wordDatas = $this->LocalService()->tmpMedicalword->fetchAll($wordCond);
        if(!empty($wordDatas)){
            $white_arr = $black_arr = [];
            foreach($wordDatas as $wordData){
                if($wordData['word_type'] == 1){
                    $data['white_word'][] = $wordData['word_name'];
                }
                if($wordData['word_type'] == 2){
                    $data['black_word'][] = $wordData['word_name'];
                }
                if($wordData['word_type'] == 3){
                    $data['black_white_word'][] = $wordData['word_name'];
                }
            }
        }
        unset($wordCond);
        unset($wordDatas);
        return $data;
    }
}