作者 zhl

Merge branch 'develop' of 47.244.231.31:zhl/globalso-v6 into develop

@@ -3,18 +3,9 @@ @@ -3,18 +3,9 @@
3 namespace App\Http\Controllers\Aside\Devops; 3 namespace App\Http\Controllers\Aside\Devops;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 -use App\Exceptions\AsideGlobalException;  
7 -use App\Exceptions\BsideGlobalException;  
8 use App\Http\Controllers\Aside\BaseController; 6 use App\Http\Controllers\Aside\BaseController;
9 -use App\Http\Logic\Aside\Devops\ServerInformationLogic;  
10 -use App\Http\Requests\Aside\Devops\ServerInformationRequest;  
11 -use App\Models\Devops\ServerInformation;  
12 use App\Models\Devops\ServerInformationLog; 7 use App\Models\Devops\ServerInformationLog;
13 -use Illuminate\Http\JsonResponse;  
14 use Illuminate\Http\Request; 8 use Illuminate\Http\Request;
15 -use Illuminate\Support\Facades\DB;  
16 -use Psr\Container\ContainerExceptionInterface;  
17 -use Psr\Container\NotFoundExceptionInterface;  
18 9
19 class ServerInformationLogController extends BaseController 10 class ServerInformationLogController extends BaseController
20 { 11 {
@@ -25,8 +25,6 @@ class ServerInformationLogic extends BaseLogic @@ -25,8 +25,6 @@ class ServerInformationLogic extends BaseLogic
25 { 25 {
26 parent::__construct(); 26 parent::__construct();
27 27
28 - $this->model = new ServerInformation();  
29 -  
30 $this->param = $this->requestAll; 28 $this->param = $this->requestAll;
31 29
32 } 30 }
@@ -41,23 +39,23 @@ class ServerInformationLogic extends BaseLogic @@ -41,23 +39,23 @@ class ServerInformationLogic extends BaseLogic
41 { 39 {
42 $request = $this->param ?? []; 40 $request = $this->param ?? [];
43 $service = new ServerInformation(); 41 $service = new ServerInformation();
44 - $this->extracted( $request, $service );  
45 - if ( $this->checkIp( $service->ip ) ) {  
46 - return $this->fail( '服务器信息添加失败,ip已存在' ); 42 + $this->extracted($request, $service);
  43 + if ($this->checkIp($request['ip'])) {
  44 + return $this->fail('服务器信息添加失败,ip已存在');
47 } 45 }
48 DB::beginTransaction(); 46 DB::beginTransaction();
49 47
50 - if ( $service->save() ) { 48 + if ($service->save()) {
51 $original = $service->getOriginal(); 49 $original = $service->getOriginal();
52 $original['type'] = $request['type']; 50 $original['type'] = $request['type'];
53 $original['belong_to'] = $request['belong_to']; 51 $original['belong_to'] = $request['belong_to'];
54 // 添加日志 52 // 添加日志
55 - $this->server_action_log( ServerInformationLog::ACTION_ADD, $original, $original, '添加服务器信息成功 - ID : ' . $service->id ); 53 + $this->server_action_log(ServerInformationLog::ACTION_ADD, $original, $original, '添加服务器信息成功 - ID : ' . $service->id);
56 DB::commit(); 54 DB::commit();
57 return $this->success(); 55 return $this->success();
58 } 56 }
59 DB::rollBack(); 57 DB::rollBack();
60 - return $this->fail( '服务器信息添加失败' ); 58 + return $this->fail('服务器信息添加失败');
61 59
62 } 60 }
63 61
@@ -73,49 +71,49 @@ class ServerInformationLogic extends BaseLogic @@ -73,49 +71,49 @@ class ServerInformationLogic extends BaseLogic
73 $fields_array = $service->FieldsArray(); 71 $fields_array = $service->FieldsArray();
74 $request = $this->param ?? []; 72 $request = $this->param ?? [];
75 $original = $service->getOriginal(); 73 $original = $service->getOriginal();
76 - $original['type'] = $service->ServiceStr( $original['type'] );  
77 - $original['belong_to'] = $service->BelongToStr( $original['belong_to'] );  
78 - $this->extracted( $request, $service, $original ); 74 + $original['type'] = $service->ServiceStr($original['type']);
  75 + $original['belong_to'] = $service->BelongToStr($original['belong_to']);
  76 + $this->extracted($request, $service, $original);
79 // 检查ip是否存在 77 // 检查ip是否存在
80 - if ( $service->ip != $request['ip'] ) {  
81 - if ( $this->checkIp( $request['ip'] ) ) {  
82 - $this->fail( '服务器信息修改失败,ip已存在', Code::USER_ERROR ); 78 + if ($service->ip != $request['ip']) {
  79 + if ($this->checkIp($request['ip'])) {
  80 + $this->fail('服务器信息修改失败,ip已存在', Code::USER_ERROR);
83 } 81 }
84 } 82 }
85 DB::beginTransaction(); 83 DB::beginTransaction();
86 - if ( $service->save() ) { 84 + if ($service->save()) {
87 $revised = $service->getAttributes(); 85 $revised = $service->getAttributes();
88 - $diff = array_diff_assoc( $original, $revised );  
89 - unset( $diff['created_at'] );  
90 - unset( $diff['updated_at'] );  
91 - unset( $diff['deleted'] ); 86 + $diff = array_diff_assoc($original, $revised);
  87 + unset($diff['created_at']);
  88 + unset($diff['updated_at']);
  89 + unset($diff['deleted']);
92 $remarks = ''; 90 $remarks = '';
93 - if ( $diff ) { 91 + if ($diff) {
94 $remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,修改内容为:'; 92 $remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,修改内容为:';
95 - foreach ( $diff as $key => $value ) { 93 + foreach ($diff as $key => $value) {
96 $remarks .= $fields_array[$key] . ' 由 ' . $value . ' 修改为 ' . $revised[$key] . '; '; 94 $remarks .= $fields_array[$key] . ' 由 ' . $value . ' 修改为 ' . $revised[$key] . '; ';
97 } 95 }
98 } else { 96 } else {
99 $remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,无修改'; 97 $remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,无修改';
100 } 98 }
101 // 添加日志 99 // 添加日志
102 - $this->server_action_log( ServerInformationLog::ACTION_UPDATE, $original, $revised, $remarks ); 100 + $this->server_action_log(ServerInformationLog::ACTION_UPDATE, $original, $revised, $remarks);
103 DB::commit(); 101 DB::commit();
104 return $this->success(); 102 return $this->success();
105 } 103 }
106 DB::rollBack(); 104 DB::rollBack();
107 - return $this->fail( '服务器信息修改失败' ); 105 + return $this->fail('服务器信息修改失败');
108 } 106 }
109 107
110 - public function getService( int $deleted = ServerInformation::DELETED_NORMAL ) 108 + public function getService(int $deleted = ServerInformation::DELETED_NORMAL)
111 { 109 {
112 $id = $this->param['id'] ?? 0; 110 $id = $this->param['id'] ?? 0;
113 - if ( !$id ) {  
114 - return $this->fail( 'ID不能为空' ); 111 + if (!$id) {
  112 + return $this->fail('ID不能为空');
115 } 113 }
116 - $data = ServerInformation::query()->where( 'deleted', $deleted )->find( $id );  
117 - if ( !$data ) {  
118 - return $this->fail( '数据不存在!' ); 114 + $data = ServerInformation::query()->where('deleted', $deleted)->find($id);
  115 + if (!$data) {
  116 + return $this->fail('数据不存在!');
119 } 117 }
120 return $data; 118 return $data;
121 } 119 }
@@ -125,10 +123,10 @@ class ServerInformationLogic extends BaseLogic @@ -125,10 +123,10 @@ class ServerInformationLogic extends BaseLogic
125 * @param $ip 123 * @param $ip
126 * @return bool 124 * @return bool
127 */ 125 */
128 - public function checkIp( $ip ) 126 + public function checkIp($ip)
129 { 127 {
130 - $usIp = ServerInformation::query()->where( 'ip', $ip )->first();  
131 - if ( $usIp ) { 128 + $usIp = ServerInformation::query()->where('ip', $ip)->first();
  129 + if ($usIp) {
132 return true; 130 return true;
133 } else { 131 } else {
134 return false; 132 return false;
@@ -142,15 +140,15 @@ class ServerInformationLogic extends BaseLogic @@ -142,15 +140,15 @@ class ServerInformationLogic extends BaseLogic
142 * @throws AsideGlobalException 140 * @throws AsideGlobalException
143 * @throws BsideGlobalException 141 * @throws BsideGlobalException
144 */ 142 */
145 - public function serverInfo( int $deleted = ServerInformation::DELETED_NORMAL ) 143 + public function serverInfo(int $deleted = ServerInformation::DELETED_NORMAL)
146 { 144 {
147 $id = $this->param['id'] ?? 0; 145 $id = $this->param['id'] ?? 0;
148 - if ( !$id ) {  
149 - return $this->fail( 'ID不能为空' ); 146 + if (!$id) {
  147 + return $this->fail('ID不能为空');
150 } 148 }
151 - $data = ServerInformation::query()->where( 'deleted', $deleted )->find( $id, [ 'type', 'ip', 'title', 'belong_to', 'ports', 'created_at', 'updated_at' ] );  
152 - if ( !$data ) {  
153 - return $this->fail( '数据不存在!' ); 149 + $data = ServerInformation::query()->where('deleted', $deleted)->find($id, ['type', 'ip', 'title', 'belong_to', 'ports', 'created_at', 'updated_at']);
  150 + if (!$data) {
  151 + return $this->fail('数据不存在!');
154 } 152 }
155 return $data; 153 return $data;
156 } 154 }
@@ -161,10 +159,10 @@ class ServerInformationLogic extends BaseLogic @@ -161,10 +159,10 @@ class ServerInformationLogic extends BaseLogic
161 * @param array $original 原始数据 159 * @param array $original 原始数据
162 * @param array $revised 修改后数据 160 * @param array $revised 修改后数据
163 */ 161 */
164 - public function server_action_log( int $action = ServerInformationLog::ACTION_ADD, array $original = [], array $revised = [], $remarks = '' ) 162 + public function server_action_log(int $action = ServerInformationLog::ACTION_ADD, array $original = [], array $revised = [], $remarks = '')
165 { 163 {
166 $log = new ServerInformationLog(); 164 $log = new ServerInformationLog();
167 - $this->log( $log, $action, $original, $revised, $remarks ); 165 + $this->log($log, $action, $original, $revised, $remarks);
168 } 166 }
169 167
170 /** 168 /**
@@ -172,14 +170,14 @@ class ServerInformationLogic extends BaseLogic @@ -172,14 +170,14 @@ class ServerInformationLogic extends BaseLogic
172 * @param $service 170 * @param $service
173 * @return void 171 * @return void
174 */ 172 */
175 - public function extracted( array $request, $service, array $original = [] ) 173 + public function extracted(array $request, $service, array $original = [])
176 { 174 {
177 - $service->type = trim( $request['type'] ) ?? $original['type']; // 服务器类型  
178 - $service->ip = trim( $request['ip'] ) ?? $original['ip']; // 服务器ip  
179 - $service->title = trim( $request['title'] ) ?? $original['title']; // 服务器标题  
180 - $service->belong_to = trim( $request['belong_to'] ) ?? $original['belong_to']; // 服务器归属  
181 - $service->sshpass = trim( $request['sshpass'] ) ?? $original['sshpass']; // ssh密码  
182 - $service->ports = trim( $request['ports'] ) ?? $original['ports']; // ssh端口 175 + $service->type = trim($request['type']) ?? $original['type']; // 服务器类型
  176 + $service->ip = trim($request['ip']) ?? $original['ip']; // 服务器ip
  177 + $service->title = trim($request['title']) ?? $original['title']; // 服务器标题
  178 + $service->belong_to = trim($request['belong_to']) ?? $original['belong_to']; // 服务器归属
  179 + $service->sshpass = trim($request['sshpass']) ?? $original['sshpass']; // ssh密码
  180 + $service->ports = trim($request['ports']) ?? $original['ports']; // ssh端口
183 } 181 }
184 182
185 /** 183 /**
@@ -188,27 +186,27 @@ class ServerInformationLogic extends BaseLogic @@ -188,27 +186,27 @@ class ServerInformationLogic extends BaseLogic
188 * @throws AsideGlobalException 186 * @throws AsideGlobalException
189 * @throws BsideGlobalException 187 * @throws BsideGlobalException
190 */ 188 */
191 - public function get_batch_update( $action = ServerInformationLog::ACTION_DELETE, $deleted = ServerInformation::DELETED_NORMAL ) 189 + public function get_batch_update($action = ServerInformationLog::ACTION_DELETE, $deleted = ServerInformation::DELETED_NORMAL)
192 { 190 {
193 $ids = $this->getIds(); 191 $ids = $this->getIds();
194 - $data = ServerInformation::query()->whereIn( 'id', $ids )->where( 'deleted', $deleted )->get();  
195 - $restore_ids = $data->pluck( 'id' )->toArray(); 192 + $data = ServerInformation::query()->whereIn('id', $ids)->where('deleted', $deleted)->get();
  193 + $restore_ids = $data->pluck('id')->toArray();
196 $actionArr = ServerInformationLog::actionArr(); 194 $actionArr = ServerInformationLog::actionArr();
197 $actionStr = $actionArr[$action]; 195 $actionStr = $actionArr[$action];
198 - if ( empty( $restore_ids ) ) {  
199 - $this->fail( $actionStr . '服务器信息不存在!', Code::USER_ERROR ); 196 + if (empty($restore_ids)) {
  197 + $this->fail($actionStr . '服务器信息不存在!', Code::USER_ERROR);
200 } 198 }
201 $original = $data->toArray(); 199 $original = $data->toArray();
202 DB::beginTransaction(); 200 DB::beginTransaction();
203 try { 201 try {
204 $update = $deleted == ServerInformation::DELETED_NORMAL ? ServerInformation::DELETED_DELETE : ServerInformation::DELETED_NORMAL; 202 $update = $deleted == ServerInformation::DELETED_NORMAL ? ServerInformation::DELETED_DELETE : ServerInformation::DELETED_NORMAL;
205 - ServerInformation::query()->whereIn( 'id', $restore_ids )->update( [ 'deleted' => $update ] );  
206 - $this->server_action_log( $action, $original, $original, $actionStr . '服务器信息 - ID : ' . implode( ', ', $restore_ids ) ); 203 + ServerInformation::query()->whereIn('id', $restore_ids)->update(['deleted' => $update]);
  204 + $this->server_action_log($action, $original, $original, $actionStr . '服务器信息 - ID : ' . implode(', ', $restore_ids));
207 DB::commit(); 205 DB::commit();
208 return $this->success(); 206 return $this->success();
209 - } catch ( \Exception $e ) { 207 + } catch (\Exception $e) {
210 DB::rollBack(); 208 DB::rollBack();
211 - return $this->fail( '服务器信息' . $actionStr . '失败', Code::USER_ERROR ); 209 + return $this->fail('服务器信息' . $actionStr . '失败', Code::USER_ERROR);
212 } 210 }
213 } 211 }
214 212
@@ -221,16 +219,16 @@ class ServerInformationLogic extends BaseLogic @@ -221,16 +219,16 @@ class ServerInformationLogic extends BaseLogic
221 public function getIds() 219 public function getIds()
222 { 220 {
223 $id = $this->param['id'] ?? 0; 221 $id = $this->param['id'] ?? 0;
224 - if ( !$id ) {  
225 - return $this->fail( '参数错误' ); 222 + if (!$id) {
  223 + return $this->fail('参数错误');
226 } 224 }
227 $ids = []; 225 $ids = [];
228 - if ( !is_array( $id ) ) {  
229 - $ids = explode( ',', $id ); 226 + if (!is_array($id)) {
  227 + $ids = explode(',', $id);
230 } 228 }
231 - $ids = array_filter( $ids, 'intval' );  
232 - if ( empty( $ids ) ) {  
233 - return $this->fail( '参数错误' ); 229 + $ids = array_filter($ids, 'intval');
  230 + if (empty($ids)) {
  231 + return $this->fail('参数错误');
234 } 232 }
235 return $ids; 233 return $ids;
236 } 234 }
@@ -182,12 +182,9 @@ class DomainInfoLogic extends BaseLogic @@ -182,12 +182,9 @@ class DomainInfoLogic extends BaseLogic
182 * @throws AsideGlobalException 182 * @throws AsideGlobalException
183 * @throws BsideGlobalException 183 * @throws BsideGlobalException
184 */ 184 */
185 - public function extracted( array $request, $domain, array $original = []) 185 + public function extracted(array $request, $domain, array $original = [])
186 { 186 {
187 $domain->domain = trim($request['domain']) ?? $original['domain']; 187 $domain->domain = trim($request['domain']) ?? $original['domain'];
188 - if (!$this->validateDomain($domain->domain)) {  
189 - $this->fail('域名格式错误');  
190 - }  
191 $domain->belong_to = trim($request['belong_to']) ?? $original['belong_to']; // 域名归属 1 - 公司 2 - 客户 188 $domain->belong_to = trim($request['belong_to']) ?? $original['belong_to']; // 域名归属 1 - 公司 2 - 客户
192 $domain->status = trim($request['status']) ?? $original['status']; // 域名状态 0 - 正常 1 - 关闭 189 $domain->status = trim($request['status']) ?? $original['status']; // 域名状态 0 - 正常 1 - 关闭
193 $domain->domain_start_time = trim($request['domain_start_time']) ?? $original['domain_start_time']; // 域名开始时间 190 $domain->domain_start_time = trim($request['domain_start_time']) ?? $original['domain_start_time']; // 域名开始时间
@@ -280,36 +277,6 @@ class DomainInfoLogic extends BaseLogic @@ -280,36 +277,6 @@ class DomainInfoLogic extends BaseLogic
280 } 277 }
281 278
282 /** 279 /**
283 - * 验证给定的值是否是有效的域名。  
284 - *  
285 - * @param mixed $value  
286 - * @return bool  
287 - */  
288 - public function validateDomain($value)  
289 - {  
290 - // 从域中删除任何空间或路径。  
291 - $domain = preg_replace('/\s|\/.*$/', '', $value);  
292 - // 验证域是否至少包含一个句点。  
293 - if (strpos($domain, '.') === false) {  
294 - return false;  
295 - }  
296 - // 验证域是否以句点开始或结束。  
297 - if (strpos($domain, '.') === 0 || strrpos($domain, '.') === strlen($domain) - 1) {  
298 - return false;  
299 - }  
300 - // 验证域是否不包含无效字符。  
301 - if (!preg_match('/^[a-zA-Z0-9\-\.]+$/', $domain)) {  
302 - return false;  
303 - }  
304 - // 验证域是否具有有效的顶级域。  
305 - $tld = substr($domain, strrpos($domain, '.') + 1);  
306 - if (!in_array($tld, ['com', 'net', 'org'])) { // 如有必要,添加更多TLD。  
307 - return false;  
308 - }  
309 - return true;  
310 - }  
311 -  
312 - /**  
313 * 根据域名更新证书到期时间 280 * 根据域名更新证书到期时间
314 * @param $id 281 * @param $id
315 * @param $updata 282 * @param $updata
@@ -16,9 +16,16 @@ class EnableCrossRequestMiddleware @@ -16,9 +16,16 @@ class EnableCrossRequestMiddleware
16 public function handle($request, Closure $next) 16 public function handle($request, Closure $next)
17 { 17 {
18 $response = $next($request); 18 $response = $next($request);
19 - $response->header('Access-Control-Allow-Origin', '*'); 19 + $http_origin = "*";
  20 + if(isset($_SERVER['HTTP_ORIGIN'])){
  21 + $http_origin = $_SERVER['HTTP_ORIGIN'];
  22 + }
  23 + $response->header('Access-Control-Allow-Origin', $http_origin);
20 $response->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS'); 24 $response->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
21 $response->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Authorization'); 25 $response->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Authorization');
  26 + if (strtolower($_SERVER['REQUEST_METHOD']) == 'options') {
  27 + exit;
  28 + }
22 return $response; 29 return $response;
23 // 指定允许其他域名访问 30 // 指定允许其他域名访问
24 // $http_origin = "*"; 31 // $http_origin = "*";
@@ -4,6 +4,7 @@ namespace App\Http\Requests\Aside\Domain; @@ -4,6 +4,7 @@ namespace App\Http\Requests\Aside\Domain;
4 4
5 use App\Models\Aside\Domain\DomainInfo; 5 use App\Models\Aside\Domain\DomainInfo;
6 use Illuminate\Foundation\Http\FormRequest; 6 use Illuminate\Foundation\Http\FormRequest;
  7 +use Illuminate\Support\Facades\Validator;
7 use Illuminate\Validation\Rule; 8 use Illuminate\Validation\Rule;
8 9
9 class DomainInfoRequest extends FormRequest 10 class DomainInfoRequest extends FormRequest
@@ -25,11 +26,14 @@ class DomainInfoRequest extends FormRequest @@ -25,11 +26,14 @@ class DomainInfoRequest extends FormRequest
25 */ 26 */
26 public function rules() 27 public function rules()
27 { 28 {
  29 + Validator::extend('validate_domain', function ($attribute, $value, $parameters, $validator) {
  30 + return $this->validateDomain($value);
  31 + });
28 $domain = new DomainInfo(); 32 $domain = new DomainInfo();
29 $status_tot_keys = array_keys($domain->StatusToArray()); 33 $status_tot_keys = array_keys($domain->StatusToArray());
30 $belong_to_keys = array_keys($domain->BelongToArray()); 34 $belong_to_keys = array_keys($domain->BelongToArray());
31 return [ 35 return [
32 - 'domain' => 'required|max:200', 36 + 'domain' => 'required|max:200|validate_domain',
33 'belong_to' => [ 37 'belong_to' => [
34 'required', 38 'required',
35 Rule::in($belong_to_keys) 39 Rule::in($belong_to_keys)
@@ -41,11 +45,42 @@ class DomainInfoRequest extends FormRequest @@ -41,11 +45,42 @@ class DomainInfoRequest extends FormRequest
41 ]; 45 ];
42 } 46 }
43 47
  48 + /**
  49 + * 验证给定的值是否是有效的域名。
  50 + *
  51 + * @param mixed $value
  52 + * @return bool
  53 + */
  54 + public function validateDomain($value)
  55 + {
  56 + // 从域中删除任何空间或路径。
  57 + $domain = preg_replace('/\s|\/.*$/', '', $value);
  58 + // 验证域是否至少包含一个句点。
  59 + if (strpos($domain, '.') === false) {
  60 + return false;
  61 + }
  62 + // 验证域是否以句点开始或结束。
  63 + if (strpos($domain, '.') === 0 || strrpos($domain, '.') === strlen($domain) - 1) {
  64 + return false;
  65 + }
  66 + // 验证域是否不包含无效字符。
  67 + if (!preg_match('/^[a-zA-Z0-9\-\.]+$/', $domain)) {
  68 + return false;
  69 + }
  70 + // 验证域是否具有有效的顶级域。
  71 + $tld = substr($domain, strrpos($domain, '.') + 1);
  72 + if (!in_array($tld, ['com', 'net', 'org'])) { // 如有必要,添加更多TLD。
  73 + return false;
  74 + }
  75 + return true;
  76 + }
  77 +
44 public function messages() 78 public function messages()
45 { 79 {
46 return [ 80 return [
47 'domain.required' => '域名不能为空', 81 'domain.required' => '域名不能为空',
48 'domain.max' => '域名长度不能超过200个字符', 82 'domain.max' => '域名长度不能超过200个字符',
  83 + 'domain.validate_domain' => '域名格式不正确',
49 'belong_to.required' => '域名所属不能为空', 84 'belong_to.required' => '域名所属不能为空',
50 'belong_to.in' => '域名所属参数错误', 85 'belong_to.in' => '域名所属参数错误',
51 'status.required' => '域名状态不能为空', 86 'status.required' => '域名状态不能为空',
@@ -2,9 +2,9 @@ @@ -2,9 +2,9 @@
2 2
3 namespace App\Models\Devops; 3 namespace App\Models\Devops;
4 4
5 -use Illuminate\Database\Eloquent\Model; 5 +use App\Models\Base;
6 6
7 -class ServerInformation extends Model 7 +class ServerInformation extends Base
8 { 8 {
9 9
10 protected $table = 'gl_server_information'; 10 protected $table = 'gl_server_information';
@@ -2,9 +2,9 @@ @@ -2,9 +2,9 @@
2 2
3 namespace App\Models\Devops; 3 namespace App\Models\Devops;
4 4
5 -use Illuminate\Database\Eloquent\Model; 5 +use App\Models\Base;
6 6
7 -class ServerInformationLog extends Model 7 +class ServerInformationLog extends Base
8 { 8 {
9 protected $table = 'gl_server_information_log'; 9 protected $table = 'gl_server_information_log';
10 10
@@ -68,16 +68,15 @@ class User extends Base @@ -68,16 +68,15 @@ class User extends Base
68 //TODO::验证验证码是否正确 68 //TODO::验证验证码是否正确
69 $info = $this->read(['mobile'=>$param['mobile']],['*']); 69 $info = $this->read(['mobile'=>$param['mobile']],['*']);
70 } 70 }
71 - if(empty($info)){ 71 + if($info === false){
72 return false; 72 return false;
73 } 73 }
74 //当前用户角色是否被禁用 74 //当前用户角色是否被禁用
75 $projectRoleModel = new ProjectRoleModel(); 75 $projectRoleModel = new ProjectRoleModel();
76 $role_info = $projectRoleModel->read(['id'=>$info['role_id'],'status'=>0]); 76 $role_info = $projectRoleModel->read(['id'=>$info['role_id'],'status'=>0]);
77 - if(empty($role_info)){ 77 + if($role_info === false){
78 return false; 78 return false;
79 } 79 }
80 - //验证码登录  
81 if(isset($info['token']) && !empty($info['token'])){ 80 if(isset($info['token']) && !empty($info['token'])){
82 //清除上一次用户缓存 81 //清除上一次用户缓存
83 Cache::pull($info['token']); 82 Cache::pull($info['token']);