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
2bab81c8
Commit
2bab81c8
authored
Dec 12, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
14eca0b1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
155 additions
and
13 deletions
+155
-13
AppController.php
api/controllers/AppController.php
+26
-0
AppController.php
backend/controllers/AppController.php
+12
-7
list.php
backend/views/app/list.php
+11
-1
package.php
backend/views/coin/package.php
+1
-1
index.js
backend/web/js/app/index.js
+11
-4
CoinAppVersion.php
common/models/psources/CoinAppVersion.php
+94
-0
No files found.
api/controllers/AppController.php
View file @
2bab81c8
...
...
@@ -9,6 +9,7 @@
namespace
api\controllers
;
use
api\base\BaseController
;
use
common\models\psources\CoinAppVersion
;
use
common\models\pwallet\AppVersion
;
class
AppController
extends
BaseController
...
...
@@ -48,4 +49,28 @@ class AppController extends BaseController
$data
[
'version_code'
]
=
(
integer
)
$data
[
'version_code'
];
return
$data
;
}
public
function
actionUpdateVersion
()
{
$type
=
\Yii
::
$app
->
request
->
post
(
'type'
,
1
);
$platform_id
=
\Yii
::
$app
->
request
->
post
(
'platform_id'
,
1
);
$data
=
CoinAppVersion
::
getLastStable
(
$type
,
$platform_id
);
if
(
$data
)
{
$logItems
=
json_decode
(
$data
[
'log'
]);
$logstr
=
''
;
foreach
(
$logItems
as
$item
){
if
(
$logstr
){
$logstr
.=
"
\n
"
.
$item
;
}
else
{
$logstr
=
$item
;
}
}
$data
[
'log'
]
=
$logstr
;
$data
[
'id'
]
=
(
integer
)
$data
[
'id'
];
$data
[
'status'
]
=
(
integer
)
$data
[
'status'
];
$data
[
'version_code'
]
=
(
integer
)
$data
[
'version_code'
];
}
return
$data
;
}
}
\ No newline at end of file
backend/controllers/AppController.php
View file @
2bab81c8
...
...
@@ -8,6 +8,8 @@
namespace
backend\controllers
;
use
common\models\psources\CoinPlatform
;
use
common\models\psources\CoinAppVersion
;
use
Yii
;
use
common\models\pwallet\AppVersion
;
use
yii\web\UploadedFile
;
...
...
@@ -24,12 +26,15 @@ class AppController extends BaseController
$page
=
$request
->
get
(
'page'
,
1
);
$limit
=
$request
->
get
(
'limit'
,
10
);
$type
=
$request
->
get
(
'type'
,
[
1
,
2
,
3
]);
$platform_id
=
$request
->
get
(
'platform_id'
,
1
);
$where
=
[];
$where
[]
=
[
'in'
,
'type'
,
$type
];
$data
=
AppVersion
::
getList
(
$page
,
$limit
,
$where
);
$where
[]
=
[
'platform_id'
=>
$platform_id
];
$data
=
CoinAppVersion
::
getList
(
$page
,
$limit
,
$where
);
return
$data
;
}
return
$this
->
render
(
'list'
);
$platforms
=
CoinPlatform
::
find
()
->
asArray
()
->
all
();
return
$this
->
render
(
'list'
,[
'platforms'
=>
$platforms
]);
}
/**
...
...
@@ -40,11 +45,11 @@ class AppController extends BaseController
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
if
(
$id
=
Yii
::
$app
->
request
->
post
(
'id'
))
{
$model
=
AppVersion
::
findOne
(
$id
);
$model
->
scenario
=
AppVersion
::
APP_UPDATE
;
$model
=
Coin
AppVersion
::
findOne
(
$id
);
$model
->
scenario
=
Coin
AppVersion
::
APP_UPDATE
;
}
else
{
$model
=
new
AppVersion
();
$model
->
scenario
=
AppVersion
::
APP_ADD
;
$model
=
new
Coin
AppVersion
();
$model
->
scenario
=
Coin
AppVersion
::
APP_ADD
;
}
$post
=
array_filter
(
Yii
::
$app
->
request
->
post
(),
function
(
$item
)
{
return
$item
;
...
...
@@ -81,7 +86,7 @@ class AppController extends BaseController
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
if
(
$id
)
{
$model
=
AppVersion
::
findOne
(
$id
);
$model
=
Coin
AppVersion
::
findOne
(
$id
);
if
(
$model
)
{
$model
->
delete
();
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
...
...
backend/views/app/list.php
View file @
2bab81c8
...
...
@@ -10,11 +10,21 @@ use yii\helpers\Html;
use
backend\assets\app\IndexAsset
;
IndexAsset
::
register
(
$this
);
?>
<div
class=
"layui-row"
>
<form
class=
"layui-form"
>
<div>
<a
class=
"layui-btn btn-primary btn_add"
>
添加
<i
class=
"fa fa-plus"
></i></a>
<div
class=
"layui-inline"
>
<div
class=
"layui-input-inline"
>
<select
class=
"layui-select"
name=
"platform_id"
lay-filter=
"platform_change"
>
<?php
foreach
(
$platforms
as
$key
=>
$value
)
:
?>
<option
value=
"
<?=
$value
[
'id'
]
?>
"
>
<?=
$value
[
'name'
]
?>
</option>
<?php
endforeach
;
?>
</select>
</div>
</div>
</div>
</form>
<div
class=
"layui-tab layui-tab-card"
>
<ul
class=
"layui-tab-title"
>
<li
class=
"layui-this"
>
Android
</li>
...
...
backend/views/coin/package.php
View file @
2bab81c8
...
...
@@ -6,7 +6,7 @@
* Time: 下午5:45
*/
;
?>
?>
<style
type=
"text/css"
>
.layui-form-label
{
...
...
backend/web/js/app/index.js
View file @
2bab81c8
...
...
@@ -23,7 +23,7 @@ table1.render({
elem
:
'#table1'
,
page
:
1
,
limit
:
10
,
where
:
{
type
:
[
1
,
2
,
3
]},
where
:
{
type
:
[
1
,
2
,
3
]
,
platform_id
:
$
(
"select[name='platform_id']"
).
val
()
},
url
:
'/admin/app/list'
,
cols
:
[[
{
field
:
'id'
,
title
:
'编号'
},
...
...
@@ -44,7 +44,7 @@ table2.render({
elem
:
'#table2'
,
page
:
1
,
limit
:
10
,
where
:
{
type
:
[
4
,
5
,
6
]},
where
:
{
type
:
[
4
,
5
,
6
]
,
platform_id
:
$
(
"select[name='platform_id']"
).
val
()
},
url
:
'/admin/app/list'
,
cols
:
[[
{
field
:
'id'
,
title
:
'编号'
},
...
...
@@ -140,6 +140,8 @@ $(".btn_add").click(function () {
});
});
form
.
on
(
'submit(formDemo)'
,
function
(
data
)
{
var
platform_obj
=
{
platform_id
:
$
(
"select[name='platform_id']"
).
val
()};
data
.
field
=
Object
.
assign
(
data
.
field
,
platform_obj
);
$
.
post
(
'/admin/app/add'
,
data
.
field
,
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
rev
.
code
==
0
)
{
...
...
@@ -177,4 +179,9 @@ function before_show(data) {
$
(
'textarea[name="log"]'
).
val
(
JSON
.
parse
(
data
.
log
).
join
(
"
\
n"
));
}
form
.
render
();
}
\ No newline at end of file
}
form
.
on
(
'select(platform_change)'
,
function
(
data
){
table1
.
reload
(
'table1'
,
{
where
:{
platform_id
:
data
.
value
}});
table2
.
reload
(
'table2'
,
{
where
:{
platform_id
:
data
.
value
}});
});
\ No newline at end of file
common/models/psources/CoinAppVersion.php
0 → 100644
View file @
2bab81c8
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/12/12
* Time: 10:42
*/
namespace
common\models\psources
;
use
common\core\BaseActiveRecord
;
use
Yii
;
/**
* Class AppVersion
* @property integer $id
* @property integer $status
* @property integer $type
* @property integer $version_code
* @property string $version
* @property string $download_url
* @property string $log
* @property string $created_at
* @property string $updated_at
* @package common\models\pwallet
*/
class
CoinAppVersion
extends
BaseActiveRecord
{
const
APP_ADD
=
'add'
;
const
APP_UPDATE
=
'update'
;
/**
* @throws \yii\base\InvalidConfigException
* @return null|object|\yii\db\Connection
*/
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
/**
* 获取最新的稳定版app
*
* @param int $type android(1) IOS(3)
* @return array
*/
public
static
function
getLastStable
(
$type
=
1
,
$platform_id
=
1
)
{
$max_version
=
self
::
find
()
->
where
([
'type'
=>
$type
,
'platform_id'
=>
$platform_id
])
->
max
(
'version'
);
$data
=
self
::
find
()
->
where
([
'type'
=>
$type
,
'platform_id'
=>
$platform_id
,
'version'
=>
$max_version
])
->
asArray
()
->
one
();
return
$data
;
}
public
function
formName
()
{
return
''
;
}
public
function
attributeLabels
()
{
return
[
'id'
=>
'ID'
,
'status'
=>
'状态'
,
'type'
=>
'类型'
,
'version_code'
=>
'版本代码'
,
'version'
=>
'版本号'
,
'download_url'
=>
'下载地址'
,
'log'
=>
'升级日志'
,
'platform_id'
=>
'平台'
,
'created_at'
=>
'创建时间'
,
'updated_at'
=>
'更新时间'
,
];
}
public
function
rules
()
{
return
[
[[
'id'
,
'status'
,
'type'
,
'version_code'
,
'platform_id'
],
'integer'
],
[[
'log'
,
'created_at'
,
'updated_at'
],
'string'
],
[[
'version'
],
'string'
,
'max'
=>
17
],
[[
'download_url'
],
'string'
,
'max'
=>
255
],
[[
'status'
,
'type'
,
'version_code'
,
'version'
,
'download_url'
],
'required'
,
'on'
=>
'add'
],
[[
'id'
,
'status'
,
'type'
,
'version_code'
,
'version'
,
'download_url'
],
'required'
,
'on'
=>
'update'
],
];
}
public
function
scenarios
()
{
return
[
'add'
=>
[
'status'
,
'type'
,
'version_code'
,
'version'
,
'download_url'
,
'log'
,
'platform_id'
],
'update'
=>
[
'id'
,
'status'
,
'type'
,
'version_code'
,
'version'
,
'download_url'
,
'log'
],
];
}
}
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