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
b8b83fd0
Commit
b8b83fd0
authored
Oct 29, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新版探索应用
parent
b340acf5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
164 additions
and
0 deletions
+164
-0
ExploreController.php
api/controllers/ExploreController.php
+42
-0
ExploreApp.php
common/models/psources/ExploreApp.php
+70
-0
ExploreAppCategory.php
common/models/psources/ExploreAppCategory.php
+52
-0
No files found.
api/controllers/ExploreController.php
0 → 100644
View file @
b8b83fd0
<?php
namespace
api\controllers
;
use
common\models\psources\ExploreAppCategory
;
use
Yii
;
use
api\base\BaseController
;
class
ExploreController
extends
BaseController
{
public
function
actionIndex
()
{
$header
=
Yii
::
$app
->
request
->
headers
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
if
(
false
==
$platform_id
){
$msg
=
'参数错误'
;
$code
=
-
1
;
$data
=
null
;
goto
doEnd
;
}
$app_category_model
=
ExploreAppCategory
::
find
()
->
where
([
'platform_id'
=>
$platform_id
])
->
all
();
foreach
(
$app_category_model
as
&
$val
){
foreach
(
$val
->
applications
as
$app
){
$app
->
name
=
$app
->
name
[
$this
->
lang
];
}
$val
->
name
=
$val
->
name
[
$this
->
lang
];
$val
->
apps
=
$val
->
applications
;
unset
(
$val
->
id
);
unset
(
$val
->
sort
);
unset
(
$val
->
platform_id
);
}
$data
=
$app_category_model
;
$msg
=
'success'
;
$code
=
0
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
\ No newline at end of file
common/models/psources/ExploreApp.php
0 → 100644
View file @
b8b83fd0
<?php
namespace
common\models\psources
;
use
Yii
;
use
yii\db\Expression
;
use
common\core\BaseActiveRecord
;
use
yii\behaviors\TimestampBehavior
;
class
ExploreApp
extends
BaseActiveRecord
{
const
STATUS_ON
=
1
;
//激活
const
STATUS_OFF
=
0
;
//未激活
public
function
behaviors
()
{
return
[
[
'class'
=>
TimestampBehavior
::
className
(),
'createdAtAttribute'
=>
'created_at'
,
'updatedAtAttribute'
=>
'updated_at'
,
'value'
=>
new
Expression
(
'NOW()'
)
]
];
}
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{explore_app}}'
;
}
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
function
rules
()
{
return
[
[[
'name'
,
'icon'
,
'app_url'
,
'slogan'
,
'type'
,
'status'
,
'platform_id'
,
'app_category_id'
],
'required'
],
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'icon'
,
'app_url'
,
'slogan'
,
'type'
,
'status'
,
'platform_id'
,
'app_category_id'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
public
function
getAppCategory
()
{
return
$this
->
hasOne
(
ExploreAppCategory
::
className
(),
[
'id'
=>
'app_category_id'
]);
}
public
static
function
getCasesStatus
()
{
return
[
self
::
STATUS_ON
=>
'激活'
,
self
::
STATUS_OFF
=>
'未激活'
,
];
}
}
\ No newline at end of file
common/models/psources/ExploreAppCategory.php
0 → 100644
View file @
b8b83fd0
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
ExploreAppCategory
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{explore_app_category}}'
;
}
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
function
rules
()
{
return
[
[[
'name'
,
'sort'
,
'style'
,
'platform_id'
],
'required'
],
];
}
public
function
attributes
()
{
return
array_merge
(
parent
::
attributes
(),
[
'apps'
]);
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'sort'
,
'style'
,
'platform_id'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
public
function
getApplications
()
{
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