service
This commit is contained in:
@@ -49,15 +49,17 @@ public class NoteController {
|
||||
public NoteMeta getNoteMeta(@PathVariable("key") String key) {
|
||||
NoteMeta meta = new NoteMeta();
|
||||
Note note = noteService.getNote(key);
|
||||
meta.setKey(key);
|
||||
|
||||
if (null == note) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
|
||||
meta.setServerTime(new Date().getTime());
|
||||
meta.setKey(key);
|
||||
meta.setLock(note.getLock());
|
||||
meta.setMd5(note.getMd5());
|
||||
|
||||
meta.setState(note.getState());
|
||||
meta.setTtl(note.getTtl());
|
||||
|
||||
return meta;
|
||||
|
||||
@@ -17,8 +17,6 @@ public class Note implements Serializable {
|
||||
|
||||
private String key;
|
||||
|
||||
private String text;
|
||||
|
||||
private String md5;
|
||||
|
||||
private Integer lock;
|
||||
|
||||
@@ -16,6 +16,8 @@ public class NoteMeta implements Serializable {/**
|
||||
|
||||
private String key;
|
||||
|
||||
private Integer state;
|
||||
|
||||
private String cipher;
|
||||
|
||||
private Integer lock;
|
||||
|
||||
@@ -3,10 +3,6 @@ package com.flagnote.note.service;
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.ExampleMatcher;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.flagnote.note.entity.Note;
|
||||
@@ -14,6 +10,7 @@ import com.flagnote.note.repository.NoteMongoRepository;
|
||||
import com.flagnote.note.utils.BizKeyUtils;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
|
||||
@Service
|
||||
public class NoteServiceImpl implements NoteService {
|
||||
@@ -33,11 +30,14 @@ public class NoteServiceImpl implements NoteService {
|
||||
}
|
||||
|
||||
if (note.getState() != 1) {
|
||||
return null;
|
||||
note.setTextBytes(null);
|
||||
return note;
|
||||
}
|
||||
|
||||
if (note.getExpireTime().getTime() <= new Date().getTime()) {
|
||||
return null;
|
||||
note.setState(0);
|
||||
note.setTextBytes(null);
|
||||
return note;
|
||||
}
|
||||
|
||||
return note;
|
||||
@@ -63,8 +63,13 @@ public class NoteServiceImpl implements NoteService {
|
||||
@Override
|
||||
public void deleteNote(String key) {
|
||||
String mixKey = BizKeyUtils.mixKey(key);
|
||||
Note note = noteMongoRepository.findById(mixKey).orElse(null);
|
||||
|
||||
noteMongoRepository.deleteById(mixKey);
|
||||
if(null!=note && ArrayUtil.isNotEmpty(note.getTextBytes())) {
|
||||
note.setState(0);
|
||||
note.setTextBytes(null);
|
||||
noteMongoRepository.save(note);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user