opt: 字典增加缓存
This commit is contained in:
@@ -7,6 +7,7 @@ import org.nl.modules.wql.util.SpringContextHolder;
|
|||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||||
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
* @date 2021/2/22 9:20:19
|
* @date 2021/2/22 9:20:19
|
||||||
*/
|
*/
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
|
@EnableCaching
|
||||||
@RestController
|
@RestController
|
||||||
@EnableDynamicTp
|
@EnableDynamicTp
|
||||||
@SpringBootApplication(exclude = {
|
@SpringBootApplication(exclude = {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.system.controller.dict;
|
package org.nl.system.controller.dict;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.nl.common.TableDataInfo;
|
import org.nl.common.TableDataInfo;
|
||||||
import org.nl.common.domain.query.PageQuery;
|
import org.nl.common.domain.query.PageQuery;
|
||||||
@@ -8,6 +9,7 @@ import org.nl.system.service.dict.ISysDictService;
|
|||||||
import org.nl.system.service.dict.dao.Dict;
|
import org.nl.system.service.dict.dao.Dict;
|
||||||
import org.nl.system.service.dict.dto.DictQuery;
|
import org.nl.system.service.dict.dto.DictQuery;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -59,7 +61,6 @@ public class SysDictController {
|
|||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@Log("修改字典")
|
@Log("修改字典")
|
||||||
|
|
||||||
//@SaCheckPermission("@el.check('dict:edit')")
|
//@SaCheckPermission("@el.check('dict:edit')")
|
||||||
public ResponseEntity<Object> updateDict(@Validated @RequestBody Dict dto) {
|
public ResponseEntity<Object> updateDict(@Validated @RequestBody Dict dto) {
|
||||||
dictService.updateDict(dto);
|
dictService.updateDict(dto);
|
||||||
@@ -76,12 +77,16 @@ public class SysDictController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/dictDetail")
|
@GetMapping("/dictDetail")
|
||||||
|
|
||||||
public ResponseEntity<Object> queryDetails(@RequestParam Map criteria, PageQuery pageable) {
|
public ResponseEntity<Object> queryDetails(@RequestParam Map criteria, PageQuery pageable) {
|
||||||
DictQuery dictQuery = JSONObject.parseObject(JSONObject.toJSONString(criteria), DictQuery.class);
|
DictQuery dictQuery = JSONObject.parseObject(JSONObject.toJSONString(criteria), DictQuery.class);
|
||||||
return new ResponseEntity<>(TableDataInfo.build(dictService.queryAllDetail(dictQuery, pageable)), HttpStatus.OK);
|
return new ResponseEntity<>(TableDataInfo.build(dictService.queryAllDetail(dictQuery, pageable)), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/dictDetail/post")
|
||||||
|
public ResponseEntity<Object> queryDetailsPost(@RequestBody String code) {
|
||||||
|
return new ResponseEntity<>(TableDataInfo.build(dictService.queryDetailsPost(code)), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping(value = "/dictDetail/map")
|
@GetMapping(value = "/dictDetail/map")
|
||||||
public ResponseEntity<Object> getDictDetailMaps(@RequestParam String dictName) {
|
public ResponseEntity<Object> getDictDetailMaps(@RequestParam String dictName) {
|
||||||
|
|||||||
@@ -94,4 +94,11 @@ public interface ISysDictService extends IService<Dict> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Dict> queryAll();
|
List<Dict> queryAll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据code获取字典数据
|
||||||
|
* @param code
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Dict> queryDetailsPost(String code);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import org.nl.system.service.dict.dao.Dict;
|
|||||||
import org.nl.system.service.dict.dao.mapper.SysDictMapper;
|
import org.nl.system.service.dict.dao.mapper.SysDictMapper;
|
||||||
import org.nl.system.service.dict.dto.DictQuery;
|
import org.nl.system.service.dict.dto.DictQuery;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -77,6 +79,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@CacheEvict(value = "dict", key = "#dto.code")
|
||||||
public void updateDict(Dict dto) {
|
public void updateDict(Dict dto) {
|
||||||
Dict dict = sysDictMapper.selectById(dto.getDict_id());
|
Dict dict = sysDictMapper.selectById(dto.getDict_id());
|
||||||
if (ObjectUtil.isEmpty(dict)) {
|
if (ObjectUtil.isEmpty(dict)) {
|
||||||
@@ -102,6 +105,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@CacheEvict(value = "dict", allEntries = true)
|
||||||
public void deleteBatchByIds(Set<String> ids) {
|
public void deleteBatchByIds(Set<String> ids) {
|
||||||
// 查找code删除
|
// 查找code删除
|
||||||
ids.forEach(id -> {
|
ids.forEach(id -> {
|
||||||
@@ -132,6 +136,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@CacheEvict(value = {"dict"}, key = "#dict.code")
|
||||||
public void createDetail(Dict dict) {
|
public void createDetail(Dict dict) {
|
||||||
// 校验是否已经有标签
|
// 校验是否已经有标签
|
||||||
Dict one = sysDictMapper.selectOne(new LambdaQueryWrapper<Dict>().eq(Dict::getLabel, dict.getLabel())
|
Dict one = sysDictMapper.selectOne(new LambdaQueryWrapper<Dict>().eq(Dict::getLabel, dict.getLabel())
|
||||||
@@ -170,6 +175,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@CacheEvict(value = {"dict"}, key = "#resources.code")
|
||||||
public void updateDetail(Dict resources) {
|
public void updateDetail(Dict resources) {
|
||||||
Dict dict = sysDictMapper.selectById(resources.getDict_id());
|
Dict dict = sysDictMapper.selectById(resources.getDict_id());
|
||||||
if (ObjectUtil.isEmpty(dict)) {
|
if (ObjectUtil.isEmpty(dict)) {
|
||||||
@@ -189,6 +195,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@CacheEvict(value = "dict", allEntries = true)
|
||||||
public void deleteDetail(String id) {
|
public void deleteDetail(String id) {
|
||||||
sysDictMapper.deleteById(id);
|
sysDictMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
@@ -201,4 +208,15 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
|||||||
.groupBy(Dict::getCode, Dict::getName));
|
.groupBy(Dict::getCode, Dict::getName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Cacheable(value = {"dict"}, key = "#code")
|
||||||
|
public List<Dict> queryDetailsPost(String code) {
|
||||||
|
LambdaQueryWrapper<Dict> lam = new LambdaQueryWrapper<>();
|
||||||
|
lam.eq(Dict::getCode, code)
|
||||||
|
.isNotNull(Dict::getLabel)
|
||||||
|
.ne(Dict::getLabel, "")
|
||||||
|
.orderBy(true, true, Dict::getDict_sort);
|
||||||
|
return sysDictMapper.selectList(lam);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,9 +98,8 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer countByReceiveNotRead() {
|
public Integer countByReceiveNotRead() {
|
||||||
List<SysNotice> sysNotices = sysNoticeMapper.selectList(new LambdaQueryWrapper<SysNotice>()
|
return sysNoticeMapper.selectCount(new LambdaQueryWrapper<SysNotice>()
|
||||||
.eq(SysNotice::getHave_read, NoticeEnum.HAVE_READ_OFF.getValue()));
|
.eq(SysNotice::getHave_read, NoticeEnum.HAVE_READ_OFF.getValue()));
|
||||||
return ObjectUtil.isNotEmpty(sysNotices) ? sysNotices.size() : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import { get as getDictDetail } from '@/views/system/dict/dictDetail'
|
import { getDictDetails as getDictDetail } from '@/views/system/dict/dictDetail'
|
||||||
|
|
||||||
export default class Dict {
|
export default class Dict {
|
||||||
constructor(dict) {
|
constructor(dict) {
|
||||||
|
|||||||
@@ -49,4 +49,12 @@ export function edit(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default { get, add, edit, del, getDictMap }
|
export function getDictDetails(data) {
|
||||||
|
return request({
|
||||||
|
url: 'api/dict/dictDetail/post',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default { get, add, edit, del, getDictMap, getDictDetails }
|
||||||
|
|||||||
@@ -1,36 +1,37 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-popover
|
<el-popover
|
||||||
|
v-model="visible"
|
||||||
placement="top-end"
|
placement="top-end"
|
||||||
width="900"
|
width="900"
|
||||||
trigger="manual"
|
trigger="manual"
|
||||||
v-model="visible">
|
>
|
||||||
点击信息标识已读
|
点击信息标识已读
|
||||||
<div style="margin: 5px" v-loading="loading">
|
<div v-loading="loading" style="margin: 5px">
|
||||||
<el-tabs v-model="activeName" @tab-click="handleClick" >
|
<el-tabs v-model="activeName" @tab-click="handleClick">
|
||||||
<el-tab-pane :label="d.label" :name="d.value" v-for="d in dict.notice_type" :key="d.id" >
|
<el-tab-pane v-for="d in dict.notice_type" :key="d.id" :label="d.label" :name="d.value">
|
||||||
<el-empty v-if="notReadMsgList && notReadMsgList[d.value-1] && notReadMsgList[d.value-1].length === 0" description="暂无信息" ></el-empty>
|
<el-empty v-if="notReadMsgList && notReadMsgList[d.value-1] && notReadMsgList[d.value-1].length === 0" description="暂无信息" />
|
||||||
<div v-for="o in notReadMsgList[d.value-1]" :key="o.notice_id">
|
<div v-for="o in notReadMsgList[d.value-1]" :key="o.notice_id">
|
||||||
<a href="javascript:" @click="showMessage(o)">
|
<a href="javascript:" @click="showMessage(o)">
|
||||||
<el-row @click="showMessage">
|
<el-row @click="showMessage">
|
||||||
<el-col :span="2">
|
<el-col :span="2">
|
||||||
<el-tag type="danger">{{ dict.label.notice_type[o.notice_type] }}</el-tag>
|
<el-tag type="danger">{{ dict.label.notice_type[o.notice_type] }}</el-tag>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="15" style="font-weight: bolder">{{o.notice_title}}</el-col>
|
<el-col :span="15" style="font-weight: bolder">{{ o.notice_title }}</el-col>
|
||||||
<el-col :span="7" style="color: #cccccc">{{o.create_time}}</el-col>
|
<el-col :span="7" style="color: #cccccc">{{ o.create_time }}</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-divider ></el-divider>
|
<el-divider />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
<div style="text-align: right">
|
<div style="text-align: right">
|
||||||
<el-button type="text" @click="visible = !visible">取消</el-button>
|
<el-button type="text" @click="visible = !visible">取消</el-button>
|
||||||
<el-button type="text" @click="toSiteMessage" >查看更多>></el-button>
|
<el-button type="text" @click="toSiteMessage">查看更多>></el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span slot="reference" @click="fetchNotice">
|
<span slot="reference" @click="fetchNotice">
|
||||||
<el-badge :value="notReadMsgCount" :hidden="notReadMsgCount==0">
|
<el-badge :value="notReadMsgCount" :hidden="notReadMsgCount==0">
|
||||||
<el-icon class="el-icon-bell" style="font-size: 22px;"></el-icon>
|
<el-icon class="el-icon-bell" style="font-size: 22px;" />
|
||||||
</el-badge>
|
</el-badge>
|
||||||
</span>
|
</span>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
@@ -57,6 +58,15 @@ export default {
|
|||||||
beforeMount() {
|
beforeMount() {
|
||||||
this.getMessage()
|
this.getMessage()
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.getMessage()
|
||||||
|
this.receivedCount()
|
||||||
|
this.initStageData()
|
||||||
|
this.$bus.on(NOTICE_MESSAGE_UPDATE, this.receivedCount) // 监听事件
|
||||||
|
},
|
||||||
|
destroyed() {
|
||||||
|
this.$bus.off(NOTICE_MESSAGE_UPDATE)
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/**
|
/**
|
||||||
* 打开列表页
|
* 打开列表页
|
||||||
@@ -94,7 +104,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 定时获取消息数量
|
// 定时获取消息数量
|
||||||
initStageData() {
|
initStageData() {
|
||||||
// todo: 定时器
|
// 定时器
|
||||||
this.timer = setInterval(() => {
|
this.timer = setInterval(() => {
|
||||||
console.log('定时器启动')
|
console.log('定时器启动')
|
||||||
this.receivedCount()
|
this.receivedCount()
|
||||||
@@ -125,15 +135,6 @@ export default {
|
|||||||
// console.log(this.dict.notice_type)
|
// console.log(this.dict.notice_type)
|
||||||
// console.log(tab, event)
|
// console.log(tab, event)
|
||||||
}
|
}
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.getMessage()
|
|
||||||
this.receivedCount()
|
|
||||||
this.initStageData()
|
|
||||||
this.$bus.on(NOTICE_MESSAGE_UPDATE, this.receivedCount) // 监听事件
|
|
||||||
},
|
|
||||||
destroyed() {
|
|
||||||
this.$bus.off(NOTICE_MESSAGE_UPDATE)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user