You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
41 lines
1.2 KiB
<?php
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use app\model\CountryModel;
|
|
use think\response\Json;
|
|
|
|
class Country extends AdminBaseController
|
|
{
|
|
/**
|
|
* @desc 获取国家码和地区
|
|
* @return Json
|
|
*/
|
|
public function getAll(): Json
|
|
{
|
|
try {
|
|
$res = CountryModel::getAll();
|
|
$returnData = [];
|
|
if(!$res->isEmpty()){
|
|
$deny = explode(',', env('NATION.DENY_NATION'));
|
|
foreach ($res as $item) {
|
|
$active = 1;
|
|
if(in_array($item['code'],$deny )){
|
|
$active = 0;
|
|
}
|
|
$returnData[] = [
|
|
'id' => $item['id'],
|
|
'nameCn' => $item['name_cn'],
|
|
'nameEn' => $item['name_en'],
|
|
'nation' => $item['code'],
|
|
'active' => $active,
|
|
];
|
|
}
|
|
}
|
|
return json(['code' => '0', 'message' => '请求成功','data' => $returnData]);
|
|
}catch (\Exception $exception){
|
|
return json(['code' => '100500', 'message' => '系统繁忙','data' => []]);
|
|
}
|
|
|
|
}
|
|
}
|