Commit a7fb4eb6 by 刘剑华

update save model

parent 1aabb7c3
......@@ -2,6 +2,7 @@
namespace app\api\controller\v1;
use app\api\controller\Send;
use think\Controller;
use think\Request;
use app\api\controller\Api;
......@@ -15,8 +16,9 @@ use app\api\controller\UnauthorizedException;
* 在具体资源方法中,不需要再依赖注入,直接调用$this->request返回为请具体信息的一个对象
* date:2017-07-25
*/
class User extends Api
class User extends Controller
{
use Send;
/**
* 允许访问的方式列表,资源数组如果没有对应的方式列表,请不要把该方法写上,如user这个资源,客户端没有delete操作
*/
......@@ -61,12 +63,12 @@ class User extends Api
* @param int $id
* @return \think\Response
*/
public function read()
{
echo 'get';
dump($this->request);
dump($this->clientInfo);
}
// public function read()
// {
// echo 'get';
// dump($this->request);
// dump($this->clientInfo);
// }
/**
* PUT方式
......@@ -75,25 +77,25 @@ class User extends Api
* @param int $id
* @return \think\Response
*/
public function update()
{
echo 'update';
}
/**
* delete方式
*
* @param int $id
* @return \think\Response
*/
public function delete()
{
return 'delete';
}
public function fans($id)
{
return $id;
}
// public function update()
// {
// echo 'update';
// }
//
// /**
// * delete方式
// *
// * @param int $id
// * @return \think\Response
// */
// public function delete()
// {
// return 'delete';
// }
//
//
// public function fans($id)
// {
// return $id;
// }
}
<?php
namespace app\api\model;
use app\api\controller\Send;
use think\Model;
/**
......@@ -8,6 +9,7 @@ use think\Model;
*/
class User extends Model
{
use Send;
/**
* 表名,
......@@ -15,24 +17,37 @@ class User extends Model
protected $table = 'oauth_user';
public function vali($json){
// var_dump($json);die;
if(empty($json->app_id)||empty($json->app_secret)||empty($json->type)||empty($json->entry_name)){
return returnmsg(400);
return self::returnmsg(400);
}
if(count($json->app_id)>128||count($json->app_secret)>128||count($json->entry_name)>128){
return returnmsg('402',[],[],'service_message','Data error.','参数长度超限');
return self::returnmsg('402',[],[],'service_message','Data error.','参数长度超限');
}
// var_dump($json->type);die;
switch ($json->type){
case 'web':
case "web":
break;
case 'java':
case 'php':
break;
case "php":
break;
case 'android':
break;
case 'ios':
break;
default:
return returnmsg('402',[],[],'service_message','Type error.','所属类型错误');
return self::returnmsg('402',[],[],'service_message','Type error.','所属类型错误');
break;
}
$status="app_id='{$json->app_id}'";
$status_db=$this->where($status)->find();
if($status_db){
return self::returnmsg('402',[],[],'service_message','save error.','app_id已存在');
}
$data['app_id']=$json->app_id;
$data['app_secret']=$json->app_secret;
$data['type']=$json->type;
......@@ -42,7 +57,7 @@ class User extends Model
if($list){
return true;
}else{
return returnmsg('402',[],[],'service_message','save error.','新增失败');
return self::returnmsg('402',[],[],'service_message','save error.','新增失败');
}
}
......
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 to comment