Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
clubAdmin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhoujun
clubAdmin
Commits
ac66175f
Commit
ac66175f
authored
Jul 31, 2021
by
zhoujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
预警接口
parent
3bbe8182
Pipeline
#2069
passed with stage
in 0 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
4 deletions
+81
-4
app/Http/Controllers/Api/WarnController.php
app/Http/Controllers/Api/WarnController.php
+26
-4
app/Services/Warn/IWarnService.php
app/Services/Warn/IWarnService.php
+4
-0
app/Services/Warn/WarnService.php
app/Services/Warn/WarnService.php
+50
-0
config/msg.php
config/msg.php
+1
-0
No files found.
app/Http/Controllers/Api/WarnController.php
View file @
ac66175f
...
...
@@ -229,9 +229,20 @@ class WarnController extends BaseController
* @date 2021/07/31
* @author live
*/
public
function
getConfigSetStatus
()
public
function
getConfigSetStatus
(
Request
$request
)
{
$postData
=
$request
->
all
();
$validate
=
Validator
::
make
(
$postData
,
[
'id'
=>
'required|numeric'
,
'status'
=>
'required|numeric'
]);
if
(
$validate
->
fails
())
return
$this
->
getErrorMsg
(
'1001'
,
config
(
'msg.common.1001'
));
try
{
$data
=
$this
->
warnService
->
getConfigSetStatus
(
$postData
);
return
$this
->
getSuccessMsg
(
$data
);
}
catch
(
Exception
$e
)
{
return
$this
->
getErrorMsg
(
$e
->
getCode
(),
$e
->
getMessage
());
}
}
/**
...
...
@@ -240,9 +251,20 @@ class WarnController extends BaseController
* @date 2021/07/31
* @author live
*/
public
function
getConfigSetAllStatus
()
public
function
getConfigSetAllStatus
(
Request
$request
)
{
$postData
=
$request
->
all
();
$validate
=
Validator
::
make
(
$postData
,
[
'ids'
=>
'required|string'
,
'status'
=>
'required|numeric'
]);
if
(
$validate
->
fails
())
return
$this
->
getErrorMsg
(
'1001'
,
config
(
'msg.common.1001'
));
try
{
$data
=
$this
->
warnService
->
getConfigSetAllStatus
(
$postData
);
return
$this
->
getSuccessMsg
(
$data
[
'list'
],
$data
[
'msg'
]);
}
catch
(
Exception
$e
)
{
return
$this
->
getErrorMsg
(
$e
->
getCode
(),
$e
->
getMessage
());
}
}
...
...
app/Services/Warn/IWarnService.php
View file @
ac66175f
...
...
@@ -20,4 +20,8 @@ interface IWarnService
public
function
getConfigEdit
(
$postData
);
//预警配置编辑
public
function
getConfigDel
(
$postData
);
//预警配置删除
public
function
getConfigSetStatus
(
$postData
);
//设置预警配置状态
public
function
getConfigSetAllStatus
(
$postData
);
//批量设置预警状态
}
\ No newline at end of file
app/Services/Warn/WarnService.php
View file @
ac66175f
...
...
@@ -261,4 +261,54 @@ class WarnService implements IWarnService
if
(
$list
->
delete
())
return
true
;
throw
new
Exception
(
config
(
'msg.common.1003'
),
1003
);
}
/**
* 预警配置状态设置
* @return araay
* @date 2021/07/31
* @author live
*/
public
function
getConfigSetStatus
(
$postData
)
{
$list
=
WarnConfigModel
::
where
(
'id'
,
$postData
[
'id'
])
->
first
();
if
(
!
$list
)
throw
new
Exception
(
config
(
'msg.common.1002'
),
1002
);
if
(
$list
->
status
==
$postData
[
'status'
])
throw
new
Exception
(
config
(
'msg.common.1009'
),
1009
);
$list
->
status
=
$postData
[
'status'
];
$list
->
op_user
=
$postData
[
'user'
]
??
''
;
$list
->
updated_at
=
$this
->
time
;
if
(
$list
->
save
())
return
true
;
throw
new
Exception
(
config
(
'msg.common.1003'
),
1003
);
}
/**
* 批量设置预警状态
* @return araay
* @date 2021/07/31
* @author live
*/
public
function
getConfigSetAllStatus
(
$postData
)
{
$array
=
[
'list'
=>
true
,
'msg'
=>
''
];
$ids
=
explode
(
'#'
,
$postData
[
'ids'
]);
if
(
empty
(
$ids
))
throw
new
Exception
(
config
(
'msg.common.1015'
),
1015
);
$lists
=
WarnConfigModel
::
whereIn
(
'id'
,
$ids
)
->
get
();
if
(
$lists
->
isEmpty
())
throw
new
Exception
(
config
(
'msg.common.1002'
),
1002
);
$total
=
$lists
->
count
();
$succuss
=
0
;
$fail
=
0
;
foreach
(
$lists
as
$list
){
$list
->
status
=
$postData
[
'status'
];
$list
->
op_user
=
$postData
[
'user'
]
??
''
;
$list
->
updated_at
=
$this
->
time
;
if
(
$list
->
save
()){
$succuss
++
;
}
else
{
$fail
++
;
}
}
$array
[
'msg'
]
=
'总共操作'
.
$total
.
'条数据,其中成功'
.
$succuss
.
'条,失败'
.
$fail
.
'条'
;
return
$array
;
}
}
\ No newline at end of file
config/msg.php
View file @
ac66175f
...
...
@@ -22,6 +22,7 @@ return [
'1012'
=>
'用户ID不存在'
,
'1013'
=>
'请填写有效的预警手机号'
,
'1014'
=>
'平台和渠道为必填项'
,
'1015'
=>
'请选择有效的数据ID'
,
],
];
\ 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