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