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
babdd991
Commit
babdd991
authored
Feb 11, 2018
by
刘剑华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
e0804aea
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
1 deletion
+63
-1
User.php
app/api/controller/v1/User.php
+12
-1
User.php
app/api/model/User.php
+51
-0
No files found.
app/api/controller/v1/User.php
View file @
babdd991
...
@@ -40,7 +40,18 @@ class User extends Api
...
@@ -40,7 +40,18 @@ class User extends Api
*/
*/
public
function
save
()
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'
);
}
}
}
...
...
app/api/model/User.php
View file @
babdd991
<?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
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