From b4865d886961b8d910a033ce368f89cd25b85d18 Mon Sep 17 00:00:00 2001 From: "dengchao@xgtl" <2325690622@qq.com> Date: Fri, 17 Apr 2020 14:29:21 +0800 Subject: [PATCH] Fix TopicRepository related class --- .../cc/persistence/es/TopicRepository.java | 48 +++--- .../impl/TopicDataExchangeImpl.java | 92 ++++++----- .../impl/TopicMoreDataExchangeImpl.java | 96 +++++------ .../interfaces/DataExchangeInterface.java | 55 ++++--- .../cc/util/dsdata/process/TopicProcess.java | 154 +++++++++--------- 5 files changed, 226 insertions(+), 219 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/TopicRepository.java b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/TopicRepository.java index 3c7844d1..869a5dd5 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/TopicRepository.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/TopicRepository.java @@ -1,24 +1,24 @@ -/* - * Copyright (C) 2017 优客服-多渠道客服系统 - * Modifications copyright (C) 2018-2019 Chatopera Inc, - * - * 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 , TopicEsCommonRepository { - -} +/* + * Copyright (C) 2017 优客服-多渠道客服系统 + * Modifications copyright (C) 2018-2019 Chatopera Inc, + * + * 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, TopicEsCommonRepository { + +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/TopicDataExchangeImpl.java b/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/TopicDataExchangeImpl.java index 2a3fd7b9..fb6abcfc 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/TopicDataExchangeImpl.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/TopicDataExchangeImpl.java @@ -1,44 +1,48 @@ -/* - * Copyright (C) 2017 优客服-多渠道客服系统 - * Modifications copyright (C) 2018-2019 Chatopera Inc, - * - * 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 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, + * + * 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 getListDataByIdAndOrgi(String id, String creater, String orgi) { + return topicRes.getTopicByTopAndOrgi(true, orgi, id, 0, 10).getContent(); + } + + public void process(Object data, String orgi) { + + } +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/TopicMoreDataExchangeImpl.java b/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/TopicMoreDataExchangeImpl.java index aa577f2b..34b359ba 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/TopicMoreDataExchangeImpl.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/TopicMoreDataExchangeImpl.java @@ -1,47 +1,49 @@ -/* - * Copyright (C) 2017 优客服-多渠道客服系统 - * Modifications copyright (C) 2018-2019 Chatopera Inc, - * - * 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 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, + * + * 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 getListDataByIdAndOrgi(String id, String creater, String orgi) { + return null; + } + + public void process(Object data, String orgi) { + topicProcess.process(data, orgi); + } +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/persistence/interfaces/DataExchangeInterface.java b/contact-center/app/src/main/java/com/chatopera/cc/persistence/interfaces/DataExchangeInterface.java index 5b76072c..3f768863 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/persistence/interfaces/DataExchangeInterface.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/persistence/interfaces/DataExchangeInterface.java @@ -1,27 +1,28 @@ -/* - * Copyright (C) 2017 优客服-多渠道客服系统 - * Modifications copyright (C) 2018-2019 Chatopera Inc, - * - * 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, + * + * 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); +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/process/TopicProcess.java b/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/process/TopicProcess.java index 39c925b4..8e99d94f 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/process/TopicProcess.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/process/TopicProcess.java @@ -1,77 +1,77 @@ -/* - * Copyright (C) 2017 优客服-多渠道客服系统 - * Modifications copyright (C) 2018-2019 Chatopera Inc, - * - * 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 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, + * + * 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 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() { + + } +}