1、预警功能一键标记已读实现
2、前端通过消息总线进行组件之间传值,比如预警信息页面全部处理后,右上角的组件计数需要清零
This commit is contained in:
parent
bb4c812c17
commit
68e78bdc7b
|
|
@ -52,3 +52,11 @@ export function clearAll() {
|
|||
method: 'delete',
|
||||
})
|
||||
}
|
||||
|
||||
// 全部标记已读
|
||||
export function AllHaveRead() {
|
||||
return request({
|
||||
url: '/warning/apiwarning/handleAll',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,9 +122,17 @@ export default {
|
|||
"apiWarning",
|
||||
this.getData
|
||||
);
|
||||
|
||||
this.$bus.$on('clearCount', this.clearCount)
|
||||
},
|
||||
|
||||
methods: {
|
||||
//小红点清零
|
||||
clearCount(data) {
|
||||
if (data) {
|
||||
this.warnData.count = 0
|
||||
}
|
||||
},
|
||||
|
||||
//已读操作
|
||||
haveRead() {
|
||||
|
|
@ -143,18 +151,15 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
append() {
|
||||
let str = this.warnData.data;
|
||||
if (str != null) {
|
||||
var json = eval("(" + str + ")");
|
||||
if (json.apiName !== undefined && json.warningMessage !== undefined) {
|
||||
let data = json.apiName + "-" + json.warningMessage;
|
||||
if (json.warningMessage !== undefined) {
|
||||
// this.visible = true
|
||||
return data
|
||||
return json.warningMessage
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -86,5 +86,10 @@ new Vue({
|
|||
el: '#app',
|
||||
router,
|
||||
store,
|
||||
|
||||
beforeCreate() {
|
||||
Vue.prototype.$bus = this //安装全局事件总线,$bus就是当前应用的vm
|
||||
},
|
||||
|
||||
render: h => h(App)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -35,10 +35,22 @@
|
|||
icon="el-icon-delete-solid"
|
||||
size="mini"
|
||||
@click="clearAll"
|
||||
|
||||
v-hasPermi="['warning:warning:remove']"
|
||||
>清空
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-success"
|
||||
size="mini"
|
||||
@click="AllHaveRead"
|
||||
v-hasPermi="['warning:warning:handleAll']"
|
||||
>全部标记已读
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
|
|
@ -84,7 +96,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {listApiwarning,clearAll } from "@/api/business/warning/apiwarning";
|
||||
import {listApiwarning,clearAll,AllHaveRead } from "@/api/business/warning/apiwarning";
|
||||
|
||||
export default {
|
||||
name: "Warning",
|
||||
|
|
@ -124,6 +136,16 @@ export default {
|
|||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
//全部标记已读
|
||||
AllHaveRead() {
|
||||
AllHaveRead().then(res =>{
|
||||
this.$modal.msgSuccess("处理"+res.data+"条");
|
||||
this.getList();
|
||||
//组件传值
|
||||
this.$bus.$emit('clearCount',true)
|
||||
})
|
||||
},
|
||||
|
||||
//清空预警信息
|
||||
clearAll() {
|
||||
clearAll().then(res =>{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ package com.xjs.enums;
|
|||
*/
|
||||
public enum WarnTypeEnum {
|
||||
|
||||
API("API","API接口调用超出限定值。限定值--%s次,实际值--%s次");
|
||||
API("API","API接口(%s)调用超出限定值。限定值--%s次,实际值--%s次");
|
||||
|
||||
private final String type;
|
||||
|
||||
|
|
|
|||
|
|
@ -197,7 +197,9 @@ public class ApiLogAspect {
|
|||
}
|
||||
apiWarning.setWarningType(WarnTypeEnum.API.getType());
|
||||
String message = String.format(WarnTypeEnum.API.getMessage(),
|
||||
haveApiRecord.getLimitCount(), haveApiRecord.getDayCount());
|
||||
haveApiRecord.getApiName(),
|
||||
haveApiRecord.getLimitCount(),
|
||||
haveApiRecord.getDayCount());
|
||||
apiWarning.setWarningMessage(message);
|
||||
remoteWarningCRUDFeign.saveApiWarningForRPC(apiWarning);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import static com.xjs.consts.ApiWarnHandleConst.NO;
|
||||
import static com.xjs.consts.ApiWarnHandleConst.YES;
|
||||
|
|
@ -176,6 +174,14 @@ public class ApiWarningController extends BaseController {
|
|||
return integer > 0 ? R.ok(integer) : R.fail();
|
||||
}
|
||||
|
||||
@RequiresPermissions("warning:warning:handleAll")
|
||||
@PutMapping("handleAll")
|
||||
@ApiOperation("全部标记已读")
|
||||
@Log(title = "全部标记已读")
|
||||
public R<Object> AllHaveRead() {
|
||||
Integer integer = apiWarningService.AllHaveRead();
|
||||
return integer > 0 ? R.ok(integer) : R.fail();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------代码生成------------------------------------
|
||||
|
|
|
|||
|
|
@ -17,4 +17,11 @@ public interface ApiWarningMapper extends BaseMapper<ApiWarning> {
|
|||
* @return Integer
|
||||
*/
|
||||
Integer clearAll();
|
||||
|
||||
|
||||
/**
|
||||
* 一键标记已读
|
||||
* @return Integer
|
||||
*/
|
||||
Integer AllHaveRead();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ public interface ApiWarningService extends IService<ApiWarning> {
|
|||
*/
|
||||
Integer clearAll();
|
||||
|
||||
/**
|
||||
* 一键标记已读
|
||||
* @return Integer
|
||||
*/
|
||||
Integer AllHaveRead();
|
||||
|
||||
//---------------------代码生成---------------------------------
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ public class ApiWarningServiceImpl extends ServiceImpl<ApiWarningMapper, ApiWarn
|
|||
return apiWarningMapper.clearAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer AllHaveRead() {
|
||||
return apiWarningMapper.AllHaveRead();
|
||||
}
|
||||
|
||||
|
||||
//------------------------代码生成-------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xjs.mapper.ApiWarningMapper">
|
||||
|
||||
<update id="AllHaveRead">
|
||||
update api_warning
|
||||
set handle = 1
|
||||
where handle = 2
|
||||
</update>
|
||||
|
||||
|
||||
<delete id="clearAll">
|
||||
delete
|
||||
|
|
|
|||
Loading…
Reference in New Issue