新增定时任务 Redis文章转MongoDB
This commit is contained in:
@ -104,7 +104,32 @@ public class MongdbApplicationTests extends BaseSpringBootTest{
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void redisToMgDB(){
|
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) {
|
public int userUpdateNote(NmNote nmNote) {
|
||||||
//储存到redis中 只缓存频繁操作的文章内容
|
//储存到redis中 只缓存频繁操作的文章内容
|
||||||
redisCache.setCacheObject(Constants.NM_NOTE_CONTENT+nmNote.getTiymceUeditor(),nmNote.getUeditorContent());
|
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
|
//文章UUID
|
||||||
String mgDbContentUUID=str.replace(Constants.NM_NOTE_CONTENT,"");
|
String mgDbContentUUID=str.replace(Constants.NM_NOTE_CONTENT,"");
|
||||||
//文章
|
//文章
|
||||||
String redisContent= redisCache.getCacheObject(str);
|
String redisContent= redisCache.getCacheObject(str).toString();
|
||||||
//查询mongoDb 存在就修改 不存在就新增
|
//查询mongoDb 存在就修改 不存在就新增
|
||||||
List<NoteContentMgDb> listMgDbContent = noteRepositoryService.findById(mgDbContentUUID);
|
List<NoteContentMgDb> listMgDbContent = noteRepositoryService.findById(mgDbContentUUID);
|
||||||
if (listMgDbContent!=null&&!listMgDbContent.isEmpty()){
|
if (listMgDbContent!=null&&!listMgDbContent.isEmpty()){
|
||||||
|
@ -35,6 +35,12 @@
|
|||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 便签模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-note</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,16 +1,27 @@
|
|||||||
package com.ruoyi.quartz.task;
|
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 org.springframework.stereotype.Component;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时任务调度测试
|
* 定时任务调度测试
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Component("ryTask")
|
@Component("ryTask")
|
||||||
public class 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)
|
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
|
||||||
{
|
{
|
||||||
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
|
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
|
||||||
@ -25,4 +36,17 @@ public class RyTask
|
|||||||
{
|
{
|
||||||
System.out.println("执行无参方法");
|
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) {
|
export function userUpdateNote(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/note/note/userUpdateNote',
|
url: '/note/note/userUpdateNote',
|
||||||
method: 'put',
|
method: 'post',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
//便签模式
|
//便签模式
|
||||||
that.isdescription = true;
|
that.isdescription = false;
|
||||||
that.noteTime = true;
|
that.noteTime = true;
|
||||||
that.isBookmarkIcon = false;
|
that.isBookmarkIcon = false;
|
||||||
break;
|
break;
|
||||||
|
@ -477,7 +477,7 @@
|
|||||||
that.queryParams.menuId = routedata;
|
that.queryParams.menuId = routedata;
|
||||||
that.noteParams.menuId = routedata;
|
that.noteParams.menuId = routedata;
|
||||||
}
|
}
|
||||||
console.log("当前状态:"+that.property)
|
|
||||||
if (property != null && property != undefined && property != ''){
|
if (property != null && property != undefined && property != ''){
|
||||||
that.property =property;
|
that.property =property;
|
||||||
}
|
}
|
||||||
@ -575,7 +575,7 @@
|
|||||||
//缓存状态
|
//缓存状态
|
||||||
that.$store.state.property=e;
|
that.$store.state.property=e;
|
||||||
this.showimg=false;
|
this.showimg=false;
|
||||||
console.log("缓存property:"+that.$store.state.property)
|
// console.log("缓存property:"+that.$store.state.property)
|
||||||
// console.log("缓存property:"+store.state.property)
|
// console.log("缓存property:"+store.state.property)
|
||||||
//初始化
|
//初始化
|
||||||
this.queryParams.pageNum=1;
|
this.queryParams.pageNum=1;
|
||||||
@ -837,7 +837,6 @@
|
|||||||
this.loading = true;
|
this.loading = true;
|
||||||
selectBymenuIdUserID(this.queryParams).then(response => {
|
selectBymenuIdUserID(this.queryParams).then(response => {
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
console.log("response.rows" + response.rows)
|
|
||||||
this.bookmarkList = this.bookmarkList.concat(response.rows);
|
this.bookmarkList = this.bookmarkList.concat(response.rows);
|
||||||
this.total = response.total;
|
this.total = response.total;
|
||||||
this.listloading = false
|
this.listloading = false
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
<div class="mdui-textfield mdui-textfield-floating-label inputtop">
|
<div class="mdui-textfield mdui-textfield-floating-label inputtop">
|
||||||
<input class="mdui-textfield-input" v-model="queryParamsAndMg.title" type="text" required/>
|
<input class="mdui-textfield-input" v-model="queryParamsAndMg.title" type="text" required/>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>{{queryParamsAndMg.updateTime==null?'0000:00:00':queryParamsAndMg.updateTime}}</span>
|
||||||
|
<span @click="updateEdit">{{updateOpn}}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-loading="loading" v-if="!showEditor" class="mian" v-html="queryParamsAndMg.ueditorContent">
|
<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">
|
<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="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 = true">禁用</button>
|
||||||
<button class="mdui-btn mdui-ripple mdui-btn-raised " @click="disabled = false">启用</button>
|
<button class="mdui-btn mdui-ripple mdui-btn-raised " @click="disabled = false">启用</button>
|
||||||
</div>
|
</div>
|
||||||
@ -94,6 +98,7 @@
|
|||||||
},
|
},
|
||||||
showEditor:false,
|
showEditor:false,
|
||||||
loading:false,
|
loading:false,
|
||||||
|
updateOpn:'编辑'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@ -103,12 +108,17 @@
|
|||||||
/** 实时更新文章的信息 */
|
/** 实时更新文章的信息 */
|
||||||
UpdateNote() {
|
UpdateNote() {
|
||||||
userUpdateNote(this.queryParamsAndMg).then(response => {
|
userUpdateNote(this.queryParamsAndMg).then(response => {
|
||||||
console.log("已保存:" + Date.now())
|
if (response.code==200){
|
||||||
|
console.log("已保存:" + Date.now())
|
||||||
|
this.$message({
|
||||||
|
message: '保存成功!',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 查询便签管理列表 */
|
/** 查询便签管理列表 */
|
||||||
getNoteById() {
|
getNoteById() {
|
||||||
console.log("请求执行了!!!")
|
|
||||||
var that = this;
|
var that = this;
|
||||||
that.loading=true;
|
that.loading=true;
|
||||||
var blueditor = that.ueditor != null && that.ueditor != '' && that.ueditor != undefined;
|
var blueditor = that.ueditor != null && that.ueditor != '' && that.ueditor != undefined;
|
||||||
@ -135,6 +145,16 @@
|
|||||||
//清空内容
|
//清空内容
|
||||||
clear() {
|
clear() {
|
||||||
this.$refs.editor.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;
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
.edit{
|
.edit{
|
||||||
margin-left: 3px;
|
margin-left: 13px;
|
||||||
|
|
||||||
}
|
}
|
||||||
.nqtitle{
|
.nqtitle{
|
||||||
margin-left: 3px;
|
margin-left: 13px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
.inputtop{
|
.inputtop{
|
||||||
|
@ -575,10 +575,7 @@
|
|||||||
//颜色改变提醒
|
//颜色改变提醒
|
||||||
resize[i].style.background = 'transparent';
|
resize[i].style.background = 'transparent';
|
||||||
var startX = e.clientX;
|
var startX = e.clientX;
|
||||||
console.log("鼠标按下后:" + e.clientX)
|
|
||||||
resize[i].left = resize[i].offsetLeft;
|
resize[i].left = resize[i].offsetLeft;
|
||||||
console.log("鼠标按下后:" + resize[i].left)
|
|
||||||
console.log("鼠标按下后:" + resize[i].offsetLeft)
|
|
||||||
// 鼠标拖动事件
|
// 鼠标拖动事件
|
||||||
document.onmousemove = function (e) {
|
document.onmousemove = function (e) {
|
||||||
var endX = e.clientX;
|
var endX = e.clientX;
|
||||||
|
Reference in New Issue
Block a user