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
aa3207c8
Commit
aa3207c8
authored
Nov 15, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/explore' into 'master'
Feature/explore See merge request
!190
parents
568d7a0f
e12952b1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
445 additions
and
1 deletion
+445
-1
CoinDogController.php
api/controllers/CoinDogController.php
+3
-1
ExploreController.php
api/controllers/ExploreController.php
+133
-0
CoinBannerItem.php
common/models/psources/CoinBannerItem.php
+23
-0
ExploreApp.php
common/models/psources/ExploreApp.php
+61
-0
ExploreAppCategory.php
common/models/psources/ExploreAppCategory.php
+66
-0
ExploreAppController.php
wallet/controllers/ExploreAppController.php
+0
-0
ExploreBannerController.php
wallet/controllers/ExploreBannerController.php
+114
-0
OssController.php
wallet/controllers/OssController.php
+45
-0
No files found.
api/controllers/CoinDogController.php
View file @
aa3207c8
...
...
@@ -126,10 +126,12 @@ class CoinDogController extends BaseController
public
function
actionArticleBanner
()
{
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
1
);
$data
=
Article
::
find
()
->
select
(
'id, image_url ,title, url'
)
->
limit
(
5
)
->
where
([
'type'
=>
$type
]
)
->
orderBy
(
'update_at desc'
)
->
limit
(
5
)
->
asArray
()
->
all
();
...
...
api/controllers/ExploreController.php
0 → 100644
View file @
aa3207c8
<?php
namespace
api\controllers
;
use
Yii
;
use
api\base\BaseController
;
use
common\models\psources\ExploreApp
;
use
common\models\psources\CoinBannerItem
;
use
common\models\psources\ExploreAppCategory
;
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
,
'status'
=>
ExploreAppCategory
::
STATUS_ON
])
->
all
();
foreach
(
$app_category_model
as
&
$val
)
{
unset
(
$val
->
apps
);
$val
->
name
=
$val
->
name
[
$this
->
lang
];
$apps_model
=
ExploreApp
::
find
()
->
select
(
'id, name, icon, type, 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
->
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
];
}
$val
->
name
=
$val
->
name
[
$this
->
lang
];
$val
->
apps
=
$val
->
applications
;
unset
(
$val
->
id
);
unset
(
$val
->
sort
);
unset
(
$val
->
style
);
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
actionSearch
()
{
$header
=
Yii
::
$app
->
request
->
headers
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
$ids
=
Yii
::
$app
->
request
->
get
(
'ids'
,
''
);
if
(
false
==
$platform_id
||
false
==
$ids
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
$data
=
null
;
goto
doEnd
;
}
$id_arr
=
explode
(
','
,
$ids
);
$order
=
"FIELD(`id`,
$ids
)"
;
$apps_model
=
ExploreApp
::
find
()
->
select
(
'id, name, icon, type, app_url, slogan'
)
->
where
([
'in'
,
'id'
,
$id_arr
])
->
orderBy
([
$order
=>
true
])
->
limit
(
4
)
->
all
();
foreach
(
$apps_model
as
&
$app
)
{
$app
->
name
=
$app
->
name
[
$this
->
lang
];
}
$data
=
$apps_model
;
$msg
=
'success'
;
$code
=
0
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionBanner
()
{
$msg
=
'ok'
;
$code
=
0
;
$header
=
Yii
::
$app
->
request
->
headers
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
if
(
false
==
$platform_id
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
$data
=
null
;
goto
doEnd
;
}
$coin_banner
=
CoinBannerItem
::
find
()
->
select
(
'banner_url, image_url, title'
)
->
where
([
'platform_id'
=>
$platform_id
])
->
asArray
()
->
all
();
$data
=
$coin_banner
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
\ No newline at end of file
common/models/psources/CoinBannerItem.php
View file @
aa3207c8
...
...
@@ -12,6 +12,10 @@ use Yii;
class
CoinBannerItem
extends
BaseActiveRecord
{
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
...
...
@@ -22,6 +26,25 @@ class CoinBannerItem extends BaseActiveRecord
return
'{{coin_banner_item}}'
;
}
public
function
rules
()
{
return
[
[[
'image_url'
,
'platform_id'
],
'required'
],
[[
'banner_url'
,
'title'
],
'safe'
],
[[
'banner_url'
,
'image_url'
],
'url'
]
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'image_url'
,
'banner_url'
,
'title'
,
'platform_id'
],
self
::
SCENARIOS_UPDATE
=>
[
'id'
,
'image_url'
,
'banner_url'
,
'title'
,
'platform_id'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
public
static
function
getItems
(
$condition
=
[])
{
return
self
::
find
()
->
joinWith
(
'platform'
)
->
where
(
$condition
)
->
asArray
()
->
all
();
...
...
common/models/psources/ExploreApp.php
0 → 100644
View file @
aa3207c8
<?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
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'
,
'sort'
,
'status'
,
'platform_id'
,
'app_category_id'
],
'required'
],
[[
'type'
,
'sort'
,
'status'
,
'platform_id'
,
'app_category_id'
],
'integer'
],
[[
'icon'
],
'url'
]
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'icon'
,
'app_url'
,
'slogan'
,
'type'
,
'sort'
,
'status'
,
'platform_id'
,
'app_category_id'
],
self
::
SCENARIOS_UPDATE
=>
[
'id'
,
'name'
,
'icon'
,
'app_url'
,
'slogan'
,
'type'
,
'sort'
,
'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 @
aa3207c8
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
ExploreAppCategory
extends
BaseActiveRecord
{
const
STATUS_ON
=
1
;
//激活
const
STATUS_OFF
=
0
;
//未激活
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'
,
'limit'
,
'style'
,
'platform_id'
,
'status'
],
'required'
],
];
}
public
function
attributes
()
{
return
array_merge
(
parent
::
attributes
(),
[
'apps'
]);
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'sort'
,
'limit'
,
'style'
,
'platform_id'
,
'status'
],
self
::
SCENARIOS_UPDATE
=>
[
'name'
,
'sort'
,
'limit'
,
'style'
,
'platform_id'
,
'status'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
public
function
attributeLabels
()
{
return
[
'name'
=>
'应用分类名称'
,
'sort'
=>
'应用分类排序'
,
'limit'
=>
'该分类下首页可显示的应用数量'
,
'style'
=>
'应用分类展示样式'
,
'status'
=>
'应用分类状态'
];
}
public
function
getApplications
()
{
return
$this
->
hasMany
(
ExploreApp
::
className
(),
[
'app_category_id'
=>
'id'
])
->
select
([
'id'
,
'name'
,
'icon'
,
'app_url'
,
'slogan'
,
'type'
]);
}
}
\ No newline at end of file
wallet/controllers/ExploreAppController.php
0 → 100644
View file @
aa3207c8
This diff is collapsed.
Click to expand it.
wallet/controllers/ExploreBannerController.php
0 → 100644
View file @
aa3207c8
<?php
namespace
wallet\controllers
;
use
Yii
;
use
yii\data\Pagination
;
use
wallet\base\BaseController
;
use
common\models\psources\CoinBannerItem
;
class
ExploreBannerController
extends
BaseController
{
public
function
actionIndex
()
{
$msg
=
'ok'
;
$code
=
0
;
$data
=
null
;
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
if
(
Yii
::
$app
->
request
->
isGet
)
{
$query
=
CoinBannerItem
::
find
()
->
select
(
'id, banner_url, image_url, title'
)
->
where
([
'platform_id'
=>
$platform_id
])
->
asArray
();
$banner_model
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
10
)
->
asArray
()
->
all
();
$countQuery
=
clone
$query
;
$pages
=
new
Pagination
([
'totalCount'
=>
$countQuery
->
count
(),
'pageSize'
=>
'10'
]);
$data
=
[
'list'
=>
$banner_model
,
'page'
=>
[
'pageCount'
=>
$pages
->
pageCount
,
'pageSize'
=>
10
,
'currentPage'
=>
$page
,
]
];
goto
doEnd
;
}
if
(
Yii
::
$app
->
request
->
isPost
)
{
$model
=
new
CoinBannerItem
();
$model
->
setScenario
(
CoinBannerItem
::
SCENARIOS_CREATE
);
$params
=
Yii
::
$app
->
request
->
post
();
$params
[
'platform_id'
]
=
$platform_id
;
if
(
$model
->
load
(
$params
,
''
)
&&
$model
->
save
())
{
goto
doEnd
;
}
$msg
=
$model
->
errors
;
$code
=
-
1
;
goto
doEnd
;
}
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionUpdate
()
{
$msg
=
'ok'
;
$code
=
0
;
$data
=
null
;
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
if
(
Yii
::
$app
->
request
->
isGet
)
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
$data
=
CoinBannerItem
::
find
()
->
select
(
'id, banner_url, image_url, title'
)
->
where
([
'platform_id'
=>
$platform_id
,
'id'
=>
$id
])
->
asArray
()
->
one
();
goto
doEnd
;
}
if
(
Yii
::
$app
->
request
->
isPut
)
{
$params
=
Yii
::
$app
->
request
->
post
();
$id
=
isset
(
$params
[
'id'
])
?
$params
[
'id'
]
:
null
;
if
(
false
==
$id
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
goto
doEnd
;
}
$model
=
CoinBannerItem
::
findOne
(
$id
);
$model
->
setScenario
(
CoinBannerItem
::
SCENARIOS_UPDATE
);
unset
(
$params
[
'id'
]);
if
(
$model
->
load
(
$params
,
''
)
&&
$model
->
save
())
{
goto
doEnd
;
}
$msg
=
$model
->
errors
;
$code
=
-
1
;
goto
doEnd
;
}
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionRemove
()
{
$msg
=
'ok'
;
$code
=
0
;
$data
=
null
;
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
if
(
false
==
$id
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
goto
doEnd
;
}
if
(
Yii
::
$app
->
request
->
isDelete
)
{
$model
=
CoinBannerItem
::
find
()
->
where
([
'id'
=>
$id
,
'platform_id'
=>
$platform_id
])
->
one
();
if
(
false
==
$model
||
!
$model
->
delete
())
{
$msg
=
'删除失败'
;
$code
=
-
1
;
goto
doEnd
;
}
}
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
\ No newline at end of file
wallet/controllers/OssController.php
0 → 100644
View file @
aa3207c8
<?php
namespace
wallet\controllers
;
use
Yii
;
use
OSS\OssClient
;
use
yii\web\UploadedFile
;
use
wallet\base\BaseController
;
class
OssController
extends
BaseController
{
protected
$accessKeyId
=
"LTAI4FxZ787zpBmjLmr6yMwA"
;
protected
$accessKeySecret
=
"5OMu030RFIE2KP3fNJrhVRTlVqBLaE"
;
protected
$endpoint
=
"http://oss-cn-shanghai.aliyuncs.com"
;
protected
$bucket
=
"bqbwallet"
;
public
function
actionUpload
()
{
$data
=
[];
$type
=
Yii
::
$app
->
request
->
post
(
'type'
,
''
);
$uploaded_file
=
UploadedFile
::
getInstanceByName
(
'file'
);
if
(
false
==
$uploaded_file
||
false
==
$type
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
goto
doEnd
;
}
$object
=
md5
(
date
(
'Y-m-d H:i:s'
)
.
$uploaded_file
->
tempName
)
.
'.'
.
$uploaded_file
->
extension
;
$filePath
=
$uploaded_file
->
tempName
;
$ossClient
=
new
OssClient
(
$this
->
accessKeyId
,
$this
->
accessKeySecret
,
$this
->
endpoint
);
$result
=
$ossClient
->
uploadFile
(
$this
->
bucket
,
'upload/'
.
(
empty
(
$type
)
?
''
:
$type
.
'/'
)
.
$object
,
$filePath
);
if
(
!
isset
(
$result
[
"info"
][
'url'
]))
{
$msg
=
'上传失败'
;
$code
=
-
1
;
goto
doEnd
;
}
$code
=
0
;
$msg
=
'ok'
;
$data
=
$result
[
"info"
][
'url'
];
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
\ 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