Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
wallet
token
Commits
99e793a9
Commit
99e793a9
authored
Oct 29, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
应用类别
parent
b8b83fd0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
7 deletions
+49
-7
ExploreController.php
api/controllers/ExploreController.php
+43
-3
ExploreApp.php
common/models/psources/ExploreApp.php
+2
-2
ExploreAppCategory.php
common/models/psources/ExploreAppCategory.php
+4
-2
No files found.
api/controllers/ExploreController.php
View file @
99e793a9
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
api\controllers
;
namespace
api\controllers
;
use
common\models\psources\ExploreApp
;
use
common\models\psources\ExploreAppCategory
;
use
common\models\psources\ExploreAppCategory
;
use
Yii
;
use
Yii
;
use
api\base\BaseController
;
use
api\base\BaseController
;
...
@@ -13,7 +14,7 @@ class ExploreController extends BaseController
...
@@ -13,7 +14,7 @@ class ExploreController extends BaseController
$header
=
Yii
::
$app
->
request
->
headers
;
$header
=
Yii
::
$app
->
request
->
headers
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
if
(
false
==
$platform_id
)
{
if
(
false
==
$platform_id
)
{
$msg
=
'参数错误'
;
$msg
=
'参数错误'
;
$code
=
-
1
;
$code
=
-
1
;
$data
=
null
;
$data
=
null
;
...
@@ -21,14 +22,53 @@ class ExploreController extends BaseController
...
@@ -21,14 +22,53 @@ class ExploreController extends BaseController
}
}
$app_category_model
=
ExploreAppCategory
::
find
()
->
where
([
'platform_id'
=>
$platform_id
])
->
all
();
$app_category_model
=
ExploreAppCategory
::
find
()
->
where
([
'platform_id'
=>
$platform_id
])
->
all
();
foreach
(
$app_category_model
as
&
$val
){
foreach
(
$app_category_model
as
&
$val
)
{
foreach
(
$val
->
applications
as
$app
){
unset
(
$val
->
apps
);
$val
->
name
=
$val
->
name
[
$this
->
lang
];
$apps_model
=
ExploreApp
::
find
()
->
select
(
'name, icon, app_url, slogan'
)
->
where
([
'app_category_id'
=>
(
int
)
$val
->
id
])
->
orderBy
(
'sort'
)
->
limit
(
$val
->
limit
)
->
all
();
foreach
(
$apps_model
as
&
$app
)
{
$app
->
name
=
$app
->
name
[
$this
->
lang
];
}
$val
->
apps
=
$apps_model
;
unset
(
$val
->
id
);
unset
(
$val
->
sort
);
unset
(
$val
->
limit
);
unset
(
$val
->
platform_id
);
}
$data
=
$app_category_model
;
$msg
=
'success'
;
$code
=
0
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionCategory
()
{
$header
=
Yii
::
$app
->
request
->
headers
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
$category_id
=
Yii
::
$app
->
request
->
get
(
'id'
,
0
);
if
(
false
==
$platform_id
||
false
==
$category_id
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
$data
=
null
;
goto
doEnd
;
}
$app_category_model
=
ExploreAppCategory
::
find
()
->
where
([
'id'
=>
(
int
)
$category_id
,
'platform_id'
=>
$platform_id
])
->
all
();
foreach
(
$app_category_model
as
&
$val
)
{
foreach
(
$val
->
applications
as
$app
)
{
$app
->
name
=
$app
->
name
[
$this
->
lang
];
$app
->
name
=
$app
->
name
[
$this
->
lang
];
}
}
$val
->
name
=
$val
->
name
[
$this
->
lang
];
$val
->
name
=
$val
->
name
[
$this
->
lang
];
$val
->
apps
=
$val
->
applications
;
$val
->
apps
=
$val
->
applications
;
unset
(
$val
->
id
);
unset
(
$val
->
id
);
unset
(
$val
->
sort
);
unset
(
$val
->
sort
);
unset
(
$val
->
limit
);
unset
(
$val
->
platform_id
);
unset
(
$val
->
platform_id
);
}
}
$data
=
$app_category_model
;
$data
=
$app_category_model
;
...
...
common/models/psources/ExploreApp.php
View file @
99e793a9
...
@@ -42,14 +42,14 @@ class ExploreApp extends BaseActiveRecord
...
@@ -42,14 +42,14 @@ class ExploreApp extends BaseActiveRecord
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'name'
,
'icon'
,
'app_url'
,
'slogan'
,
'type'
,
'status'
,
'platform_id'
,
'app_category_id'
],
'required'
],
[[
'name'
,
'icon'
,
'app_url'
,
'slogan'
,
'type'
,
's
ort'
,
's
tatus'
,
'platform_id'
,
'app_category_id'
],
'required'
],
];
];
}
}
public
function
scenarios
()
public
function
scenarios
()
{
{
$scenarios
=
[
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'icon'
,
'app_url'
,
'slogan'
,
'type'
,
'status'
,
'platform_id'
,
'app_category_id'
],
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'icon'
,
'app_url'
,
'slogan'
,
'type'
,
's
ort'
,
's
tatus'
,
'platform_id'
,
'app_category_id'
],
];
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
...
...
common/models/psources/ExploreAppCategory.php
View file @
99e793a9
...
@@ -26,7 +26,7 @@ class ExploreAppCategory extends BaseActiveRecord
...
@@ -26,7 +26,7 @@ class ExploreAppCategory extends BaseActiveRecord
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'name'
,
'sort'
,
'style'
,
'platform_id'
],
'required'
],
[[
'name'
,
'sort'
,
'
limit'
,
'
style'
,
'platform_id'
],
'required'
],
];
];
}
}
...
@@ -39,7 +39,7 @@ class ExploreAppCategory extends BaseActiveRecord
...
@@ -39,7 +39,7 @@ class ExploreAppCategory extends BaseActiveRecord
public
function
scenarios
()
public
function
scenarios
()
{
{
$scenarios
=
[
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'sort'
,
'style'
,
'platform_id'
],
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'sort'
,
'
limit'
,
'
style'
,
'platform_id'
],
];
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
...
@@ -48,4 +48,5 @@ class ExploreAppCategory extends BaseActiveRecord
...
@@ -48,4 +48,5 @@ class ExploreAppCategory extends BaseActiveRecord
{
{
return
$this
->
hasMany
(
ExploreApp
::
className
(),
[
'app_category_id'
=>
'id'
])
->
select
([
'name'
,
'icon'
,
'app_url'
,
'slogan'
]);
return
$this
->
hasMany
(
ExploreApp
::
className
(),
[
'app_category_id'
=>
'id'
])
->
select
([
'name'
,
'icon'
,
'app_url'
,
'slogan'
]);
}
}
}
}
\ 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