|
@@ -1,40 +1,64 @@
|
|
|
-<?php
|
|
|
-namespace app\home\controller;
|
|
|
-
|
|
|
-use think\Controller;
|
|
|
-use app\user\model\UserSkill;
|
|
|
-
|
|
|
-class User extends Controller {
|
|
|
-
|
|
|
- private $userModel, $skillModel;
|
|
|
-
|
|
|
- public function _initialize(){
|
|
|
- $this->skillModel = new UserSkill();
|
|
|
- }
|
|
|
-
|
|
|
- public function login()
|
|
|
- {
|
|
|
- $data = decode($this->request->post());
|
|
|
- $this->userModel = new \app\user\model\User();
|
|
|
-
|
|
|
- $info = $this->userModel->loginByUid($data['u']);
|
|
|
- $info['skill'] = $this->skillModel->getUserSkill($info['i']);
|
|
|
-
|
|
|
- return json($info);
|
|
|
- }
|
|
|
-
|
|
|
- public function getskill(){
|
|
|
- $data = decode($this->request->post());
|
|
|
-
|
|
|
- $info = $this->skillModel->getSkillByInfo($data['i']);
|
|
|
- return json($info);
|
|
|
- }
|
|
|
-
|
|
|
- public function addskill(){
|
|
|
- $data = decode($this->request->post());
|
|
|
-
|
|
|
- $info = $this->skillModel->addUserSkill($data['u'], $data['s']);
|
|
|
- return json($info);
|
|
|
- }
|
|
|
-
|
|
|
+<?php
|
|
|
+namespace app\home\controller;
|
|
|
+
|
|
|
+use think\Controller;
|
|
|
+use app\user\model\UserSkill;
|
|
|
+
|
|
|
+class User extends Controller {
|
|
|
+
|
|
|
+ private $userModel, $skillModel;
|
|
|
+
|
|
|
+ public function _initialize(){
|
|
|
+ $this->skillModel = new UserSkill();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function login()
|
|
|
+ {
|
|
|
+ $data = decode($this->request->post());
|
|
|
+ $this->userModel = new \app\user\model\User();
|
|
|
+
|
|
|
+ $info = $this->userModel->loginByUid($data['u']);
|
|
|
+ $info['skill'] = $this->skillModel->getUserSkill($info['i']);
|
|
|
+
|
|
|
+ return json($info);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getskill(){
|
|
|
+ $data = decode($this->request->post());
|
|
|
+
|
|
|
+ $info = $this->skillModel->getSkillByInfo($data['i']);
|
|
|
+ return json($info);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addskill(){
|
|
|
+ $data = decode($this->request->post());
|
|
|
+
|
|
|
+ $info = $this->skillModel->addUserSkill($data['u'], $data['s']);
|
|
|
+ return json($info);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function load(){
|
|
|
+ $data = decode($this->request->post());
|
|
|
+ $id = $data['i'];
|
|
|
+ $path = "load/$id.txt";
|
|
|
+
|
|
|
+ $file = fopen($path, "r") or die(json(['error'=>1009]));
|
|
|
+ $info = fread($file, filesize($path));
|
|
|
+ fclose($file);
|
|
|
+
|
|
|
+ return json(['l'=>$info]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function save(){
|
|
|
+ $data = decode($this->request->post());
|
|
|
+ $id = $data['i'];
|
|
|
+ $path = "load/$id.txt";
|
|
|
+
|
|
|
+ $file = fopen($path, 'w') or die(json(['error'=>1009]));
|
|
|
+ fwrite($file, $data['l']);
|
|
|
+ fclose($file);
|
|
|
+
|
|
|
+ return json(['error'=>0]);
|
|
|
+ }
|
|
|
+
|
|
|
}
|