mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
Fix TopicRepository related class
This commit is contained in:
parent
0a11285ac7
commit
b4865d8869
@ -19,6 +19,6 @@ package com.chatopera.cc.persistence.es;
|
||||
import com.chatopera.cc.model.Topic;
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
|
||||
public interface TopicRepository extends ElasticsearchRepository<Topic, String> , TopicEsCommonRepository {
|
||||
public interface TopicRepository extends ElasticsearchRepository<Topic, String>, TopicEsCommonRepository {
|
||||
|
||||
}
|
||||
|
@ -19,26 +19,30 @@ package com.chatopera.cc.persistence.impl;
|
||||
import com.chatopera.cc.model.Topic;
|
||||
import com.chatopera.cc.persistence.es.TopicRepository;
|
||||
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service("topic")
|
||||
public class TopicDataExchangeImpl implements DataExchangeInterface{
|
||||
@Autowired
|
||||
private TopicRepository topicRes ;
|
||||
@RequiredArgsConstructor
|
||||
public class TopicDataExchangeImpl implements DataExchangeInterface {
|
||||
@NonNull
|
||||
private final TopicRepository topicRes;
|
||||
|
||||
public Topic getDataByIdAndOrgi(String id, String orgi){
|
||||
return topicRes.findOne(id) ;
|
||||
}
|
||||
@Nullable
|
||||
public Topic getDataByIdAndOrgi(String id, String orgi) {
|
||||
return topicRes.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Topic> getListDataByIdAndOrgi(String id , String creater, String orgi) {
|
||||
return topicRes.getTopicByTopAndOrgi(true,orgi , id , 0, 10).getContent() ;
|
||||
}
|
||||
@Override
|
||||
public List<Topic> getListDataByIdAndOrgi(String id, String creater, String orgi) {
|
||||
return topicRes.getTopicByTopAndOrgi(true, orgi, id, 0, 10).getContent();
|
||||
}
|
||||
|
||||
public void process(Object data , String orgi) {
|
||||
public void process(Object data, String orgi) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,28 +20,30 @@ import com.chatopera.cc.model.TopicItem;
|
||||
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
|
||||
import com.chatopera.cc.persistence.repository.TopicItemRepository;
|
||||
import com.chatopera.cc.util.dsdata.process.TopicProcess;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service("topicmore")
|
||||
public class TopicMoreDataExchangeImpl implements DataExchangeInterface{
|
||||
@Autowired
|
||||
private TopicItemRepository topicItemRes ;
|
||||
@RequiredArgsConstructor
|
||||
public class TopicMoreDataExchangeImpl implements DataExchangeInterface {
|
||||
@NonNull
|
||||
private final TopicItemRepository topicItemRes;
|
||||
@NonNull
|
||||
private final TopicProcess topicProcess;
|
||||
|
||||
private TopicProcess topicProcess = new TopicProcess();
|
||||
public TopicItem getDataByIdAndOrgi(String id, String orgi) {
|
||||
return topicItemRes.findByIdAndOrgi(id, orgi);
|
||||
}
|
||||
|
||||
public TopicItem getDataByIdAndOrgi(String id, String orgi){
|
||||
return topicItemRes.findByIdAndOrgi(id, orgi) ;
|
||||
}
|
||||
@Override
|
||||
public List<TopicItem> getListDataByIdAndOrgi(String id, String creater, String orgi) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicItem> getListDataByIdAndOrgi(String id , String creater, String orgi) {
|
||||
return null ;
|
||||
}
|
||||
|
||||
public void process(Object data , String orgi) {
|
||||
topicProcess.process(data, orgi);
|
||||
}
|
||||
public void process(Object data, String orgi) {
|
||||
topicProcess.process(data, orgi);
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,9 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public interface DataExchangeInterface {
|
||||
public Serializable getDataByIdAndOrgi(String id, String orgi) ;
|
||||
public List<?> getListDataByIdAndOrgi(String id , String creater, String orgi) ;
|
||||
Serializable getDataByIdAndOrgi(String id, String orgi);
|
||||
|
||||
public void process(Object data , String orgi) ;
|
||||
List<?> getListDataByIdAndOrgi(String id, String creater, String orgi);
|
||||
|
||||
void process(Object data, String orgi);
|
||||
}
|
||||
|
@ -21,57 +21,57 @@ import com.chatopera.cc.model.Topic;
|
||||
import com.chatopera.cc.model.TopicItem;
|
||||
import com.chatopera.cc.persistence.es.TopicRepository;
|
||||
import com.chatopera.cc.persistence.repository.TopicItemRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class TopicProcess implements JPAProcess{
|
||||
@RequiredArgsConstructor
|
||||
public class TopicProcess implements JPAProcess {
|
||||
|
||||
private TopicRepository topicRes ;
|
||||
@NonNull
|
||||
private final TopicRepository topicRes;
|
||||
|
||||
public TopicProcess(TopicRepository topicRes){
|
||||
this.topicRes = topicRes ;
|
||||
}
|
||||
@Override
|
||||
public void process(Object data) {
|
||||
Topic topic = (Topic) data;
|
||||
topicRes.save(topic);
|
||||
this.process(data, topic.getOrgi());
|
||||
}
|
||||
|
||||
public TopicProcess(){}
|
||||
/**
|
||||
* 只处理 类似问题
|
||||
*/
|
||||
public void process(Object data, String orgi) {
|
||||
Topic topic = (Topic) data;
|
||||
if (topic.getSilimar() != null && topic.getSilimar().size() > 0) {
|
||||
TopicItemRepository topicItemRes = MainContext.getContext().getBean(TopicItemRepository.class);
|
||||
List<TopicItem> topicItemList = topicItemRes.findByTopicid(topic.getId());
|
||||
if (topicItemList == null) {
|
||||
return;
|
||||
}
|
||||
if (topicItemList.size() > 0) {
|
||||
topicItemRes.deleteAll(topicItemList);
|
||||
}
|
||||
topicItemList.clear();
|
||||
for (String item : topic.getSilimar()) {
|
||||
TopicItem topicItem = new TopicItem();
|
||||
topicItem.setTitle(item);
|
||||
topicItem.setTopicid(topic.getId());
|
||||
topicItem.setOrgi(topic.getOrgi());
|
||||
topicItem.setCreater(topic.getCreater());
|
||||
topicItem.setCreatetime(new Date());
|
||||
topicItemList.add(topicItem);
|
||||
}
|
||||
if (topicItemList.size() > 0) {
|
||||
topicItemRes.saveAll(topicItemList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(Object data) {
|
||||
Topic topic = (Topic) data ;
|
||||
topicRes.save(topic) ;
|
||||
this.process(data, topic.getOrgi());
|
||||
}
|
||||
/**
|
||||
* 只处理 类似问题
|
||||
* @param data
|
||||
* @param orgi
|
||||
*/
|
||||
public void process(Object data , String orgi) {
|
||||
Topic topic = (Topic) data ;
|
||||
if(topic.getSilimar()!=null && topic.getSilimar().size() > 0) {
|
||||
TopicItemRepository topicItemRes = MainContext.getContext().getBean(TopicItemRepository.class) ;
|
||||
List<TopicItem> topicItemList = topicItemRes.findByTopicid(topic.getId()) ;
|
||||
if(topicItemList!=null && topicItemList.size() > 0) {
|
||||
topicItemRes.delete(topicItemList);
|
||||
}
|
||||
topicItemList.clear();
|
||||
for(String item : topic.getSilimar()) {
|
||||
TopicItem topicItem = new TopicItem();
|
||||
topicItem.setTitle(item);
|
||||
topicItem.setTopicid(topic.getId());
|
||||
topicItem.setOrgi(topic.getOrgi());
|
||||
topicItem.setCreater(topic.getCreater());
|
||||
topicItem.setCreatetime(new Date());
|
||||
topicItemList.add(topicItem) ;
|
||||
}
|
||||
if(topicItemList.size() > 0) {
|
||||
topicItemRes.save(topicItemList) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void end() {
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user