<?php

declare(strict_types=1);

namespace App\Http\Controllers\Api\Nasa\V1;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\Nasa\V1\Base\ListController;
use App\Services\Tg\Hook\Mod\Arma;

final class ArticleBaseController extends ListController
{
    protected string $sModelPath = 'App\Models\Article';
    protected array $aFilterFields = [ // 允许where的字段，不设视为全允许
//        's_name',
//        'i_status'
    ];
    
    protected string $sPageName = "article";
    
    protected array $aListFields = [ // list展示的字段和名字映射
        'id'        => 'id',
        'user_name' => 'user_name',
        'project_name'=> 'project_name',
        'mail_name' => 'mail_name',
        'mail_tail' => 'mail_tail',
        'sale_code' => 'sale_code',
        'sale_rate' => 'sale_rate',
        'sale_price' => 'sale_price',
        'i_in10' => 'i_in10',
        'inday_count' => 'inday_count',
        'cron_condition' => 'cron_condition',
        'mod' => 'mod',
        'mod_type' => 'mod_type',
        'status' => 'status',
        'memo' => 'memo',
        'ship_code' => 'ship_code',
        'fn_www' => 'fn_www',
        'show_huodong' => 'show_huodong',
        'show_error' => 'show_error',
//        'updated_at' => 'updated_at',
//        'created_at' => 'created_at'
    ];
    
    protected array $aValueStyle = [ // 特定文字渲染样式
        '关闭'    => "<span class='text-danger'>关闭</span>",
        '开启'    => "<span class='text-success'>开启</span>"
    ];
    
    protected array $aFieldTypes = [
//        'schema' => 'text',
//        'schema_pro' => 'text',
//        'cmd'   => 'text',
//        'cmd_log' => 'text',
//        'opt'   => 'text'
    ];
    
    protected array $aOrderBy = [
        [
            "sField"    => "id",
            "sSort"     => "desc",
        ]
    ];
    
    protected array $aJsonFields = [ // json字段
//        'schema'
    ];
    
    protected array $aDateFields = [ // date字段
//        'dtUpdatedAt'
    ];
    
    protected array $aLenthFields = [ // 限制长度的字段
//        "xx" => 100,
    ];
    
    protected array $aSelectFields = [ // 作为默认select的字段
//        'status',
    ];
    
    protected array $aValueFields = [ // 值映射
        'status' => [
            '1'   => '开启',
            '0'  => '关闭',
        ]
    ];
    
    protected array $aCcExtFields = [
//        'dtCreatedAt'   => '创建时间'
    ];
    
//    protected array $aLimit = [3, 15, 40, 100]; // list长度，第一个为默认
    
//    public function syncSave(Request $oRequest)
//    {
//        $id = request('id');
//        $siteGroupCode = request('siteGroupCode');
//        $cmd = request('type');
//        
//        $aParam['aOption'][1] = $id;
//        $aParam['aArg'][1] = $siteGroupCode;
//        $aParam['aArg'][2] = $cmd;
//        $oArma = new Arma([]);
//        $r = $oArma->cmd($aParam, []);
//        
//        return response()->json([
//            'iCode' => 200,
//            'aData' => [],
//            'sMsg'  => $r
//        ], 200);
//        
//    }
}
