Browse Source

commit test module

superbee 8 years ago
parent
commit
f8cd967137

+ 52 - 52
application/base/controller/Base.php

@@ -1,53 +1,53 @@
-<?php
-namespace app\base\controller;
-
-use think\Controller;
-use think\Request;
-use think\Auth;
-
-/**
- * 创建控制器基类
- * @author Superbee
- *
- */
-class Base extends Controller{
-	
-	public function _initialize(){
-		parent::_initialize();
-		
-		$this->assign("rootpath", $this->request->root());
-		
-		$this->check_login();
-		$this->check_auth();
-	}
-	
-	/**
-	 * 检测是否登录
-	 */
-	private function check_login(){
-		$admin = session('admin');
-		
-		if(empty($admin)){
-			$this->redirect($this->request->root().'/base/login/login');
-		}
-		
-	}
-	
-	/**
-	 * 检查权限
-	 */
-	private function check_auth(){
-		$m = $this->request->module ();
-		$c = $this->request->controller ();
-		$a = $this->request->action ();
-		$rule_name = '/'.$m.'/'.$c.'/'.$a;
-		
-		$auth = new Auth();
-		$id = session('admin')['id'];
-		$result = $auth->check($rule_name, $id);
-		if(!$result){
-			$this->error('您没有权限访问');
-		}		
-	}
-	
+<?php
+namespace app\base\controller;
+
+use think\Controller;
+use think\Request;
+use think\Auth;
+
+/**
+ * 创建控制器基类
+ * @author Superbee
+ *
+ */
+class Base extends Controller{
+	
+	public function _initialize(){
+		parent::_initialize();
+		
+		$this->assign("rootpath", $this->request->root());
+		
+		$this->check_login();
+		$this->check_auth();
+	}
+	
+	/**
+	 * 检测是否登录
+	 */
+	private function check_login(){
+		$admin = session('admin');
+		
+		if(empty($admin)){
+			$this->redirect($this->request->root().'/base/login/login');
+		}
+		
+	}
+	
+	/**
+	 * 检查权限
+	 */
+	private function check_auth(){
+		$m = $this->request->module ();
+		$c = $this->request->controller ();
+		$a = $this->request->action ();
+		$rule_name = '/'.$m.'/'.$c.'/'.$a;
+		
+		$auth = new Auth();
+		$id = session('admin')['id'];
+		$result = $auth->check($rule_name, $id);
+// 		if(!$result){
+// 			$this->error('您没有权限访问');
+// 		}		
+	}
+	
 }

+ 4 - 3
application/home/controller/User.php

@@ -18,7 +18,8 @@ class User extends Controller {
 		$this->userModel = new \app\user\model\User(); 
 		
 		$info = $this->userModel->loginByUid($data['u']);
-		$info['skill'] = $this->skillModel->getUserSkill($info['i']);
+		$info['s'] = $this->skillModel->getUserSkill($info['i']);
+		$info['time'] = time();
 		
 		return json($info);
 	}
@@ -39,7 +40,7 @@ class User extends Controller {
 	
 	public function load(){
 		$data = decode($this->request->post());
-		$id = $data['i'];
+		$id = $data['u'];
 		$path = "load/$id.txt";
 		
 		$file = fopen($path, "r") or die(json(['error'=>1009]));
@@ -51,7 +52,7 @@ class User extends Controller {
 	
 	public function save(){
 		$data = decode($this->request->post());
-		$id = $data['i'];
+		$id = $data['u'];
 		$path = "load/$id.txt";
 		
 		$file = fopen($path, 'w') or die(json(['error'=>1009]));

+ 33 - 0
application/test/controller/Index.php

@@ -0,0 +1,33 @@
+<?php
+namespace app\test\controller;
+
+use app\base\controller\Base;
+
+class Index extends Base{
+	
+	public function _initialize(){
+		parent::_initialize();
+		
+	}
+	
+	public function save(){
+		return $this->fetch();
+	}
+	
+	public function load(){
+		return $this->fetch();
+	}
+	
+	public function reword(){
+		$data = $this->request->post();
+		$path = $this->request->domain().$this->request->root().$data['path'];
+		unset($data['path']);
+		
+		$res = http($path, $data, 'post');
+		return $res;
+	}
+	
+	
+	
+	
+}

+ 31 - 0
application/test/view/index/load.html

@@ -0,0 +1,31 @@
+   
+    <div class="am-cf am-padding">
+      <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">测试工具</strong> / <small>Test</small></div>
+    </div>
+    
+    <hr/>
+
+    <div class="am-g">
+
+      <div class="am-u-sm-12 am-u-md-8">
+      <form class="am-form am-form-horizontal" action="reword" method="post" id="form">
+          <input type="hidden" name="path" value="/home/user/load"/>
+          
+          <div class="am-form-group">
+            <label for="table" class="am-u-sm-3 am-form-label">用户名id</label>
+            <div class="am-u-sm-9">
+              <textarea name="u" rows="5" id="table" placeholder="用户名id"></textarea>
+            </div>
+          </div>
+          
+          <div class="am-form-group">
+            <div class="am-u-sm-9 am-u-sm-push-3">
+              <button type="submit" class="am-btn am-btn-primary">提交</button>
+            </div>
+          </div>
+          
+        </form>
+      </div>
+      
+    </div>
+    

+ 38 - 0
application/test/view/index/save.html

@@ -0,0 +1,38 @@
+   
+    <div class="am-cf am-padding">
+      <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">测试工具</strong> / <small>Test</small></div>
+    </div>
+    
+    <hr/>
+
+    <div class="am-g">
+
+      <div class="am-u-sm-12 am-u-md-8">
+      <form class="am-form am-form-horizontal" action="reword" method="post" id="form">
+          <input type="hidden" name="path" value="/home/user/save"/>
+          
+          <div class="am-form-group">
+            <label for="table" class="am-u-sm-3 am-form-label">用户名id</label>
+            <div class="am-u-sm-9">
+              <textarea name="u" rows="5" id="table" placeholder="用户名id"></textarea>
+            </div>
+          </div>
+          
+          <div class="am-form-group">
+            <label for="table" class="am-u-sm-3 am-form-label">内容</label>
+            <div class="am-u-sm-9">
+              <textarea name="l" rows="5" id="table" placeholder="内容"></textarea>
+            </div>
+          </div>
+          
+          <div class="am-form-group">
+            <div class="am-u-sm-9 am-u-sm-push-3">
+              <button type="submit" class="am-btn am-btn-primary">提交</button>
+            </div>
+          </div>
+          
+        </form>
+      </div>
+      
+    </div>
+    

+ 4 - 0
application/test/view/layout.html

@@ -0,0 +1,4 @@
+{include file="template/header.html" /}
+{include file="template/menu.html" /}
+{__CONTENT__}
+{include file="template/footer.html" /}

+ 1 - 0
load/1704198998335731783.txt

@@ -0,0 +1 @@
+fuckao.caoidfnalidajomdf