Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dk_oauth
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘剑华
dk_oauth
Commits
a7fb4eb6
Commit
a7fb4eb6
authored
Feb 11, 2018
by
刘剑华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update save model
parent
1aabb7c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
35 deletions
+52
-35
User.php
app/api/controller/v1/User.php
+30
-28
User.php
app/api/model/User.php
+22
-7
No files found.
app/api/controller/v1/User.php
View file @
a7fb4eb6
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
app\api\controller\v1
;
namespace
app\api\controller\v1
;
use
app\api\controller\Send
;
use
think\Controller
;
use
think\Controller
;
use
think\Request
;
use
think\Request
;
use
app\api\controller\Api
;
use
app\api\controller\Api
;
...
@@ -15,8 +16,9 @@ use app\api\controller\UnauthorizedException;
...
@@ -15,8 +16,9 @@ use app\api\controller\UnauthorizedException;
* 在具体资源方法中,不需要再依赖注入,直接调用$this->request返回为请具体信息的一个对象
* 在具体资源方法中,不需要再依赖注入,直接调用$this->request返回为请具体信息的一个对象
* date:2017-07-25
* date:2017-07-25
*/
*/
class
User
extends
Api
class
User
extends
Controller
{
{
use
Send
;
/**
/**
* 允许访问的方式列表,资源数组如果没有对应的方式列表,请不要把该方法写上,如user这个资源,客户端没有delete操作
* 允许访问的方式列表,资源数组如果没有对应的方式列表,请不要把该方法写上,如user这个资源,客户端没有delete操作
*/
*/
...
@@ -61,12 +63,12 @@ class User extends Api
...
@@ -61,12 +63,12 @@ class User extends Api
* @param int $id
* @param int $id
* @return \think\Response
* @return \think\Response
*/
*/
public
function
read
()
//
public function read()
{
// {
echo
'get'
;
//
echo 'get';
dump
(
$this
->
request
);
//
dump($this->request);
dump
(
$this
->
clientInfo
);
//
dump($this->clientInfo);
}
//
}
/**
/**
* PUT方式
* PUT方式
...
@@ -75,25 +77,25 @@ class User extends Api
...
@@ -75,25 +77,25 @@ class User extends Api
* @param int $id
* @param int $id
* @return \think\Response
* @return \think\Response
*/
*/
public
function
update
()
//
public function update()
{
//
{
echo
'update'
;
//
echo 'update';
}
//
}
//
/**
//
/**
* delete方式
//
* delete方式
*
//
*
* @param int $id
//
* @param int $id
* @return \think\Response
//
* @return \think\Response
*/
//
*/
public
function
delete
()
//
public function delete()
{
//
{
return
'delete'
;
//
return 'delete';
}
//
}
//
//
public
function
fans
(
$id
)
//
public function fans($id)
{
//
{
return
$id
;
//
return $id;
}
//
}
}
}
app/api/model/User.php
View file @
a7fb4eb6
<?php
<?php
namespace
app\api\model
;
namespace
app\api\model
;
use
app\api\controller\Send
;
use
think\Model
;
use
think\Model
;
/**
/**
...
@@ -8,6 +9,7 @@ use think\Model;
...
@@ -8,6 +9,7 @@ use think\Model;
*/
*/
class
User
extends
Model
class
User
extends
Model
{
{
use
Send
;
/**
/**
* 表名,
* 表名,
...
@@ -15,24 +17,37 @@ class User extends Model
...
@@ -15,24 +17,37 @@ class User extends Model
protected
$table
=
'oauth_user'
;
protected
$table
=
'oauth_user'
;
public
function
vali
(
$json
){
public
function
vali
(
$json
){
// var_dump($json);die;
if
(
empty
(
$json
->
app_id
)
||
empty
(
$json
->
app_secret
)
||
empty
(
$json
->
type
)
||
empty
(
$json
->
entry_name
)){
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
){
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
){
switch
(
$json
->
type
){
case
"web"
:
case
'web'
:
break
;
case
'java'
:
case
'java'
:
case
'php'
:
break
;
case
"php"
:
break
;
case
'android'
:
case
'android'
:
break
;
case
'ios'
:
case
'ios'
:
break
;
default
:
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_id'
]
=
$json
->
app_id
;
$data
[
'app_secret'
]
=
$json
->
app_secret
;
$data
[
'app_secret'
]
=
$json
->
app_secret
;
$data
[
'type'
]
=
$json
->
type
;
$data
[
'type'
]
=
$json
->
type
;
...
@@ -42,7 +57,7 @@ class User extends Model
...
@@ -42,7 +57,7 @@ class User extends Model
if
(
$list
){
if
(
$list
){
return
true
;
return
true
;
}
else
{
}
else
{
return
returnmsg
(
'402'
,[],[],
'service_message'
,
'save error.'
,
'新增失败'
);
return
self
::
returnmsg
(
'402'
,[],[],
'service_message'
,
'save error.'
,
'新增失败'
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment