Commit d2370688 by lzzzzl

增加日志功能

parent 7b38f176
...@@ -3,11 +3,6 @@ ...@@ -3,11 +3,6 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="77000b58-e61d-499b-a063-4fbd5e5111a8" name="Default" comment=""> <list default="true" id="77000b58-e61d-499b-a063-4fbd5e5111a8" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change beforePath="$PROJECT_DIR$/app/Http/Controllers/AccessController.php" afterPath="$PROJECT_DIR$/app/Http/Controllers/AccessController.php" />
<change beforePath="$PROJECT_DIR$/app/Model/DataManageModel.php" afterPath="" />
<change beforePath="$PROJECT_DIR$/app/Model/SpiderModel.php" afterPath="$PROJECT_DIR$/app/Model/SpiderModel.php" />
<change beforePath="$PROJECT_DIR$/public/js/spider/addboard.js" afterPath="$PROJECT_DIR$/public/js/spider/addboard.js" />
<change beforePath="$PROJECT_DIR$/resources/views/spider/addboard.blade.php" afterPath="$PROJECT_DIR$/resources/views/spider/addboard.blade.php" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" /> <option name="TRACKING_ENABLED" value="true" />
...@@ -25,7 +20,7 @@ ...@@ -25,7 +20,7 @@
<entry file="file://$PROJECT_DIR$/public/js/spider/addboard.js"> <entry file="file://$PROJECT_DIR$/public/js/spider/addboard.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="396"> <state relative-caret-position="396">
<caret line="12" column="22" lean-forward="true" selection-start-line="12" selection-start-column="22" selection-end-line="12" selection-end-column="22" /> <caret line="12" column="22" lean-forward="false" selection-start-line="12" selection-start-column="22" selection-end-line="12" selection-end-column="22" />
<folding /> <folding />
</state> </state>
</provider> </provider>
...@@ -37,7 +32,6 @@ ...@@ -37,7 +32,6 @@
<state relative-caret-position="66"> <state relative-caret-position="66">
<caret line="2" column="0" lean-forward="false" selection-start-line="2" selection-start-column="0" selection-end-line="7" selection-end-column="14" /> <caret line="2" column="0" lean-forward="false" selection-start-line="2" selection-start-column="0" selection-end-line="7" selection-end-column="14" />
<folding> <folding>
<element signature="n#style#0;n#input#0;n#div#0;n#div#4;n#form#0;n#!!top" expanded="true" />
<marker date="1564989176329" expanded="true" signature="1900:1905" ph="..." /> <marker date="1564989176329" expanded="true" signature="1900:1905" ph="..." />
</folding> </folding>
</state> </state>
...@@ -47,7 +41,7 @@ ...@@ -47,7 +41,7 @@
<file leaf-file-name="AccessController.php" pinned="false" current-in-tab="false"> <file leaf-file-name="AccessController.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/Http/Controllers/AccessController.php"> <entry file="file://$PROJECT_DIR$/app/Http/Controllers/AccessController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="682"> <state relative-caret-position="8778">
<caret line="305" column="44" lean-forward="false" selection-start-line="305" selection-start-column="44" selection-end-line="305" selection-end-column="44" /> <caret line="305" column="44" lean-forward="false" selection-start-line="305" selection-start-column="44" selection-end-line="305" selection-end-column="44" />
<folding /> <folding />
</state> </state>
...@@ -57,7 +51,7 @@ ...@@ -57,7 +51,7 @@
<file leaf-file-name="SpiderModel.php" pinned="false" current-in-tab="true"> <file leaf-file-name="SpiderModel.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/app/Model/SpiderModel.php"> <entry file="file://$PROJECT_DIR$/app/Model/SpiderModel.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="429"> <state relative-caret-position="33">
<caret line="72" column="0" lean-forward="false" selection-start-line="72" selection-start-column="0" selection-end-line="72" selection-end-column="0" /> <caret line="72" column="0" lean-forward="false" selection-start-line="72" selection-start-column="0" selection-end-line="72" selection-end-column="0" />
<folding /> <folding />
</state> </state>
...@@ -67,7 +61,7 @@ ...@@ -67,7 +61,7 @@
<file leaf-file-name="AccessApiController.php" pinned="false" current-in-tab="false"> <file leaf-file-name="AccessApiController.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/Http/Controllers/AccessApiController.php"> <entry file="file://$PROJECT_DIR$/app/Http/Controllers/AccessApiController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="461"> <state relative-caret-position="3234">
<caret line="103" column="50" lean-forward="false" selection-start-line="103" selection-start-column="37" selection-end-line="103" selection-end-column="50" /> <caret line="103" column="50" lean-forward="false" selection-start-line="103" selection-start-column="37" selection-end-line="103" selection-end-column="50" />
<folding /> <folding />
</state> </state>
...@@ -602,11 +596,12 @@ ...@@ -602,11 +596,12 @@
<workItem from="1564561312310" duration="5174000" /> <workItem from="1564561312310" duration="5174000" />
<workItem from="1564712055483" duration="3361000" /> <workItem from="1564712055483" duration="3361000" />
<workItem from="1564987926206" duration="1405000" /> <workItem from="1564987926206" duration="1405000" />
<workItem from="1564990438833" duration="273000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="1846999000" /> <option name="totallyTimeSpent" value="1847272000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="-11" y="-11" width="2278" height="1466" extended-state="6" /> <frame x="-11" y="-11" width="2278" height="1466" extended-state="6" />
...@@ -872,7 +867,6 @@ ...@@ -872,7 +867,6 @@
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="264"> <state relative-caret-position="264">
<caret line="8" column="26" lean-forward="false" selection-start-line="8" selection-start-column="20" selection-end-line="8" selection-end-column="26" /> <caret line="8" column="26" lean-forward="false" selection-start-line="8" selection-start-column="20" selection-end-line="8" selection-end-column="26" />
<folding />
</state> </state>
</provider> </provider>
</entry> </entry>
...@@ -880,7 +874,6 @@ ...@@ -880,7 +874,6 @@
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="660"> <state relative-caret-position="660">
<caret line="20" column="36" lean-forward="false" selection-start-line="20" selection-start-column="36" selection-end-line="20" selection-end-column="36" /> <caret line="20" column="36" lean-forward="false" selection-start-line="20" selection-start-column="36" selection-end-line="20" selection-end-column="36" />
<folding />
</state> </state>
</provider> </provider>
</entry> </entry>
...@@ -896,7 +889,6 @@ ...@@ -896,7 +889,6 @@
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="441"> <state relative-caret-position="441">
<caret line="22" column="0" lean-forward="false" selection-start-line="22" selection-start-column="0" selection-end-line="22" selection-end-column="0" /> <caret line="22" column="0" lean-forward="false" selection-start-line="22" selection-start-column="0" selection-end-line="22" selection-end-column="0" />
<folding />
</state> </state>
</provider> </provider>
</entry> </entry>
...@@ -904,25 +896,14 @@ ...@@ -904,25 +896,14 @@
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="33"> <state relative-caret-position="33">
<caret line="113" column="56" lean-forward="false" selection-start-line="112" selection-start-column="32" selection-end-line="113" selection-end-column="56" /> <caret line="113" column="56" lean-forward="false" selection-start-line="112" selection-start-column="32" selection-end-line="113" selection-end-column="56" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/Model/DataManageModel.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="395">
<caret line="98" column="33" lean-forward="false" selection-start-line="98" selection-start-column="20" selection-end-line="98" selection-end-column="33" />
<folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/app/Model/DataManageModel.php" />
<entry file="file://$PROJECT_DIR$/resources/views/spider/board.blade.php"> <entry file="file://$PROJECT_DIR$/resources/views/spider/board.blade.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="222"> <state relative-caret-position="222">
<caret line="13" column="124" lean-forward="false" selection-start-line="13" selection-start-column="110" selection-end-line="13" selection-end-column="124" /> <caret line="13" column="124" lean-forward="false" selection-start-line="13" selection-start-column="110" selection-end-line="13" selection-end-column="124" />
<folding>
<marker date="1564713465742" expanded="true" signature="734:753" ph="..." />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
...@@ -930,19 +911,12 @@ ...@@ -930,19 +911,12 @@
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="484"> <state relative-caret-position="484">
<caret line="19" column="89" lean-forward="false" selection-start-line="19" selection-start-column="55" selection-end-line="19" selection-end-column="89" /> <caret line="19" column="89" lean-forward="false" selection-start-line="19" selection-start-column="55" selection-end-line="19" selection-end-column="89" />
<folding>
<marker date="1564563710804" expanded="true" signature="135:146" ph="..." />
<marker date="1564563710804" expanded="true" signature="406:431" ph="..." />
<marker date="1564563710804" expanded="true" signature="743:771" ph="..." />
<marker date="1564563710804" expanded="true" signature="1046:1068" ph="..." />
<marker date="1564563710804" expanded="true" signature="1353:1379" ph="..." />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/app/Http/Controllers/AccessController.php"> <entry file="file://$PROJECT_DIR$/app/Http/Controllers/AccessController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="682"> <state relative-caret-position="8778">
<caret line="305" column="44" lean-forward="false" selection-start-line="305" selection-start-column="44" selection-end-line="305" selection-end-column="44" /> <caret line="305" column="44" lean-forward="false" selection-start-line="305" selection-start-column="44" selection-end-line="305" selection-end-column="44" />
<folding /> <folding />
</state> </state>
...@@ -950,7 +924,7 @@ ...@@ -950,7 +924,7 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/app/Http/Controllers/AccessApiController.php"> <entry file="file://$PROJECT_DIR$/app/Http/Controllers/AccessApiController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="461"> <state relative-caret-position="3234">
<caret line="103" column="50" lean-forward="false" selection-start-line="103" selection-start-column="37" selection-end-line="103" selection-end-column="50" /> <caret line="103" column="50" lean-forward="false" selection-start-line="103" selection-start-column="37" selection-end-line="103" selection-end-column="50" />
<folding /> <folding />
</state> </state>
...@@ -961,7 +935,6 @@ ...@@ -961,7 +935,6 @@
<state relative-caret-position="66"> <state relative-caret-position="66">
<caret line="2" column="0" lean-forward="false" selection-start-line="2" selection-start-column="0" selection-end-line="7" selection-end-column="14" /> <caret line="2" column="0" lean-forward="false" selection-start-line="2" selection-start-column="0" selection-end-line="7" selection-end-column="14" />
<folding> <folding>
<element signature="n#style#0;n#input#0;n#div#0;n#div#4;n#form#0;n#!!top" expanded="true" />
<marker date="1564989176329" expanded="true" signature="1900:1905" ph="..." /> <marker date="1564989176329" expanded="true" signature="1900:1905" ph="..." />
</folding> </folding>
</state> </state>
...@@ -970,14 +943,14 @@ ...@@ -970,14 +943,14 @@
<entry file="file://$PROJECT_DIR$/public/js/spider/addboard.js"> <entry file="file://$PROJECT_DIR$/public/js/spider/addboard.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="396"> <state relative-caret-position="396">
<caret line="12" column="22" lean-forward="true" selection-start-line="12" selection-start-column="22" selection-end-line="12" selection-end-column="22" /> <caret line="12" column="22" lean-forward="false" selection-start-line="12" selection-start-column="22" selection-end-line="12" selection-end-column="22" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/app/Model/SpiderModel.php"> <entry file="file://$PROJECT_DIR$/app/Model/SpiderModel.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="429"> <state relative-caret-position="33">
<caret line="72" column="0" lean-forward="false" selection-start-line="72" selection-start-column="0" selection-end-line="72" selection-end-column="0" /> <caret line="72" column="0" lean-forward="false" selection-start-line="72" selection-start-column="0" selection-end-line="72" selection-end-column="0" />
<folding /> <folding />
</state> </state>
......
...@@ -69,9 +69,10 @@ class AccessApiController extends Controller ...@@ -69,9 +69,10 @@ class AccessApiController extends Controller
/** /**
* 更新开始结束状态 * 更新开始结束状态
*/ */
private function ApiUpdateStatus() { private function ApiUpdateStatus($request) {
$data = (new SpiderModel())->updateStatus(); $user_id = $request->user->userId;
$data = (new SpiderModel())->updateStatus($user_id);
$this->Export($data); $this->Export($data);
} }
...@@ -79,9 +80,10 @@ class AccessApiController extends Controller ...@@ -79,9 +80,10 @@ class AccessApiController extends Controller
/** /**
* 更新手动推送 * 更新手动推送
*/ */
private function ApiUpdateManualPush() { private function ApiUpdateManualPush($request) {
$data = (new DataManageModel())->updateManualPush(); $user_id = $request->user->userId;
$data = (new DataManageModel())->updateManualPush($user_id);
$this->Export($data); $this->Export($data);
} }
...@@ -89,9 +91,10 @@ class AccessApiController extends Controller ...@@ -89,9 +91,10 @@ class AccessApiController extends Controller
/** /**
* 更新编辑内容 * 更新编辑内容
*/ */
private function ApiConfigContent() { private function ApiConfigContent($request) {
$data = (new SpiderModel())->updateContent(); $user_id = $request->user->userId;
$data = (new SpiderModel())->updateContent($user_id);
$this->Export($data); $this->Export($data);
} }
...@@ -99,9 +102,10 @@ class AccessApiController extends Controller ...@@ -99,9 +102,10 @@ class AccessApiController extends Controller
/** /**
* 插入新增内容 * 插入新增内容
*/ */
private function ApiAddConfig() { private function ApiAddConfig($request) {
$data = (new SpiderModel())->insertContent(); $user_id = $request->user->userId;
$data = (new SpiderModel())->insertContent($user_id);
$this->Export($data); $this->Export($data);
} }
...@@ -109,9 +113,10 @@ class AccessApiController extends Controller ...@@ -109,9 +113,10 @@ class AccessApiController extends Controller
/** /**
* 更新节点信息 * 更新节点信息
*/ */
private function ApiUpdateNode() { private function ApiUpdateNode($request) {
$data = (new SpiderModel())->updateNode(); $user_id = $request->user->userId;
$data = (new SpiderModel())->updateNode($user_id);
$this->Export($data); $this->Export($data);
} }
...@@ -119,9 +124,10 @@ class AccessApiController extends Controller ...@@ -119,9 +124,10 @@ class AccessApiController extends Controller
/** /**
* 更新所有节点信息 * 更新所有节点信息
*/ */
private function ApiUpdateAllNode() { private function ApiUpdateAllNode($request) {
$data = (new SpiderModel())->updateAllNode(); $user_id = $request->user->userId;
$data = (new SpiderModel())->updateAllNode($user_id);
$this->Export($data); $this->Export($data);
} }
...@@ -129,11 +135,25 @@ class AccessApiController extends Controller ...@@ -129,11 +135,25 @@ class AccessApiController extends Controller
/** /**
* 更新所有面板状态 * 更新所有面板状态
*/ */
private function ApiUpdateAllBoard() { private function ApiUpdateAllBoard($request) {
$data = (new SpiderModel())->updateAllBoard(); $user_id = $request->user->userId;
$data = (new SpiderModel())->updateAllBoard($user_id);
$this->Export($data); $this->Export($data);
} }
private function ApiLogsList($request) {
$limit = $request['limit'];
$p = $request['p'];
$start_time = empty($request['start_time']) ? date("Y-m-d",strtotime("-1 day")) : $request['start_time'];
$end_time = empty($request['end_time']) ? date("Y-m-d") : $request['end_time'];
$user_id = $request['user_id'];
$data = (new SpiderModel())->logsList($limit, $p, $start_time, $end_time, $user_id);
$this->ExportLayui(0,'成功',$data['data'],$data['total']);
}
} }
...@@ -358,4 +358,16 @@ class AccessController extends Controller ...@@ -358,4 +358,16 @@ class AccessController extends Controller
return view('spiderwindow', $data); return view('spiderwindow', $data);
} }
/**
* 操作日志
* @param $request
* @param $data
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function logs($request, $data, $id) {
$data['title'] = '操作日志';
return view('spider', $data);
}
} }
...@@ -48,17 +48,21 @@ class SpiderModel extends Model ...@@ -48,17 +48,21 @@ class SpiderModel extends Model
* 更新状态 * 更新状态
* @return array * @return array
*/ */
public function updateStatus() { public function updateStatus($user_id) {
$collect = Request::all(); $collect = Request::all();
$map['id'] = !empty($collect['id']) ? $collect['id'] : ''; $map['id'] = !empty($collect['id']) ? $collect['id'] : '';
$collect = TrimX($collect, false, ['status']); $collect = TrimX($collect, false, ['status']);
$result = $this->where($map)->update($collect); $result = $this->where($map)->update($collect);
if ($result) { if ($result) {
return [0,'成功']; $re = [0,'成功'];
$re_log = ['result' => 'true'];
} else { } else {
return [1,'失败']; $re = [1,'失败'];
$re_log = ['result' => 'false'];
} }
$this->writeLog($user_id, '更新状态', json_encode(['status' => $collect['status']]), json_encode($re_log));
return $re;
} }
...@@ -66,13 +70,14 @@ class SpiderModel extends Model ...@@ -66,13 +70,14 @@ class SpiderModel extends Model
* 插入内容 * 插入内容
* @return mixed * @return mixed
*/ */
public function insertContent() { public function insertContent($user_id) {
$collect = Request::all(); $collect = Request::all();
$collect['start_time'] = strtotime($collect['start_time']); $collect['start_time'] = strtotime($collect['start_time']);
unset($collect['s']); unset($collect['s']);
$return = $this->insert($collect);
return $this->insert($collect); $return = $this->writeLog($user_id, '插入新任务', json_encode($collect), json_encode(['result' => $return]));
return $return;
} }
...@@ -80,7 +85,7 @@ class SpiderModel extends Model ...@@ -80,7 +85,7 @@ class SpiderModel extends Model
* 更新内容 * 更新内容
* @return array * @return array
*/ */
public function updateContent() { public function updateContent($user_id) {
$collect = Request::all(); $collect = Request::all();
$map['id'] = !empty($collect['id']) ? $collect['id'] : 0; $map['id'] = !empty($collect['id']) ? $collect['id'] : 0;
...@@ -93,11 +98,16 @@ class SpiderModel extends Model ...@@ -93,11 +98,16 @@ class SpiderModel extends Model
$result = $this->where($map)->update($collect); $result = $this->where($map)->update($collect);
if ($result) { if ($result) {
return [0,'成功']; $re = [0,'成功'];
$re_log = ['result' => 'true'];
} else { } else {
return [1,'失败']; $re = [1,'失败'];
$re_log = ['result' => 'false'];
} }
$this->writeLog($user_id, '更新内容', json_encode($collect), json_encode($re_log));
return $re;
} }
/** /**
...@@ -166,7 +176,7 @@ class SpiderModel extends Model ...@@ -166,7 +176,7 @@ class SpiderModel extends Model
* 更新节点 * 更新节点
* @return array * @return array
*/ */
public function updateNode() { public function updateNode($user_id) {
$collect = Request::all(); $collect = Request::all();
$map['id'] = !empty($collect['id']) ? $collect['id'] : 0; $map['id'] = !empty($collect['id']) ? $collect['id'] : 0;
...@@ -176,10 +186,15 @@ class SpiderModel extends Model ...@@ -176,10 +186,15 @@ class SpiderModel extends Model
$result = DB::connection('dashboard')->table('spider_node')->where($map)->update($collect); $result = DB::connection('dashboard')->table('spider_node')->where($map)->update($collect);
if ($result) { if ($result) {
return [0,'成功']; $re = [0,'成功'];
$re_log = ['result' => 'true'];
} else { } else {
return [1,'失败']; $re = [1,'失败'];
$re_log = ['result' => 'false'];
} }
$this->writeLog($user_id, '更新节点', json_encode($collect), json_encode($re_log));
return $re;
} }
...@@ -187,7 +202,7 @@ class SpiderModel extends Model ...@@ -187,7 +202,7 @@ class SpiderModel extends Model
* 更新所有节点 * 更新所有节点
* @return array * @return array
*/ */
public function updateAllNode() { public function updateAllNode($user_id) {
$collect = Request::all(); $collect = Request::all();
...@@ -196,10 +211,15 @@ class SpiderModel extends Model ...@@ -196,10 +211,15 @@ class SpiderModel extends Model
$result = DB::connection('dashboard')->table('spider_node')->update($collect); $result = DB::connection('dashboard')->table('spider_node')->update($collect);
if ($result) { if ($result) {
return [0,'成功']; $re = [0,'成功'];
$re_log = ['result' => 'true'];
} else { } else {
return [1,'失败']; $re = [1,'失败'];
$re_log = ['result' => 'false'];
} }
$this->writeLog($user_id, '更新所有节点', json_encode($collect), json_encode($re_log));
return $re;
} }
...@@ -207,7 +227,7 @@ class SpiderModel extends Model ...@@ -207,7 +227,7 @@ class SpiderModel extends Model
* 更新所有面板状态 * 更新所有面板状态
* @return array * @return array
*/ */
public function updateAllBoard() { public function updateAllBoard($user_id) {
$collect = Request::all(); $collect = Request::all();
...@@ -216,11 +236,63 @@ class SpiderModel extends Model ...@@ -216,11 +236,63 @@ class SpiderModel extends Model
$result = DB::connection('dashboard')->table('spider_board')->where('status', '!=', '2')->update($collect); $result = DB::connection('dashboard')->table('spider_board')->where('status', '!=', '2')->update($collect);
if ($result) { if ($result) {
return [0,'成功']; $re = [0,'成功'];
$re_log = ['result' => 'true'];
} else { } else {
return [1,'失败']; $re = [1,'失败'];
$re_log = ['result' => 'false'];
}
$this->writeLog($user_id, '更新所有面板', json_encode($collect), json_encode($re_log));
return $re;
}
/**
* 日志列表
*/
public function logsList($limit, $p, $start_time, $end_time, $user_id) {
$limit = !empty($limit) ? $limit : '';
$p = !empty($p) ? $p : 1;
$map = [];
$map[] = ['update_time', '>=', strtotime($start_time)];
$map[] = ['update_time', '<=', strtotime($end_time) + 86400];
if (!empty($user_id))
$map[] = ['user_id', '=', $user_id];
$data = DB::connection('dashboard')->table('spider_action_log')->where($map)->paginate($limit,['*'],'p',$p)->toArray();
foreach ($data['data'] as $k => $v) {
$data['data'][$k]['update_time'] = date("Y-m-d H:i:s", $v['update_time']);
} }
return $data;
}
/**
* 写入日志
* @user_id 会员id
* @action 行为
* @content 修改内容
* @result 结果
*/
public function writeLog($user_id, $action, $content, $result) {
$arr = [
'user_id' => $user_id,
'action' => $action,
'content' => $content,
'result' => $result,
'update_time' => time()
];
DB::connection('dashboard')->table('spider_action_log')->insert($arr);
} }
} }
layui.use(['table', 'form', 'laydate', 'layer'], function () {
var table = layui.table;
var form = layui.form;
var laydate = layui.laydate;
laydate.render({
elem: '#start_time'
,format:'yyyy-MM-dd'
});
laydate.render({
elem: '#end_time'
,format:'yyyy-MM-dd'
});
table.render({
elem:'#table',
loading:true,
cellMinWidth: 100,
page:true,
limit: 50,
url: '/api/ApiLogsList/',
request:{pageName:'p', limitName:'limit'},
cols: [[
{field:'user_id', title:'用户id', sort: true},
{field:'action', title: '行为', sort: true},
{field:'content', title:'修改内容', sort: true},
{field:'result', title:'结果', width: 250, sort: true},
{field:'update_time', title:'更新时间', width: 140, sort: true},
]],
id: 'idTest'
});
var $ = layui.$, active = {
reload: function(){
//执行重载
table.reload('idTest', {
page: {
curr: 1 //重新从第 1 页开始
}
, where: {
start_time: $('#start_time').val(),
end_time: $('#end_time').val(),
user_id: $('#user_id').val(),
}
})
},
};
$('.load').on('click', function(){
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
})
<div class="layui-form">
<div class="layui-form-item">
<div class="layui-inline">
<div class="layui-input-inline">
<input type="text" name="start_time" id="start_time" autocomplete="off" class="layui-input" value="{{$_GET['start_time'] or ''}}">
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="end_time" id="end_time" autocomplete="off" class="layui-input" value="{{$_GET['end_time'] or ''}}">
</div>
</div>
<div class="layui-inline">
<input type="text" id="user_id" placeholder="用户id" class="layui-input" value="{{$_GET['end_time'] or ''}}">
</div>
<div class="layui-inline">
<button class="btn btn btn-outline btn-primary load" id="search" lay-submit lay-filter="*" data-type="reload">搜索</button>
</div>
</div>
</div>
<table class="layui-table" id="table" lay-filter="demo"></table>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment