提交 258c0567 编写于 作者: 街头小贩's avatar 街头小贩

重构更新

上级 6d36bf68
package com.apobates.forum.core.impl;
import com.apobates.forum.core.entity.ActionEventDescriptor;
import com.apobates.forum.utils.cache.AbstractCubbyHole;
import com.apobates.forum.utils.cache.CubbyHoleLinkedDeque;
import com.apobates.forum.utils.cache.CubbyHoleProcessor;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
......@@ -22,7 +26,7 @@ public class CoreAppConfig {
public CoreModuleActionEventAspect buildCmae() {
return new com.apobates.forum.core.impl.CoreModuleActionEventAspect();
}
/*
@Bean
public CubbyHoleProcessor<ActionEventDescriptor> getCubbyHoleProcessor(){
return new ActionEventCubbyHoleProcessor();
......@@ -31,5 +35,5 @@ public class CoreAppConfig {
@Bean("cubbyHole")
public AbstractCubbyHole<ActionEventDescriptor> getCubbyHole(CubbyHoleProcessor<ActionEventDescriptor> cubbyHoleProcessor){
return new CubbyHoleLinkedDeque<>(cubbyHoleProcessor);
}*/
}
}
\ No newline at end of file
package com.apobates.forum.core.impl;
import com.apobates.forum.core.dao.BoardActionCollectionDao;
import com.apobates.forum.core.dao.BoardDao;
import com.apobates.forum.core.dao.PostsDao;
import com.apobates.forum.core.dao.TopicActionCollectionDao;
import com.apobates.forum.core.dao.TopicDao;
import com.apobates.forum.core.entity.ActionEventDescriptor;
import com.apobates.forum.core.entity.Board;
import com.apobates.forum.core.entity.BoardActionCollection;
import com.apobates.forum.core.entity.Posts;
......@@ -12,6 +11,7 @@ import com.apobates.forum.core.entity.Topic;
import com.apobates.forum.core.entity.TopicActionCollection;
import com.apobates.forum.event.elderly.ActionEventCulpritor;
import com.apobates.forum.event.elderly.ForumActionEnum;
import com.apobates.forum.utils.cache.AbstractCubbyHole;
import java.util.Optional;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
......@@ -35,12 +35,12 @@ public class CoreModuleActionEventAspect {
private TopicDao topicDao;
@Autowired
private PostsDao postsDao;
//@Autowired
//private AbstractCubbyHole<ActionEventDescriptor> cubbyHole;
@Autowired
private BoardActionCollectionDao boardActionCollectionDao;
@Autowired
private TopicActionCollectionDao topicActionCollectionDao;
private AbstractCubbyHole<ActionEventDescriptor> cubbyHole;
//@Autowired
//private BoardActionCollectionDao boardActionCollectionDao;
//@Autowired
//private TopicActionCollectionDao topicActionCollectionDao;
private final static Logger logger = LoggerFactory.getLogger(CoreModuleActionEventAspect.class);
@Before("execution(* com.apobates.forum.core.impl.service.*.*(..)) && @annotation(actionDescriptor)")
......@@ -108,8 +108,8 @@ public class CoreModuleActionEventAspect {
}else {
entity = buildTopicAction(id, culpritor, actionDescriptor);
}
topicActionCollectionDao.save(entity);
//cubbyHole.put(entity);
//topicActionCollectionDao.save(entity);
cubbyHole.put(entity);
}
private TopicActionCollection buildTopicAction(long topicId, ActionEventCulpritor culpritor, ActionDescriptor actionDescriptor){
......@@ -150,8 +150,8 @@ public class CoreModuleActionEventAspect {
long rodeMember = culpritor.getMemberId();
logger.info("[CAT]12>7.1 board id: "+board.getId()+", title: "+board.getTitle());
BoardActionCollection entity = new BoardActionCollection(actionDescriptor.action(), board.getTitle(), primaryKey, culpritor, rodeMember);
boardActionCollectionDao.save(entity);
//cubbyHole.put(entity);
//boardActionCollectionDao.save(entity);
cubbyHole.put(entity);
}
private Long getPrimaryKey(Object[] paramValues, String[] paramNames, String keyName) {
......
......@@ -4,6 +4,7 @@ import com.apobates.forum.core.dao.BoardConfigDao;
import com.apobates.forum.core.entity.Board;
import com.apobates.forum.core.entity.BoardConfig;
import com.apobates.forum.core.impl.event.BoardCreateEvent;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -25,10 +26,7 @@ public class BoardConfigListener implements ApplicationListener<BoardCreateEvent
public void onApplicationEvent(BoardCreateEvent event) {
logger.info("[Event][Board][1]版块配置文件开始执行");
Board board = event.getBoard();
BoardConfig boardConfig = event.getBoardConfig();
if (null == boardConfig) {
boardConfig = BoardConfig.defaultConfig(board.getId());
}
BoardConfig boardConfig = Optional.ofNullable(event.getBoardConfig()).orElse(BoardConfig.defaultConfig(board.getId()));
//版块配置
boardConfigDao.save(boardConfig);
logger.info("[Event][Board][2]版块配置文件执行结束");
......
......@@ -135,12 +135,11 @@ public class AlbumServiceImpl implements AlbumService{
}
@Override
public Stream<Album> getAll(Set<Long> topicIdSet, ImageIOMeta imageIO, final String scale, final String defaultPicture) {
public Stream<Album> getAll(final Set<Long> topicIdSet, final ImageIOMeta imageIO, final String scale, final String defaultPicture) {
if (null == topicIdSet || topicIdSet.isEmpty()) {
return Stream.empty();
}
List<Long> topicIds = topicIdSet.stream().filter(topicId -> topicId > 0).collect(Collectors.toList());
List<Album> abs = albumDao.findAllByTopic(topicIds).collect(Collectors.toList());
//上传图片的路径转换
final UploadImagePathConvert uipc = new UploadImagePathConvert(imageIO.getImageBucketDomain(), imageIO.getUploadImageDirectName());
Consumer<Album> action = album->{
......@@ -156,7 +155,7 @@ public class AlbumServiceImpl implements AlbumService{
}
}
};
return abs.stream().peek(action);
return albumDao.findAllByTopic(topicIds).peek(action);
}
@Override
......
......@@ -166,8 +166,7 @@ public class BoardGroup implements Serializable, Comparable<BoardGroup> {
//默认版块组(卷),用于分组
@Transient
public static BoardGroup defaultInstance() { //getDefault
BoardGroup bg = new BoardGroup("默认版块组", "no description", null, true, 0);
return bg;
return defaultInstance(0);
}
@Transient
public static BoardGroup defaultInstance(int ranking) { //getDefault
......
......@@ -112,15 +112,15 @@ public class AdminBoardModeratorController {
bm.setStatus(form.getBooleanStatus());
bm.setLevel(form.getEnumLevel());
boolean symbol;
boolean symbol=false;
String jumpLink = "/board/moderator/?board=" + bm.getBoardId() + "&volume=" + bm.getVolumesId();
if (form.isUpdate()) {
symbol = boardModeratorService.edit(form.getLongRecord(), bm).orElse(false);
} else {
Member m = memberService.get(bm.getMemberId()).orElse(Member.empty(bm.getMemberId()));
Optional<BoardModerator> rObj = boardModeratorService.create(bm.getVolumesId(), bm.getBoardId(), m, bm.getLevel());
symbol = rObj.isPresent();
if (symbol) {
if (rObj.isPresent()) {
symbol = true;
jumpLink = "/board/moderator/permission?id=" + rObj.get().getId(); //进行授权
}
}
......
......@@ -58,7 +58,9 @@ public abstract class AbstractCubbyHole<T> {
if(null == data || data.isEmpty()){
return "";
}
String v = data.entrySet().stream().filter(entry -> !entry.getKey().toLowerCase().equalsIgnoreCase("id") && Commons.isNotBlank(entry.getValue().toString())).map(entry -> entry.getKey() + "=" + entry.getValue()).collect(Collectors.joining(","));
return Commons.md5(v);
String v = data.entrySet().stream().filter(entry -> !entry.getKey().toLowerCase().equalsIgnoreCase("id") && null != entry.getValue() && Commons.isNotBlank(entry.getValue().toString())).map(entry -> entry.getKey() + "=" + entry.getValue()).collect(Collectors.joining(","));
String key = Commons.md5(v);
logger.info("[CH][Abs]"+v+",key="+key);
return key;
}
}
\ No newline at end of file
......@@ -68,6 +68,7 @@ public final class CubbyHoleLinkedDeque<T> extends AbstractCubbyHole<T>{
return;
}
final Set<String> affect = processor.process(data);
queue.removeIf(aed -> affect.contains(CubbyHoleLinkedDeque.toChecksum(aed)));
boolean bol=queue.removeIf(aed -> affect.contains(CubbyHoleLinkedDeque.toChecksum(aed)));
logger.info("[CH][Dequre]Clear Keys: "+String.join(",", affect)+", result: "+bol);
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册