suyuan-breed/app/api/controller/CommonController.php

81 lines
2.3 KiB
PHP
Raw Permalink Normal View History

2024-01-17 11:59:25 +08:00
<?php
namespace app\api\controller;
use app\common\model\dict\DictData;
use think\facade\Db;
class CommonController extends BaseApiController
{
public array $notNeedLogin = ['city', 'area', 'street','province','village','brigade','dict_data_lists','dict_data_lists_by_type_value','getMiniProgramInfo'];
//**省列表 */
public function province()
{
$data = Db::name('geo_province')->where(['switch' => 1])->select();
return $this->data($data->toArray());
} //**市列表 */
public function city($city)
{
$data = Db::name('geo_city')->where(['province_code' => $city])->select();
return $this->data($data->toArray());
}
//**区域列表 */
public function area($area)
{
$data = Db::name('geo_county')->where(['city_code' => $area])->select();
return $this->data($data->toArray());
}
//**街道列表 */
public function street($street)
{
$data = Db::name('geo_town')->where(['county_code' => $street])->select();
return $this->data($data->toArray());
}
//**村列表 */
public function village($village)
{
$data = Db::name('geo_village')->where(['street_code' => $village])->select();
return $this->data($data->toArray());
}
//**小队列表 */
public function brigade()
{
$data = Db::name('geo_brigade')->select();
return $this->data($data->toArray());
}
//**字典列表 */
public function dict_data_lists($type_id)
{
$data= DictData::where(['type_id' => $type_id])
->append(['status_desc'])
->limit(100)
->order(['sort' => 'desc', 'id' => 'desc'])
->select();
return $this->data($data->toArray());
}
public function dict_data_lists_by_type_value($type_value)
{
$data= DictData::where(['type_value' => $type_value])
->append(['status_desc'])
->limit(100)
->order(['sort' => 'desc', 'id' => 'desc'])
->select();
return $this->data($data->toArray());
}
public function getMiniProgramInfo()
{
$param = $this->request->param();
$data = Db::name('miniprogram')->where(['name' => $param['name']])->order('id', 'desc')->find();
return $this->data($data);
}
}