<?php
namespace app\api\model;

use think\Model;

/**
 * 分类
 */
class User 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.','新增失败');
            }

    }

}