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
@ -1,24 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
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 {
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
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 {
|
||||
|
||||
}
|
||||
|
@ -1,44 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
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 org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service("topic")
|
||||
public class TopicDataExchangeImpl implements DataExchangeInterface{
|
||||
@Autowired
|
||||
private TopicRepository topicRes ;
|
||||
|
||||
public Topic getDataByIdAndOrgi(String id, String orgi){
|
||||
return topicRes.findOne(id) ;
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
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 lombok.RequiredArgsConstructor;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service("topic")
|
||||
@RequiredArgsConstructor
|
||||
public class TopicDataExchangeImpl implements DataExchangeInterface {
|
||||
@NonNull
|
||||
private final TopicRepository topicRes;
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
public void process(Object data, String orgi) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.persistence.impl;
|
||||
|
||||
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 org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service("topicmore")
|
||||
public class TopicMoreDataExchangeImpl implements DataExchangeInterface{
|
||||
@Autowired
|
||||
private TopicItemRepository topicItemRes ;
|
||||
|
||||
private TopicProcess topicProcess = new TopicProcess();
|
||||
|
||||
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 ;
|
||||
}
|
||||
|
||||
public void process(Object data , String orgi) {
|
||||
topicProcess.process(data, orgi);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.persistence.impl;
|
||||
|
||||
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 lombok.RequiredArgsConstructor;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service("topicmore")
|
||||
@RequiredArgsConstructor
|
||||
public class TopicMoreDataExchangeImpl implements DataExchangeInterface {
|
||||
@NonNull
|
||||
private final TopicItemRepository topicItemRes;
|
||||
@NonNull
|
||||
private final TopicProcess topicProcess;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public void process(Object data, String orgi) {
|
||||
topicProcess.process(data, orgi);
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.persistence.interfaces;
|
||||
|
||||
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) ;
|
||||
|
||||
public void process(Object data , String orgi) ;
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.persistence.interfaces;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public interface DataExchangeInterface {
|
||||
Serializable getDataByIdAndOrgi(String id, String orgi);
|
||||
|
||||
List<?> getListDataByIdAndOrgi(String id, String creater, String orgi);
|
||||
|
||||
void process(Object data, String orgi);
|
||||
}
|
||||
|
@ -1,77 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.util.dsdata.process;
|
||||
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
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 java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class TopicProcess implements JPAProcess{
|
||||
|
||||
private TopicRepository topicRes ;
|
||||
|
||||
public TopicProcess(TopicRepository topicRes){
|
||||
this.topicRes = topicRes ;
|
||||
}
|
||||
|
||||
public TopicProcess(){}
|
||||
|
||||
@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() {
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.util.dsdata.process;
|
||||
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
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;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class TopicProcess implements JPAProcess {
|
||||
|
||||
@NonNull
|
||||
private final TopicRepository topicRes;
|
||||
|
||||
@Override
|
||||
public void process(Object data) {
|
||||
Topic topic = (Topic) data;
|
||||
topicRes.save(topic);
|
||||
this.process(data, topic.getOrgi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 只处理 类似问题
|
||||
*/
|
||||
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 end() {
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user