Commit babdd991 by 刘剑华

init

parent e0804aea
......@@ -40,7 +40,18 @@ class User extends Api
*/
public function save()
{
echo 'save';
if(empty($_POST['json'])){
$this->returnmsg(400);
}
$json=$_POST['json'];
// var_dump($json);die;
$json_obj=json_decode($json);
// var_dump($json_obj);die;
$groupModel = model('User');
$list=$groupModel->vali($json_obj);
if($list){
$this->render(200,'success');
}
}
......
<?php
namespace app\api\model;
use think\Model;
/**
* 分类
*/
class Token extends Model
{
/**
* 表名,
*/
protected $table = 'oauth_user';
public function vali($json){
if(empty($json->app_id)||empty($json->app_secret)||empty($json->type)||empty($json->entry_name)){
return 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.','参数长度超限');
}
switch ($json->type){
case 'web':
case 'java':
case 'php':
case 'android':
case 'ios':
default:
return returnmsg('402',[],[],'service_message','Type error.','所属类型错误');
}
$data['app_id']=$json->app_id;
$data['app_secret']=$json->app_secret;
$data['type']=$json->type;
$data['entry_name']=$json->entry_name;
$data['possessor']=$json->possessor;
$list=$this->insert($data);
if($list){
return true;
}else{
return returnmsg('402',[],[],'service_message','save error.','新增失败');
}
}
}
\ No newline at end of file
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