diff --git a/README.en.md b/README.en.md index cc6c45a3fc5e7e49cec18f416e71a0dc7b116035..888b122e17514202d4a4f12965b62a971f83d41d 100644 --- a/README.en.md +++ b/README.en.md @@ -8,9 +8,11 @@ Software architecture description #### Installation -1. xxxx -2. xxxx -3. xxxx +1. composer install +2. cp .env.example .env +3. 生成 APP_KEY:php artisan key:generate +4. JWT的key:php artisan jwt:secret +5. 导入sql:laravel-vue-admin #### Instructions diff --git a/README.md b/README.md index 21689a17b943addc03efe28eccc1d768520be5c6..19385307a5a5805bd662f46731813f1aa2d66dbe 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,11 @@ Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN #### 安装教程 -1. 生成 APP_KEY:php artisan key:generate -2. JWT的key:php artisan jwt:secret -3. xxxx +1. composer install +2. cp .env.example .env +3. 生成 APP_KEY:php artisan key:generate +4. JWT的key:php artisan jwt:secret +5. 导入sql:laravel-vue-admin #### 使用说明 diff --git a/app/Exceptions/AuthException.php b/app/Exceptions/Admin/AuthException.php similarity index 49% rename from app/Exceptions/AuthException.php rename to app/Exceptions/Admin/AuthException.php index 3d886d3193975cad36b353b70342ed1635da6c9d..dbac6721ffc7a1e95df533459f90000c3fd07f9a 100644 --- a/app/Exceptions/AuthException.php +++ b/app/Exceptions/Admin/AuthException.php @@ -1,21 +1,28 @@ admin_id = $admin_id; } public function render(Request $request) { if ($request->expectsJson()) { + // 登录日志 + AdminLoginLog::getInstance()->add($this->admin_id, 0, $this->msg); + $this->setHttpCode(401); - return $this->errorJson($this->msg, -1); + return $this->errorJson($this->msg); } } } diff --git a/app/Exceptions/Admin/AuthTokenException.php b/app/Exceptions/Admin/AuthTokenException.php new file mode 100644 index 0000000000000000000000000000000000000000..70d58bd884c87a069ae4d13581f598532192e3cd --- /dev/null +++ b/app/Exceptions/Admin/AuthTokenException.php @@ -0,0 +1,28 @@ +admin_id = $admin_id; + } + + public function render(Request $request) + { + if ($request->expectsJson()) { + // 登录日志 + AdminLoginLog::getInstance()->add($this->admin_id, 0, $this->msg); + + $this->setHttpCode(401); + return $this->errorJson($this->msg); + } + } +} diff --git a/app/Modules/Admin/Entities/Log/AdminLog.php b/app/Modules/Admin/Entities/Log/AdminLog.php index e5befa0e12aacb660f415c01386cf36ab4c85f8f..eca099a1a61f067a4db2bcb305c47cd55fbe46c0 100644 --- a/app/Modules/Admin/Entities/Log/AdminLog.php +++ b/app/Modules/Admin/Entities/Log/AdminLog.php @@ -14,4 +14,9 @@ class AdminLog extends MonthModel { return $this->belongsTo(Admin::class, 'admin_id', 'admin_id'); } + + public function getLogDurationAttribute($key) + { + return floatval($key); + } } diff --git a/app/Modules/Admin/Entities/Log/AdminLoginLog.php b/app/Modules/Admin/Entities/Log/AdminLoginLog.php index 8a17a8eb62ee29ee85118e385be89f7815dd1d85..063c8d0e253fbc551454f62d4f5e708e9f15029d 100644 --- a/app/Modules/Admin/Entities/Log/AdminLoginLog.php +++ b/app/Modules/Admin/Entities/Log/AdminLoginLog.php @@ -14,4 +14,25 @@ class AdminLoginLog extends MonthModel { return $this->belongsTo(Admin::class, 'admin_id', 'admin_id'); } + + public function getLogDurationAttribute($key) + { + return floatval($key); + } + + public function add(int $admin_id = 0, int $log_status = 1, $description = '登录成功') + { + $ip_agent = get_client_info(); + return $this->setMonthTable()->create([ + 'admin_id' => $admin_id, + 'created_ip' => $ip_agent['ip'] ?? get_ip(), + 'browser_type' => $ip_agent['agent'] ?? $_SERVER['HTTP_USER_AGENT'], + 'log_status' => $log_status, + 'description' => $description, + 'log_action' => request()->route()->getActionName(), + 'log_method' => request()->getMethod(), + 'log_duration' => microtime(true) - LARAVEL_START, + 'request_data' => json_encode(request()->all()), + ]); + } } diff --git a/app/Modules/Admin/Http/Controllers/AuthController.php b/app/Modules/Admin/Http/Controllers/AuthController.php index 0b765b6aa61f1ec0b49f469043601e595e7cae21..2e63e0d286c254dfb2d35daef1bc76f1619e9be2 100644 --- a/app/Modules/Admin/Http/Controllers/AuthController.php +++ b/app/Modules/Admin/Http/Controllers/AuthController.php @@ -18,7 +18,7 @@ class AuthController extends BaseController * * @param LoginRequest $request * @return \Illuminate\Http\JsonResponse - * @throws \App\Exceptions\AuthException + * @throws \App\Exceptions\Admin\AuthException * @throws \App\Exceptions\InvalidRequestException */ public function login(LoginRequest $request) @@ -35,7 +35,7 @@ class AuthController extends BaseController * 获取登录管理员信息 * * @return \Illuminate\Http\JsonResponse - * @throws \App\Exceptions\AuthException + * @throws \App\Exceptions\Admin\AuthException */ public function me() { diff --git a/app/Modules/Admin/Http/Controllers/IndexController.php b/app/Modules/Admin/Http/Controllers/IndexController.php index a936e00b2505b7a32f58ff04d0c51647aa62d13b..2ba5bd679d4be120d486c7e28eb18768d0d4f72b 100644 --- a/app/Modules/Admin/Http/Controllers/IndexController.php +++ b/app/Modules/Admin/Http/Controllers/IndexController.php @@ -2,6 +2,7 @@ namespace App\Modules\Admin\Http\Controllers; +use App\Models\MonthModel; use Illuminate\Http\Request; class IndexController extends BaseController @@ -10,4 +11,14 @@ class IndexController extends BaseController { return $this->successJson([]); } + + /** + * 月份表列表 + * + * @return \Illuminate\Http\JsonResponse + */ + public function getMonthList() + { + return $this->successJson(MonthModel::getInstance()->getAllMonthes()); + } } diff --git a/app/Modules/Admin/Http/Middleware/AdminLog.php b/app/Modules/Admin/Http/Middleware/AdminLog.php index 5093e5b355b91fea1d4fd35da308f43d151ae646..fe78bdcd1322562cb01d0a35aa70e07bcfd3712e 100644 --- a/app/Modules/Admin/Http/Middleware/AdminLog.php +++ b/app/Modules/Admin/Http/Middleware/AdminLog.php @@ -22,6 +22,7 @@ class AdminLog $resource = $next($request); if (strtoupper($request->getMethod()) != 'GET'){ + $ip_agent = get_client_info(); \App\Modules\Admin\Entities\Log\AdminLog::getInstance()->create([ 'request_data' => json_encode($request->all()), 'admin_id' => !empty(auth($guard)->user()) ? auth($guard)->user()->admin_id : 0, diff --git a/app/Modules/Admin/Http/Requests/Rabc/AdminMenuRequest.php b/app/Modules/Admin/Http/Requests/Rabc/AdminMenuRequest.php index 4ae6689fda5b88f9a9151c0f11df952f4f514b8f..0be8cf4dd85d78f4d4c31380869c05375fb8888a 100644 --- a/app/Modules/Admin/Http/Requests/Rabc/AdminMenuRequest.php +++ b/app/Modules/Admin/Http/Requests/Rabc/AdminMenuRequest.php @@ -24,9 +24,6 @@ class AdminMenuRequest extends BaseRequest 'max:256', 'unique:' . $instance->getTable() . ',menu_name' . $validate_id ], - 'is_check' => [ - 'required', - ] ]; } diff --git a/app/Modules/Admin/Resources/views/admin.blade.php b/app/Modules/Admin/Resources/views/admin.blade.php index 34989bc3e349e84c0efec8d12712d50e2ddd3b96..1ff0628a33ee6ce2bcfd9a333e22bffeaa73923d 100644 --- a/app/Modules/Admin/Resources/views/admin.blade.php +++ b/app/Modules/Admin/Resources/views/admin.blade.php @@ -6,10 +6,12 @@