作者 李美松

域名方法完成 | 服务器方法修改

... ... @@ -22,24 +22,24 @@ class ServerInformationController extends BaseController
*/
public function lists($deleted = ServerInformation::DELETED_NORMAL)
{
$request = $this->param;
$search = [];
$ip = response()->input('ip');
if ($ip) {
$search['ip'] = $ip;
$search_array = [
'ip' => 'ip',
'title' => 'title'
];
foreach ($search_array as $key => $item) {
if (isset($request[$key]) && $request[$key]) {
$search[$item] = $request[$key];
}
$remark = response()->input('title');
if ($remark) {
$search['title'] = $remark;
}
if (empty($search)) {
return $this->response('请输入搜索内容', Code::USER_ERROR);
}
$size = request()->input('size', $this->row);
$query = ServerInformation::query()->select(['id', 'title', 'ip']);
if ($search) {
foreach ($search as $key => $item) {
$query = $query->Where("{$key}", 'like', "%{$item}%");
}
}
$data = $query->where('deleted', $deleted)
->orderBy('id', 'desc')
->paginate($size);
... ... @@ -74,9 +74,10 @@ class ServerInformationController extends BaseController
public function edit(ServerInformationRequest $serverInformationRequest, ServerInformationLogic $serverInformationLogic)
{
$serverInformationRequest->validate([
'id' => ['required'],
'id' => 'required|integer',
], [
'id.required' => 'ID不能为空',
'id.integer' => 'ID必须为整数',
]);
$serverInformationLogic->update();
$this->response('服务器修改成功!');
... ...
... ... @@ -27,9 +27,28 @@ class DomainInfoController extends BaseController
*/
public function lists(int $deleted = DomainInfo::DELETED_NORMAL)
{
$request = $this->param;
$search = [];
$search_array = [
'domain' => 'domain',
'belong' => 'belong_to',
'domain_time' => 'domain_end_time',
'certificate_time' => 'certificate_end_time'
];
foreach ($search_array as $key => $item) {
if (isset($request[$key]) && $request[$key]) {
$search[$item] = $request[$key];
}
}
// 每页条数
$size = request()->input('size', $this->row);
$data = DomainInfo::query()->select(['id', 'domain', 'belong_to'])
->where('deleted', $deleted)
$query = DomainInfo::query()->select(['id', 'domain', 'belong_to']);
if ($search) {
foreach ($search as $key => $item) {
$query = $query->Where("{$key}", 'like', "%{$item}%");
}
}
$data = $query->where('deleted', $deleted)
->orderBy('id', 'desc')
->paginate($size);
return $this->response('success', Code::SUCCESS, $data);
... ... @@ -89,7 +108,7 @@ class DomainInfoController extends BaseController
public function delete(DomainInfoLogic $domainInfoLogic)
{
$domainInfoLogic->get_batch_update();
$this->response('服务器删除成功!');
$this->response('域名删除成功!');
}
/**
... ... @@ -102,7 +121,7 @@ class DomainInfoController extends BaseController
public function restore(DomainInfoLogic $domainInfoLogic)
{
$domainInfoLogic->get_batch_update(DomainInfoLog::ACTION_RECOVER, DomainInfo::DELETED_DELETE);
$this->response('服务器恢复成功!');
$this->response('域名恢复成功!');
}
/**
... ... @@ -114,12 +133,12 @@ class DomainInfoController extends BaseController
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getDomainInfo(int $deleted = DomainInfo::DELETED_NORMAL)
public function info(int $deleted = DomainInfo::DELETED_NORMAL)
{
$domainInfoLogic = new DomainInfoLogic();
$data = $domainInfoLogic->domainInfo($deleted);
if (!$data) {
return $this->response('服务器信息不存在', Code::USER_ERROR);
return $this->response('域名信息不存在', Code::USER_ERROR);
}
return $this->success($data->toArray());
}
... ... @@ -134,6 +153,6 @@ class DomainInfoController extends BaseController
*/
public function getDeleteDomainInfo()
{
return $this->getDomainInfo(DomainInfo::DELETED_DELETE);
return $this->info(DomainInfo::DELETED_DELETE);
}
}
... ...
<?php
namespace App\Http\Controllers\Aside\Domain;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Aside\Domain\DomainInfoLog;
use Illuminate\Http\Request;
class DomainInfoLogController extends BaseController
{
public function lists(Request $request)
{
$size = $request->input('size', $this->row);
$data = DomainInfoLog::query()
->orderBy('id', 'desc')
->paginate($size);
return $this->response('success', Code::SUCCESS, $data);
}
}
... ...
... ... @@ -12,9 +12,7 @@ use App\Models\Devops\ServerInformationLog;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class ServerInformationLogic extends BaseLogic
{
... ... @@ -41,7 +39,7 @@ class ServerInformationLogic extends BaseLogic
*/
public function create()
{
$request = $this->param;
$request = $this->param ?? [];
$service = new ServerInformation();
$this->extracted($request, $service);
if ($this->checkIp($service->ip)) {
... ... @@ -50,15 +48,9 @@ class ServerInformationLogic extends BaseLogic
DB::beginTransaction();
if ($service->save()) {
$original = [
'id' => $service->id,
'type' => $service->type,
'ip' => $service->ip,
'title' => $service->title,
'belong_to' => $service->belong_to,
'sshpass' => $service->sshpass,
'ports' => $service->ports,
];
$original = $service->getOriginal();
$original['type'] = $request['type'];
$original['belong_to'] = $request['belong_to'];
// 添加日志
$this->server_action_log(ServerInformationLog::ACTION_ADD, $original, $original, '添加服务器信息成功 - ID : ' . $service->id);
DB::commit();
... ... @@ -77,14 +69,13 @@ class ServerInformationLogic extends BaseLogic
*/
public function update()
{
$service = new ServerInformation();
$service = $this->getService();
$fields_array = $service->FieldsArray();
$request = $this->param;
$service = $this->ServerInfo();
$original = $service->toArray();
$request = $this->param ?? [];
$original = $service->getOriginal();
$original['type'] = $service->ServiceStr($original['type']);
$original['belong_to'] = $service->BelongToStr($original['belong_to']);
$this->extracted($request, $service);
// 检查ip是否存在
if ($service->ip != $request['ip']) {
if ($this->checkIp($request['ip'])) {
... ... @@ -93,20 +84,10 @@ class ServerInformationLogic extends BaseLogic
}
DB::beginTransaction();
if ($service->save()) {
$revised = [
'id' => $service->id,
'type' => $service->type,
'ip' => $service->ip,
'title' => $service->title,
'belong_to' => $service->belong_to,
'sshpass' => $service->sshpass,
'ports' => $service->ports,
'other' => $service->other,
'delete' => $service->delete,
];
$revised = $service->getAttributes();
$diff = array_diff_assoc($original, $revised);
unset($diff['create_at']);
unset($diff['update_at']);
unset($diff['created_at']);
unset($diff['updated_at']);
unset($diff['deleted']);
$remarks = '';
if ($diff) {
... ... @@ -114,6 +95,8 @@ class ServerInformationLogic extends BaseLogic
foreach ($diff as $key => $value) {
$remarks .= $fields_array[$key] . ' 由 ' . $value . ' 修改为 ' . $revised[$key] . '; ';
}
} else {
$remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,无修改';
}
// 添加日志
$this->server_action_log(ServerInformationLog::ACTION_UPDATE, $original, $revised, $remarks);
... ... @@ -124,6 +107,19 @@ class ServerInformationLogic extends BaseLogic
return $this->fail('服务器信息修改失败');
}
public function getService(int $deleted = ServerInformation::DELETED_NORMAL)
{
$id = $this->param['id'] ?? 0;
if (!$id) {
return $this->fail('ID不能为空');
}
$data = ServerInformation::query()->where('deleted', $deleted)->find($id);
if (!$data) {
return $this->fail('数据不存在!');
}
return $data;
}
/**
* 检查ip是否存在
* @param $ip
... ... @@ -148,11 +144,11 @@ class ServerInformationLogic extends BaseLogic
*/
public function serverInfo(int $deleted = ServerInformation::DELETED_NORMAL)
{
$id = \request()->input('id');
$id = $this->param['id'] ?? 0;
if (!$id) {
return $this->fail('参数错误');
return $this->fail('ID不能为空');
}
$data = ServerInformation::query()->where('deleted', $deleted)->find($id, ['type', 'ip', 'title', 'belong_to', 'ports', 'create_at', 'update_at']);
$data = ServerInformation::query()->where('deleted', $deleted)->find($id, ['type', 'ip', 'title', 'belong_to', 'ports', 'created_at', 'updated_at']);
if (!$data) {
return $this->fail('数据不存在!');
}
... ... @@ -167,30 +163,8 @@ class ServerInformationLogic extends BaseLogic
*/
public function server_action_log(int $action = ServerInformationLog::ACTION_ADD, array $original = [], array $revised = [], $remarks = '')
{
// $action 1:添加 2:修改 3:删除 4:恢复
$actionArr = ServerInformationLog::actionArr();
$actionStr = $actionArr[$action];
$ip = request()->getClientIp();
$url = request()->getRequestUri();
$method = request()->getMethod();
$userId = $this->uid ?? 0;
$log = new ServerInformationLog();
$log->user_id = $userId;
$log->action = $actionStr;
$log->original = json_encode($original);
$log->revised = json_encode($revised);
$log->ip = $ip;
$log->url = $url;
$log->method = $method;
$log->remarks = $remarks;
DB::beginTransaction();
try {
$log->save();
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
Log::error('服务器信息日志添加失败');
}
$this->log($log, $action, $original, $revised, $remarks);
}
/**
... ... @@ -216,18 +190,7 @@ class ServerInformationLogic extends BaseLogic
*/
public function get_batch_update($action = ServerInformationLog::ACTION_DELETE, $deleted = ServerInformation::DELETED_NORMAL)
{
$id = request()->input('id');
if (!$id) {
return $this->fail('参数错误');
}
$ids = [];
if (!is_array($id)) {
$ids = explode(',', $id);
}
$ids = array_filter($ids, 'intval');
if (empty($ids)) {
return $this->fail('参数错误');
}
$ids = $this->getIds();
$data = ServerInformation::query()->whereIn('id', $ids)->where('deleted', $deleted)->get();
$restore_ids = $data->pluck('id')->toArray();
$actionArr = ServerInformationLog::actionArr();
... ... @@ -248,4 +211,27 @@ class ServerInformationLogic extends BaseLogic
return $this->fail('服务器信息' . $actionStr . '失败', Code::USER_ERROR);
}
}
/**
* 批量获取数据恢复
* @return array
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function getIds()
{
$id = $this->param['id'] ?? 0;
if (!$id) {
return $this->fail('参数错误');
}
$ids = [];
if (!is_array($id)) {
$ids = explode(',', $id);
}
$ids = array_filter($ids, 'intval');
if (empty($ids)) {
return $this->fail('参数错误');
}
return $ids;
}
}
... ...
... ... @@ -7,15 +7,14 @@ use App\Enums\Common\Code;
use App\Exceptions\AsideGlobalException;
use App\Exceptions\BsideGlobalException;
use App\Http\Logic\Aside\BaseLogic;
use App\Http\Logic\Aside\Devops\ServerInformationLogic;
use App\Models\Aside\Domain\DomainInfo;
use App\Models\Aside\Domain\DomainInfoLog;
use App\Models\Devops\ServerInformation;
use App\Models\Devops\ServerInformationLog;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class DomainInfoLogic extends BaseLogic
{
... ... @@ -42,23 +41,19 @@ class DomainInfoLogic extends BaseLogic
*/
public function create()
{
$request = $this->param;
$request = $this->param ?? [];
if ($this->checkDomain($request['domain'])) {
return $this->fail('域名已存在!');
}
$domain = new DomainInfo();
$this->extracted($request, $domain);
DB::beginTransaction();
if ($domain->save()) {
$original = [
'id' => $domain->id,
'domain' => $domain->domain,
'belong_to' => $domain->belong_to,
'status' => $domain->status,
'domain_start_time' => $domain->domain_start_time,
'domain_end_time' => $domain->domain_end_time,
'certificate_start_time' => $domain->certificate_start_time,
'certificate_end_time' => $domain->certificate_end_time,
];
$original = $domain->getOriginal();
$original['belong_to'] = $request['belong_to'];
$original['status'] = $request['status'];
// 添加日志
$this->domain_action_log(ServerInformationLog::ACTION_ADD, $original, $original, '添加服务器信息成功 - ID : ' . $domain->id);
$this->domain_action_log(DomainInfoLog::ACTION_ADD, $original, $original, '添加域名信息成功 - ID : ' . $domain->id);
DB::commit();
return $this->success();
}
... ... @@ -75,25 +70,25 @@ class DomainInfoLogic extends BaseLogic
*/
public function update()
{
$domain = new DomainInfo();
$domain = $this->getDomain();
$original = $domain->getOriginal();
$original['belong_to'] = $domain->BelongToStr($original['belong_to']);
$original['status'] = $domain->StatusToStr($original['status']);
$request = $this->param;
$this->extracted($request, $domain);
// 检查ip是否存在
if ($domain->domain != $request['domain']) {
if ($this->checkDomain($request['domain'])) {
$this->fail('域名信息修改失败,域名已存在', Code::USER_ERROR);
}
}
DB::beginTransaction();
if ($domain->save()) {
$fields_array = $domain->FieldsArray();
$original = $domain->getOriginal();
$revised = [
'id' => $domain->id,
'domain' => $domain->domain,
'belong_to' => $domain->belong_to,
'status' => $domain->status,
'domain_start_time' => $domain->domain_start_time,
'domain_end_time' => $domain->domain_end_time,
'certificate_start_time' => $domain->certificate_start_time,
'certificate_end_time' => $domain->certificate_end_time,
'delete' => $domain->delete,
];
$revised = $domain->getAttributes();
$diff = array_diff_assoc($original, $revised);
unset($diff['created_at']);
unset($diff['updated_at']);
unset($diff['deleted']);
$remarks = '';
if ($diff) {
... ... @@ -101,9 +96,11 @@ class DomainInfoLogic extends BaseLogic
foreach ($diff as $key => $value) {
$remarks .= $fields_array[$key] . ' 由 ' . $value . ' 修改为 ' . $revised[$key] . '; ';
}
} else {
$remarks .= '修改ID为 ' . $domain->id . ' 的域名信息,无修改';
}
// 添加日志
$this->domain_action_log(ServerInformationLog::ACTION_UPDATE, $original, $revised, $remarks);
$this->domain_action_log(DomainInfoLog::ACTION_UPDATE, $original, $revised, $remarks);
DB::commit();
return $this->success();
}
... ... @@ -112,6 +109,25 @@ class DomainInfoLogic extends BaseLogic
}
/**
* 根据ID获取数据
* @return array
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function getDomain(int $deleted = DomainInfo::DELETED_NORMAL)
{
$id = $this->param['id'] ?? 0;
if (!$id) {
return $this->fail('ID不能为空');
}
$data = DomainInfo::query()->where('deleted', $deleted)->find($id);
if (!$data) {
return $this->fail('数据不存在!');
}
return $data;
}
/**
* 检查域名是否存在
* @param $domain
* @return bool
... ... @@ -135,11 +151,11 @@ class DomainInfoLogic extends BaseLogic
*/
public function domainInfo(int $deleted = DomainInfo::DELETED_NORMAL)
{
$id = request()->input('id');
$id = $this->param['id'] ?? 0;
if (!$id) {
return $this->fail('参数错误');
return $this->fail('ID不能为空');
}
$data = DomainInfo::query()->where('deleted', $deleted)->find($id, ['domain', 'belong_to', 'title', 'domain_start_time', 'domain_end_time', 'certificate_start_time', 'certificate_end_time', 'create_at', 'update_at']);
$data = DomainInfo::query()->where('deleted', $deleted)->find($id, ['domain', 'belong_to', 'status', 'domain_start_time', 'domain_end_time', 'certificate_start_time', 'certificate_end_time', 'created_at', 'updated_at']);
if (!$data) {
return $this->fail('数据不存在!');
}
... ... @@ -154,44 +170,27 @@ class DomainInfoLogic extends BaseLogic
*/
public function domain_action_log(int $action = DomainInfoLog::ACTION_ADD, array $original = [], array $revised = [], $remarks = '')
{
// $action 1:添加 2:修改 3:删除 4:恢复
$actionArr = DomainInfoLog::actionArr();
$actionStr = $actionArr[$action];
$ip = request()->getClientIp();
$url = request()->getRequestUri();
$method = request()->getMethod();
$userId = $this->uid ?? 0;
$log = new ServerInformationLog();
$log->user_id = $userId;
$log->action = $actionStr;
$log->original = json_encode($original);
$log->revised = json_encode($revised);
$log->ip = $ip;
$log->url = $url;
$log->method = $method;
$log->remarks = $remarks;
DB::beginTransaction();
try {
$log->save();
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
Log::error('服务器信息日志添加失败');
}
$log = new DomainInfoLog();
$this->log($log, $action, $original, $revised, $remarks);
}
/**
* @param array $request
* @param $domain
* @return void
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function extracted(array $request, $domain)
{
$domain->domain = trim($request['domain']); // 域名
$domain->domain = trim($request['domain']);
if (!$this->validateDomain($domain->domain)) {
$this->fail('域名格式错误');
}
$domain->belong_to = trim($request['belong_to']); // 域名归属 1 - 公司 2 - 客户
$domain->status = trim($request['status']); // 域名状态 0 - 正常 1 - 关闭
$domain->domain_start_time = trim($request['domain_start_time']); // 域名开始时间
$domain->domain_end_time = trim($request['domain_end_time']); // 域名结束时间
$domain->domain_end_time = trim($request['domain_end_time']);
$domain->certificate_start_time = trim($request['certificate_start_time']); // 证书开始时间
$domain->certificate_end_time = trim($request['certificate_end_time']); // 证书结束时间
}
... ... @@ -204,36 +203,78 @@ class DomainInfoLogic extends BaseLogic
*/
public function get_batch_update($action = DomainInfoLog::ACTION_DELETE, $deleted = DomainInfo::DELETED_NORMAL)
{
$id = request()->input('id');
if (!$id) {
return $this->fail('参数错误');
}
$ids = [];
if (!is_array($id)) {
$ids = explode(',', $id);
}
$ids = array_filter($ids, 'intval');
if (empty($ids)) {
return $this->fail('参数错误');
}
$ids = (new ServerInformationLogic())->getIds();
$data = DomainInfo::query()->whereIn('id', $ids)->where('deleted', $deleted)->get();
$restore_ids = $data->pluck('id')->toArray();
$actionArr = DomainInfoLog::actionArr();
$actionStr = $actionArr[$action];
if (empty($restore_ids)) {
$this->fail($actionStr . '服务器信息不存在!', Code::USER_ERROR);
$this->fail($actionStr . '域名信息不存在!', Code::USER_ERROR);
}
$original = $data->toArray();
DB::beginTransaction();
try {
$update = $deleted == DomainInfo::DELETED_NORMAL ? DomainInfo::DELETED_DELETE : DomainInfo::DELETED_NORMAL;
DomainInfo::query()->whereIn('id', $restore_ids)->update(['deleted' => $update]);
$this->domain_action_log($action, $original, $original, $actionStr . '服务器信息 - ID : ' . implode(', ', $restore_ids));
$this->domain_action_log($action, $original, $original, $actionStr . '域名信息 - ID : ' . implode(', ', $restore_ids));
DB::commit();
return $this->success();
} catch (\Exception $e) {
DB::rollBack();
return $this->fail('服务器信息' . $actionStr . '失败', Code::USER_ERROR);
return $this->fail('域名信息' . $actionStr . '失败', Code::USER_ERROR);
}
}
/**
* 域名到期时间
* @return array
*/
public function domainCertificateTime($domain)
{
$domain = trim($domain);
$data = [];
$context = stream_context_create(['ssl' => ['capture_peer_cert' => true]]); // Notice: only 7.0.7+ supports this
$stream = stream_socket_client("ssl://$domain:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
if ($stream) {
$params = stream_context_get_params($stream);
$peerCertificate = openssl_x509_parse($params['options']['ssl']['peer_certificate']);
if ($peerCertificate) {
$validFrom = date_create_from_format('U', $peerCertificate['validFrom_time_t']); // 有效期开始时间
$validTo = date_create_from_format('U', $peerCertificate['validTo_time_t']); // 有效期结束时间
$data['validFrom'] = $validFrom->format('Y-m-d H:i:s');
$data['validTo'] = $validTo->format('Y-m-d H:i:s');
}
}
return $data;
}
/**
* 验证给定的值是否是有效的域名。
*
* @param mixed $value
* @return bool
*/
public function validateDomain($value)
{
// 从域中删除任何空间或路径。
$domain = preg_replace('/\s|\/.*$/', '', $value);
// 验证域是否至少包含一个句点。
if (strpos($domain, '.') === false) {
return false;
}
// 验证域是否以句点开始或结束。
if (strpos($domain, '.') === 0 || strrpos($domain, '.') === strlen($domain) - 1) {
return false;
}
// 验证域是否不包含无效字符。
if (!preg_match('/^[a-zA-Z0-9\-\.]+$/', $domain)) {
return false;
}
// 验证域是否具有有效的顶级域。
$tld = substr($domain, strrpos($domain, '.') + 1);
if (!in_array($tld, ['com', 'net', 'org'])) { // 如有必要,添加更多TLD。
return false;
}
return true;
}
}
... ...
... ... @@ -8,7 +8,10 @@ use \App\Helper\Common as CommonHelper;
use App\Exceptions\AsideGlobalException;
use App\Exceptions\BsideGlobalException;
use App\Helper\Arr;
use App\Models\Devops\ServerInformationLog;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
/**
... ... @@ -393,4 +396,40 @@ class Logic
public static function instance(...$params){
return new static(...$params);
}
/**
* 添加日志
* @param $log
* @param int $action 1:添加 2:修改 3:删除 4:搜索 5:详情 6:列表
* @param array $original 原始数据
* @param array $revised 修改后数据
* @param string $remarks 备注
* @return bool
*/
public function log($log, int $action = ServerInformationLog::ACTION_ADD, array $original = [], array $revised = [], string $remarks = ''): bool
{
// $action 1:添加 2:修改 3:删除 4:恢复
$actionArr = $log->actionArr();
$actionStr = $actionArr[$action];
$ip = request()->getClientIp();
$url = request()->getRequestUri();
$method = request()->getMethod();
$userId = $this->uid ?? 0;
$log->user_id = $userId;
$log->action = $actionStr;
$log->original = json_encode($original);
$log->revised = json_encode($revised);
$log->ip = $ip;
$log->url = $url;
$log->method = $method;
$log->remarks = $remarks;
DB::beginTransaction();
if($log->save()){
DB::commit();
return true;
}
DB::rollBack();
Log::error('日志添加失败');
return false;
}
}
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Http\Requests\Aside\Domain;
use App\Models\Aside\Domain\DomainInfo;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
... ... @@ -24,15 +25,18 @@ class DomainInfoRequest extends FormRequest
*/
public function rules()
{
$domain = new DomainInfo();
$status_tot_keys = array_keys($domain->StatusToArray());
$belong_to_keys = array_keys($domain->BelongToArray());
return [
'domain' => 'required|max:200',
'belong_to' => [
'required',
Rule::in([1, 2])
Rule::in($belong_to_keys)
],
'status' => [
'required',
Rule::in([0, 1])
Rule::in($status_tot_keys)
]
];
}
... ... @@ -42,10 +46,10 @@ class DomainInfoRequest extends FormRequest
return [
'domain.required' => '域名不能为空',
'domain.max' => '域名长度不能超过200个字符',
'belong_to.required' => '所属不能为空',
'belong_to.in' => '所属参数错误',
'status.required' => '状态不能为空',
'status.in' => '状态参数错误',
'belong_to.required' => '域名所属不能为空',
'belong_to.in' => '域名所属参数错误',
'status.required' => '域名状态不能为空',
'status.in' => '域名状态参数错误',
];
}
... ...
... ... @@ -55,8 +55,63 @@ class DomainInfo extends Base
];
}
public function BelongToStr($num)
{
return array_flip($this->BelongToArray())[$num];
}
public function BelongTo($num)
{
return $this->BelongToArray()[$num];
}
/**
* 域名状态信息
* @return array
*/
public function StatusToArray()
{
return [
0 => '未使用',
1 => '使用中',
];
}
public function StatusToStr($num)
{
return array_flip($this->StatusToArray())[$num];
}
/**
* 返回域名状态
* @param $num
*
* @return string
*/
public function StatusTo($num)
{
return $this->StatusToArray()[$num];
}
/**
* 返回服务器归属
* @param $value
*
* @return string
*/
public function getBelongToAttribute($value)
{
return $this->BelongTo($value);
}
/**
* 返回服务器状态
* @param $value
*
* @return string
*/
public function getStatusAttribute($value)
{
return $this->StatusTo($value);
}
}
... ...
... ... @@ -7,8 +7,6 @@ use Illuminate\Database\Eloquent\Model;
class DomainInfoLog extends Model
{
protected $table = 'gl_domain_info_log';
const CREATED_AT = 'create_at';
const UPDATED_AT = 'update_at';
public function getOriginalAttribute($value)
{
... ...
... ... @@ -8,8 +8,6 @@ class ServerInformation extends Model
{
protected $table = 'gl_server_information';
const CREATED_AT = 'create_at';
const UPDATED_AT = 'update_at';
// 软删除 0:正常 1:删除
const DELETED_NORMAL = 0;
... ... @@ -44,6 +42,11 @@ class ServerInformation extends Model
];
}
public function ServiceStr($num)
{
return array_flip($this->ServiceArray())[$num];
}
/**
* 字段信息
* @return array
... ... @@ -73,6 +76,11 @@ class ServerInformation extends Model
];
}
public function BelongToStr($num)
{
return array_flip($this->BelongToArray())[$num];
}
public function BelongTo($num)
{
return $this->BelongToArray()[$num];
... ...
... ... @@ -7,8 +7,6 @@ use Illuminate\Database\Eloquent\Model;
class ServerInformationLog extends Model
{
protected $table = 'gl_server_information_log';
const CREATED_AT = 'create_at';
const UPDATED_AT = 'update_at';
public function getOriginalAttribute($value)
{
... ...
... ... @@ -116,6 +116,19 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w
Route::post('/save_follow', [Aside\Task\TaskController::class, 'save_follow'])->name('admin.task_save_follow');
});
// 域名
Route::prefix('domain')->group(function () {
Route::get('/', [Aside\Domain\DomainInfoController::class, 'lists'])->name('admin.domain'); // 列表 | 搜索
Route::get('/info', [Aside\Domain\DomainInfoController::class, 'info'])->name('admin.domain_info'); // 详情
Route::get('/delete_info', [Aside\Domain\DomainInfoController::class, 'getDeleteDomainInfo'])->name('admin.domain_delete_info'); // 删除信息
Route::post('/add', [Aside\Domain\DomainInfoController::class, 'add'])->name('admin.domain_save'); // 添加
Route::post('/edit', [Aside\Domain\DomainInfoController::class, 'edit'])->name('admin.domain_edit'); // 编辑
Route::any('/delete', [Aside\Domain\DomainInfoController::class, 'delete'])->name('admin.domain_delete'); // 删除
Route::get('/delete_list', [Aside\Domain\DomainInfoController::class, 'delete_list'])->name('admin.domain_delete_list'); // 删除列表
Route::any('/restore', [Aside\Domain\DomainInfoController::class, 'restore'])->name('admin.domain_restore'); // 恢复
Route::get('/log', [Aside\Domain\DomainInfoLogController::class, 'lists'])->name('admin.domain_log_lists'); // 日志
});
//运维
Route::prefix('devops')->group(function () {
//服务器配置
... ... @@ -137,7 +150,6 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w
Route::get('/restore', [Aside\Devops\ServerInformationController::class, 'restore'])->name('admin.devops.bt_restore'); //恢复数据
Route::get('/log', [Aside\Devops\ServerInformationLogController::class, 'lists'])->name('admin.devops.bt_log_lists'); //日志列表
});
});
// 自定义页面 模板,头部底部
... ...