账户
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
namespace app\common\controller;
|
||||||
|
|
||||||
use app\admin\service\RoleService;
|
use app\admin\service\RoleService;
|
||||||
|
use app\common\service\SysCurrencyService;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
use app\common\service\CorpService;
|
use app\common\service\CorpService;
|
||||||
use app\common\service\CorpFeishuAppService;
|
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()
|
public function cacheClear()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 = [];
|
||||||
|
}
|
||||||
@@ -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
@@ -61,6 +61,7 @@ Route::group('/common', function () {
|
|||||||
Route::any('/feishu/app', [app\common\controller\PresetController::class, 'feishuApp']);
|
Route::any('/feishu/app', [app\common\controller\PresetController::class, 'feishuApp']);
|
||||||
Route::any('/systems', [app\common\controller\PresetController::class, 'systems']);
|
Route::any('/systems', [app\common\controller\PresetController::class, 'systems']);
|
||||||
Route::any('/roles', [app\common\controller\PresetController::class, 'roles']);
|
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('/cache/clear', [app\common\controller\PresetController::class, 'cacheClear']);
|
||||||
Route::any('/menus', [app\common\controller\PresetController::class, 'menus']);
|
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::any('/destroy', [app\admin\controller\VehColorController::class, 'destroy']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 汽车颜色
|
// 汽车改装项目
|
||||||
Route::group('/modification', function () {
|
Route::group('/modification', function () {
|
||||||
Route::any('/list', [app\admin\controller\VehModificationController::class, 'index']);
|
Route::any('/list', [app\admin\controller\VehModificationController::class, 'index']);
|
||||||
Route::any('/show', [app\admin\controller\VehModificationController::class, 'show']);
|
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::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']);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user