1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?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['s'] = $this->skillModel->getUserSkill($info['i']);
- $info['time'] = time();
-
- 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['u'];
- $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['u'];
- $path = "load/$id.txt";
-
- $file = fopen($path, 'w') or die(json(['error'=>1009]));
- fwrite($file, $data['l']);
- fclose($file);
-
- return json(['error'=>0]);
- }
-
- }
|