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
4294f896
Commit
4294f896
authored
Oct 16, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
3d3683e5
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
167 additions
and
157 deletions
+167
-157
ApplicationController.php
backend/controllers/ApplicationController.php
+13
-3
CoinApplication.php
backend/models/coin/CoinApplication.php
+0
-94
CoinApplicationCategoryForm.php
backend/models/coin/CoinApplicationCategoryForm.php
+26
-39
CoinApplicationForm.php
backend/models/coin/CoinApplicationForm.php
+126
-0
add.php
backend/views/application/add.php
+0
-6
list.php
backend/views/application/list.php
+2
-1
CoinAppCate.php
common/models/psources/CoinAppCate.php
+0
-14
No files found.
backend/controllers/ApplicationController.php
View file @
4294f896
...
...
@@ -6,6 +6,7 @@
* Time: 10:26
*/
namespace
backend\controllers
;
use
backend\models\coin\CoinApplicationForm
;
use
common\models\psources\CoinAppCate
;
use
common\models\psources\CoinApplication
;
use
common\models\psources\CoinApplicationCategory
;
...
...
@@ -30,7 +31,7 @@ class ApplicationController extends BaseController
if
(
$app_ids
){
$app_items
=
array_column
(
$app_ids
,
'app_id'
);
}
$where
[]
=
[
'in'
,
'id'
,
[
$app_items
]
];
$where
[]
=
[
'in'
,
'id'
,
$app_items
];
$data
=
CoinApplication
::
getList
(
$page
,
$limit
,
$where
);
return
$data
;
}
else
{
...
...
@@ -52,12 +53,21 @@ class ApplicationController extends BaseController
public
function
actionAdd
()
{
if
(
Yii
::
$app
->
request
->
isPost
){
Yii
::
$app
->
response
->
format
=
'json'
;
$category_id
=
Yii
::
$app
->
request
->
get
(
'category_id'
);
Yii
::
$app
->
response
->
format
=
'json'
;
$fields
=
[
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
];
$fields
=
[
'
category_id'
,
'
name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
];
$params
=
array_merge
(
Yii
::
$app
->
request
->
post
(),[
'category_id'
=>
$category_id
]);
$params
=
$this
->
initParams
(
$params
,
$fields
);
var_dump
(
$params
);
die
;
$coin_applicateion_form
=
new
CoinApplicationForm
();
$coin_applicateion_form
->
setScenario
(
CoinApplicationForm
::
SCENARIO_ADD
);
$coin_applicateion_form
->
load
(
$params
,
''
);
$result
=
$coin_applicateion_form
->
add
();
if
(
$result
[
'code'
]
==
0
){
$this
->
success
(
'添加成功'
,
'/admin/application/list?id='
.
$category_id
);
}
else
{
$this
->
error
(
$result
[
'msg'
],
Yii
::
$app
->
request
->
getReferrer
());
}
}
return
$this
->
render
(
'add'
);
}
...
...
backend/models/coin/CoinApplication.php
deleted
100644 → 0
View file @
3d3683e5
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/16
* Time: 11:43
*/
namespace
backend\models\coin
;
use
backend\models\BaseForm
;
use
common\models\psources\CoinApplicationCategory
;
class
CoinApplicationCategoryForm
extends
BaseForm
{
const
SCENARIO_ADD
=
'add'
;
const
SCENARIO_EDIT
=
'edit'
;
public
$id
;
public
$name
;
public
$sort
;
public
$icon
;
public
$pid
;
public
$banner
;
public
$banner_url
;
public
function
scenarios
()
{
return
[
self
::
SCENARIO_ADD
=>
[
'name'
,
'sort'
,
'icon'
,
'banner'
,
'banner_url'
],
self
::
SCENARIO_EDIT
=>
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'banner'
,
'banner_url'
],
];
}
public
function
attributeLabels
()
{
return
[
'id'
=>
'ID'
,
'name'
=>
'名称'
,
'icon'
=>
'图标'
,
'sort'
=>
'排序'
,
'banner'
=>
'banner图片'
,
'banner_url'
=>
'banner链接'
];
}
public
function
rules
()
{
return
[
[[
'name'
],
'required'
,
'on'
=>
self
::
SCENARIO_ADD
],
[[
'id'
,
'name'
,
'sort'
],
'required'
,
'on'
=>
self
::
SCENARIO_EDIT
],
[
'sort'
,
'default'
,
'value'
=>
1
],
[
'sort'
,
'integer'
],
[
'icon'
,
'default'
,
'value'
=>
0
],
[
'banner'
,
'default'
,
'value'
=>
0
],
[
'name'
,
'checkName'
],
];
}
public
function
checkName
(
$attribute
,
$params
)
{
$res
=
CoinApplicationCategory
::
find
()
->
where
([
'name'
=>
$this
->
$attribute
])
->
one
();
$scenario
=
$this
->
getScenario
();
if
(
$scenario
==
self
::
SCENARIO_ADD
)
{
if
(
$res
)
{
$this
->
addError
(
$attribute
,
'应用分类名称已存在'
);
}
}
else
if
(
$scenario
==
self
::
SCENARIO_EDIT
)
{
if
(
$res
&&
$res
->
id
!=
$this
->
id
)
{
$this
->
addError
(
$attribute
,
'应用分类名称已存在'
);
}
}
}
/**
* 添加应用
*/
public
function
add
()
{
if
(
$this
->
validate
())
{
$coin_applicate_category
=
new
CoinApplicationCategory
();
$coin_applicate_category
->
setAttributes
(
$this
->
attributes
,
false
);
$coin_applicate_category
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'应用分类添加成功!'
];
}
else
{
$error
=
self
::
getModelError
(
$this
);
return
[
'code'
=>
1
,
'msg'
=>
$error
];
}
}
}
\ No newline at end of file
backend/models/coin/CoinApplicationCategoryForm.php
View file @
4294f896
...
...
@@ -2,38 +2,33 @@
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/1
2
* Time: 1
9:10
* Date: 2018/10/1
6
* Time: 1
1:43
*/
namespace
backend\models\coin
;
use
backend\models\BaseForm
;
use
common\models\psources\CoinApplicationCategory
;
class
CoinApplication
Form
extends
BaseForm
class
CoinApplication
CategoryForm
extends
BaseForm
{
const
SCENARIO_ADD
=
'add'
;
const
SCENARIO_EDIT
=
'edit'
;
public
$id
;
public
$name
;
public
$icon
;
public
$sort
;
public
$type
;
public
$native_url
;
public
$h5_url
;
public
$android_url
;
public
$ios_url
;
public
$app_store_url
;
public
$advertise
;
public
$description
;
public
$image_ids
;
public
$redirect_type
;
public
$icon
;
public
$pid
;
public
$banner
;
public
$banner_url
;
public
function
scenarios
()
{
return
[
self
::
SCENARIO_ADD
=>
[
'name'
,
'sort'
,
'icon'
,
'banner'
,
'banner_url'
],
self
::
SCENARIO_EDIT
=>
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'banner'
,
'banner_url'
],
self
::
SCENARIO_ADD
=>
[
'name'
,
'sort'
,
'icon'
,
'banner'
,
'banner_url'
],
self
::
SCENARIO_EDIT
=>
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'banner'
,
'banner_url'
],
];
}
...
...
@@ -45,15 +40,8 @@ class CoinApplicationForm extends BaseForm
'name'
=>
'名称'
,
'icon'
=>
'图标'
,
'sort'
=>
'排序'
,
'type'
=>
'类型'
,
'native_url'
=>
'原生链接'
,
'h5_url'
=>
'h5链接'
,
'android_url'
=>
'安卓链接'
,
'ios_url'
=>
'ios企业版链接'
,
'app_store_url'
=>
'ios商店版链接'
,
'advertise'
=>
'宣传语'
,
'description'
=>
'介绍'
,
'redirect_type'
=>
'跳转方式'
,
'banner'
=>
'banner图片'
,
'banner_url'
=>
'banner链接'
];
}
...
...
@@ -61,11 +49,11 @@ class CoinApplicationForm extends BaseForm
{
return
[
[[
'name'
],
'required'
,
'on'
=>
self
::
SCENARIO_ADD
],
[[
'id'
,
'name'
,
'sort'
],
'required'
,
'on'
=>
self
::
SCENARIO_EDIT
],
[[
'id'
,
'name'
,
'sort'
],
'required'
,
'on'
=>
self
::
SCENARIO_EDIT
],
[
'sort'
,
'default'
,
'value'
=>
1
],
[
'sort'
,
'integer'
],
[
'icon'
,
'default'
,
'value'
=>
0
],
[
'banner'
,
'default'
,
'value'
=>
0
],
[
'banner'
,
'default'
,
'value'
=>
0
],
[
'name'
,
'checkName'
],
];
}
...
...
@@ -74,32 +62,31 @@ class CoinApplicationForm extends BaseForm
{
$res
=
CoinApplicationCategory
::
find
()
->
where
([
'name'
=>
$this
->
$attribute
])
->
one
();
$scenario
=
$this
->
getScenario
();
if
(
$scenario
==
self
::
SCENARIO_ADD
){
if
(
$res
){
$this
->
addError
(
$attribute
,
'应用分类名称已存在'
);
if
(
$scenario
==
self
::
SCENARIO_ADD
)
{
if
(
$res
)
{
$this
->
addError
(
$attribute
,
'应用分类名称已存在'
);
}
}
else
if
(
$scenario
==
self
::
SCENARIO_EDIT
){
if
(
$res
&&
$res
->
id
!=
$this
->
id
){
$this
->
addError
(
$attribute
,
'应用分类名称已存在'
);
}
else
if
(
$scenario
==
self
::
SCENARIO_EDIT
)
{
if
(
$res
&&
$res
->
id
!=
$this
->
id
)
{
$this
->
addError
(
$attribute
,
'应用分类名称已存在'
);
}
}
}
/**
* 添加应用分类
*/
public
function
add
()
{
if
(
$this
->
validate
()){
if
(
$this
->
validate
())
{
$coin_applicate_category
=
new
CoinApplicationCategory
();
$coin_applicate_category
->
setAttributes
(
$this
->
attributes
,
false
);
$coin_applicate_category
->
setAttributes
(
$this
->
attributes
,
false
);
$coin_applicate_category
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'应用分类添加成功!'
];
}
else
{
return
[
'code'
=>
0
,
'msg'
=>
'应用分类添加成功!'
];
}
else
{
$error
=
self
::
getModelError
(
$this
);
return
[
'code'
=>
1
,
'msg'
=>
$error
];
return
[
'code'
=>
1
,
'msg'
=>
$error
];
}
}
...
...
backend/models/coin/CoinApplicationForm.php
0 → 100644
View file @
4294f896
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/12
* Time: 19:10
*/
namespace
backend\models\coin
;
use
backend\models\BaseForm
;
use
common\models\psources\CoinAppCate
;
use
common\models\psources\CoinApplication
;
use
Yii
;
class
CoinApplicationForm
extends
BaseForm
{
const
SCENARIO_ADD
=
'add'
;
const
SCENARIO_EDIT
=
'edit'
;
public
$id
;
public
$category_id
;
public
$name
;
public
$icon
;
public
$sort
;
public
$type
;
public
$native_url
;
public
$h5_url
;
public
$android_url
;
public
$ios_url
;
public
$app_store_url
;
public
$advertise
;
public
$description
;
public
$image_ids
;
public
$redirect_type
;
public
function
scenarios
()
{
return
[
self
::
SCENARIO_ADD
=>
[
'category_id'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
],
self
::
SCENARIO_EDIT
=>
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
],
];
}
public
function
attributeLabels
()
{
return
[
'id'
=>
'ID'
,
'category_id'
=>
'分类ID'
,
'name'
=>
'名称'
,
'icon'
=>
'图标'
,
'sort'
=>
'排序'
,
'type'
=>
'类型'
,
'native_url'
=>
'原生链接'
,
'h5_url'
=>
'h5链接'
,
'android_url'
=>
'安卓链接'
,
'ios_url'
=>
'ios企业版链接'
,
'app_store_url'
=>
'ios商店版链接'
,
'advertise'
=>
'宣传语'
,
'description'
=>
'介绍'
,
'redirect_type'
=>
'跳转方式'
,
];
}
public
function
rules
()
{
return
[
[[
'name'
,
'category_id'
],
'required'
,
'on'
=>
self
::
SCENARIO_ADD
],
[
'sort'
,
'default'
,
'value'
=>
1
],
[
'sort'
,
'integer'
],
[
'icon'
,
'default'
,
'value'
=>
0
],
[
'advertise'
,
'string'
,
'length'
=>
[
0
,
20
]],
[
'description'
,
'string'
,
'length'
=>
[
0
,
500
]],
[
'type'
,
'default'
,
'value'
=>
1
],
[
'redirect_type'
,
'default'
,
'value'
=>
1
],
];
}
public
function
checkName
(
$attribute
,
$params
)
{
$res
=
CoinApplication
::
find
()
->
where
([
'name'
=>
$this
->
$attribute
])
->
one
();
$scenario
=
$this
->
getScenario
();
if
(
$scenario
==
self
::
SCENARIO_ADD
){
if
(
$res
){
$this
->
addError
(
$attribute
,
'应用名称已存在'
);
}
}
else
if
(
$scenario
==
self
::
SCENARIO_EDIT
){
if
(
$res
&&
$res
->
id
!=
$this
->
id
){
$this
->
addError
(
$attribute
,
'应用名称已存在'
);
}
}
}
/**
* 添加应用
*/
public
function
add
()
{
if
(
$this
->
validate
()){
$tr
=
CoinApplication
::
getDb
()
->
beginTransaction
();
try
{
$coin_applicate
=
new
CoinApplication
();
$coin_applicate
->
setAttributes
(
$this
->
attributes
,
false
);
$res
=
$coin_applicate
->
save
();
if
(
$res
){
$coin_app_cate
=
new
CoinAppCate
();
$coin_app_cate
->
app_id
=
$coin_applicate
->
id
;
$coin_app_cate
->
cate_id
=
$this
->
category_id
;
$coin_app_cate
->
save
();
$tr
->
commit
();
}
return
[
'code'
=>
0
,
'msg'
=>
'应用添加成功!'
];
}
catch
(
\Exception
$e
){
$tr
->
rollBack
();
return
[
'code'
=>
1
,
'msg'
=>
$e
->
getMessage
()];
}
}
else
{
$error
=
self
::
getModelError
(
$this
);
return
[
'code'
=>
1
,
'msg'
=>
$error
];
}
}
}
\ No newline at end of file
backend/views/application/add.php
View file @
4294f896
...
...
@@ -77,12 +77,6 @@
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
众筹价格
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
""
placeholder=
"¥"
value=
""
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
宣传语
</label>
<div
class=
"layui-input-block"
>
<input
type=
"text"
class=
"layui-input"
name=
"advertise"
value=
""
>
...
...
backend/views/application/list.php
View file @
4294f896
...
...
@@ -14,6 +14,7 @@
</a>
</div>
</div>
<input
id=
"category_id"
type=
"hidden"
value=
"
<?=
$parent_category
->
id
?>
"
>
<div
class=
"layui-col-md8"
>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
</div>
...
...
@@ -29,7 +30,7 @@
<script
type=
"text/javascript"
>
var
table
=
layui
.
table
;
var
category_id
=
$
(
"#
parent
_id"
).
val
();
var
category_id
=
$
(
"#
category
_id"
).
val
();
table
.
render
({
elem
:
'#table1'
,
page
:
true
,
...
...
common/models/psources/CoinAppCate.php
View file @
4294f896
...
...
@@ -23,20 +23,6 @@ class CoinAppCate extends BaseActiveRecord
return
'{{%coin_app_cate}}'
;
}
public
function
beforeSave
(
$instert
)
{
if
(
parent
::
beforeSave
(
$instert
))
{
if
(
$this
->
isNewRecord
)
{
$this
->
create_time
=
Yii
::
$app
->
formatter
->
asTimestamp
(
'now'
);
}
else
{
$this
->
update_time
=
Yii
::
$app
->
formatter
->
asTimestamp
(
'now'
);
}
return
true
;
}
else
{
return
false
;
}
}
public
static
function
getAppIdByCateId
(
$cate_id
)
{
return
self
::
find
()
->
where
([
'cate_id'
=>
$cate_id
])
->
asArray
()
->
all
();
...
...
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