This commit is contained in:
2025-08-28 15:19:39 +08:00
parent 035450e762
commit df8a47c947
9 changed files with 293 additions and 1 deletions
@@ -0,0 +1,48 @@
<?php
namespace app\admin\controller;
use app\common\controller\BaseController;
use app\common\traits\crud\CrudControllerTrait;
use app\admin\service\SysAccountService;
class SysAccountController extends BaseController
{
use CrudControllerTrait;
protected $service;
public function __construct()
{
$this->service = new SysAccountService();
}
/**
* 列表页数据格式化
*
* @param array $data
* @return array
*/
protected function indexFormat($data)
{
if (isset($data['created_at']))
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
if (isset($data['updated_at']))
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
return $data;
}
/**
* 数据格式化
*
* @param array $data
* @return array
*/
protected function showFormat($data)
{
if (isset($data['created_at']))
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
if (isset($data['updated_at']))
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
return $data;
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace app\admin\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\SysAccount;
class SysAccountLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = SysAccount::class;
}
+82
View File
@@ -0,0 +1,82 @@
<?php
namespace app\admin\service;
use app\admin\validate\SysAccountValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\SysAccount;
use support\Request;
class SysAccountService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = SysAccount::class;
/**
* 验证器
*/
protected $validator = SysAccountValidate::class;
/**
* 获取验证器
*/
public function getValidator()
{
return new $this->validator;
}
/**
* 构建查询条件
*/
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
{
$p = $request->all();
$config = [];
$config['model'] = $this->modelClass;
switch ($scene) {
case 'index':
// ====== ====== 排序 ====== ======
$config['order']['sort'] = 'desc';
$config['order']['id'] = 'desc';
// ====== ====== 筛选 ====== ======
// 状态
if (isset($p['status']) && in_array($p['status'], [0,1])) {
$config['where']['status'] = $p['status'];
}
// 状态
if (isset($p['type']) && $p['type']) {
$config['where']['type'] = $p['type'];
}
// 关键字
if (isset($p['keyword']) && $p['keyword']) {
$k = '%' . $p['keyword'] . '%';
foreach (['account_name','account_number','bank_name','bank_branch','description'] as $col) {
$config['orWhere'][] = [$col, 'like', $k];
}
}
//$config['where']['status'] = 1;
break;
case 'show':
$config['where']['id'] = $p['id'];
//$config['where']['status'] = 1;
break;
case 'store':
break;
case 'update':
$config['where']['id'] = $p['id'];
break;
case 'destroy':
$config['where']['id'] = $p['id'];
break;
}
return $config;
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace app\admin\validate;
use think\Validate;
class SysAccountValidate extends Validate
{
// 规则
protected $rule = [
];
// 提示
protected $message = [
];
// 场景
protected $scene = [
'store' => [
],
'update' => [
]
];
}
@@ -3,6 +3,7 @@
namespace app\common\controller;
use app\admin\service\RoleService;
use app\common\service\SysCurrencyService;
use support\Request;
use app\common\service\CorpService;
use app\common\service\CorpFeishuAppService;
@@ -76,6 +77,16 @@ class PresetController extends BaseController
}
}
public function currency()
{
try {
$result = (new SysCurrencyService)->getList();
return $this->success($result, '获取货币列表');
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
public function cacheClear()
{
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace app\common\logic;
use app\common\model\SysCurrency;
use app\common\traits\crud\CrudLogicTrait;
class SysCurrencyLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = SysCurrency::class;
public function getList()
{
return SysCurrency::where('status', 1)->get(['id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'float_percent']);
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace app\common\model;
use support\Model;
class SysAccount extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'sys_account';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'account_name', 'account_type', 'account_number', 'account_holder', 'bank_name', 'bank_branch', 'daily_limit', 'single_limit', 'description', 'status', 'sort', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace app\common\service;
use app\common\logic\SysCurrencyLogic;
use app\common\logic\SystemsLogic;
class SysCurrencyService
{
protected $logic;
public function __construct()
{
$this->logic = (new SysCurrencyLogic());
}
/**
* 获取系统list
*/
public function getList()
{
return $this->logic->getList();
}
}
+11 -1
View File
@@ -61,6 +61,7 @@ Route::group('/common', function () {
Route::any('/feishu/app', [app\common\controller\PresetController::class, 'feishuApp']);
Route::any('/systems', [app\common\controller\PresetController::class, 'systems']);
Route::any('/roles', [app\common\controller\PresetController::class, 'roles']);
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']);
});
@@ -235,7 +236,7 @@ Route::group('/admin', function () {
Route::any('/destroy', [app\admin\controller\VehColorController::class, 'destroy']);
});
// 汽车颜色
// 汽车改装项目
Route::group('/modification', function () {
Route::any('/list', [app\admin\controller\VehModificationController::class, 'index']);
Route::any('/show', [app\admin\controller\VehModificationController::class, 'show']);
@@ -244,6 +245,15 @@ Route::group('/admin', function () {
Route::any('/destroy', [app\admin\controller\VehModificationController::class, 'destroy']);
});
// 账户
Route::group('/account', function () {
Route::any('/list', [app\admin\controller\SysAccountController::class, 'index']);
Route::any('/show', [app\admin\controller\SysAccountController::class, 'show']);
Route::any('/store', [app\admin\controller\SysAccountController::class, 'store']);
Route::any('/update', [app\admin\controller\SysAccountController::class, 'update']);
Route::any('/destroy', [app\admin\controller\SysAccountController::class, 'destroy']);
});
});