Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
bf56583b
Commit
bf56583b
authored
Oct 11, 2016
by
庄欣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
样片,套系编辑时对精选的影响
parent
8883939f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
4 deletions
+85
-4
app/Choice/Model/Choice.php
+35
-0
app/Providers/EventServiceProvider.php
+4
-2
app/Sets/Listeners/PropChoice.php
+21
-0
app/Test/Controller/TestController.php
+4
-2
app/Works/Listeners/PropChoice.php
+21
-0
No files found.
app/Choice/Model/Choice.php
0 → 100755
View file @
bf56583b
<?php
/**
* Created by PhpStorm.
* User: zhuangxin
* Date: 16-9-20
* Time: 下午2:09
*/
namespace
App\Choice\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Support\Facades\DB
;
class
Choice
extends
Model
{
protected
$table
=
"myp_choice"
;
const
SETS
=
"sets"
;
const
WORKS
=
"works"
;
const
TYPE
=
[
self
::
SETS
=>
'套系'
,
self
::
WORKS
=>
'样片'
];
public
static
function
isChoiceItem
(
$id
,
$type
=
self
::
SETS
)
{
$sql
=
"SELECT a.id,b.id as sid FROM %s a JOIN %s b ON b.choice_id = a.id WHERE a.type = '%s' AND b.src_id=%d"
;
$sql
=
sprintf
(
$sql
,
"myp_choice"
,
"myp_choice_set"
,
$type
,
$id
);
return
count
(
DB
::
select
(
$sql
))
>
0
;
}
public
static
function
UpdateStatus
(
$id
,
$type
=
self
::
SETS
,
$status
=
0
)
{
$sql
=
"UPDATE %s a,%s b SET b.is_del = %d WHERE a.type = '%s' AND b.src_id=%d"
;
$sql
=
sprintf
(
$sql
,
"myp_choice"
,
"myp_choice_set"
,
$status
,
$type
,
$id
);
return
DB
::
update
(
$sql
);
}
}
\ No newline at end of file
app/Providers/EventServiceProvider.php
View file @
bf56583b
...
@@ -15,11 +15,13 @@ class EventServiceProvider extends ServiceProvider
...
@@ -15,11 +15,13 @@ class EventServiceProvider extends ServiceProvider
*/
*/
protected
$listen
=
[
protected
$listen
=
[
\App\Works\Events\WorksEditedEvent
::
class
=>
[
\App\Works\Events\WorksEditedEvent
::
class
=>
[
\App\Works\Listeners\WorksSearcherListener
::
class
\App\Works\Listeners\WorksSearcherListener
::
class
,
\App\Works\Listeners\PropChoice
::
class
],
],
\App\Sets\Events\SetsEditedEvent
::
class
=>
[
\App\Sets\Events\SetsEditedEvent
::
class
=>
[
\App\Sets\Listeners\SetsSearcherListener
::
class
,
\App\Sets\Listeners\SetsSearcherListener
::
class
,
\App\Sets\Listeners\SetsEditedListener
::
class
\App\Sets\Listeners\SetsEditedListener
::
class
,
\App\Sets\Listeners\PropChoice
::
class
],
],
\App\Article\Events\ArtAddEvent
::
class
=>
[
\App\Article\Events\ArtAddEvent
::
class
=>
[
\App\Article\Listeners\ArtListener
::
class
\App\Article\Listeners\ArtListener
::
class
...
...
app/Sets/Listeners/PropChoice.php
0 → 100644
View file @
bf56583b
<?php
namespace
App\Sets\Listeners
;
use
App\Choice\Model\Choice
as
ChoiceModel
;
class
PropChoice
{
public
function
handle
(
$event
)
{
/** @var \App\Sets\Model\Sets $model */
$model
=
$event
->
model
;
if
(
!
ChoiceModel
::
isChoiceItem
(
$model
->
id
,
ChoiceModel
::
SETS
))
{
return
;
}
if
(
$model
->
exists
===
false
||
$model
->
is_del
==
1
||
$model
->
is_shelf
==
1
)
{
ChoiceModel
::
UpdateStatus
(
$model
->
id
,
ChoiceModel
::
SETS
,
1
);
}
else
{
ChoiceModel
::
UpdateStatus
(
$model
->
id
,
ChoiceModel
::
SETS
,
0
);
}
}
}
\ No newline at end of file
app/Test/Controller/TestController.php
View file @
bf56583b
...
@@ -10,6 +10,7 @@ namespace App\Test\Controller;
...
@@ -10,6 +10,7 @@ namespace App\Test\Controller;
use
App\Article\Model\Art
;
use
App\Article\Model\Art
;
use
App\Choice\Model\Choice
;
use
App\Ident\Model\Ident
;
use
App\Ident\Model\Ident
;
use
App\Ident\Validation\IdentValidator
;
use
App\Ident\Validation\IdentValidator
;
use
App\Libraries\Upyun\UpyunClient
;
use
App\Libraries\Upyun\UpyunClient
;
...
@@ -36,7 +37,7 @@ class TestController extends Controller
...
@@ -36,7 +37,7 @@ class TestController extends Controller
public
function
index
()
public
function
index
()
{
{
$
k
=
User
::
getUserInfo
(
14
,[
"nickname"
])
->
nickname
;
$
res
=
Choice
::
UpdateStatus
(
13
,
Choice
::
SETS
,
0
)
;
var_dump
(
$
k
);
var_dump
(
$
res
);
}
}
}
}
\ No newline at end of file
app/Works/Listeners/PropChoice.php
0 → 100644
View file @
bf56583b
<?php
namespace
App\Works\Listeners
;
use
App\Choice\Model\Choice
as
ChoiceModel
;
class
PropChoice
{
public
function
handle
(
$event
)
{
/** @var \App\Works\Model\Works $model */
$model
=
$event
->
model
;
if
(
!
ChoiceModel
::
isChoiceItem
(
$model
->
id
,
ChoiceModel
::
WORKS
))
{
return
;
}
if
(
$model
->
exists
===
false
||
$model
->
is_del
==
1
||
$model
->
is_hidden
==
1
)
{
ChoiceModel
::
UpdateStatus
(
$model
->
id
,
ChoiceModel
::
WORKS
,
1
);
}
else
{
ChoiceModel
::
UpdateStatus
(
$model
->
id
,
ChoiceModel
::
WORKS
,
0
);
}
}
}
\ 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