1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-08-01 16:38:02 +08:00

#325 fix startup problems

This commit is contained in:
mukaiu 2020-04-23 17:57:02 +08:00
parent 3f7edce29c
commit 70ad41480d
8 changed files with 32 additions and 50 deletions

View File

@ -44,9 +44,6 @@ public class ACDAgentDispatcher implements IACDDispatcher {
@Autowired
private AgentStatusRepository agentStatusRes;
@Autowired
private ACDAgentService acdAgentService;
@Autowired
private RedisCommand redisCommand;

View File

@ -1,39 +0,0 @@
/*
* 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.config;
import com.lmax.disruptor.ExceptionHandler;
public class CSKeFuExceptionHandler implements ExceptionHandler<Object>{
@Override
public void handleEventException(Throwable ex, long arg1, Object arg2) {
ex.printStackTrace();
}
@Override
public void handleOnShutdownException(Throwable ex) {
}
@Override
public void handleOnStartException(Throwable ex) {
}
}

View File

@ -22,10 +22,13 @@ import com.chatopera.cc.interceptor.UserInterceptorHandler;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@EnableWebMvc
@RequiredArgsConstructor
public class CSKeFuWebAppConfigurer implements WebMvcConfigurer {
@NonNull
@ -42,4 +45,10 @@ public class CSKeFuWebAppConfigurer implements WebMvcConfigurer {
registry.addInterceptor(new CrossInterceptorHandler()).addPathPatterns("/**");
registry.addInterceptor(logInterceptorHandler).addPathPatterns("/**");
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/static/");
}
}

View File

@ -432,8 +432,7 @@ public class Handler {
public Tenant getTenant(HttpServletRequest request) {
String id = getOrgi(request);
return tenantRes.findById(id)
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("Tenant %s not found", id)));
return tenantRes.findById(id).orElse(null);
}
/**

View File

@ -19,6 +19,8 @@ package com.chatopera.cc.model;
import com.chatopera.cc.basic.MainUtils;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import javax.persistence.*;
import java.util.Date;
@ -149,6 +151,8 @@ public class Contacts extends ESBean implements java.io.Serializable{
private Date touchtime;
private boolean datastatus;
private String processid;
@Field(type = FieldType.Text, fielddata = true)
private String creater;
private String username;
private String updateuser;
@ -160,6 +164,8 @@ public class Contacts extends ESBean implements java.io.Serializable{
private String compper;
private Date createtime = new Date();
@Field(type = FieldType.Text, fielddata = true)
private String name;
private String assignedto;
private String wfstatus;

View File

@ -4,6 +4,7 @@ import com.chatopera.cc.socketio.message.ChatMessage;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.transaction.annotation.Transactional;
public interface ChatMessageEsRepository extends ElasticsearchRepository<ChatMessage,String> {

View File

@ -18,6 +18,7 @@ package com.chatopera.cc.persistence.hibernate;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -46,13 +47,14 @@ public class BaseService<T> {
public void saveOrUpdateAll(final List<Object> ts) {
Session session = hibernateFactory.openSession();
try {
Transaction tx = session.beginTransaction();
for (final Object t : ts) {
session.saveOrUpdate(t);
}
tx.commit();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
session.flush();
session.close();
}
}
@ -60,11 +62,12 @@ public class BaseService<T> {
public void saveOrUpdate(final Object t) {
Session session = hibernateFactory.openSession();
try {
Transaction tx = session.beginTransaction();
session.saveOrUpdate(t);
tx.commit();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
session.flush();
session.close();
}
}
@ -72,11 +75,12 @@ public class BaseService<T> {
public void save(final Object t) {
Session session = hibernateFactory.openSession();
try {
Transaction tx = session.beginTransaction();
session.save(t);
tx.commit();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
session.flush();
session.close();
}
}
@ -89,13 +93,14 @@ public class BaseService<T> {
public void deleteAll(final List<Object> objects) {
Session session = hibernateFactory.openSession();
try {
Transaction tx = session.beginTransaction();
for (final Object t : objects) {
session.delete(session.merge(t));
}
tx.commit();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
session.flush();
session.close();
}
}
@ -103,11 +108,12 @@ public class BaseService<T> {
public void delete(final Object object) {
Session session = hibernateFactory.openSession();
try {
Transaction tx = session.beginTransaction();
session.delete(session.merge(object));
tx.commit();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
session.flush();
session.close();
}
}
@ -117,11 +123,12 @@ public class BaseService<T> {
List<T> dataList = null;
Session session = hibernateFactory.openSession();
try {
Transaction tx = session.beginTransaction();
dataList = session.createCriteria(Class.forName(bean)).list();
tx.commit();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
session.flush();
session.close();
}
return dataList;

View File

@ -28,6 +28,7 @@ import com.google.gson.JsonObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.io.Serializable;
@ -47,6 +48,7 @@ public class AgentAuditProxy {
@Autowired
private Cache cache;
@Lazy
@Autowired
private AgentUserProxy agentUserProxy;