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
fbbd5525
Commit
fbbd5525
authored
Dec 02, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into develop
parents
1bdabc9a
907b6142
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
6 deletions
+29
-6
NoticeController.php
api/controllers/NoticeController.php
+3
-3
Notice.php
common/models/pwallet/Notice.php
+26
-3
NoticeController.php
wallet/controllers/NoticeController.php
+0
-0
No files found.
api/controllers/NoticeController.php
View file @
fbbd5525
...
...
@@ -44,9 +44,9 @@ class NoticeController extends BaseController
$size
=
\Yii
::
$app
->
request
->
get
(
'size'
,
10
);
$query
=
Notice
::
find
()
->
select
(
'id, title, author, type, create_
at
'
)
->
select
(
'id, title, author, type, create_
time
'
)
->
where
([
'status'
=>
Notice
::
STATUS_ON
])
->
orderBy
(
'create_
at
desc'
);
->
orderBy
(
'create_
time
desc'
);
if
(
false
!=
$type
)
{
$query
->
andWhere
([
'type'
=>
(
int
)
$type
]);
...
...
@@ -90,7 +90,7 @@ class NoticeController extends BaseController
goto
doEnd
;
}
$data
=
Notice
::
find
()
->
select
(
'title,content,author,type,create_
at
'
)
->
where
([
'id'
=>
$id
,
'platform_id'
=>
$platform_id
])
->
asArray
()
->
one
();
$data
=
Notice
::
find
()
->
select
(
'title,content,author,type,create_
time
'
)
->
where
([
'id'
=>
$id
,
'platform_id'
=>
$platform_id
])
->
asArray
()
->
one
();
$msg
=
'ok'
;
$code
=
0
;
...
...
common/models/pwallet/Notice.php
View file @
fbbd5525
...
...
@@ -16,6 +16,9 @@ class Notice extends BaseActiveRecord
const
STATUS_ON
=
1
;
//激活
const
STATUS_OFF
=
0
;
//未激活
const
TYPE_ROLL
=
1
;
//滚动
const
TYPE_POP
=
0
;
//弹窗
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
...
...
@@ -28,12 +31,32 @@ class Notice extends BaseActiveRecord
public
function
rules
()
{
return
[
[[
'title'
,
'content'
,
'type'
,
'
platform_id
'
],
'required'
],
[[
'
author'
],
'safe
'
],
[
[
'status'
,
'status'
,
'platform_id'
],
'integer
'
],
[[
'title'
,
'content'
,
'type'
,
'
status'
,
'platform_id'
,
'author
'
],
'required'
],
[[
'
status'
,
'type'
,
'platform_id'
],
'integer
'
],
[
'type'
,
'verfiyType
'
],
];
}
public
function
verfiyType
(
$attribute
,
$params
)
{
if
(
'create'
==
self
::
getScenario
()){
$count
=
self
::
find
()
->
where
([
'platform_id'
=>
$this
->
platform_id
,
'type'
=>
$this
->
type
])
->
count
();
if
(
Notice
::
TYPE_ROLL
==
$this
->
type
)
{
if
(
$count
>=
3
)
{
$this
->
addError
(
$attribute
,
'滚动公告最多只能3条'
);
return
false
;
}
}
if
(
Notice
::
TYPE_POP
==
$this
->
type
)
{
if
(
$count
>=
1
)
{
$this
->
addError
(
$attribute
,
'弹窗公告最多只能3条'
);
return
false
;
}
}
}
}
public
function
scenarios
()
{
$scenarios
=
[
...
...
wallet/controllers/NoticeController.php
View file @
fbbd5525
This diff is collapsed.
Click to expand it.
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