下拉接口

This commit is contained in:
2025-08-29 17:58:43 +08:00
parent 87728793c2
commit a763bfc84c
18 changed files with 525 additions and 0 deletions
@@ -3,7 +3,15 @@
namespace app\common\controller;
use app\admin\service\RoleService;
use app\common\service\BrandSeriesService;
use app\common\service\BrandService;
use app\common\service\SysAccountService;
use app\common\service\SysCurrencyService;
use app\common\service\SysDictItemService;
use app\common\service\SysDictService;
use app\common\service\SysPortService;
use app\common\service\VehColorService;
use app\common\service\VehModificationService;
use support\Request;
use app\common\service\CorpService;
use app\common\service\CorpFeishuAppService;
@@ -87,6 +95,89 @@ class PresetController extends BaseController
}
}
public function brand()
{
try {
$result = (new BrandService)->getList();
return $this->success($result, '获取品牌列表');
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
public function series(Request $request)
{
try {
$params = $request->all();
$result = (new BrandSeriesService)->getList($params);
return $this->success($result, '获取车系列表');
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
public function account()
{
try {
$result = (new SysAccountService)->getList();
return $this->success($result, '获取账号列表');
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
public function dict()
{
try {
$result = (new SysDictService)->getList();
return $this->success($result, '获取字典列表');
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
public function dictItem(Request $request)
{
try {
$params = $request->all();
$result = (new SysDictItemService)->getList($params);
return $this->success($result, '获取字典项列表');
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
public function port()
{
try {
$result = (new SysPortService)->getList();
return $this->success($result, '获取港口列表');
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
public function color(Request $request)
{
try {
$params = $request->all();
$result = (new VehColorService)->getList($params);
return $this->success($result, '获取颜色列表');
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
public function modification()
{
try {
$result = (new VehModificationService)->getList();
return $this->success($result, '获取货币列表');
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
public function cacheClear()
{
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\Brand;
class BrandLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = Brand::class;
public function getList()
{
return Brand::where('status', 1)->orderBy('sort','desc')->get(['id', 'brand_code', 'brand_name', 'logo', 'description']);
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\BrandSeries;
class BrandSeriesLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = BrandSeries::class;
public function getList($where)
{
return BrandSeries::where('status', 1)->where($where)->orderBy('sort','desc')->get(['id', 'series_code', 'series_name', 'description']);
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\SysAccount;
class SysAccountLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = SysAccount::class;
public function getList()
{
return SysAccount::where('status', 1)->orderBy('sort','desc')->get(['id', 'account_name', 'currency_id', 'account_number', 'bank_name', 'bank_branch', 'description']);
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\SysDictItem;
class SysDictItemLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = SysDictItem::class;
public function getList($where)
{
return SysDictItem::where('status', 1)->where($where)->orderBy('sort','desc')->get(['id', 'item_label', 'item_value', 'remark', 'dict_id']);
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\SysDict;
class SysDictLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = SysDict::class;
public function getDictByCode($code)
{
return SysDict::where('status', 1)->where('code', $code)->orderBy('sort','desc')->first(['id']);
}
public function getList()
{
return SysDict::where('status', 1)->get(['id', 'dict_name', 'dict_code', 'description']);
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\SysPort;
class SysPortLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = SysPort::class;
public function getList()
{
return SysPort::where('status', 1)->orderBy('sort','desc')->get(['id', 'port_code', 'port_name', 'country_id', 'description']);
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\VehColor;
class VehColorLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = VehColor::class;
public function getList($where)
{
return VehColor::where('status', 1)->where($where)->orderBy('sort','desc')->get(['id', 'color_code', 'color_text']);
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\VehModification;
class VehModificationLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = VehModification::class;
public function getList()
{
return VehModification::where('status', 1)->orderBy('sort','desc')->get(['id', 'code', 'name', 'type', 'price']);
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace app\common\service;
use app\admin\validate\BrandSeriesValidate;
use app\common\logic\BrandSeriesLogic;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\BrandSeries;
use support\exception\BusinessException;
use support\Request;
class BrandSeriesService
{
protected $logic;
public function __construct()
{
$this->logic = (new BrandSeriesLogic());
}
/**
* 获取系统list
*/
public function getList($params)
{
if (empty($params['brand_id']))
throw new BusinessException('品牌id不能为空');
$where = [];
if(isset($params['brand_id']) && $params['brand_id'])
$where[] = ['brand_id', '=', $params['brand_id']];
return $this->logic->getList($where);
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace app\common\service;
use app\common\logic\BrandLogic;
class BrandService
{
protected $logic;
public function __construct()
{
$this->logic = (new BrandLogic());
}
/**
* 获取系统list
*/
public function getList()
{
return $this->logic->getList();
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace app\common\service;
use app\admin\validate\SysAccountValidate;
use app\common\logic\SysAccountLogic;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\SysAccount;
use support\Request;
class SysAccountService
{
protected $logic;
public function __construct()
{
$this->logic = (new SysAccountLogic());
}
/**
* 获取系统list
*/
public function getList()
{
return $this->logic->getList();
}
}
+42
View File
@@ -0,0 +1,42 @@
<?php
namespace app\common\service;
use app\admin\validate\SysDictItemValidate;
use app\common\logic\SysDictItemLogic;
use app\common\logic\SysDictLogic;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\SysDictItem;
use support\exception\BusinessException;
use support\Request;
class SysDictItemService
{
protected $logic;
public function __construct()
{
$this->logic = (new SysDictItemLogic());
}
/**
* 获取系统list
*/
public function getList($params)
{
if (empty($params['dict_id']) && empty($params['dict_code']))
throw new BusinessException('未明确要查询的字典组');
$where = [];
if(isset($params['dict_id']) && $params['dict_id'])
$where[] = ['dict_id', '=', $params['dict_id']];
if(isset($params['dict_code']) && $params['dict_code']){
$dict = (new SysDictLogic)->getDictByCode($params['dict_code']);
if (empty($dict['id']))
throw new BusinessException('字典组code错误');
$where[] = ['dict_id', '=', $dict['id']];
}
return $this->logic->getList($where);
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace app\common\service;
use app\admin\validate\SysDictValidate;
use app\common\logic\SysDictLogic;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\SysDict;
use support\Request;
class SysDictService
{
protected $logic;
public function __construct()
{
$this->logic = (new SysDictLogic());
}
/**
* 获取系统list
*/
public function getList()
{
return $this->logic->getList();
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace app\common\service;
use app\admin\validate\SysPortValidate;
use app\common\logic\SysPortLogic;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\SysPort;
use support\Request;
class SysPortService
{
protected $logic;
public function __construct()
{
$this->logic = (new SysPortLogic());
}
/**
* 获取系统list
*/
public function getList()
{
return $this->logic->getList();
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace app\common\service;
use app\admin\validate\VehColorValidate;
use app\common\logic\VehColorLogic;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\VehColor;
use support\exception\BusinessException;
class VehColorService
{
protected $logic;
public function __construct()
{
$this->logic = (new VehColorLogic());
}
/**
* 获取系统list
*/
public function getList($params)
{
if (empty($params['type']))
throw new BusinessException('类型不能为空');
$where = [];
if(isset($params['type']) && $params['type'])
$where[] = ['type', '=', $params['type']];
return $this->logic->getList($where);
}
}
@@ -0,0 +1,28 @@
<?php
namespace app\common\service;
use app\admin\validate\VehModificationValidate;
use app\common\logic\VehModificationLogic;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\VehModification;
use support\Request;
class VehModificationService
{
protected $logic;
public function __construct()
{
$this->logic = (new VehModificationLogic());
}
/**
* 获取系统list
*/
public function getList()
{
return $this->logic->getList();
}
}
+8
View File
@@ -64,6 +64,14 @@ Route::group('/common', function () {
Route::any('/currency', [app\common\controller\PresetController::class, 'currency']);
Route::any('/cache/clear', [app\common\controller\PresetController::class, 'cacheClear']);
Route::any('/menus', [app\common\controller\PresetController::class, 'menus']);
Route::any('/brand', [app\common\controller\PresetController::class, 'brand']);
Route::any('/brand/series', [app\common\controller\PresetController::class, 'series']);
Route::any('/account', [app\common\controller\PresetController::class, 'account']);
Route::any('/dict', [app\common\controller\PresetController::class, 'dict']);
Route::any('/dictItem', [app\common\controller\PresetController::class, 'dictItem']);
Route::any('/port', [app\common\controller\PresetController::class, 'port']);
Route::any('/color', [app\common\controller\PresetController::class, 'color']);
Route::any('/modification', [app\common\controller\PresetController::class, 'modification']);
});