新增定时任务 Redis文章转MongoDB
This commit is contained in:
parent
e7b6e1f5dc
commit
046aba8a28
@ -104,7 +104,32 @@ public class MongdbApplicationTests extends BaseSpringBootTest{
|
||||
*/
|
||||
@Test
|
||||
public void redisToMgDB(){
|
||||
|
||||
//模糊查询 获取所有的key
|
||||
Collection<String> listNote= redisCache.keys(Constants.NM_NOTE_CONTENT+"*");
|
||||
for(String str:listNote){
|
||||
//文章UUID
|
||||
String mgDbContentUUID=str.replace(Constants.NM_NOTE_CONTENT,"");
|
||||
System.out.println("str:"+str);
|
||||
//文章
|
||||
String redisContent= redisCache.getCacheObject(str).toString();
|
||||
//查询mongoDb 存在就修改 不存在就新增
|
||||
List<NoteContentMgDb> listMgDbContent = noteRepositoryService.findById(mgDbContentUUID);
|
||||
if (listMgDbContent!=null&&!listMgDbContent.isEmpty()){
|
||||
//修改
|
||||
NoteContentMgDb noteContentMgDb = new NoteContentMgDb();
|
||||
noteContentMgDb.setId(Long.valueOf(mgDbContentUUID));
|
||||
noteContentMgDb.setNoteContent(redisContent);
|
||||
noteRepositoryService.update(noteContentMgDb);
|
||||
}else {
|
||||
//新增
|
||||
NoteContentMgDb noteContentMgDb = new NoteContentMgDb();
|
||||
noteContentMgDb.setId(Long.valueOf(mgDbContentUUID));
|
||||
noteContentMgDb.setNoteContent(redisContent);
|
||||
noteRepositoryService.save(noteContentMgDb);
|
||||
}
|
||||
//删除对应缓存
|
||||
//redisCache.deleteObject(str);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -157,7 +157,8 @@ public class NmNoteServiceImpl implements INmNoteService {
|
||||
public int userUpdateNote(NmNote nmNote) {
|
||||
//储存到redis中 只缓存频繁操作的文章内容
|
||||
redisCache.setCacheObject(Constants.NM_NOTE_CONTENT+nmNote.getTiymceUeditor(),nmNote.getUeditorContent());
|
||||
return 1;
|
||||
// 更新标题信息
|
||||
return nmNoteMapper.updateNmNote(nmNote);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -174,7 +175,7 @@ public class NmNoteServiceImpl implements INmNoteService {
|
||||
//文章UUID
|
||||
String mgDbContentUUID=str.replace(Constants.NM_NOTE_CONTENT,"");
|
||||
//文章
|
||||
String redisContent= redisCache.getCacheObject(str);
|
||||
String redisContent= redisCache.getCacheObject(str).toString();
|
||||
//查询mongoDb 存在就修改 不存在就新增
|
||||
List<NoteContentMgDb> listMgDbContent = noteRepositoryService.findById(mgDbContentUUID);
|
||||
if (listMgDbContent!=null&&!listMgDbContent.isEmpty()){
|
||||
|
@ -35,6 +35,12 @@
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 便签模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-note</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,5 +1,11 @@
|
||||
package com.ruoyi.quartz.task;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.note.service.INmNoteService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
@ -11,6 +17,11 @@ import com.ruoyi.common.utils.StringUtils;
|
||||
@Component("ryTask")
|
||||
public class RyTask
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(RyTask.class);
|
||||
|
||||
@Autowired
|
||||
private INmNoteService nmNoteService;
|
||||
|
||||
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
|
||||
{
|
||||
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
|
||||
@ -25,4 +36,17 @@ public class RyTask
|
||||
{
|
||||
System.out.println("执行无参方法");
|
||||
}
|
||||
|
||||
/**
|
||||
* 每天凌晨 Redis缓存中的文章 转移到MongoDB数据库
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public void redisToMongonDB()
|
||||
{
|
||||
log.info(DateUtil.now()+"开始执行>>>Redis缓存中的文章 转移到MongoDB数据库");
|
||||
nmNoteService.redisToMongonDB();
|
||||
log.info(DateUtil.now()+"执行完毕>>>Redis缓存中的文章 转移到MongoDB数据库");
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ export function addUserNote(data) {
|
||||
export function userUpdateNote(data) {
|
||||
return request({
|
||||
url: '/note/note/userUpdateNote',
|
||||
method: 'put',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
@ -90,7 +90,7 @@
|
||||
break;
|
||||
case 1:
|
||||
//便签模式
|
||||
that.isdescription = true;
|
||||
that.isdescription = false;
|
||||
that.noteTime = true;
|
||||
that.isBookmarkIcon = false;
|
||||
break;
|
||||
|
@ -477,7 +477,7 @@
|
||||
that.queryParams.menuId = routedata;
|
||||
that.noteParams.menuId = routedata;
|
||||
}
|
||||
console.log("当前状态:"+that.property)
|
||||
|
||||
if (property != null && property != undefined && property != ''){
|
||||
that.property =property;
|
||||
}
|
||||
@ -575,7 +575,7 @@
|
||||
//缓存状态
|
||||
that.$store.state.property=e;
|
||||
this.showimg=false;
|
||||
console.log("缓存property:"+that.$store.state.property)
|
||||
// console.log("缓存property:"+that.$store.state.property)
|
||||
// console.log("缓存property:"+store.state.property)
|
||||
//初始化
|
||||
this.queryParams.pageNum=1;
|
||||
@ -837,7 +837,6 @@
|
||||
this.loading = true;
|
||||
selectBymenuIdUserID(this.queryParams).then(response => {
|
||||
if (response.code == 200) {
|
||||
console.log("response.rows" + response.rows)
|
||||
this.bookmarkList = this.bookmarkList.concat(response.rows);
|
||||
this.total = response.total;
|
||||
this.listloading = false
|
||||
|
@ -5,6 +5,10 @@
|
||||
<div class="mdui-textfield mdui-textfield-floating-label inputtop">
|
||||
<input class="mdui-textfield-input" v-model="queryParamsAndMg.title" type="text" required/>
|
||||
</div>
|
||||
<div>
|
||||
<span>{{queryParamsAndMg.updateTime==null?'0000:00:00':queryParamsAndMg.updateTime}}</span>
|
||||
<span @click="updateEdit">{{updateOpn}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-loading="loading" v-if="!showEditor" class="mian" v-html="queryParamsAndMg.ueditorContent">
|
||||
|
||||
@ -21,7 +25,7 @@
|
||||
|
||||
<div v-if="showEditor" STYLE="margin-top: 10px;margin-bottom: 10px">
|
||||
<button class="mdui-btn mdui-btn-raised mdui-color-indigo-300" @click="clear">清空内容</button>
|
||||
<button class="mdui-btn mdui-btn-raised mdui-color-indigo-300" @click="clear">发布</button>
|
||||
<button class="mdui-btn mdui-btn-raised mdui-color-indigo-300" @click="UpdateNote">发布</button>
|
||||
<button class="mdui-btn mdui-ripple mdui-btn-raised " @click="disabled = true">禁用</button>
|
||||
<button class="mdui-btn mdui-ripple mdui-btn-raised " @click="disabled = false">启用</button>
|
||||
</div>
|
||||
@ -94,6 +98,7 @@
|
||||
},
|
||||
showEditor:false,
|
||||
loading:false,
|
||||
updateOpn:'编辑'
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@ -103,12 +108,17 @@
|
||||
/** 实时更新文章的信息 */
|
||||
UpdateNote() {
|
||||
userUpdateNote(this.queryParamsAndMg).then(response => {
|
||||
if (response.code==200){
|
||||
console.log("已保存:" + Date.now())
|
||||
this.$message({
|
||||
message: '保存成功!',
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 查询便签管理列表 */
|
||||
getNoteById() {
|
||||
console.log("请求执行了!!!")
|
||||
var that = this;
|
||||
that.loading=true;
|
||||
var blueditor = that.ueditor != null && that.ueditor != '' && that.ueditor != undefined;
|
||||
@ -135,6 +145,16 @@
|
||||
//清空内容
|
||||
clear() {
|
||||
this.$refs.editor.clear()
|
||||
},
|
||||
updateEdit(){
|
||||
var that=this;
|
||||
|
||||
that.showEditor=!that.showEditor;
|
||||
if (that.showEditor) {
|
||||
that.updateOpn='退出编辑';
|
||||
}else {
|
||||
that.updateOpn='编辑';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -168,11 +188,11 @@
|
||||
overflow: scroll;
|
||||
}
|
||||
.edit{
|
||||
margin-left: 3px;
|
||||
margin-left: 13px;
|
||||
|
||||
}
|
||||
.nqtitle{
|
||||
margin-left: 3px;
|
||||
margin-left: 13px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.inputtop{
|
||||
|
@ -575,10 +575,7 @@
|
||||
//颜色改变提醒
|
||||
resize[i].style.background = 'transparent';
|
||||
var startX = e.clientX;
|
||||
console.log("鼠标按下后:" + e.clientX)
|
||||
resize[i].left = resize[i].offsetLeft;
|
||||
console.log("鼠标按下后:" + resize[i].left)
|
||||
console.log("鼠标按下后:" + resize[i].offsetLeft)
|
||||
// 鼠标拖动事件
|
||||
document.onmousemove = function (e) {
|
||||
var endX = e.clientX;
|
||||
|
Loading…
x
Reference in New Issue
Block a user