1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-06-16 18:30:03 +08:00

Spring Boot 3

This commit is contained in:
lecjy 2023-06-22 13:38:51 +08:00
parent 2680ed3bbb
commit 95f35c13e0
273 changed files with 987 additions and 1196 deletions

View File

@ -19,21 +19,6 @@
<build>
<finalName>contact-center</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
@ -73,28 +58,6 @@
<injectAllReactorProjects>true</injectAllReactorProjects>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.8.RELEASE</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
@ -113,13 +76,27 @@
</configuration>
<version>3.3.2</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.8.RELEASE</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
</plugins>
<defaultGoal>compile</defaultGoal>

View File

@ -21,6 +21,7 @@ import com.cskefu.cc.basic.MainContext;
import com.cskefu.cc.config.AppCtxRefreshEventListener;
import com.cskefu.cc.util.SystemEnvHelper;
import com.cskefu.cc.util.mobile.MobileNumberUtils;
import jakarta.servlet.MultipartConfigElement;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -28,15 +29,18 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jms.JmsPoolConnectionFactoryFactory;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.http.HttpStatus;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.util.unit.DataSize;
import javax.servlet.MultipartConfigElement;
import java.io.IOException;
@SpringBootApplication
@ -50,10 +54,10 @@ public class Application {
private String uploaddir;
@Value("${spring.servlet.multipart.max-file-size}")
private String multipartMaxUpload;
private Long multipartMaxUpload;
@Value("${spring.servlet.multipart.max-request-size}")
private String multipartMaxRequest;
private Long multipartMaxRequest;
/**
* 加载模块
@ -63,7 +67,6 @@ public class Application {
if (StringUtils.equalsIgnoreCase(SystemEnvHelper.parseFromApplicationProps("cskefu.modules.contacts"), "true")) {
MainContext.enableModule(Constants.CSKEFU_MODULE_CONTACTS);
}
// 会话监控模块 Customer Chats Audit
if (StringUtils.equalsIgnoreCase(SystemEnvHelper.parseFromApplicationProps("cskefu.modules.cca"), "true")) {
MainContext.enableModule(Constants.CSKEFU_MODULE_CCA);
@ -99,7 +102,7 @@ public class Application {
app.setBannerMode(Banner.Mode.CONSOLE);
app.setAddCommandLineProperties(false);
app.addListeners(new AppCtxRefreshEventListener());
MainContext.setApplicationContext(app.run(args));
} catch (IOException e) {
logger.error("Application Startup Error", e);
@ -107,24 +110,34 @@ public class Application {
}
}
// TODO lecjy
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
factory.setMaxFileSize(multipartMaxUpload); //KB,MB
factory.setMaxRequestSize(multipartMaxRequest);
factory.setMaxFileSize(DataSize.ofMegabytes(multipartMaxUpload)); //KB,MB
factory.setMaxRequestSize(DataSize.ofMegabytes(multipartMaxRequest));
factory.setLocation(uploaddir);
return factory.createMultipartConfig();
}
// TODO lecjy
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
return container -> {
ErrorPage error = new ErrorPage("/error.html");
container.addErrorPages(error);
public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
return factory -> {
// 定义404错误页
HttpStatus notFound = HttpStatus.NOT_FOUND;
// 定义404错误页
ErrorPage errorPage = new ErrorPage(notFound, "/error.html");
// 追加错误页替换springboot默认的错误页
factory.addErrorPages(errorPage);
};
}
public static void main(String[] args) {
Application.serve(args);
try {
Application.serve(args);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -1,28 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2023 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.cskefu.cc;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}

View File

@ -37,6 +37,7 @@ import org.apache.commons.lang3.StringUtils;
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.util.Date;
@ -61,6 +62,7 @@ public class ACDAgentService {
private ACDPolicyService acdPolicyService;
@Autowired
@Lazy
private PeerSyncIM peerSyncIM;
@Autowired
@ -325,7 +327,7 @@ public class ACDAgentService {
*/
AgentService service = null;
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
service = agentServiceRes.findById(agentUser.getAgentserviceid());
service = agentServiceRes.getReferenceById(agentUser.getAgentserviceid());
} else if (agentStatus != null) {
// 该访客没有和坐席对话因此没有 AgentService
// 当做留言处理创建一个新的 AgentService
@ -339,7 +341,7 @@ public class ACDAgentService {
service.setSessiontimes(System.currentTimeMillis() - service.getServicetime().getTime());
}
final AgentUserTask agentUserTask = agentUserTaskRes.findOne(
final AgentUserTask agentUserTask = agentUserTaskRes.getReferenceById(
agentUser.getId());
if (agentUserTask != null) {
service.setAgentreplyinterval(agentUserTask.getAgentreplyinterval());
@ -514,7 +516,7 @@ public class ACDAgentService {
AgentService agentService = new AgentService();
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
AgentService existAgentService = agentServiceRes.findById(agentUser.getAgentserviceid());
AgentService existAgentService = agentServiceRes.getReferenceById(agentUser.getAgentserviceid());
if (existAgentService != null) {
agentService = existAgentService;
} else {
@ -581,7 +583,7 @@ public class ACDAgentService {
agentService.setOwner(agentUser.getOwner());
agentService.setTimes(0);
final User agent = userRes.findOne(agentService.getAgentno());
final User agent = userRes.getReferenceById(agentService.getAgentno());
agentUser.setAgentname(agent.getUname());
agentUser.setAgentno(agentService.getAgentno());

View File

@ -46,7 +46,7 @@ public class ACDChatbotService {
AgentService agentService = new AgentService(); //放入缓存的对象
Date now = new Date();
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
agentService = agentServiceRes.findById(agentUser.getAgentserviceid());
agentService = agentServiceRes.getReferenceById(agentUser.getAgentserviceid());
agentService.setEndtime(now);
if (agentService.getServicetime() != null) {
agentService.setSessiontimes(System.currentTimeMillis() - agentService.getServicetime().getTime());

View File

@ -164,7 +164,7 @@ public class ACDPolicyService {
}
if (agentUser != null && StringUtils.isNotBlank(agentUser.getAgentno())) {
User user = userRes.findById(agentUser.getAgentno());
User user = userRes.getReferenceById(agentUser.getAgentno());
if (user != null && !user.isSuperadmin()) {
// 用户不为空并且不是超级管理员
// 指定坐席

View File

@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
/**
* 处置访客分配

View File

@ -57,7 +57,7 @@ public class ACDVisBindingMw implements Middleware<ACDComposeContext> {
if (StringUtils.isNotBlank(ctx.getOrganid())) {
logger.info("[apply] bind skill {}", ctx.getOrganid());
// 绑定技能组
Organ organ = organRes.findOne(ctx.getOrganid());
Organ organ = organRes.getReferenceById(ctx.getOrganid());
if (organ != null) {
ctx.getAgentUser().setSkill(organ.getId());
ctx.setOrgan(organ);
@ -73,7 +73,7 @@ public class ACDVisBindingMw implements Middleware<ACDComposeContext> {
// 绑定坐席有可能是因为前端展示了技能组和坐席
// 也有可能是坐席发送了邀请该访客接收邀请
ctx.getAgentUser().setAgentno(ctx.getAgentno());
User agent = userRes.findOne(ctx.getAgentno());
User agent = userRes.getReferenceById(ctx.getAgentno());
ctx.setAgent(agent);
ctx.getAgentUser().setAgentname(agent.getUname());
} else {

View File

@ -69,7 +69,7 @@ public class AgentAuditSubscription {
// 查找关联的会话监控信息
final AgentUserAudit agentUserAudit = cache.findOneAgentUserAuditById(
json.get("agentUserId").getAsString()).orElseGet(() -> {
final AgentUser agentUser = agentUserRes.findOne(json.get("agentUserId").getAsString());
final AgentUser agentUser = agentUserRes.getReferenceById(json.get("agentUserId").getAsString());
if (agentUser != null) {
return agentAuditProxy.updateAgentUserAudits(agentUser);
} else {

View File

@ -12,15 +12,18 @@
package com.cskefu.cc.activemq;
import com.alibaba.fastjson.JSONObject;
import jakarta.annotation.PostConstruct;
import org.apache.activemq.ScheduledMessage;
import org.apache.activemq.command.ActiveMQTopic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.messaging.Message;
import org.springframework.messaging.core.MessagePostProcessor;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.Map;
@Component
@ -36,7 +39,6 @@ public class BrokerPublisher {
logger.info("[ActiveMQ Publisher] setup successfully.");
}
/**
* 时延消息
*

View File

@ -22,7 +22,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
/**
* IM OnlineUser

View File

@ -27,7 +27,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import java.util.Date;
/**

View File

@ -62,8 +62,8 @@ import org.springframework.beans.FatalBeanException;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.beans.BeanInfo;
import java.beans.Introspector;
@ -891,7 +891,7 @@ public class MainUtils {
Template templet = null;
if ((templet = MainContext.getCache().findOneSystemById(id)) == null) {
TemplateRepository templateRes = MainContext.getContext().getBean(TemplateRepository.class);
templet = templateRes.findById(id);
templet = templateRes.getReferenceById(id);
MainContext.getCache().putSystemById(id, templet);
}
return templet;
@ -1030,7 +1030,7 @@ public class MainUtils {
SystemConfig config = MainUtils.getSystemConfig();
if (config != null && config.isEnablemail() && config.getEmailid() != null) {
SystemMessage systemMessage = MainContext.getContext().getBean(
SystemMessageRepository.class).findById(config.getEmailid());
SystemMessageRepository.class).getReferenceById(config.getEmailid());
MailSender sender = new MailSender(
systemMessage.getSmtpserver(), systemMessage.getMailfrom(), systemMessage.getSmtpuser(),
decryption(systemMessage.getSmtppassword()), systemMessage.getSeclev(), systemMessage.getSslport());
@ -1234,7 +1234,7 @@ public class MainUtils {
SystemConfig config = MainUtils.getSystemConfig();
if (config != null) {
SystemMessage systemMessage = MainContext.getContext().getBean(
SystemMessageRepository.class).findById(id);
SystemMessageRepository.class).getReferenceById(id);
if (systemMessage == null) {
return false;
}

View File

@ -10,7 +10,7 @@
*/
package com.cskefu.cc.basic;
import javax.annotation.PreDestroy;
import jakarta.annotation.PreDestroy;
public class TerminateBean {
@PreDestroy

View File

@ -27,7 +27,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import java.util.concurrent.TimeUnit;
/**

View File

@ -20,7 +20,8 @@ import com.cskefu.cc.basic.MainContext;
import com.cskefu.cc.model.JobDetail;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author jaddy0302 Rivulet Resource.java 2010-3-6
@ -28,7 +29,7 @@ import java.util.logging.Logger;
*/
public abstract class Resource {
public static Logger log = Logger.getLogger(Resource.class.getName()) ;
public static Logger log = LoggerFactory.getLogger(Resource.class.getName()) ;
public abstract void begin() throws Exception;

View File

@ -22,7 +22,7 @@ import org.springframework.data.redis.core.*;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import java.util.*;
import java.util.concurrent.TimeUnit;

View File

@ -10,14 +10,13 @@
*/
package com.cskefu.cc.config;
import jakarta.jms.ConnectionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerContainerFactory;
import javax.jms.ConnectionFactory;
@EnableJms
@Configuration
public class ActiveMQConfigure {

View File

@ -24,9 +24,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.security.web.util.matcher.RequestMatcher;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import static com.cskefu.cc.basic.Constants.AUTH_TOKEN_TYPE_BASIC;

View File

@ -22,13 +22,10 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.config.annotation.*;
@Configuration
public class CSKeFuWebAppConfigurer
extends WebMvcConfigurerAdapter {
public class CSKeFuWebAppConfigurer implements WebMvcConfigurer {
private final static Logger logger = LoggerFactory.getLogger(CSKeFuWebAppConfigurer.class);
private final static String ENABLE_LOG_REQUEST = SystemEnvHelper.parseFromApplicationProps("extras.log.request");
@ -43,6 +40,17 @@ public class CSKeFuWebAppConfigurer
registry.addMapping("/**").allowedOrigins("*");
}
@Override
@SuppressWarnings("deprecation")
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(Boolean.TRUE);
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 多个拦截器组成一个拦截器链
@ -60,6 +68,5 @@ public class CSKeFuWebAppConfigurer
}
registry.addInterceptor(new ViewsInterceptorHandler()).addPathPatterns("/**");
super.addInterceptors(registry);
}
}

View File

@ -21,9 +21,9 @@ import com.cskefu.cc.model.User;
import org.apache.catalina.connector.ClientAbortException;
import org.springframework.security.web.util.matcher.RequestMatcher;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
public class DelegateRequestMatchingFilter implements Filter {

View File

@ -1,102 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2023 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.cskefu.cc.config;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DatabaseDriver;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
@Configuration
@ConditionalOnClass(com.alibaba.druid.pool.DruidDataSource.class)
@ConditionalOnProperty(name = "spring.datasource.type", havingValue = "com.alibaba.druid.pool.DruidDataSource", matchIfMissing = true)
public class DruidConfiguration {
@SuppressWarnings("unchecked")
protected <T> T createDataSource(DataSourceProperties properties,
Class<? extends DataSource> type) {
return (T) properties.initializeDataSourceBuilder().type(type).build();
}
/**
* @see org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.Tomcat 仿写的你可以去了解
* @param properties 读入的配置
* @return DruidDataSource
*/
@Bean
@ConfigurationProperties("spring.datasource.druid")
public com.alibaba.druid.pool.DruidDataSource dataSource(DataSourceProperties properties) {
com.alibaba.druid.pool.DruidDataSource dataSource = createDataSource(properties, com.alibaba.druid.pool.DruidDataSource.class);
DatabaseDriver databaseDriver = DatabaseDriver.fromJdbcUrl(properties.determineUrl());
String validationQuery = databaseDriver.getValidationQuery();
if (validationQuery != null) {
dataSource.setTestOnBorrow(true);
dataSource.setValidationQuery(validationQuery);
}
return dataSource;
}
/**
* 注册一个StatViewServlet
* @return
*/
@Bean
public ServletRegistrationBean DruidStatViewServle2(){
//org.springframework.boot.context.embedded.ServletRegistrationBean提供类的进行注册.
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(),"/druid/*");
//添加初始化参数initParams
//白名单
// servletRegistrationBean.addInitParameter("allow","127.0.0.1");
//IP黑名单 (存在共同时deny优先于allow) : 如果满足deny的话提示:Sorry, you are not permitted to view this page.
// servletRegistrationBean.addInitParameter("deny","192.168.1.73");
//登录查看信息的账号密码.
servletRegistrationBean.addInitParameter("loginUsername","admin");
servletRegistrationBean.addInitParameter("loginPassword","123456");
//是否能够重置数据.
servletRegistrationBean.addInitParameter("resetEnable","false");
return servletRegistrationBean;
}
/**
* 注册一个filterRegistrationBean
* @return
*/
@Bean
public FilterRegistrationBean druidStatFilter2(){
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new WebStatFilter());
//添加过滤规则.
filterRegistrationBean.addUrlPatterns("/*");
//添加不需要忽略的格式信息.
filterRegistrationBean.addInitParameter("exclusions","*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid2/*");
return filterRegistrationBean;
}
}

View File

@ -27,7 +27,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import javax.annotation.PreDestroy;
import jakarta.annotation.PreDestroy;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

View File

@ -30,7 +30,6 @@ public class PugConfig {
@Value("${spring.pug4j.template-loader-path}")
private String templatePath;
@Bean
public SpringTemplateLoader templateLoader() {
SpringTemplateLoader templateLoader = new SpringTemplateLoader();

View File

@ -10,7 +10,7 @@ public class PugCskefuViewResolver extends PugViewResolver {
AbstractUrlBasedView view = super.buildView(viewName);
if (viewName.startsWith("/resource/css")) {
PugView pugView = (PugView) view;
pugView.setContentType("text/css ; charset=UTF-8");
pugView.setContentType("text/css; charset=UTF-8");
}
return view;
}

View File

@ -15,10 +15,9 @@
*/
package com.cskefu.cc.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import java.util.concurrent.Executors;
@ -26,13 +25,10 @@ import java.util.concurrent.Executors;
@Configuration
public class RedisConfigure {
@Autowired
JedisConnectionFactory jedisConnectionFactory;
@Bean
RedisMessageListenerContainer redisContainer() {
RedisMessageListenerContainer redisContainer(RedisConnectionFactory redisConnectionFactory) {
final RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(jedisConnectionFactory);
container.setConnectionFactory(redisConnectionFactory);
container.setTaskExecutor(Executors.newFixedThreadPool(100));
return container;
}

View File

@ -24,7 +24,7 @@ import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
import org.springframework.web.multipart.support.StandardServletMultipartResolver;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
@Configuration
public class WebConfigBeans {

View File

@ -16,11 +16,19 @@
*/
package com.cskefu.cc.config;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configurers.CsrfConfigurer;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.security.web.csrf.CsrfToken;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
@ -28,29 +36,24 @@ import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.WebUtils;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
public class WebSecurityConfig {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.addFilterAfter(tokenInfoTokenFilterSecurityInterceptor() , BasicAuthenticationFilter.class)
.antMatcher("*/*").authorizeRequests()
.anyRequest().permitAll()
.and().addFilterAfter(csrfHeaderFilter(), BasicAuthenticationFilter.class)
.addFilterAfter(apiTokenFilterSecurityInterceptor(), BasicAuthenticationFilter.class);
}
@Bean
public Filter tokenInfoTokenFilterSecurityInterceptor() throws Exception
{
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http.addFilterAfter(tokenInfoTokenFilterSecurityInterceptor(), BasicAuthenticationFilter.class)
.authorizeHttpRequests(authorize -> authorize.requestMatchers("/**").permitAll())
.csrf().disable().headers().frameOptions().sameOrigin()
// .addFilterAfter(csrfHeaderFilter(), BasicAuthenticationFilter.class) // TODO lecjy
.and().addFilterAfter(apiTokenFilterSecurityInterceptor(), BasicAuthenticationFilter.class)
.build();
}
@Bean
public Filter tokenInfoTokenFilterSecurityInterceptor() throws Exception {
RequestMatcher autconfig = new AntPathRequestMatcher("/autoconfig/**");
RequestMatcher configprops = new AntPathRequestMatcher("/configprops/**");
RequestMatcher beans = new AntPathRequestMatcher("/beans/**");
@ -67,15 +70,14 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
// RequestMatcher health = new AntPathRequestMatcher("/health/**");
// RequestMatcher metrics = new AntPathRequestMatcher("/metrics/**");
// return new DelegateRequestMatchingFilter(autconfig , configprops , beans , dump , env , health , info , mappings , metrics , trace, druid);
return new DelegateRequestMatchingFilter(autconfig , configprops , beans , dump , env , mappings , trace, druid);
return new DelegateRequestMatchingFilter(autconfig, configprops, beans, dump, env, mappings, trace, druid);
}
@Bean
public Filter apiTokenFilterSecurityInterceptor() throws Exception
{
public Filter apiTokenFilterSecurityInterceptor() throws Exception {
return new ApiRequestMatchingFilter(new AntPathRequestMatcher("/api/**"));
}
private Filter csrfHeaderFilter() {
return new OncePerRequestFilter() {

View File

@ -18,11 +18,10 @@ package com.cskefu.cc.config;
import org.apache.catalina.connector.Connector;
import org.apache.coyote.http11.Http11NioProtocol;
import org.apache.tomcat.util.http.LegacyCookieProcessor;
import org.apache.tomcat.util.http.Rfc6265CookieProcessor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -42,12 +41,13 @@ public class WebServerContainerConfigure {
private String path;
@Bean
public EmbeddedServletContainerFactory createEmbeddedServletContainerFactory() throws IOException, NoSuchAlgorithmException {
TomcatEmbeddedServletContainerFactory tomcatFactory = new TomcatEmbeddedServletContainerFactory();
public TomcatServletWebServerFactory createEmbeddedServletContainerFactory() throws IOException, NoSuchAlgorithmException {
TomcatServletWebServerFactory tomcatFactory = new TomcatServletWebServerFactory();
tomcatFactory.addConnectorCustomizers(new CSKeFuTomcatConnectorCustomizer(maxthread, maxconnections));
// Enable cookie value with space
// https://stackoverflow.com/questions/38687210/error-with-cookie-value-when-adding-a-new-spring-session
tomcatFactory.addContextCustomizers(context -> context.setCookieProcessor(new LegacyCookieProcessor()));
// TODO lecjy
tomcatFactory.addContextCustomizers(context -> context.setCookieProcessor(new Rfc6265CookieProcessor()));
return tomcatFactory;
}
@ -60,6 +60,7 @@ public class WebServerContainerConfigure {
this.maxconnection = maxconnection;
}
@Override
public void customize(Connector connector) {
Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
//设置最大连接数

View File

@ -25,10 +25,12 @@ import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.session.data.redis.RedisFlushMode;
import org.springframework.session.data.redis.RedisOperationsSessionRepository;
import org.springframework.session.FlushMode;
import org.springframework.session.data.redis.RedisSessionRepository;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import java.time.Duration;
/**
* maxInactiveIntervalInSeconds: 设置 Session 失效时间
@ -39,14 +41,13 @@ import org.springframework.session.data.redis.config.annotation.web.http.EnableR
*/
@Configuration
@EnableRedisHttpSession()
public class WebServerSessionConfigure {
/**
* spring在多长时间后强制使redis中的session失效,默认是1800.(单位/)
*/
@Value("${server.session-timeout}")
private int maxInactiveIntervalInSeconds;
private long maxInactiveIntervalInSeconds;
@Value("${spring.redis.host}")
private String host;
@ -68,16 +69,17 @@ public class WebServerSessionConfigure {
@Primary
@Bean
public RedisOperationsSessionRepository sessionRepository(RedisTemplate<Object, Object> sessionRedisTemplate) {
RedisOperationsSessionRepository sessionRepository = new RedisOperationsSessionRepository(sessionRedisTemplate);
sessionRepository.setDefaultMaxInactiveInterval(maxInactiveIntervalInSeconds);
sessionRepository.setRedisFlushMode(RedisFlushMode.IMMEDIATE);
// TODO lecjy
public RedisSessionRepository sessionRepository(RedisTemplate<String, Object> sessionRedisTemplate) {
RedisSessionRepository sessionRepository = new RedisSessionRepository(sessionRedisTemplate);
sessionRepository.setDefaultMaxInactiveInterval(Duration.ofSeconds(maxInactiveIntervalInSeconds));
sessionRepository.setFlushMode(FlushMode.IMMEDIATE);
sessionRepository.setRedisKeyNamespace(RedisKey.CACHE_SESSIONS);
return sessionRepository;
}
@Bean
public RedisTemplate<Object, Object> sessionRedisTemplate() {
public RedisTemplate<String, Object> sessionRedisTemplate() {
JedisConnectionFactory factory = new JedisConnectionFactory();
factory.setHostName(host);
factory.setPort(port);
@ -87,7 +89,7 @@ public class WebServerSessionConfigure {
}
factory.setTimeout(timeout);
factory.afterPropertiesSet();
RedisTemplate<Object, Object> template = new RedisTemplate<>();
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
template.setConnectionFactory(factory);

View File

@ -22,6 +22,7 @@ import com.cskefu.cc.basic.MainContext;
import com.cskefu.cc.basic.MainUtils;
import com.cskefu.cc.cache.Cache;
import com.cskefu.cc.model.Organ;
import com.cskefu.cc.model.PbxHost;
import com.cskefu.cc.model.User;
import com.cskefu.cc.persistence.repository.ExtensionRepository;
import com.cskefu.cc.persistence.repository.OrganRepository;
@ -37,8 +38,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.List;
@ -117,19 +118,18 @@ public class ApplicationController extends Handler {
// 呼叫中心信息
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER) && logined.isCallcenter()) {
extensionRes.findByAgentno(logined.getId()).ifPresent(ext -> {
pbxHostRes.findById(ext.getHostid()).ifPresent(pbx -> {
Map<String, Object> webrtcData = new HashMap<>();
webrtcData.put("callCenterWebrtcIP", pbx.getWebrtcaddress());
webrtcData.put("callCenterWebRtcPort", pbx.getWebrtcport());
webrtcData.put("callCenterExtensionNum", ext.getExtension());
try {
webrtcData.put("callCenterExtensionPassword", MainUtils.decryption(ext.getPassword()));
} catch (NoSuchAlgorithmException e) {
logger.error("[admin]", e);
webrtcData.put("callCenterError", "Invalid data for callcenter agent.");
}
view.addObject("webrtc", webrtcData);
});
PbxHost one = pbxHostRes.getReferenceById(ext.getHostid());
Map<String, Object> webrtcData = new HashMap<>();
webrtcData.put("callCenterWebrtcIP", one.getWebrtcaddress());
webrtcData.put("callCenterWebRtcPort", one.getWebrtcport());
webrtcData.put("callCenterExtensionNum", ext.getExtension());
try {
webrtcData.put("callCenterExtensionPassword", MainUtils.decryption(ext.getPassword()));
} catch (NoSuchAlgorithmException e) {
logger.error("[admin]", e);
webrtcData.put("callCenterError", "Invalid data for callcenter agent.");
}
view.addObject("webrtc", webrtcData);
});
}
@ -145,7 +145,7 @@ public class ApplicationController extends Handler {
@ResponseBody
public String setOrgan(HttpServletRequest request, @Valid String organ) {
if (StringUtils.isNotBlank(organ)) {
Organ currentOrgan = organRepository.findById(organ);
Organ currentOrgan = organRepository.getReferenceById(organ);
if (currentOrgan != null) {
request.getSession(true).setAttribute(Constants.ORGAN_SESSION_NAME, currentOrgan);
}

View File

@ -39,8 +39,8 @@ import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;

View File

@ -46,10 +46,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
@ -140,7 +140,7 @@ public class LoginController extends Handler {
try {
flagid = MainUtils.decryption(cookie.getValue());
if (StringUtils.isNotBlank(flagid)) {
User user = userRepository.findById(flagid);
User user = userRepository.getReferenceById(flagid);
if (user != null) {
view = this.processLogin(request, user, referer);
}
@ -214,10 +214,11 @@ public class LoginController extends Handler {
}
// add authorization code for rest api
String token = String.format("%s %s", Constants.AUTH_TOKEN_TYPE_BEARER, MainUtils.getUUID());
String uuid = MainUtils.getUUID();
String token = String.format("%s %s", Constants.AUTH_TOKEN_TYPE_BEARER, uuid);
bearerTokenMgr.update(token, loginUser);
userRepository.save(loginUser); // 更新登录状态到数据库
response.addCookie((new Cookie("authorization", token)));
response.addCookie((new Cookie("authorization", uuid)));
// 该登录用户是坐席并且具有坐席对话的角色
if ((loginUser.isAgent() &&

View File

@ -36,7 +36,7 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

View File

@ -34,8 +34,8 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.util.*;
/**
@ -143,10 +143,10 @@ public class OrganController extends Handler {
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String parent, @Valid String area) {
map.addAttribute("areaList", areaRepository.findAll());
if (!StringUtils.isBlank(parent)) {
map.addAttribute("organ", organRepository.findById(parent));
map.addAttribute("organ", organRepository.getReferenceById(parent));
}
if (!StringUtils.isBlank(area)) {
map.addAttribute("area", areaRepository.findById(area));
map.addAttribute("area", areaRepository.getReferenceById(area));
}
map.addAttribute("organList", getOwnOragans(request));
@ -184,7 +184,7 @@ public class OrganController extends Handler {
public ModelAndView seluser(ModelMap map, HttpServletRequest request, @Valid String organ) {
Map<String, Organ> organs = organProxy.findAllOrganByParent(super.getOrgan(request));
map.addAttribute("userList", userProxy.findUserInOrgans(organs.keySet()));
Organ organData = organRepository.findById(organ);
Organ organData = organRepository.getReferenceById(organ);
map.addAttribute("userOrganList", userProxy
.findByOrganAndDatastatus(organ, false));
map.addAttribute("organ", organData);
@ -210,8 +210,8 @@ public class OrganController extends Handler {
if (users != null && users.length > 0) {
List<String> chosen = new ArrayList<>(Arrays.asList(users));
Organ organData = organRepository.findById(organ);
List<User> organUserList = userRepository.findAll(chosen);
Organ organData = organRepository.getReferenceById(organ);
List<User> organUserList = userRepository.findAllById(chosen);
for (final User user : organUserList) {
OrganUser ou = organUserRes.findByUseridAndOrgan(user.getId(), organ);
@ -254,7 +254,7 @@ public class OrganController extends Handler {
}
}
}
userRepository.save(organUserList);
userRepository.saveAll(organUserList);
}
return request(super.createView("redirect:/admin/organ/index.html?organ=" + organ));
@ -285,7 +285,7 @@ public class OrganController extends Handler {
ModelAndView view = request(super.createView("/admin/organ/edit"));
Organ currentOrgan = super.getOrgan(request);
map.addAttribute("areaList", areaRepository.findAll());
view.addObject("organData", organRepository.findById(id));
view.addObject("organData", organRepository.getReferenceById(id));
view.addObject("isRootOrgan", id.equals(currentOrgan.getId()));
map.addAttribute("organList", getOwnOragans(request));
return view;
@ -310,14 +310,14 @@ public class OrganController extends Handler {
}
map.addAttribute("cacheList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_AREA_DIC));
map.addAttribute("organData", organRepository.findById(id));
map.addAttribute("organData", organRepository.getReferenceById(id));
return request(super.createView("/admin/organ/area"));
}
@RequestMapping("/area/update")
@Menu(type = "admin", subtype = "organ")
public ModelAndView areaupdate(HttpServletRequest request, @Valid Organ organ) {
Organ tempOrgan = organRepository.findById(organ.getId());
Organ tempOrgan = organRepository.getReferenceById(organ.getId());
String msg = "admin_organ_update_success";
if (tempOrgan != null) {
tempOrgan.setArea(organ.getArea());
@ -334,7 +334,7 @@ public class OrganController extends Handler {
public ModelAndView delete(HttpServletRequest request, @Valid Organ organ) {
String msg = "admin_organ_delete";
Organ organSelf = organRepository.findById(organ.getId());
Organ organSelf = organRepository.getReferenceById(organ.getId());
List<Organ> organParentAre = organRepository.findByParent(organSelf.getId());
if (organ != null && organParentAre != null && organParentAre.size() > 0) {
msg = "admin_oran_not_delete";
@ -353,9 +353,9 @@ public class OrganController extends Handler {
@RequestMapping("/auth/save")
@Menu(type = "admin", subtype = "role")
public ModelAndView authsave(HttpServletRequest request, @Valid String id, @Valid String menus) {
Organ organData = organRepository.findById(id);
Organ organData = organRepository.getReferenceById(id);
List<OrganRole> organRoleList = organRoleRes.findByOrgan(organData);
organRoleRes.delete(organRoleList);
organRoleRes.deleteAll(organRoleList);
if (!StringUtils.isBlank(menus)) {
String[] menusarray = menus.split(",");
for (String menu : menusarray) {

View File

@ -38,8 +38,8 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@ -96,10 +96,10 @@ public class RoleController extends Handler {
// Page<UserRole> userRoleList =
// userRoleRes.findByOrganAndRole(currentOrgan.getId(), roleData,
// new PageRequest(super.getP(request), super.getPs(request)));
// PageRequest.of(super.getP(request), super.getPs(request)));
Page<UserRole> userRoleList = userRoleRes.findByOrganInAndRole(organs.keySet(), roleData,
new PageRequest(super.getP(request), super.getPs(request)));
PageRequest.of(super.getP(request), super.getPs(request)));
if (userRoleList.getContent().size() > 0) {
for (UserRole ur : userRoleList.getContent()) {
@ -148,7 +148,7 @@ public class RoleController extends Handler {
public ModelAndView seluser(ModelMap map, HttpServletRequest request, @Valid String role) {
Organ currentOrgan = super.getOrgan(request);
map.addAttribute("userList", userProxy.findUserInOrgans(Arrays.asList(currentOrgan.getId())));
Role roleData = roleRepository.findById(role);
Role roleData = roleRepository.getReferenceById(role);
map.addAttribute("userRoleList", userRoleRes.findByRole(roleData));
map.addAttribute("role", roleData);
return request(super.createView("/admin/role/seluser"));
@ -158,7 +158,7 @@ public class RoleController extends Handler {
@Menu(type = "admin", subtype = "saveuser", admin = true)
public ModelAndView saveuser(HttpServletRequest request, @Valid String[] users, @Valid String role) {
Organ currentOrgan = super.getOrgan(request);
Role roleData = roleRepository.findById(role);
Role roleData = roleRepository.getReferenceById(role);
List<UserRole> userRoleList = userRoleRes.findByRole(roleData);
if (users != null && users.length > 0) {
for (String user : users) {
@ -186,7 +186,7 @@ public class RoleController extends Handler {
@Menu(type = "admin", subtype = "role")
public ModelAndView userroledelete(HttpServletRequest request, @Valid String id, @Valid String role) {
if (role != null) {
userRoleRes.delete(id);
userRoleRes.deleteById(id);
}
return request(super.createView("redirect:/admin/role/index.html?role=" + role));
}
@ -195,7 +195,7 @@ public class RoleController extends Handler {
@Menu(type = "admin", subtype = "role")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
ModelAndView view = request(super.createView("/admin/role/edit"));
view.addObject("roleData", roleRepository.findById(id));
view.addObject("roleData", roleRepository.getReferenceById(id));
return view;
}
@ -206,7 +206,7 @@ public class RoleController extends Handler {
String msg = "";
if (tempRoleExist == null) {
msg = "admin_role_update_success";
Role tempRole = roleRepository.findById(role.getId());
Role tempRole = roleRepository.getReferenceById(role.getId());
tempRole.setName(role.getName());
tempRole.setUpdatetime(new Date());
roleRepository.save(tempRole);
@ -221,7 +221,7 @@ public class RoleController extends Handler {
public ModelAndView delete(HttpServletRequest request, @Valid Role role) {
String msg = "admin_role_delete";
if (role != null) {
userRoleRes.delete(userRoleRes.findByRole(role));
userRoleRes.deleteAll(userRoleRes.findByRole(role));
roleRepository.delete(role);
} else {
msg = "admin_role_not_exist";
@ -238,7 +238,7 @@ public class RoleController extends Handler {
map.addAttribute("resourceList", sysDicRes.findByDicid(sysDic.getId()));
}
map.addAttribute("sysDic", sysDic);
Role role = roleRepository.findById(id);
Role role = roleRepository.getReferenceById(id);
map.addAttribute("role", role);
map.addAttribute("roleAuthList", roleAuthRes.findByRoleid(role.getId()));
return request(super.createView("/admin/role/auth"));
@ -250,7 +250,7 @@ public class RoleController extends Handler {
// logger.info("[authsave] id {}, menus {}", id, menus);
List<RoleAuth> roleAuthList = roleAuthRes.findByRoleid(id);
roleAuthRes.delete(roleAuthList);
roleAuthRes.deleteAll(roleAuthList);
if (StringUtils.isNotBlank(menus)) {
String[] menuarray = menus.split(",");

View File

@ -21,17 +21,13 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import com.cskefu.cc.basic.Constants;
import com.cskefu.cc.basic.MainContext;
import com.cskefu.cc.controller.Handler;
import com.cskefu.cc.model.Organ;
import com.cskefu.cc.model.OrganUser;
import com.cskefu.cc.model.Role;
import com.cskefu.cc.model.User;
import com.cskefu.cc.model.UserRole;
import com.cskefu.cc.model.*;
import com.cskefu.cc.persistence.repository.ExtensionRepository;
import com.cskefu.cc.persistence.repository.OrganUserRepository;
import com.cskefu.cc.persistence.repository.PbxHostRepository;
@ -103,7 +99,7 @@ public class UsersController extends Handler {
organs.add(currentOrgan.getId());
map.addAttribute("currentOrgan", currentOrgan);
map.addAttribute("userList", userProxy.findUserInOrgans(organs, new PageRequest(
map.addAttribute("userList", userProxy.findUserInOrgans(organs, PageRequest.of(
super.getP(request),
super.getPs(request),
Sort.Direction.ASC,
@ -130,17 +126,16 @@ public class UsersController extends Handler {
@Menu(type = "admin", subtype = "user")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
ModelAndView view = request(super.createView("/admin/user/edit"));
User user = userRepository.findById(id);
User user = userRepository.getReferenceById(id);
if (user != null && MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
// 加载呼叫中心信息
extensionRes.findByAgentno(user.getId()).ifPresent(p -> {
user.setExtensionId(p.getId());
user.setExtension(p);
pbxHostRes.findById(p.getHostid()).ifPresent(b -> {
user.setPbxhostId(b.getId());
user.setPbxHost(b);
});
PbxHost one = pbxHostRes.getReferenceById(p.getHostid());
user.setPbxhostId(one.getId());
user.setPbxHost(one);
});
}
view.addObject("userData", user);
@ -152,16 +147,16 @@ public class UsersController extends Handler {
public ModelAndView delete(HttpServletRequest request, @Valid User user) {
String msg = "admin_user_delete";
if (user != null) {
User dbUser = userRepository.getOne(user.getId());
User dbUser = userRepository.getReferenceById(user.getId());
if (dbUser.isSuperadmin()) {
msg = "admin_user_abandoned";
} else {
// 删除用户的时候同时删除用户对应的权限数据
List<UserRole> userRole = userRoleRes.findByUser(user);
userRoleRes.delete(userRole);
userRoleRes.deleteAll(userRole);
// 删除用户对应的组织机构关系
List<OrganUser> organUsers = organUserRes.findByUserid(user.getId());
organUserRes.delete(organUsers);
organUserRes.deleteAll(organUsers);
userRepository.delete(dbUser);

View File

@ -37,8 +37,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.List;
@ -74,7 +74,7 @@ public class ChannelController extends Handler {
@Menu(type = "admin", subtype = "im", admin = true)
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String execute, @RequestParam(name = "status", required = false) String status) {
Map<String, Organ> organs = organProxy.findAllOrganByParent(super.getOrgan(request));
map.addAttribute("snsAccountList", snsAccountRes.findByTypeAndOrgan(MainContext.ChannelType.WEBIM.toString(), organs.keySet(), new PageRequest(super.getP(request), super.getPs(request))));
map.addAttribute("snsAccountList", snsAccountRes.findByTypeAndOrgan(MainContext.ChannelType.WEBIM.toString(), organs.keySet(), PageRequest.of(super.getP(request), super.getPs(request))));
map.addAttribute("status", status);
List<Secret> secretConfig = secRes.findAll();
@ -140,7 +140,7 @@ public class ChannelController extends Handler {
public ModelAndView delete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String confirm) {
boolean execute;
if (execute = MainUtils.secConfirm(secRes, confirm)) {
Channel channel = snsAccountRes.findById(id);
Channel channel = snsAccountRes.getReferenceById(id);
if (snsAccountRes != null) {
// 删除网站渠道记录
snsAccountRes.delete(channel);
@ -162,8 +162,8 @@ public class ChannelController extends Handler {
@RequestMapping("/edit")
@Menu(type = "admin", subtype = "send", admin = true)
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
Channel channel = snsAccountRes.findById(id);
Organ organ = organRes.findOne(channel.getOrgan());
Channel channel = snsAccountRes.getReferenceById(id);
Organ organ = organRes.getReferenceById(channel.getOrgan());
map.put("organ", organ);
map.addAttribute("channel", channel);
return request(super.createView("/admin/channel/im/edit"));
@ -172,7 +172,7 @@ public class ChannelController extends Handler {
@RequestMapping("/update")
@Menu(type = "admin", subtype = "send", admin = true)
public ModelAndView update(HttpServletRequest request, @Valid Channel channel) throws NoSuchAlgorithmException {
Channel oldChannel = snsAccountRes.findById(channel.getId());
Channel oldChannel = snsAccountRes.getReferenceById(channel.getId());
if (oldChannel != null) {
oldChannel.setName(channel.getName());
oldChannel.setBaseURL(channel.getBaseURL());

View File

@ -37,8 +37,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

View File

@ -44,8 +44,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

View File

@ -34,8 +34,8 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
@ -53,7 +53,7 @@ public class SystemMessageController extends Handler {
@RequestMapping("/email/index")
@Menu(type = "setting", subtype = "email")
public ModelAndView index(ModelMap map, HttpServletRequest request) throws IOException {
Page<SystemMessage> emails = systemMessageRepository.findByMsgtype("email", new PageRequest(super.getP(request), super.getPs(request)));
Page<SystemMessage> emails = systemMessageRepository.findByMsgtype("email", PageRequest.of(super.getP(request), super.getPs(request)));
List<Organ> organs = organRes.findAll();
emails.getContent().stream().forEach(p -> {
@ -86,14 +86,14 @@ public class SystemMessageController extends Handler {
@Menu(type = "admin", subtype = "email")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
map.put("organList", organRes.findAll());
map.addAttribute("email", systemMessageRepository.findById(id));
map.addAttribute("email", systemMessageRepository.getReferenceById(id));
return request(super.createView("/admin/email/edit"));
}
@RequestMapping("/email/update")
@Menu(type = "admin", subtype = "user", admin = true)
public ModelAndView update(HttpServletRequest request, @Valid SystemMessage email) throws NoSuchAlgorithmException {
SystemMessage temp = systemMessageRepository.findById(email.getId());
SystemMessage temp = systemMessageRepository.getReferenceById(email.getId());
if (email != null) {
email.setCreatetime(temp.getCreatetime());
email.setMsgtype(MainContext.SystemMessageType.EMAIL.toString());
@ -110,7 +110,7 @@ public class SystemMessageController extends Handler {
@RequestMapping("/email/delete")
@Menu(type = "admin", subtype = "user")
public ModelAndView delete(HttpServletRequest request, @Valid SystemMessage email) {
SystemMessage temp = systemMessageRepository.findById(email.getId());
SystemMessage temp = systemMessageRepository.getReferenceById(email.getId());
if (email != null) {
systemMessageRepository.delete(temp);
}
@ -121,7 +121,7 @@ public class SystemMessageController extends Handler {
@RequestMapping("/sms/index")
@Menu(type = "setting", subtype = "sms")
public ModelAndView smsindex(ModelMap map, HttpServletRequest request) throws IOException {
map.addAttribute("smsList", systemMessageRepository.findByMsgtype("sms", new PageRequest(super.getP(request), super.getPs(request))));
map.addAttribute("smsList", systemMessageRepository.findByMsgtype("sms", PageRequest.of(super.getP(request), super.getPs(request))));
return request(super.createView("/admin/sms/index"));
}
@ -147,14 +147,14 @@ public class SystemMessageController extends Handler {
@Menu(type = "admin", subtype = "sms")
public ModelAndView smsedit(ModelMap map, HttpServletRequest request, @Valid String id) {
map.addAttribute("smsType", Dict.getInstance().getDic("com.dic.sms.type"));
map.addAttribute("sms", systemMessageRepository.findById(id));
map.addAttribute("sms", systemMessageRepository.getReferenceById(id));
return request(super.createView("/admin/sms/edit"));
}
@RequestMapping("/sms/update")
@Menu(type = "admin", subtype = "sms", admin = true)
public ModelAndView smsupdate(HttpServletRequest request, @Valid SystemMessage sms) throws NoSuchAlgorithmException {
SystemMessage temp = systemMessageRepository.findById(sms.getId());
SystemMessage temp = systemMessageRepository.getReferenceById(sms.getId());
if (sms != null) {
sms.setCreatetime(temp.getCreatetime());
sms.setMsgtype(MainContext.SystemMessageType.SMS.toString());
@ -171,7 +171,7 @@ public class SystemMessageController extends Handler {
@RequestMapping("/sms/delete")
@Menu(type = "admin", subtype = "sms")
public ModelAndView smsdelete(HttpServletRequest request, @Valid SystemMessage sms) {
SystemMessage temp = systemMessageRepository.findById(sms.getId());
SystemMessage temp = systemMessageRepository.getReferenceById(sms.getId());
if (sms != null) {
systemMessageRepository.delete(temp);
}

View File

@ -29,7 +29,6 @@ import com.cskefu.cc.util.metadata.UKColumnMetadata;
import com.cskefu.cc.util.metadata.UKTableMetaData;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.Session;
import org.hibernate.jdbc.Work;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
@ -40,10 +39,10 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
@ -75,21 +74,21 @@ public class MetadataController extends Handler {
@RequestMapping("/index")
@Menu(type = "admin", subtype = "metadata", admin = true)
public ModelAndView index(ModelMap map, HttpServletRequest request) throws SQLException {
map.addAttribute("metadataList", metadataRes.findAll(new PageRequest(super.getP(request), super.getPs(request))));
map.addAttribute("metadataList", metadataRes.findAll(PageRequest.of(super.getP(request), super.getPs(request))));
return request(super.createView("/admin/system/metadata/index"));
}
@RequestMapping("/edit")
@Menu(type = "admin", subtype = "metadata", admin = true)
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
map.addAttribute("metadata", metadataRes.findById(id));
map.addAttribute("metadata", metadataRes.getReferenceById(id));
return request(super.createView("/admin/system/metadata/edit"));
}
@RequestMapping("/update")
@Menu(type = "admin", subtype = "metadata", admin = true)
public ModelAndView update(ModelMap map, HttpServletRequest request, @Valid MetadataTable metadata) throws SQLException {
MetadataTable table = metadataRes.findById(metadata.getId());
MetadataTable table = metadataRes.getReferenceById(metadata.getId());
table.setName(metadata.getName());
table.setFromdb(metadata.isFromdb());
table.setListblocktemplet(metadata.getListblocktemplet());
@ -101,7 +100,7 @@ public class MetadataController extends Handler {
@RequestMapping("/properties/edit")
@Menu(type = "admin", subtype = "metadata", admin = true)
public ModelAndView propertiesedit(ModelMap map, HttpServletRequest request, @Valid String id) {
map.addAttribute("tp", tablePropertiesRes.findById(id));
map.addAttribute("tp", tablePropertiesRes.getReferenceById(id));
map.addAttribute("sysdicList", sysDicRes.findByParentid("0"));
map.addAttribute("dataImplList", Dict.getInstance().getDic("com.dic.data.impl"));
@ -111,7 +110,7 @@ public class MetadataController extends Handler {
@RequestMapping("/properties/update")
@Menu(type = "admin", subtype = "metadata", admin = true)
public ModelAndView propertiesupdate(ModelMap map, HttpServletRequest request, @Valid TableProperties tp) throws SQLException {
TableProperties tableProperties = tablePropertiesRes.findById(tp.getId());
TableProperties tableProperties = tablePropertiesRes.getReferenceById(tp.getId());
tableProperties.setName(tp.getName());
tableProperties.setSeldata(tp.isSeldata());
tableProperties.setSeldatacode(tp.getSeldatacode());
@ -136,7 +135,7 @@ public class MetadataController extends Handler {
@RequestMapping("/delete")
@Menu(type = "admin", subtype = "metadata", admin = true)
public ModelAndView delete(ModelMap map, HttpServletRequest request, @Valid String id) throws SQLException {
MetadataTable table = metadataRes.findById(id);
MetadataTable table = metadataRes.getReferenceById(id);
metadataRes.delete(table);
return request(super.createView("redirect:/admin/metadata/index.html"));
}
@ -145,7 +144,7 @@ public class MetadataController extends Handler {
@Menu(type = "admin", subtype = "metadata", admin = true)
public ModelAndView batdelete(ModelMap map, HttpServletRequest request, @Valid String[] ids) throws SQLException {
if (ids != null && ids.length > 0) {
metadataRes.delete(metadataRes.findAll(Arrays.asList(ids)));
metadataRes.deleteAll(metadataRes.findAllById(Arrays.asList(ids)));
}
return request(super.createView("redirect:/admin/metadata/index.html"));
}
@ -153,7 +152,7 @@ public class MetadataController extends Handler {
@RequestMapping("/properties/delete")
@Menu(type = "admin", subtype = "metadata", admin = true)
public ModelAndView propertiesdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String tbid) throws SQLException {
TableProperties prop = tablePropertiesRes.findById(id);
TableProperties prop = tablePropertiesRes.getReferenceById(id);
tablePropertiesRes.delete(prop);
return request(super.createView("redirect:/admin/metadata/table.html?id=" + (!StringUtils.isBlank(tbid) ? tbid : prop.getDbtableid())));
}
@ -162,7 +161,7 @@ public class MetadataController extends Handler {
@Menu(type = "admin", subtype = "metadata", admin = true)
public ModelAndView propertiesbatdelete(ModelMap map, HttpServletRequest request, @Valid String[] ids, @Valid String tbid) throws SQLException {
if (ids != null && ids.length > 0) {
tablePropertiesRes.delete(tablePropertiesRes.findAll(Arrays.asList(ids)));
tablePropertiesRes.deleteAll(tablePropertiesRes.findAllById(Arrays.asList(ids)));
}
return request(super.createView("redirect:/admin/metadata/table.html?id=" + tbid));
}
@ -172,7 +171,7 @@ public class MetadataController extends Handler {
public ModelAndView table(ModelMap map, HttpServletRequest request, @Valid String id) throws SQLException {
map.addAttribute("propertiesList", tablePropertiesRes.findByDbtableid(id));
map.addAttribute("tbid", id);
map.addAttribute("table", metadataRes.findById(id));
map.addAttribute("table", metadataRes.getReferenceById(id));
return request(super.createView("/admin/system/metadata/table"));
}
@ -270,7 +269,7 @@ public class MetadataController extends Handler {
@Menu(type = "admin", subtype = "metadata", admin = true)
public ModelAndView clean(ModelMap map, HttpServletRequest request, @Valid String id) throws SQLException, BeansException, ClassNotFoundException {
if (!StringUtils.isBlank(id)) {
MetadataTable table = metadataRes.findById(id);
MetadataTable table = metadataRes.getReferenceById(id);
}
return request(super.createView("redirect:/admin/metadata/index.html"));
}
@ -280,7 +279,7 @@ public class MetadataController extends Handler {
@Menu(type = "admin", subtype = "metadata", admin = true)
public ModelAndView synctoes(ModelMap map, HttpServletRequest request, @Valid String id) throws SQLException, BeansException, ClassNotFoundException {
if (!StringUtils.isBlank(id)) {
MetadataTable table = metadataRes.findById(id);
MetadataTable table = metadataRes.getReferenceById(id);
if (table.isFromdb() && !StringUtils.isBlank(table.getListblocktemplet())) {
SysDic dic = Dict.getInstance().getDicItem(table.getListblocktemplet());
}
@ -293,7 +292,7 @@ public class MetadataController extends Handler {
@Menu(type = "admin", subtype = "metadata", admin = true)
public ModelAndView synctodb(ModelMap map, HttpServletRequest request, @Valid String id) throws SQLException, BeansException, ClassNotFoundException {
if (!StringUtils.isBlank(id)) {
MetadataTable table = metadataRes.findById(id);
MetadataTable table = metadataRes.getReferenceById(id);
if (table.isFromdb() && !StringUtils.isBlank(table.getListblocktemplet())) {
SysDic dic = Dict.getInstance().getDicItem(table.getListblocktemplet());
}

View File

@ -30,8 +30,8 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.util.Date;
import java.util.List;
@ -49,7 +49,7 @@ public class SysDicController extends Handler {
@RequestMapping("/index")
@Menu(type = "admin", subtype = "sysdic")
public ModelAndView index(ModelMap map, HttpServletRequest request) {
map.addAttribute("sysDicList", sysDicRes.findByParentid("0", new PageRequest(super.getP(request), super.getPs(request), Direction.DESC, "createtime")));
map.addAttribute("sysDicList", sysDicRes.findByParentid("0", PageRequest.of(super.getP(request), super.getPs(request), Direction.DESC, "createtime")));
return request(super.createView("/admin/system/sysdic/index"));
}
@ -80,7 +80,7 @@ public class SysDicController extends Handler {
@RequestMapping("/edit")
@Menu(type = "admin", subtype = "sysdic")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
map.addAttribute("sysDic", sysDicRes.findById(id));
map.addAttribute("sysDic", sysDicRes.getReferenceById(id));
map.addAttribute("p", p);
return request(super.createView("/admin/system/sysdic/edit"));
}
@ -90,7 +90,7 @@ public class SysDicController extends Handler {
public ModelAndView update(HttpServletRequest request, @Valid SysDic dic, @Valid String p) {
List<SysDic> sysDicList = sysDicRes.findByCodeOrName(dic.getCode(), dic.getName());
if (sysDicList.size() == 0 || (sysDicList.size() == 1 && sysDicList.get(0).getId().equals(dic.getId()))) {
SysDic sysDic = sysDicRes.findById(dic.getId());
SysDic sysDic = sysDicRes.getReferenceById(dic.getId());
sysDic.setName(dic.getName());
sysDic.setCode(dic.getCode());
sysDic.setCtype(dic.getCtype());
@ -106,8 +106,8 @@ public class SysDicController extends Handler {
@RequestMapping("/delete")
@Menu(type = "admin", subtype = "sysdic")
public ModelAndView delete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
SysDic sysDic = sysDicRes.findById(id);
sysDicRes.delete(sysDicRes.findByDicid(id));
SysDic sysDic = sysDicRes.getReferenceById(id);
sysDicRes.deleteAll(sysDicRes.findByDicid(id));
sysDicRes.delete(sysDic);
reloadSysDicItem(sysDic);
@ -118,15 +118,15 @@ public class SysDicController extends Handler {
@RequestMapping("/dicitem")
@Menu(type = "admin", subtype = "sysdic")
public ModelAndView dicitem(ModelMap map, HttpServletRequest request, @Valid String id) {
map.addAttribute("sysDic", sysDicRes.findById(id));
map.addAttribute("sysDicList", sysDicRes.findByParentid(id, new PageRequest(super.getP(request), super.getPs(request), Direction.DESC, "createtime")));
map.addAttribute("sysDic", sysDicRes.getReferenceById(id));
map.addAttribute("sysDicList", sysDicRes.findByParentid(id, PageRequest.of(super.getP(request), super.getPs(request), Direction.DESC, "createtime")));
return request(super.createView("/admin/system/sysdic/dicitem"));
}
@RequestMapping("/dicitem/add")
@Menu(type = "admin", subtype = "sysdic")
public ModelAndView dicitemadd(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
map.addAttribute("sysDic", sysDicRes.findById(id));
map.addAttribute("sysDic", sysDicRes.getReferenceById(id));
map.addAttribute("p", p);
return request(super.createView("/admin/system/sysdic/dicitemadd"));
}
@ -172,7 +172,7 @@ public class SysDicController extends Handler {
@RequestMapping("/dicitem/batadd")
@Menu(type = "admin", subtype = "sysdic")
public ModelAndView dicitembatadd(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
map.addAttribute("sysDic", sysDicRes.findById(id));
map.addAttribute("sysDic", sysDicRes.getReferenceById(id));
map.addAttribute("p", p);
return request(super.createView("/admin/system/sysdic/batadd"));
}
@ -200,7 +200,7 @@ public class SysDicController extends Handler {
}
}
reloadSysDicItem(sysDicRes.getOne(sysDic.getParentid()));
reloadSysDicItem(sysDicRes.getReferenceById(sysDic.getParentid()));
return request(super.createView("redirect:/admin/sysdic/dicitem.html?id=" + sysDic.getParentid() + "&p=" + p));
}
@ -208,7 +208,7 @@ public class SysDicController extends Handler {
@RequestMapping("/dicitem/edit")
@Menu(type = "admin", subtype = "sysdic")
public ModelAndView dicitemedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
map.addAttribute("sysDic", sysDicRes.findById(id));
map.addAttribute("sysDic", sysDicRes.getReferenceById(id));
map.addAttribute("p", p);
return request(super.createView("/admin/system/sysdic/dicitemedit"));
}
@ -218,7 +218,7 @@ public class SysDicController extends Handler {
public ModelAndView dicitemupdate(HttpServletRequest request, @Valid SysDic dic, @Valid String p) {
List<SysDic> sysDicList = sysDicRes.findByDicidAndName(dic.getDicid(), dic.getName());
if (sysDicList.size() == 0 || (sysDicList.size() == 1 && sysDicList.get(0).getId().equals(dic.getId()))) {
SysDic sysDic = sysDicRes.findById(dic.getId());
SysDic sysDic = sysDicRes.getReferenceById(dic.getId());
sysDic.setName(dic.getName());
sysDic.setCode(dic.getCode());
sysDic.setCtype(dic.getCtype());
@ -236,8 +236,8 @@ public class SysDicController extends Handler {
@RequestMapping("/dicitem/delete")
@Menu(type = "admin", subtype = "sysdic")
public ModelAndView dicitemdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
sysDicRes.delete(sysDicRes.findByDicid(id));
SysDic dic = sysDicRes.getOne(id);
sysDicRes.deleteAll(sysDicRes.findByDicid(id));
SysDic dic = sysDicRes.getReferenceById(id);
sysDicRes.delete(dic);
reloadSysDicItem(dic);
return request(super.createView("redirect:/admin/sysdic/dicitem.html?id=" + dic.getParentid() + "&p=" + p));

View File

@ -35,9 +35,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@ -97,7 +97,7 @@ public class TemplateController extends Handler {
@RequestMapping("/list")
@Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView list(ModelMap map, HttpServletRequest request, @Valid String type) {
map.addAttribute("sysDic", dicRes.findById(type));
map.addAttribute("sysDic", dicRes.getReferenceById(type));
map.addAttribute("templateList", templateRes.findByTemplettype(type));
return request(super.createView("/admin/system/template/list"));
}
@ -105,7 +105,7 @@ public class TemplateController extends Handler {
@RequestMapping("/add")
@Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String type) {
map.addAttribute("sysDic", dicRes.findById(type));
map.addAttribute("sysDic", dicRes.getReferenceById(type));
return request(super.createView("/admin/system/template/add"));
}
@ -114,7 +114,7 @@ public class TemplateController extends Handler {
public ModelAndView save(HttpServletRequest request, @Valid Template template) {
template.setCreatetime(new Date());
SysDic dic = dicRes.findById(template.getTemplettype());
SysDic dic = dicRes.getReferenceById(template.getTemplettype());
if (dic != null && StringUtils.isBlank(template.getCode())) {
template.setCode(dic.getCode());
}
@ -126,17 +126,17 @@ public class TemplateController extends Handler {
@RequestMapping("/edit")
@Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String type) {
map.addAttribute("sysDic", dicRes.findById(type));
map.addAttribute("template", templateRes.findById(id));
map.addAttribute("sysDic", dicRes.getReferenceById(type));
map.addAttribute("template", templateRes.getReferenceById(id));
return request(super.createView("/admin/system/template/edit"));
}
@RequestMapping("/update")
@Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView update(HttpServletRequest request, @Valid Template template) {
Template oldTemplate = templateRes.findById(template.getId());
Template oldTemplate = templateRes.getReferenceById(template.getId());
if (oldTemplate != null) {
SysDic dic = dicRes.findById(oldTemplate.getTemplettype());
SysDic dic = dicRes.getReferenceById(oldTemplate.getTemplettype());
if (dic != null) {
oldTemplate.setCode(dic.getCode());
}
@ -158,15 +158,15 @@ public class TemplateController extends Handler {
@RequestMapping("/code")
@Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView code(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String type) {
map.addAttribute("sysDic", dicRes.findById(type));
map.addAttribute("template", templateRes.findById(id));
map.addAttribute("sysDic", dicRes.getReferenceById(type));
map.addAttribute("template", templateRes.getReferenceById(id));
return request(super.createView("/admin/system/template/code"));
}
@RequestMapping("/codesave")
@Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView codesave(HttpServletRequest request, @Valid Template template) {
Template oldTemplate = templateRes.findById(template.getId());
Template oldTemplate = templateRes.getReferenceById(template.getId());
if (oldTemplate != null) {
oldTemplate.setTemplettext(template.getTemplettext());
oldTemplate.setTemplettitle(template.getTemplettitle());

View File

@ -41,6 +41,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -49,8 +50,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.util.Date;
import java.util.List;
@ -76,6 +77,7 @@ public class ApiAgentUserController extends Handler {
private Cache cache;
@Autowired
@Lazy
private PeerSyncIM peerSyncIM;
@Autowired
@ -158,8 +160,8 @@ public class ApiAgentUserController extends Handler {
if (StringUtils.isNotBlank(agentUserId) &&
StringUtils.isNotBlank(transAgentId) &&
StringUtils.isNotBlank(agentServiceId)) {
final User targetAgent = userRes.findOne(transAgentId);
final AgentService agentService = agentServiceRes.findById(agentServiceId);
final User targetAgent = userRes.getReferenceById(transAgentId);
final AgentService agentService = agentServiceRes.getReferenceById(agentServiceId);
/**
* 更新AgentUser
@ -295,7 +297,7 @@ public class ApiAgentUserController extends Handler {
final User logined = super.getUser(request);
JsonObject resp = new JsonObject();
final AgentUser agentUser = agentUserRes.findById(payload.get("id").getAsString());
final AgentUser agentUser = agentUserRes.getReferenceById(payload.get("id").getAsString());
if (agentUser != null) {
if ((StringUtils.equals(
logined.getId(), agentUser.getAgentno()) || logined.isAdmin())) {

View File

@ -33,8 +33,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
@RestController
@RequestMapping("/api/apps")

View File

@ -31,8 +31,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
/**
* 获取对话内容
@ -57,7 +57,7 @@ public class ApiChatMessageController extends Handler {
public ResponseEntity<RestResult> list(HttpServletRequest request, @Valid String serviceid) {
ResponseEntity<RestResult> result = null;
if (!StringUtils.isBlank(serviceid)) {
result = new ResponseEntity<>(new RestResult(RestResultType.OK, chatMessageRes.findByAgentserviceid(serviceid, new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"))), HttpStatus.OK);
result = new ResponseEntity<>(new RestResult(RestResultType.OK, chatMessageRes.findByAgentserviceid(serviceid, PageRequest.of(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"))), HttpStatus.OK);
} else {
result = new ResponseEntity<>(new RestResult(RestResultType.LACKDATA, RestResultType.LACKDATA.getMessage()), HttpStatus.OK);
}

View File

@ -45,7 +45,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
@ -86,7 +86,7 @@ public class ApiContactNotesController extends Handler {
private JsonObject creater(final String creater) {
JsonObject data = new JsonObject();
// 增加创建人
User u = userRes.findById(creater);
User u = userRes.getReferenceById(creater);
if (u != null) {
data.addProperty("creater", u.getId());
data.addProperty("creatername", u.getUname());
@ -100,7 +100,7 @@ public class ApiContactNotesController extends Handler {
JsonArray y = new JsonArray();
for (final OrganUser organ : organs) {
Organ o = organRes.findOne(organ.getOrgan());
Organ o = organRes.getReferenceById(organ.getOrgan());
if (o != null) {
JsonObject x = new JsonObject();
x.addProperty("createrorgan", o.getName());
@ -127,7 +127,7 @@ public class ApiContactNotesController extends Handler {
JsonObject resp = new JsonObject();
// TODO 增加权限检查
if (j.has("id") && StringUtils.isNotBlank(j.get("id").getAsString())) {
ContactNotes cn = contactNotesRes.findOne(j.get("id").getAsString());
ContactNotes cn = contactNotesRes.getReferenceById(j.get("id").getAsString());
if (cn != null) {
JsonObject data = new JsonObject();
data.addProperty("contactid", cn.getContactid());
@ -213,7 +213,7 @@ public class ApiContactNotesController extends Handler {
if ((!payload.has("contactid")) || StringUtils.isBlank(payload.get("contactid").getAsString())) {
return "参数传递不合法,没有[contactid]。";
} else {
Contacts c = contactsRes.findOne(payload.get("contactid").getAsString());
Contacts c = contactsRes.getReferenceById(payload.get("contactid").getAsString());
if (c == null)
return "参数不合法,不存在该联系人。";
}
@ -248,7 +248,7 @@ public class ApiContactNotesController extends Handler {
return resp;
}
final String cid = j.get("contactid").getAsString();
Contacts c = contactsRes.findOne(cid);
Contacts c = contactsRes.getReferenceById(cid);
if (c == null) {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
@ -258,7 +258,7 @@ public class ApiContactNotesController extends Handler {
String q = querybuilder(j);
Page<ContactNotes> cns = contactNotesRes.findByContactidOrderByCreatetimeDesc(cid, new PageRequest(super.getP(request), super.getPs(request)));
Page<ContactNotes> cns = contactNotesRes.findByContactidOrderByCreatetimeDesc(cid, PageRequest.of(super.getP(request), super.getPs(request)));
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
resp.addProperty("size", cns.getSize());

View File

@ -40,7 +40,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
@ -129,7 +129,7 @@ public class ApiContactTagsController extends Handler {
final String tagId = j.get("tagId").getAsString();
final String contactid = j.get("contactid").getAsString();
Tag tag = tagRes.findOne(tagId);
Tag tag = tagRes.getReferenceById(tagId);
if (tag == null) {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_2);
@ -167,7 +167,7 @@ public class ApiContactTagsController extends Handler {
return resp;
}
TagRelation t = tagRelationRes.findOne(j.get("xid").getAsString());
TagRelation t = tagRelationRes.getReferenceById(j.get("xid").getAsString());
if (t == null) {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
resp.addProperty(RestUtils.RESP_KEY_ERROR, "该联系人没有打这个标签。");

View File

@ -46,8 +46,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.util.Date;
import java.util.List;
import java.util.Optional;
@ -87,12 +87,12 @@ public class ApiContactsController extends Handler {
if (!StringUtils.isBlank(creater)) {
User user = super.getUser(request);
contactsList = contactsRepository.findByCreaterAndSharesAndDatastatus(user.getId(), "all", false,
new PageRequest(
PageRequest.of(
super.getP(request),
super.getPs(request)));
} else {
contactsList = contactsRepository.findByDatastatus(false,
new PageRequest(super.getP(request), super.getPs(request)));
PageRequest.of(super.getP(request), super.getPs(request)));
}
return new ResponseEntity<>(new RestResult(RestResultType.OK, contactsList), HttpStatus.OK);
}
@ -131,7 +131,7 @@ public class ApiContactsController extends Handler {
public ResponseEntity<RestResult> delete(HttpServletRequest request, @Valid String id) {
RestResult result = new RestResult(RestResultType.OK);
if (!StringUtils.isBlank(id)) {
Contacts contacts = contactsRepository.findOne(id);
Contacts contacts = contactsRepository.getReferenceById(id);
if (contacts != null) { //系统管理员 不允许 使用 接口删除
contacts.setDatastatus(true);
contactsRepository.save(contacts);

View File

@ -34,11 +34,11 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.servlet.http.HttpServletRequest;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import jakarta.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@ -64,13 +64,14 @@ public class ApiLeavemsgController extends Handler {
public ResponseEntity<RestResult> list(HttpServletRequest request, @RequestBody RequestValues<AgentService> values) {
Page<AgentService> page = agentServiceRepository.findAll((root, query, cb) -> {
List<Predicate> list = new ArrayList<>();
list.add(cb.equal(root.get("leavemsg").as(Boolean.class), true));
list.add(cb.equal(root.get("leavemsgstatus").as(String.class), MainContext.LeaveMsgStatus.NOTPROCESS.toString()));
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}, new PageRequest(super.getP(values.getQuery()), super.getPs(values.getQuery()), Sort.Direction.DESC, "createtime"));
}, PageRequest.of(super.getP(values.getQuery()), super.getPs(values.getQuery()), Sort.Direction.DESC, "createtime"));
return new ResponseEntity<>(new RestResult(RestResultType.OK, page), HttpStatus.OK);
}
}

View File

@ -34,8 +34,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
/**
* 获取在线访客功能
@ -59,9 +59,9 @@ public class ApiOnlineUserController extends Handler {
public ResponseEntity<RestResult> list(HttpServletRequest request, @Valid String userid) {
Page<PassportWebIMUser> onlineUserList = null;
if (!StringUtils.isBlank(userid)) {
onlineUserList = passportWebIMUserRepository.findByUserid(userid, new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
onlineUserList = passportWebIMUserRepository.findByUserid(userid, PageRequest.of(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
} else {
onlineUserList = passportWebIMUserRepository.findByStatus(MainContext.OnlineUserStatusEnum.ONLINE.toString(), new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
onlineUserList = passportWebIMUserRepository.findByStatus(MainContext.OnlineUserStatusEnum.ONLINE.toString(), PageRequest.of(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
}
return new ResponseEntity<>(new RestResult(RestResultType.OK, onlineUserList), HttpStatus.OK);
}

View File

@ -30,8 +30,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
/**
* 组织机构/部门/技能组功能
@ -82,7 +82,7 @@ public class ApiOrganController extends Handler{
RestResult result = new RestResult(RestResultType.OK) ;
Organ organ = null ;
if(!StringUtils.isBlank(id)){
organ = organRepository.findById(id) ;
organ = organRepository.getReferenceById(id) ;
if(organ != null){ //系统管理员 不允许 使用 接口删除
organRepository.delete(organ);
}else{

View File

@ -34,12 +34,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.util.ArrayList;
import java.util.List;
@ -70,7 +70,7 @@ public class ApiQualityController extends Handler {
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}, new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
}, PageRequest.of(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
return new ResponseEntity<>(new RestResult(RestResultType.OK, page), HttpStatus.OK);
}
}

View File

@ -36,8 +36,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.util.Date;
/**

View File

@ -41,8 +41,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.util.Date;
/**

View File

@ -41,7 +41,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
/**
* 标签
@ -70,7 +70,7 @@ public class ApiTagsController extends Handler {
tagType = j.get("tagtype").getAsString();
Page<Tag> records = tagRes.findByTagtype(tagType,
new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
PageRequest.of(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
JsonArray ja = new JsonArray();

View File

@ -16,12 +16,13 @@
*/
package com.cskefu.cc.controller.api;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import com.cskefu.cc.cache.Cache;
import com.cskefu.cc.basic.Constants;
@ -54,6 +55,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -100,17 +102,16 @@ public class ApiUserController extends Handler {
public ResponseEntity<RestResult> list(HttpServletRequest request, @Valid String id, @Valid String username) {
Page<User> userList = null;
if (StringUtils.isNotBlank(id)) {
userList = userRes.findById(
id, new PageRequest(super.getP(request), super.getPs(request)));
userList = userRes.findByIdIn(Collections.singleton(id), PageRequest.of(super.getP(request), super.getPs(request)));
} else {
if (StringUtils.isNotBlank(username)) {
userList = userRes.findByDatastatusAndUsernameLike(
false, username, new PageRequest(
false, username, PageRequest.of(
super.getP(request),
super.getPs(request)));
} else {
userList = userRes.findByDatastatus(
false, new PageRequest(super.getP(request), super.getPs(request)));
false, PageRequest.of(super.getP(request), super.getPs(request)));
}
}
return new ResponseEntity<>(new RestResult(RestResultType.OK, userList), HttpStatus.OK);
@ -173,7 +174,7 @@ public class ApiUserController extends Handler {
String parent = payload.get("parent").getAsString();
Organ parentOrgan = super.getOrgan(request);
if (StringUtils.isNotEmpty(parent)) {
parentOrgan = organRes.getOne(parent);
parentOrgan = organRes.getReferenceById(parent);
}
String roleId = payload.get("role").getAsString();
@ -185,7 +186,7 @@ public class ApiUserController extends Handler {
JsonObject resp = userProxy.createNewUser(user, parentOrgan);
if (StringUtils.isNotEmpty(roleId)) {
Role role = roleRes.getOne(roleId);
Role role = roleRes.getReferenceById(roleId);
UserRole userRole = new UserRole();
userRole.setUser(user);
userRole.setRole(role);
@ -215,7 +216,7 @@ public class ApiUserController extends Handler {
return resp;
}
final User previous = userRes.findById(updated.getId());
final User previous = userRes.getReferenceById(updated.getId());
if (previous != null) {
String msg = userProxy.validUserUpdate(updated, previous);
if (StringUtils.equals(msg, "edit_user_success")) {
@ -286,7 +287,7 @@ public class ApiUserController extends Handler {
if (payload.has("organ")) {
List<OrganUser> organUsers = organUserRes.findByOrgan(payload.get("organ").getAsString());
List<String> userids = organUsers.stream().map(OrganUser::getUserid).collect(Collectors.toList());
List<User> users = userRes.findAll(userids);
List<User> users = userRes.findAllById(userids);
JsonArray data = new JsonArray();
users.stream().forEach(u -> {
@ -319,7 +320,7 @@ public class ApiUserController extends Handler {
if (payload.has("id")) {
String id = payload.get("id").getAsString();
if (StringUtils.isNotBlank(id)) {
User user = userRes.findById(id);
User user = userRes.getReferenceById(id);
if (user == null) {
// 用户不存在
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
@ -331,10 +332,10 @@ public class ApiUserController extends Handler {
if (!user.isSuperadmin()) {
// 删除用户的时候同时删除用户对应的权限
List<UserRole> userRoles = userRoleRes.findByUser(user);
userRoleRes.delete(userRoles);
userRoleRes.deleteAll(userRoles);
// 删除用户对应的组织机构关系
List<OrganUser> organUsers = organUserRes.findByUserid(id);
organUserRes.delete(organUsers);
organUserRes.deleteAll(organUsers);
// 删除用户
userRes.delete(user);
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);

View File

@ -30,8 +30,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
/**
* 在线客服

View File

@ -30,8 +30,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
/**
* 标签功能

View File

@ -49,9 +49,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
@ -113,7 +113,7 @@ public class AccountController extends Handler {
map.addAttribute("entCustomerList", accountRes.findByOrganInAndSharesAllAndDatastatusFalse(
super.getMyCurrentAffiliatesFlat(logined),
new PageRequest(super.getP(request), super.getPs(request))));
PageRequest.of(super.getP(request), super.getPs(request))));
return request(super.createView("/apps/customer/index"));
}
@ -138,7 +138,7 @@ public class AccountController extends Handler {
map.addAttribute("entCustomerList", accountRes.findByCreaterAndSharesAndDatastatus(super.getUser(request).getId(),
super.getUser(request).getId(),
false,
new PageRequest(super.getP(request), super.getPs(request))));
PageRequest.of(super.getP(request), super.getPs(request))));
return request(super.createView("/apps/customer/index"));
}
@ -164,7 +164,7 @@ public class AccountController extends Handler {
map.addAttribute("entCustomerList", accountRes.findByCreaterAndSharesAndDatastatus(super.getUser(request).getId(), super.getUser(request).getId(),
false,
new PageRequest(super.getP(request), super.getPs(request))));
PageRequest.of(super.getP(request), super.getPs(request))));
return request(super.createView("/apps/customer/index"));
}
@ -190,7 +190,7 @@ public class AccountController extends Handler {
map.addAttribute("entCustomerList", accountRes.findByCreaterAndSharesAndDatastatus(super.getUser(request).getId(),
super.getUser(request).getId(),
false,
new PageRequest(super.getP(request), super.getPs(request))));
PageRequest.of(super.getP(request), super.getPs(request))));
return request(super.createView("/apps/customer/index"));
}
@ -215,7 +215,7 @@ public class AccountController extends Handler {
map.addAttribute("entCustomerList", accountRes.findByCreaterAndSharesAndDatastatus(super.getUser(request).getId(),
super.getUser(request).getId(),
false,
new PageRequest(super.getP(request), super.getPs(request))));
PageRequest.of(super.getP(request), super.getPs(request))));
return request(super.createView("/apps/customer/index"));
}
@ -238,7 +238,7 @@ public class AccountController extends Handler {
map.put("q", q);
}
map.addAttribute("entCustomerList", accountRes.findByCreaterAndSharesAndDatastatus(super.getUser(request).getId(), super.getUser(request).getId(), false, new PageRequest(super.getP(request), super.getPs(request))));
map.addAttribute("entCustomerList", accountRes.findByCreaterAndSharesAndDatastatus(super.getUser(request).getId(), super.getUser(request).getId(), false, PageRequest.of(super.getP(request), super.getPs(request))));
return request(super.createView("/apps/customer/index"));
}
@ -285,7 +285,7 @@ public class AccountController extends Handler {
@Menu(type = "customer", subtype = "customer")
public ModelAndView delete(HttpServletRequest request, @Valid Account account, @Valid String p, @Valid String ekind) {
if (account != null) {
account = accountRes.findOne(account.getId());
account = accountRes.getReferenceById(account.getId());
account.setDatastatus(true); //客户和联系人都是 逻辑删除
accountRes.save(account);
}
@ -295,7 +295,7 @@ public class AccountController extends Handler {
@RequestMapping("/edit")
@Menu(type = "customer", subtype = "customer")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String ekind) {
map.addAttribute("entCustomer", accountRes.findOne(id));
map.addAttribute("entCustomer", accountRes.getReferenceById(id));
map.addAttribute("ekindId", ekind);
return request(super.createView("/apps/customer/edit"));
}
@ -304,7 +304,7 @@ public class AccountController extends Handler {
@Menu(type = "customer", subtype = "customer")
public ModelAndView update(HttpServletRequest request, @Valid CustomerGroupForm customerGroupForm, @Valid String ekindId) {
final User logined = super.getUser(request);
Account customer = accountRes.findOne(customerGroupForm.getEntcustomer().getId());
Account customer = accountRes.getReferenceById(customerGroupForm.getEntcustomer().getId());
String msg = "";
List<PropertiesEvent> events = PropertiesEventUtil.processPropertiesModify(request, customerGroupForm.getEntcustomer(), customer, "id", "creater", "createtime", "updatetime"); //记录 数据变更 历史
@ -372,7 +372,7 @@ public class AccountController extends Handler {
@Menu(type = "customer", subtype = "customer")
public void expids(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String[] ids) throws IOException {
if (ids != null && ids.length > 0) {
Iterable<Account> entCustomerList = accountRes.findAll(Arrays.asList(ids));
Iterable<Account> entCustomerList = accountRes.findAllById(Arrays.asList(ids));
MetadataTable table = metadataRes.findByTablename("uk_entcustomer");
List<Map<String, Object>> values = new ArrayList<>();
for (Account customer : entCustomerList) {
@ -403,7 +403,7 @@ public class AccountController extends Handler {
map.put("ekind", ekind);
}
Iterable<Account> entCustomerList = accountRes.findByCreaterAndSharesAndDatastatus(super.getUser(request).getId(), super.getUser(request).getId(), false, new PageRequest(super.getP(request), super.getPs(request)));
Iterable<Account> entCustomerList = accountRes.findByCreaterAndSharesAndDatastatus(super.getUser(request).getId(), super.getUser(request).getId(), false, PageRequest.of(super.getP(request), super.getPs(request)));
MetadataTable table = metadataRes.findByTablename("uk_entcustomer");
List<Map<String, Object>> values = new ArrayList<>();
@ -441,7 +441,7 @@ public class AccountController extends Handler {
super.getUser(request).getId(),
false,
new PageRequest(super.getP(request), super.getPs(request)));
PageRequest.of(super.getP(request), super.getPs(request)));
MetadataTable table = metadataRes.findByTablename("uk_entcustomer");
List<Map<String, Object>> values = new ArrayList<>();
for (Account customer : entCustomerList) {

View File

@ -36,6 +36,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
@ -43,8 +44,8 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
@ -100,6 +101,7 @@ public class AgentAuditController extends Handler {
private Cache cache;
@Autowired
@Lazy
private PeerSyncIM peerSyncIM;
@Autowired
@ -149,14 +151,14 @@ public class AgentAuditController extends Handler {
criterias.add(new Sort.Order(Sort.Direction.DESC, "status"));
criterias.add(new Sort.Order(Sort.Direction.DESC, "createtime"));
} else if (sort.equals("default")) {
defaultSort = new Sort(Sort.Direction.DESC, "status");
defaultSort = Sort.by(Sort.Direction.DESC, "status");
}
if (criterias.size() > 0) {
defaultSort = new Sort(criterias);
defaultSort = Sort.by(criterias);
map.addAttribute("sort", sort);
}
} else {
defaultSort = new Sort(Sort.Direction.DESC, "status");
defaultSort = Sort.by(Sort.Direction.DESC, "status");
}
// 坐席对话列表
@ -211,7 +213,7 @@ public class AgentAuditController extends Handler {
final User logined = super.getUser(request);
Sort defaultSort = new Sort(Sort.Direction.DESC, "status");
Sort defaultSort = Sort.by(Sort.Direction.DESC, "status");
// 坐席对话列表
List<AgentUser> agentUsers;
@ -241,7 +243,7 @@ public class AgentAuditController extends Handler {
public ModelAndView agentusers(HttpServletRequest request, String userid) {
ModelAndView view = request(super.createView("/apps/cca/agentusers"));
User logined = super.getUser(request);
Sort defaultSort = new Sort(Sort.Direction.DESC, "status");
Sort defaultSort = Sort.by(Sort.Direction.DESC, "status");
view.addObject(
"agentUserList", agentUserRes.findByStatusAndAgentnoIsNot(
MainContext.AgentUserStatusEnum.INSERVICE.toString(), logined.getId(), defaultSort));
@ -266,7 +268,7 @@ public class AgentAuditController extends Handler {
}
ModelAndView view = request(super.createView(mainagentuser));
final User logined = super.getUser(request);
AgentUser agentUser = agentUserRepository.findById(id);
AgentUser agentUser = agentUserRepository.getReferenceById(id);
if (agentUser != null) {
view.addObject("curagentuser", agentUser);
@ -277,12 +279,10 @@ public class AgentAuditController extends Handler {
}
view.addObject("inviteData", OnlineUserProxy.consult(agentUser.getAppid()));
List<AgentUserTask> agentUserTaskList = agentUserTaskRes.findById(id);
if (agentUserTaskList.size() > 0) {
AgentUserTask agentUserTask = agentUserTaskList.get(0);
agentUserTask.setTokenum(0);
agentUserTaskRes.save(agentUserTask);
}
AgentUserTask agentUserTask = agentUserTaskRes.getReferenceById(id);
agentUserTask.setTokenum(0);
agentUserTaskRes.save(agentUserTask);
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
List<AgentServiceSummary> summarizes = this.serviceSummaryRes.findByAgentserviceid(
@ -295,14 +295,12 @@ public class AgentAuditController extends Handler {
view.addObject(
"agentUserMessageList",
this.chatMessageRepository.findByUsession(agentUser.getUserid(),
new PageRequest(0, 20, Sort.Direction.DESC,
"updatetime"
)
PageRequest.of(0, 20, Sort.Direction.DESC,"updatetime")
)
);
AgentService agentService = null;
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
agentService = this.agentServiceRes.findOne(agentUser.getAgentserviceid());
agentService = this.agentServiceRes.getReferenceById(agentUser.getAgentserviceid());
view.addObject("curAgentService", agentService);
if (agentService != null) {
/**
@ -312,7 +310,7 @@ public class AgentAuditController extends Handler {
}
}
if (MainContext.ChannelType.WEBIM.toString().equals(agentUser.getChanneltype())) {
PassportWebIMUser passportWebIMUser = onlineUserRes.findOne(agentUser.getUserid());
PassportWebIMUser passportWebIMUser = onlineUserRes.getReferenceById(agentUser.getUserid());
if (passportWebIMUser != null) {
if (passportWebIMUser.getLogintime() != null) {
if (MainContext.OnlineUserStatusEnum.OFFLINE.toString().equals(passportWebIMUser.getStatus())) {
@ -333,7 +331,7 @@ public class AgentAuditController extends Handler {
.toString()));
view.addObject("tagRelationList", tagRelationRes.findByUserid(agentUser.getUserid()));
AgentService service = agentServiceRes.findById(agentUser.getAgentserviceid());
AgentService service = agentServiceRes.getReferenceById(agentUser.getAgentserviceid());
if (service != null) {
view.addObject("tags", tagRes.findByTagtypeAndSkill(MainContext.ModelType.USER.toString(), service.getSkill()));
}
@ -370,7 +368,7 @@ public class AgentAuditController extends Handler {
List<Organ> skillGroups = organRes.findByIdInAndSkill(ownOrgans.keySet(), true);
// 选择当前用户的默认技能组
AgentService agentService = agentServiceRes.findById(agentserviceid);
AgentService agentService = agentServiceRes.getReferenceById(agentserviceid);
String currentOrgan = agentService.getSkill();
@ -390,7 +388,7 @@ public class AgentAuditController extends Handler {
}
}
final List<User> userList = userRes.findAll(userids);
final List<User> userList = userRes.findAllById(userids);
for (final User o : userList) {
o.setAgentStatus(agentStatusMap.get(o.getId()));
// find user's skills
@ -403,7 +401,7 @@ public class AgentAuditController extends Handler {
map.addAttribute("agentuserid", agentuserid);
map.addAttribute("agentno", agentnoid);
map.addAttribute("skillGroups", skillGroups);
map.addAttribute("agentservice", this.agentServiceRes.findById(agentserviceid));
map.addAttribute("agentservice", this.agentServiceRes.getReferenceById(agentserviceid));
map.addAttribute("currentorgan", currentOrgan);
}
@ -438,7 +436,7 @@ public class AgentAuditController extends Handler {
}
}
final List<User> userList = userRes.findAll(userids);
final List<User> userList = userRes.findAllById(userids);
for (final User o : userList) {
o.setAgentStatus(agentStatusMap.get(o.getId()));
// find user's skills
@ -478,8 +476,8 @@ public class AgentAuditController extends Handler {
if (StringUtils.isNotBlank(userid) &&
StringUtils.isNotBlank(agentuserid) &&
StringUtils.isNotBlank(agentno)) {
final User targetAgent = userRes.findOne(agentno);
final AgentService agentService = agentServiceRes.findById(agentserviceid);
final User targetAgent = userRes.getReferenceById(agentno);
final AgentService agentService = agentServiceRes.getReferenceById(agentserviceid);
/**
* 更新AgentUser
*/
@ -577,7 +575,7 @@ public class AgentAuditController extends Handler {
public ModelAndView end(HttpServletRequest request, @Valid String id) {
final User logined = super.getUser(request);
final AgentUser agentUser = agentUserRes.findById(id);
final AgentUser agentUser = agentUserRes.getReferenceById(id);
if (agentUser != null) {
if ((StringUtils.equals(
@ -604,7 +602,7 @@ public class AgentAuditController extends Handler {
map.addAttribute("agentuserid", agentuserid);
map.addAttribute("agentserviceid", agentserviceid);
map.addAttribute("userid", userid);
map.addAttribute("agentUser", agentUserRes.findById(userid));
map.addAttribute("agentUser", agentUserRes.getReferenceById(userid));
return request(super.createView("/apps/cca/blacklistadd"));
}

View File

@ -43,6 +43,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
@ -59,9 +60,9 @@
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
@ -156,6 +157,7 @@
private String webUploadPath;
@Autowired
@Lazy
private PeerSyncIM peerSyncIM;
@Autowired
@ -259,7 +261,7 @@
User logined = super.getUser(request);
view.addObject(
"agentUserList", agentUserRes.findByAgentno(logined.getId(),
new Sort(Direction.DESC, "status")));
Sort.by(Direction.DESC, "status")));
List<AgentUser> agentUserList = agentUserRes.findByUserid(userid);
view.addObject(
"curagentuser", agentUserList != null && agentUserList.size() > 0 ? agentUserList.get(0) : null);
@ -277,7 +279,7 @@
Integer current) throws IOException {
String mainagentuserconter = "/apps/agent/mainagentuserconter";
ModelAndView view = request(super.createView(mainagentuserconter));
AgentUser agentUser = agentUserRes.findById(id);
AgentUser agentUser = agentUserRes.getReferenceById(id);
if (agentUser != null) {
view.addObject("curagentuser", agentUser);
view.addObject(
@ -294,7 +296,7 @@
String iconid) throws IOException {
String mainagentuserconter = "/apps/agent/mainagentuserconter";
ModelAndView view = request(super.createView(mainagentuserconter));
ChatMessage labelid = this.chatMessageRes.findById(iconid);
ChatMessage labelid = this.chatMessageRes.getReferenceById(iconid);
if (labelid != null) {
if (labelid.isIslabel() == false) {
labelid.setIslabel(true);
@ -317,16 +319,16 @@
) throws IOException {
String mainagentuserconter = "/apps/agent/mainagentusersearch";
ModelAndView view = request(super.createView(mainagentuserconter));
AgentUser agentUser = agentUserRes.findById(id);
AgentUser agentUser = agentUserRes.getReferenceById(id);
if (agentUser != null) {
Page<ChatMessage> agentUserMessageList = null;
if (condition.equals("label")) {
agentUserMessageList = this.chatMessageRes.findByislabel(
agentUser.getUserid(), search, new PageRequest(0, 9999, Direction.DESC, "updatetime"));
agentUser.getUserid(), search, PageRequest.of(0, 9999, Direction.DESC, "updatetime"));
} else {
agentUserMessageList = this.chatMessageRes.findByUsessionAndMessageContaining(
agentUser.getUserid(), search, new PageRequest(0, 9999, Direction.DESC, "updatetime"));
agentUser.getUserid(), search, PageRequest.of(0, 9999, Direction.DESC, "updatetime"));
}
view.addObject("agentUserMessageList", agentUserMessageList);
}
@ -344,7 +346,7 @@
String thisid) throws IOException, ParseException {
String mainagentuserconter = "/apps/agent/mainagentuserconter";
ModelAndView view = request(super.createView(mainagentuserconter));
AgentUser agentUser = agentUserRes.findById(id);
AgentUser agentUser = agentUserRes.getReferenceById(id);
if (agentUser != null) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = formatter.parse(createtime);
@ -381,7 +383,7 @@
ModelAndView view = request(super.createView(mainagentuser));
final User logined = super.getUser(request);
AgentUser agentUser = agentUserRes.findById(id);
AgentUser agentUser = agentUserRes.getReferenceById(id);
if (agentUser != null) {
view.addObject("curagentuser", agentUser);
@ -392,12 +394,9 @@
}
view.addObject("inviteData", OnlineUserProxy.consult(agentUser.getAppid()));
List<AgentUserTask> agentUserTaskList = agentUserTaskRes.findById(id);
if (agentUserTaskList.size() > 0) {
AgentUserTask agentUserTask = agentUserTaskList.get(0);
agentUserTask.setTokenum(0);
agentUserTaskRes.save(agentUserTask);
}
AgentUserTask agentUserTask = agentUserTaskRes.getReferenceById(id);
agentUserTask.setTokenum(0);
agentUserTaskRes.save(agentUserTask);
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
List<AgentServiceSummary> summarizes = this.serviceSummaryRes.findByAgentserviceid(
@ -410,11 +409,11 @@
view.addObject(
"agentUserMessageList",
this.chatMessageRes.findByUsession(agentUser.getUserid(),
new PageRequest(0, 20, Direction.DESC,
PageRequest.of(0, 20, Direction.DESC,
"updatetime")));
AgentService agentService = null;
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
agentService = this.agentServiceRes.findOne(agentUser.getAgentserviceid());
agentService = this.agentServiceRes.getReferenceById(agentUser.getAgentserviceid());
view.addObject("curAgentService", agentService);
if (agentService != null) {
/**
@ -430,7 +429,7 @@
view.addObject("weiXinUser", passportWechatUser);
}
} else if (MainContext.ChannelType.WEBIM.toString().equals(agentUser.getChanneltype())) {
PassportWebIMUser passportWebIMUser = onlineUserRes.findOne(agentUser.getUserid());
PassportWebIMUser passportWebIMUser = onlineUserRes.getReferenceById(agentUser.getUserid());
if (passportWebIMUser != null) {
if (passportWebIMUser.getLogintime() != null) {
if (MainContext.OnlineUserStatusEnum.OFFLINE.toString().equals(passportWebIMUser.getStatus())) {
@ -445,12 +444,10 @@
}
} else if (MainContext.ChannelType.PHONE.toString().equals(agentUser.getChanneltype())) {
if (agentService != null && StringUtils.isNotBlank(agentService.getOwner())) {
StatusEvent statusEvent = this.statusEventRes.findById(agentService.getOwner());
StatusEvent statusEvent = this.statusEventRes.getReferenceById(agentService.getOwner());
if (statusEvent != null) {
if (StringUtils.isNotBlank(statusEvent.getHostid())) {
pbxHostRes.findById(statusEvent.getHostid()).ifPresent(p -> {
view.addObject("pbxHost", p);
});
view.addObject("pbxHost", pbxHostRes.getReferenceById(statusEvent.getHostid()));
}
view.addObject("statusEvent", statusEvent);
}
@ -465,7 +462,7 @@
view.addObject("tagRelationList", tagRelationRes.findByUserid(agentUser.getUserid()));
}
AgentService service = agentServiceRes.findById(agentUser.getAgentserviceid());
AgentService service = agentServiceRes.getReferenceById(agentUser.getAgentserviceid());
if (service != null) {
view.addObject("tags", tagRes.findByTagtypeAndSkill(MainContext.ModelType.USER.toString(), service.getSkill()));
}
@ -641,14 +638,14 @@
for (AgentUser agentUser : agentUserList) {
if (agentUser != null && super.getUser(request).getId().equals(agentUser.getAgentno())) {
acdAgentService.finishAgentUser(agentUser);
AgentService agentService = agentServiceRes.findById(agentUser.getAgentserviceid());
AgentService agentService = agentServiceRes.getReferenceById(agentUser.getAgentserviceid());
if (agentService != null) {
agentService.setStatus(MainContext.AgentUserStatusEnum.END.toString());
agentServiceList.add(agentService);
}
}
}
agentServiceRes.save(agentServiceList);
agentServiceRes.saveAll(agentServiceList);
return request(super
.createView("redirect:/agent/index.html"));
}
@ -669,7 +666,7 @@
logger.info("[end] end id {}", id);
final User logined = super.getUser(request);
final AgentUser agentUser = agentUserRes.findById(id);
final AgentUser agentUser = agentUserRes.getReferenceById(id);
if (agentUser != null) {
if ((StringUtils.equals(
@ -693,12 +690,10 @@
@RequestMapping({"/readmsg"})
@Menu(type = "apps", subtype = "agent")
public ModelAndView readmsg(HttpServletRequest request, @Valid String userid) {
List<AgentUserTask> agentUserTaskList = agentUserTaskRes.findById(userid);
if (agentUserTaskList.size() > 0) {
AgentUserTask agentUserTask = agentUserTaskList.get(0);
agentUserTask.setTokenum(0);
agentUserTaskRes.save(agentUserTask);
}
AgentUserTask agentUserTask = agentUserTaskRes.getReferenceById(userid);
agentUserTask.setTokenum(0);
agentUserTaskRes.save(agentUserTask);
return request(super.createView("/public/success"));
}
@ -709,7 +704,7 @@
map.addAttribute("agentuserid", agentuserid);
map.addAttribute("agentserviceid", agentserviceid);
map.addAttribute("userid", userid);
map.addAttribute("agentUser", agentUserRes.findById(userid));
map.addAttribute("agentUser", agentUserRes.getReferenceById(userid));
return request(super.createView("/apps/agent/blacklistadd"));
}
@ -788,7 +783,7 @@
JSONObject result = new JSONObject();
HttpHeaders headers = RestUtils.header();
final AgentUser agentUser = agentUserRes.findById(id);
final AgentUser agentUser = agentUserRes.getReferenceById(id);
if (multipart != null && multipart.getOriginalFilename().lastIndexOf(".") > 0) {
try {
@ -813,7 +808,7 @@
@RequestMapping("/message/image")
@Menu(type = "resouce", subtype = "image", access = true)
public ModelAndView messageimage(HttpServletResponse response, ModelMap map, @Valid String id, @Valid String t) throws IOException {
ChatMessage message = chatMessageRes.findById(id);
ChatMessage message = chatMessageRes.getReferenceById(id);
map.addAttribute("chatMessage", message);
map.addAttribute("agentUser", cache.findOneAgentUserByUserId(message.getUserid()));
/*if(StringUtils.isNotBlank(t)){
@ -842,7 +837,7 @@
}
// 写入临时文件
FileCopyUtils.copy(image.getBytes(), tempFile);
ChatMessage chatMessage = chatMessageRes.findById(id);
ChatMessage chatMessage = chatMessageRes.getReferenceById(id);
chatMessage.setCooperation(true);
chatMessageRes.save(chatMessage);
@ -852,7 +847,7 @@
MainUtils.scaleImage(imageFile, tempFile, 0.1F);
// 保存到数据库
StreamingFile sf = streamingFileRes.findOne(fileid);
StreamingFile sf = streamingFileRes.getReferenceById(fileid);
if (sf != null) {
sf.setCooperation(jpaBlobHelper.createBlobWithFile(imageFile));
streamingFileRes.save(sf);
@ -920,7 +915,7 @@
/**
* 获得联系人
*/
Contacts contacts = contactsRes.findOne(contactsid);
Contacts contacts = contactsRes.getReferenceById(contactsid);
if (contacts != null) {
map.addAttribute("contacts", contacts);
}
@ -928,7 +923,7 @@
/**
* 在关联联系人后更新AgentUser的显示的名字
*/
AgentUser agentUser = agentUserRes.findById(agentuserid);
AgentUser agentUser = agentUserRes.getReferenceById(agentuserid);
if (agentUser != null) {
agentUser.setUsername(contacts.getName());
agentUser.setNickname(contacts.getName());
@ -946,7 +941,7 @@
onlineUserRes.save(passportWebIMUser);
}
AgentService agentService = agentServiceRes.findOne(agentserviceid);
AgentService agentService = agentServiceRes.getReferenceById(agentserviceid);
if (agentService != null) {
agentService.setContactsid(contactsid);
agentService.setUsername(contacts.getName());
@ -978,7 +973,7 @@
public ModelAndView cleanAssociated(ModelMap map, HttpServletRequest request, final @RequestParam String currentAgentUserContactsId) {
String contactsid = null;
if (StringUtils.isNotEmpty(currentAgentUserContactsId)) {
AgentUserContacts agentUserContacts = agentUserContactsRes.getOne(currentAgentUserContactsId);
AgentUserContacts agentUserContacts = agentUserContactsRes.getReferenceById(currentAgentUserContactsId);
if (agentUserContacts != null) {
agentUserContactsRes.delete(agentUserContacts);
}
@ -991,7 +986,7 @@
@RequestMapping(value = "/evaluation")
@Menu(type = "apps", subtype = "evaluation")
public String evaluation(HttpServletRequest request, @Valid String agentuserid) {
AgentUser agentUser = agentUserRes.findById(agentuserid);
AgentUser agentUser = agentUserRes.getReferenceById(agentuserid);
Message outMessage = new Message();
outMessage.setChannelMessage(agentUser);
@ -1019,7 +1014,7 @@
@Valid String agentuserid,
@Valid String channel) {
if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid)) {
AgentUser agentUser = this.agentUserRes.findById(agentuserid);
AgentUser agentUser = this.agentUserRes.getReferenceById(agentuserid);
if (agentUser != null && StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
List<AgentServiceSummary> summaries = this.serviceSummaryRes.findByAgentserviceid(
agentUser.getAgentserviceid());
@ -1027,7 +1022,7 @@
map.addAttribute("summary", summaries.get(0));
}
}
AgentService service = agentServiceRes.findById(agentserviceid);
AgentService service = agentServiceRes.getReferenceById(agentserviceid);
if (service != null) {
map.addAttribute(
"tags", tagRes.findByTagtypeAndSkill(
@ -1055,7 +1050,7 @@
if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid)) {
summary.setCreater(super.getUser(request).getId());
summary.setCreatetime(new Date());
AgentService service = agentServiceRes.findById(agentserviceid);
AgentService service = agentServiceRes.getReferenceById(agentserviceid);
summary.setAgent(service.getAgentno());
summary.setAgentno(service.getAgentno());
summary.setSkill(service.getSkill());
@ -1103,7 +1098,7 @@
List<Organ> skillGroups = organRes.findByIdInAndSkill(ownOrgans.keySet(), true);
// 选择当前用户的默认技能组
AgentService agentService = agentServiceRes.findById(agentserviceid);
AgentService agentService = agentServiceRes.getReferenceById(agentserviceid);
String currentOrgan = agentService.getSkill();
@ -1125,7 +1120,7 @@
logger.info("[transfer] get all userids except mine, {}", StringUtils.join(userids, "\t"));
final List<User> userList = userRes.findAll(userids);
final List<User> userList = userRes.findAllById(userids);
for (final User o : userList) {
o.setAgentStatus(agentStatusMap.get(o.getId()));
// find user's skills
@ -1138,7 +1133,7 @@
map.addAttribute("agentuserid", agentuserid);
map.addAttribute("skillGroups", skillGroups);
map.addAttribute("agentno", agentService.getAgentno());
map.addAttribute("agentservice", this.agentServiceRes.findById(agentserviceid));
map.addAttribute("agentservice", this.agentServiceRes.getReferenceById(agentserviceid));
map.addAttribute("currentorgan", currentOrgan);
}
@ -1172,7 +1167,7 @@
}
}
final List<User> userList = userRes.findAll(userids);
final List<User> userList = userRes.findAllById(userids);
for (final User o : userList) {
o.setAgentStatus(agentStatusMap.get(o.getId()));
// find user's skills
@ -1200,7 +1195,7 @@
@RequestParam(value = "agentuser") String agentuser,
@Valid Contacts contacts) throws CSKefuException {
logger.info("[agent ctrl] calloutcontactsave agentuser [{}]", agentuser);
AgentUser au = agentUserRes.findOne(agentuser);
AgentUser au = agentUserRes.getReferenceById(agentuser);
if (au == null) {
throw new CSKefuException("不存在该服务记录");
}
@ -1230,7 +1225,7 @@
@RequestMapping("/calloutcontact/update")
@Menu(type = "apps", subtype = "calloutcontact")
public ModelAndView update(HttpServletRequest request, @Valid Contacts contacts) {
Contacts data = contactsRes.findOne(contacts.getId());
Contacts data = contactsRes.getReferenceById(contacts.getId());
if (data != null) {
List<PropertiesEvent> events = PropertiesEventUtil.processPropertiesModify(
request, contacts, data, "id", "creater", "createtime", "updatetime"); //记录 数据变更 历史

View File

@ -40,8 +40,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.io.IOException;
import java.util.Date;
import java.util.List;
@ -150,7 +150,7 @@ public class AgentSettingsController extends Handler {
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParent(currentOrgan);
Page<BlackEntity> blackList = blackListRes.findBySkillIn(organs.keySet(), new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "endtime"));
Page<BlackEntity> blackList = blackListRes.findBySkillIn(organs.keySet(), PageRequest.of(super.getP(request), super.getPs(request), Sort.Direction.DESC, "endtime"));
map.put("blackList", blackList);
@ -162,7 +162,7 @@ public class AgentSettingsController extends Handler {
@Menu(type = "setting", subtype = "tag")
public ModelAndView blacklistdelete(ModelMap map, HttpServletRequest request, @Valid String id) {
if (!StringUtils.isBlank(id)) {
BlackEntity tempBlackEntity = blackListRes.findById(id);
BlackEntity tempBlackEntity = blackListRes.getReferenceById(id);
if (tempBlackEntity != null) {
blackListRes.delete(tempBlackEntity);
cache.deleteSystembyId(tempBlackEntity.getUserid());
@ -192,7 +192,7 @@ public class AgentSettingsController extends Handler {
map.put("tagType", tagType);
}
if (tagType != null && currentOrgan != null) {
map.put("tagList", tagRes.findByTagtypeAndSkill(tagType.getCode(), currentOrgan.getId(), new PageRequest(super.getP(request), super.getPs(request))));
map.put("tagList", tagRes.findByTagtypeAndSkill(tagType.getCode(), currentOrgan.getId(), PageRequest.of(super.getP(request), super.getPs(request))));
}
map.put("tagTypeList", tagList);
return request(super.createView("/apps/setting/agent/tag"));
@ -208,7 +208,7 @@ public class AgentSettingsController extends Handler {
@RequestMapping("/tag/edit")
@Menu(type = "setting", subtype = "tag")
public ModelAndView tagedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String tagtype) {
map.put("tag", tagRes.findOne(id));
map.put("tag", tagRes.getReferenceById(id));
map.addAttribute("tagtype", tagtype);
return request(super.createView("/apps/setting/agent/tagedit"));
}
@ -247,7 +247,7 @@ public class AgentSettingsController extends Handler {
@RequestMapping("/tag/delete")
@Menu(type = "setting", subtype = "tag")
public ModelAndView tagdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String tagtype) {
tagRes.delete(id);
tagRes.deleteById(id);
return request(super.createView("redirect:/setting/tag.html?code=" + tagtype));
}
@ -324,7 +324,7 @@ public class AgentSettingsController extends Handler {
@Menu(type = "setting", subtype = "adv")
public ModelAndView advedit(ModelMap map, HttpServletRequest request, @Valid String adpos, @Valid String id) {
map.addAttribute("adpos", adpos);
map.put("ad", adTypeRes.findById(id));
map.put("ad", adTypeRes.getReferenceById(id));
return request(super.createView("/apps/setting/agent/adedit"));
}
@ -358,9 +358,9 @@ public class AgentSettingsController extends Handler {
@RequestMapping("/adv/delete")
@Menu(type = "setting", subtype = "adv")
public ModelAndView advdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String adpos) {
AdType adType = adTypeRes.findById(id);
AdType adType = adTypeRes.getReferenceById(id);
if (adType != null) {
adTypeRes.delete(id);
adTypeRes.deleteById(id);
MainUtils.initAdv(adType.getSkill());
}
return request(super.createView("redirect:/setting/adv.html?adpos=" + adpos));

View File

@ -38,8 +38,8 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -96,7 +96,7 @@ public class AppsController extends Handler {
final Page<PassportWebIMUser> onlineUserList = onlineUserRes.findByStatusAndAppidIn(
MainContext.OnlineUserStatusEnum.ONLINE.toString(),
appids,
new PageRequest(
PageRequest.of(
super.getP(request),
super.getPs(request),
Sort.Direction.DESC,
@ -122,7 +122,7 @@ public class AppsController extends Handler {
* 获得在线访客与联系人的关联信息
*/
if (contactIds.size() > 0) {
final Iterable<Contacts> contacts = contactsRes.findAll(contactIds);
final Iterable<Contacts> contacts = contactsRes.findAllById(contactIds);
for (final PassportWebIMUser passportWebIMUser : onlineUserList.getContent()) {
if (StringUtils.isNotBlank(passportWebIMUser.getContactsid())) {
for (final Contacts contact : contacts) {
@ -206,7 +206,7 @@ public class AppsController extends Handler {
@Menu(type = "apps", subtype = "onlineuser")
public ModelAndView onlineuser(ModelMap map, HttpServletRequest request) {
Page<PassportWebIMUser> onlineUserList = this.onlineUserRes.findByStatus(MainContext.OnlineUserStatusEnum.ONLINE.toString(),
new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
PageRequest.of(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
List<String> ids = new ArrayList<>();
for (PassportWebIMUser passportWebIMUser : onlineUserList.getContent()) {
passportWebIMUser.setBetweentime((int) (System.currentTimeMillis() - passportWebIMUser.getLogintime().getTime()));
@ -215,7 +215,7 @@ public class AppsController extends Handler {
}
}
if (ids.size() > 0) {
Iterable<Contacts> contactsList = contactsRes.findAll(ids);
Iterable<Contacts> contactsList = contactsRes.findAllById(ids);
for (PassportWebIMUser passportWebIMUser : onlineUserList.getContent()) {
if (StringUtils.isNotBlank(passportWebIMUser.getContactsid())) {
for (Contacts contacts : contactsList) {
@ -243,7 +243,7 @@ public class AppsController extends Handler {
@RequestMapping({"/apps/profile/save"})
@Menu(type = "apps", subtype = "content")
public ModelAndView profile(ModelMap map, HttpServletRequest request, @Valid User user, @Valid String index) {
User tempUser = userRes.getOne(user.getId());
User tempUser = userRes.getReferenceById(user.getId());
final User logined = super.getUser(request);
// 用户名不可修改
user.setUsername(logined.getUsername());

View File

@ -46,9 +46,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
@ -117,7 +117,7 @@ public class ContactsController extends Handler {
Page<Contacts> contacts = contactsRes.findByOrganInAndSharesAllAndDatastatusFalse(
super.getMyCurrentAffiliatesFlat(logined),
new PageRequest(super.getP(request), super.getPs(request)));
PageRequest.of(super.getP(request), super.getPs(request)));
map.addAttribute("contactsList", contacts);
@ -148,7 +148,7 @@ public class ContactsController extends Handler {
Page<Contacts> contacts = contactsRes.findByCreaterAndSharesAndDatastatus(logined.getId(),
logined.getId(),
false,
new PageRequest(
PageRequest.of(
super.getP(request),
super.getPs(request)));
@ -182,7 +182,7 @@ public class ContactsController extends Handler {
Page<Contacts> contacts = contactsRes.findByCreaterAndSharesAndDatastatus(logined.getId(),
logined.getId(),
false,
new PageRequest(
PageRequest.of(
super.getP(request),
super.getPs(request)));
map.addAttribute(
@ -216,7 +216,7 @@ public class ContactsController extends Handler {
Page<Contacts> contacts = contactsRes.findByCreaterAndSharesAndDatastatus(logined.getId(),
logined.getId(),
false,
new PageRequest(
PageRequest.of(
super.getP(request),
super.getPs(request)));
@ -231,7 +231,7 @@ public class ContactsController extends Handler {
@Menu(type = "contacts", subtype = "contacts")
public ModelAndView delete(HttpServletRequest request, @Valid Contacts contacts, @Valid String p, @Valid String ckind) {
if (contacts != null) {
contacts = contactsRes.findOne(contacts.getId());
contacts = contactsRes.getReferenceById(contacts.getId());
contacts.setDatastatus(true); //客户和联系人都是 逻辑删除
contactsRes.save(contacts);
}
@ -288,7 +288,7 @@ public class ContactsController extends Handler {
@RequestMapping("/edit")
@Menu(type = "contacts", subtype = "contacts")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String ckind) {
map.addAttribute("contacts", contactsRes.findOne(id));
map.addAttribute("contacts", contactsRes.getReferenceById(id));
map.addAttribute("ckindId", ckind);
return request(super.createView("/apps/contacts/edit"));
}
@ -299,7 +299,7 @@ public class ContactsController extends Handler {
if (id == null) {
return null; // id is required. Block strange requst anyway with g2.min, https://github.com/alibaba/BizCharts/issues/143
}
map.addAttribute("contacts", contactsRes.findOne(id));
map.addAttribute("contacts", contactsRes.getReferenceById(id));
return request(super.createView("/apps/contacts/detail"));
@ -344,7 +344,7 @@ public class ContactsController extends Handler {
@Menu(type = "contacts", subtype = "contacts")
public ModelAndView update(HttpServletRequest request, @Valid Contacts contacts, @Valid String ckindId) {
final User logined = super.getUser(request);
Contacts data = contactsRes.findOne(contacts.getId());
Contacts data = contactsRes.getReferenceById(contacts.getId());
String msg = "";
String skypeIDReplace = contactsProxy.sanitizeSkypeId(contacts.getSkypeid());
@ -445,7 +445,7 @@ public class ContactsController extends Handler {
@Menu(type = "contacts", subtype = "contacts")
public void expids(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String[] ids) throws IOException {
if (ids != null && ids.length > 0) {
Iterable<Contacts> contactsList = contactsRes.findAll(Arrays.asList(ids));
Iterable<Contacts> contactsList = contactsRes.findAllById(Arrays.asList(ids));
MetadataTable table = metadataRes.findByTablename("uk_contacts");
List<Map<String, Object>> values = new ArrayList<>();
for (Contacts contacts : contactsList) {
@ -481,7 +481,7 @@ public class ContactsController extends Handler {
}
Iterable<Contacts> contactsList = contactsRes.findByCreaterAndSharesAndDatastatus(
logined.getId(), logined.getId(), false, new PageRequest(super.getP(request), super.getPs(request)));
logined.getId(), logined.getId(), false, PageRequest.of(super.getP(request), super.getPs(request)));
MetadataTable table = metadataRes.findByTablename("uk_contacts");
List<Map<String, Object>> values = new ArrayList<>();
@ -515,7 +515,7 @@ public class ContactsController extends Handler {
}
Iterable<Contacts> contactsList = contactsRes.findByCreaterAndSharesAndDatastatus(
logined.getId(), logined.getId(), false, new PageRequest(super.getP(request), super.getPs(request)));
logined.getId(), logined.getId(), false, PageRequest.of(super.getP(request), super.getPs(request)));
MetadataTable table = metadataRes.findByTablename("uk_contacts");
List<Map<String, Object>> values = new ArrayList<>();
for (Contacts contacts : contactsList) {
@ -552,11 +552,11 @@ public class ContactsController extends Handler {
map.put("ckind", ckind);
}
if (StringUtils.isNotBlank(agentserviceid)) {
AgentService service = agentServiceRes.findById(agentserviceid);
AgentService service = agentServiceRes.getReferenceById(agentserviceid);
}
Page<Contacts> contactsList = contactsRes.findByCreaterAndSharesAndDatastatus(
logined.getId(), logined.getId(), false,
new PageRequest(super.getP(request), super.getPs(request)));
PageRequest.of(super.getP(request), super.getPs(request)));
map.addAttribute("contactsList", contactsList);
@ -593,7 +593,7 @@ public class ContactsController extends Handler {
contacts.setCreater(logined.getId());
if (StringUtils.isNotBlank(agentserviceid)) {
AgentService agentService = agentServiceRes.findOne(agentserviceid);
AgentService agentService = agentServiceRes.getReferenceById(agentserviceid);
contacts.setOrgan(agentService.getSkill());
}
@ -613,7 +613,7 @@ public class ContactsController extends Handler {
@RequestMapping("/embed/edit")
@Menu(type = "contacts", subtype = "embededit")
public ModelAndView embededit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String agentserviceid) {
map.addAttribute("contacts", contactsRes.findOne(id));
map.addAttribute("contacts", contactsRes.getReferenceById(id));
if (StringUtils.isNotBlank(agentserviceid)) {
map.addAttribute("agentserviceid", agentserviceid);
}
@ -624,7 +624,7 @@ public class ContactsController extends Handler {
@Menu(type = "contacts", subtype = "embedupdate")
public ModelAndView embedupdate(HttpServletRequest request, @Valid Contacts contacts, @Valid String agentserviceid) {
final User logined = super.getUser(request);
Contacts data = contactsRes.findOne(contacts.getId());
Contacts data = contactsRes.getReferenceById(contacts.getId());
String msg = "";
String skypeIDReplace = contactsProxy.sanitizeSkypeId(contacts.getSkypeid());
Contacts theOnlyContact = contactsRes.findByskypeidAndDatastatus(

View File

@ -50,9 +50,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.File;
import java.io.IOException;
import java.util.*;
@ -100,7 +100,7 @@ public class EntIMController extends Handler {
Map<String, Organ> organs = new HashMap<>();
user.getOrgans().values().stream().forEach(o -> {
if (!StringUtils.equals(o.getParent(), "0")) {
Organ parent = organRes.findById(o.getParent());
Organ parent = organRes.getReferenceById(o.getParent());
organs.put(parent.getId(), parent);
}
@ -114,7 +114,7 @@ public class EntIMController extends Handler {
user.getAffiliates().stream().forEach(p -> {
if (!organs.containsKey(p)) {
Organ organ = organRes.findById(p);
Organ organ = organRes.getReferenceById(p);
organs.put(p, organ);
}
});
@ -177,7 +177,7 @@ public class EntIMController extends Handler {
@Menu(type = "im", subtype = "entim")
public ModelAndView chat(HttpServletRequest request, HttpServletResponse response, @Valid String userid) {
ModelAndView view = request(super.createView("/apps/entim/chat"));
User entImUser = userRes.findById(userid);
User entImUser = userRes.getReferenceById(userid);
if (entImUser != null) {
userProxy.attachOrgansPropertiesForUser(entImUser);
@ -190,7 +190,7 @@ public class EntIMController extends Handler {
Page<ChatMessage> chatMessageList = chatMessageRes.findByContextidAndUserid(userid,
super.getUser(request).getId(),
new PageRequest(0, 20, Sort.Direction.DESC, "createtime")
PageRequest.of(0, 20, Sort.Direction.DESC, "createtime")
);
view.addObject("chatMessageList", chatMessageList);
@ -233,7 +233,7 @@ public class EntIMController extends Handler {
Page<ChatMessage> chatMessageList = chatMessageRes.findByContextidAndUseridAndCreatetimeLessThan(userid,
super.getUser(request).getId(), createtime,
new PageRequest(0, 20, Sort.Direction.DESC, "createtime")
PageRequest.of(0, 20, Sort.Direction.DESC, "createtime")
);
view.addObject("chatMessageList", chatMessageList);
@ -244,12 +244,12 @@ public class EntIMController extends Handler {
@Menu(type = "im", subtype = "entim")
public ModelAndView groupMore(HttpServletRequest request, HttpServletResponse response, @Valid String id) {
ModelAndView view = request(super.createView("/apps/entim/group/index"));
IMGroup imGroup = imGroupRes.findById(id);
IMGroup imGroup = imGroupRes.getReferenceById(id);
view.addObject("imGroup", imGroup);
view.addObject("imGroupUserList", imGroupUserRes.findByImgroup(imGroup));
view.addObject("contextid", id);
view.addObject("chatMessageList", chatMessageRes.findByContextid(id,
new PageRequest(0, 20, Sort.Direction.DESC, "createtime")
PageRequest.of(0, 20, Sort.Direction.DESC, "createtime")
));
return view;
}
@ -262,7 +262,7 @@ public class EntIMController extends Handler {
) {
ModelAndView view = request(super.createView("/apps/entim/group/more"));
view.addObject("chatMessageList", chatMessageRes.findByContextidAndCreatetimeLessThan(id,
createtime, new PageRequest(0, 20, Sort.Direction.DESC, "createtime")
createtime, PageRequest.of(0, 20, Sort.Direction.DESC, "createtime")
));
return view;
}
@ -278,8 +278,8 @@ public class EntIMController extends Handler {
users.stream().forEach(u -> userProxy.attachOrgansPropertiesForUser(u));
view.addObject("userList", users);
IMGroup imGroup = imGroupRes.findById(id);
List<Organ> organs = organRes.findAll(affiliates);
IMGroup imGroup = imGroupRes.getReferenceById(id);
List<Organ> organs = organRes.findAllById(affiliates);
view.addObject("imGroup", imGroup);
view.addObject("organList", organs);
@ -331,7 +331,7 @@ public class EntIMController extends Handler {
@Valid String tipmsg
) {
ModelAndView view = request(super.createView("/apps/entim/group/tipmsg"));
IMGroup imGroup = imGroupRes.findById(id);
IMGroup imGroup = imGroupRes.getReferenceById(id);
if (imGroup != null) {
imGroup.setTipmessage(tipmsg);
imGroupRes.save(imGroup);

View File

@ -55,11 +55,11 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import javax.annotation.PostConstruct;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import jakarta.annotation.PostConstruct;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.File;
import java.io.IOException;
import java.net.URLDecoder;
@ -435,7 +435,7 @@ public class IMController extends Handler {
sessionMessage.put("uid", uid);
cache.putSystemMapById(sessionid, sessionMessage);
PassportWebIMUser passportWebIMUser = onlineUserRes.findOne(userid);
PassportWebIMUser passportWebIMUser = onlineUserRes.getReferenceById(userid);
String updateusername;
if (passportWebIMUser != null) {
updateusername = username + "@" + company_name;
@ -860,7 +860,7 @@ public class IMController extends Handler {
agentUserRepository.findOneByUserid(userid).ifPresent(p -> {
// 关联AgentService的联系人
if (StringUtils.isNotBlank(p.getAgentserviceid())) {
AgentService agentService = agentServiceRepository.findOne(
AgentService agentService = agentServiceRepository.getReferenceById(
p.getAgentserviceid());
agentService.setContactsid(contacts1.getId());
}
@ -920,7 +920,7 @@ public class IMController extends Handler {
// 是否使用机器人客服
if (invite.isAi() && MainContext.hasModule(Constants.CSKEFU_MODULE_CHATBOT)) {
// 查找机器人
bot = chatbotRes.findOne(invite.getAiid());
bot = chatbotRes.getReferenceById(invite.getAiid());
if (bot != null) {
// 判断是否接受访客切换坐席类型
isEnableExchangeAgentType = !StringUtils.equals(
@ -965,7 +965,7 @@ public class IMController extends Handler {
}
map.addAttribute(
"chatMessageList", chatMessageRes.findByUsession(userid, new PageRequest(0, 20,
"chatMessageList", chatMessageRes.findByUsession(userid, PageRequest.of(0, 20,
Direction.DESC,
"updatetime")));
}
@ -1003,7 +1003,7 @@ public class IMController extends Handler {
Page<InviteRecord> inviteRecords = inviteRecordRes.findByUseridAndResultAndCreatetimeGreaterThan(
userid,
MainContext.OnlineUserInviteStatus.DEFAULT.toString(),
threshold, new PageRequest(0, 1, Direction.DESC, "createtime"));
threshold, PageRequest.of(0, 1, Direction.DESC, "createtime"));
if (inviteRecords.getContent() != null && inviteRecords.getContent().size() > 0) {
final InviteRecord record = inviteRecords.getContent().get(0);
record.setUpdatetime(new Date());
@ -1249,7 +1249,7 @@ public class IMController extends Handler {
userid,
MainContext.OnlineUserInviteStatus.DEFAULT.toString(),
threshold,
new PageRequest(
PageRequest.of(
0,
1,
Direction.DESC,

View File

@ -24,7 +24,7 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
@Controller
@RequestMapping("/message")

View File

@ -39,10 +39,10 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.persistence.criteria.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import jakarta.persistence.criteria.*;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -105,7 +105,7 @@ public class AgentSummaryController extends Handler {
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}, new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
}, PageRequest.of(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
map.addAttribute("summaryList", page);
map.addAttribute("begin", begin);
map.addAttribute("end", end);
@ -118,14 +118,14 @@ public class AgentSummaryController extends Handler {
@RequestMapping(value = "/process")
@Menu(type = "agent", subtype = "agentsummary")
public ModelAndView process(ModelMap map, HttpServletRequest request, @Valid final String id) {
AgentServiceSummary summary = serviceSummaryRes.findById(id);
AgentServiceSummary summary = serviceSummaryRes.getReferenceById(id);
map.addAttribute("summary", summary);
map.put("summaryTags", tagRes.findByTagtype(MainContext.ModelType.SUMMARY.toString()));
if (summary != null && !StringUtils.isBlank(summary.getAgentserviceid())) {
AgentService service = agentServiceRes.findById(summary.getAgentserviceid());
AgentService service = agentServiceRes.getReferenceById(summary.getAgentserviceid());
map.addAttribute("service", service);
if (!StringUtils.isBlank(summary.getContactsid())) {
Contacts contacts = contactsRes.findOne(summary.getContactsid());
Contacts contacts = contactsRes.getReferenceById(summary.getContactsid());
map.addAttribute("contacts", contacts);
}
}
@ -136,7 +136,7 @@ public class AgentSummaryController extends Handler {
@RequestMapping(value = "/save")
@Menu(type = "agent", subtype = "agentsummary")
public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid final AgentServiceSummary summary) {
AgentServiceSummary oldSummary = serviceSummaryRes.findById(summary.getId());
AgentServiceSummary oldSummary = serviceSummaryRes.getReferenceById(summary.getId());
if (oldSummary != null) {
oldSummary.setProcess(true);
oldSummary.setUpdatetime(new Date());
@ -152,7 +152,7 @@ public class AgentSummaryController extends Handler {
@Menu(type = "agent", subtype = "agentsummary")
public void expids(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String[] ids) throws IOException {
if (ids != null && ids.length > 0) {
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findAll(Arrays.asList(ids));
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findAllById(Arrays.asList(ids));
MetadataTable table = metadataRes.findByTablename("uk_servicesummary");
List<Map<String, Object>> values = new ArrayList<>();
for (AgentServiceSummary event : statusEventList) {
@ -174,7 +174,7 @@ public class AgentSummaryController extends Handler {
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParent(currentOrgan);
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findByChannelNotAndSkillIn(
MainContext.ChannelType.PHONE.toString(), organs.keySet(), new PageRequest(0, 10000));
MainContext.ChannelType.PHONE.toString(), organs.keySet(), PageRequest.of(0, 10000));
MetadataTable table = metadataRes.findByTablename("uk_servicesummary");
List<Map<String, Object>> values = new ArrayList<>();
for (AgentServiceSummary statusEvent : statusEventList) {
@ -207,7 +207,7 @@ public class AgentSummaryController extends Handler {
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}, new PageRequest(0, 10000, Sort.Direction.DESC, "createtime"));
}, PageRequest.of(0, 10000, Sort.Direction.DESC, "createtime"));
List<Map<String, Object>> values = new ArrayList<>();
for (AgentServiceSummary summary : page) {

View File

@ -36,6 +36,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort.Direction;
@ -44,9 +45,9 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.persistence.criteria.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.persistence.criteria.*;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.nio.charset.CharacterCodingException;
import java.text.ParseException;
import java.util.*;
@ -100,6 +101,7 @@ public class ChatServiceController extends Handler {
private Cache cache;
@Autowired
@Lazy
private PeerSyncIM peerSyncIM;
@Autowired
@ -144,7 +146,7 @@ public class ChatServiceController extends Handler {
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}, new PageRequest(super.getP(request), super.getPs(request), Direction.DESC, "createtime"));
}, PageRequest.of(super.getP(request), super.getPs(request), Direction.DESC, "createtime"));
map.put("agentServiceList", page);
map.put("username", username);
map.put("channel", channel);
@ -168,7 +170,7 @@ public class ChatServiceController extends Handler {
"agentServiceList", agentServiceRes.findByStatusAndAgentskillIn(
MainContext.AgentUserStatusEnum.INSERVICE.toString(),
organs.keySet(),
new PageRequest(
PageRequest.of(
super.getP(request),
super.getPs(request), Direction.DESC,
"createtime")));
@ -183,7 +185,7 @@ public class ChatServiceController extends Handler {
Map<String, Organ> ownOrgans = organProxy.findAllOrganByParent(targetOrgan);
if (StringUtils.isNotBlank(id)) {
AgentService agentService = agentServiceRes.findById(id);
AgentService agentService = agentServiceRes.getReferenceById(id);
List<Organ> skillGroups = organRes.findByIdInAndSkill(ownOrgans.keySet(), true);
Set<String> organs = ownOrgans.keySet();
String currentOrgan = agentService.getSkill();
@ -200,7 +202,7 @@ public class ChatServiceController extends Handler {
usersids.add(o);
}
}
List<User> userList = userRes.findAll(usersids);
List<User> userList = userRes.findAllById(usersids);
for (User user : userList) {
user.setAgentStatus(cache.findOneAgentStatusByAgentno(user.getId()));
userProxy.attachOrgansPropertiesForUser(user);
@ -221,8 +223,8 @@ public class ChatServiceController extends Handler {
@Menu(type = "apps", subtype = "transfersave")
public ModelAndView transfersave(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String agentno, @Valid String memo) throws CharacterCodingException {
if (StringUtils.isNotBlank(id)) {
AgentService agentService = agentServiceRes.findById(id);
final User targetAgent = userRes.findOne(agentno);
AgentService agentService = agentServiceRes.getReferenceById(id);
final User targetAgent = userRes.getReferenceById(agentno);
AgentUser agentUser = null;
Optional<AgentUser> agentUserOpt = cache.findOneAgentUserByUserId(
agentService.getUserid());
@ -288,7 +290,7 @@ public class ChatServiceController extends Handler {
}
}
} else {
agentUser = agentUserRepository.findById(agentService.getAgentuserid());
agentUser = agentUserRepository.getReferenceById(agentService.getAgentuserid());
if (agentUser != null) {
agentUser.setAgentno(agentno);
agentUser.setAgentname(targetAgent.getUname());
@ -314,10 +316,10 @@ public class ChatServiceController extends Handler {
@Menu(type = "service", subtype = "current", admin = true)
public ModelAndView end(ModelMap map, HttpServletRequest request, @Valid String id) throws Exception {
if (StringUtils.isNotBlank(id)) {
AgentService agentService = agentServiceRes.findById(id);
AgentService agentService = agentServiceRes.getReferenceById(id);
if (agentService != null) {
User user = super.getUser(request);
AgentUser agentUser = agentUserRepository.findById(
AgentUser agentUser = agentUserRepository.getReferenceById(
agentService.getAgentuserid());
if (agentUser != null) {
acdAgentService.finishAgentUser(agentUser);
@ -345,7 +347,7 @@ public class ChatServiceController extends Handler {
final HttpServletRequest request,
final @Valid String id) throws Exception {
if (StringUtils.isNotBlank(id)) {
AgentService agentService = agentServiceRes.findById(id);
AgentService agentService = agentServiceRes.getReferenceById(id);
if (agentService != null) {
final User user = super.getUser(request);
if (StringUtils.isBlank(agentService.getAgentno())) {
@ -394,7 +396,7 @@ public class ChatServiceController extends Handler {
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParent(currentOrgan);
Page<AgentUser> agentUserList = agentUserRes.findByStatusAndSkillIn(MainContext.AgentUserStatusEnum.INQUENE.toString(), organs.keySet(),
new PageRequest(super.getP(request), super.getPs(request), Direction.DESC, "createtime"));
PageRequest.of(super.getP(request), super.getPs(request), Direction.DESC, "createtime"));
List<String> skillGroups = new ArrayList<>();
for (AgentUser agentUser : agentUserList.getContent()) {
agentUser.setWaittingtime((int) (System.currentTimeMillis() - agentUser.getCreatetime().getTime()));
@ -403,7 +405,7 @@ public class ChatServiceController extends Handler {
}
}
if (skillGroups.size() > 0) {
List<Organ> organList = organRes.findAll(skillGroups);
List<Organ> organList = organRes.findAllById(skillGroups);
for (AgentUser agentUser : agentUserList.getContent()) {
if (StringUtils.isNotBlank(agentUser.getSkill())) {
for (Organ organ : organList) {
@ -446,7 +448,7 @@ public class ChatServiceController extends Handler {
}
}
}
List<User> userList = userRes.findAll(usersids);
List<User> userList = userRes.findAllById(usersids);
for (User user : userList) {
user.setAgentStatus(cache.findOneAgentStatusByAgentno(user.getId()));
userProxy.attachOrgansPropertiesForUser(user);
@ -463,7 +465,7 @@ public class ChatServiceController extends Handler {
@RequestMapping("/quene/transfer/save")
@Menu(type = "service", subtype = "quenetransfer", admin = true)
public ModelAndView transferSave(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String skillid) {
AgentUser agentUser = agentUserRes.findById(id);
AgentUser agentUser = agentUserRes.getReferenceById(id);
if (agentUser != null && agentUser.getStatus().equals(MainContext.AgentUserStatusEnum.INQUENE.toString())) {
agentUser.setAgentno(null);
agentUser.setSkill(skillid);
@ -479,7 +481,7 @@ public class ChatServiceController extends Handler {
@Menu(type = "service", subtype = "invite", admin = true)
public ModelAndView invite(ModelMap map, HttpServletRequest request, @Valid String id) throws Exception {
final User logined = super.getUser(request);
AgentUser agentUser = agentUserRes.findById(id);
AgentUser agentUser = agentUserRes.getReferenceById(id);
if (agentUser != null && agentUser.getStatus().equals(MainContext.AgentUserStatusEnum.INQUENE.toString())) {
acdAgentService.assignVisitorAsInvite(logined.getId(), agentUser);
}
@ -524,7 +526,7 @@ public class ChatServiceController extends Handler {
@Menu(type = "service", subtype = "offline", admin = true)
public ModelAndView offline(ModelMap map, HttpServletRequest request, @Valid String id) {
AgentStatus agentStatus = agentStatusRepository.findById(id);
AgentStatus agentStatus = agentStatusRepository.getReferenceById(id);
if (agentStatus != null) {
agentStatusRepository.delete(agentStatus);
}
@ -547,7 +549,7 @@ public class ChatServiceController extends Handler {
public ModelAndView user(ModelMap map, HttpServletRequest request) {
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParent(currentOrgan);
Page<User> userList = userProxy.findUserInOrgans(organs.keySet(), new PageRequest(super.getP(request), super.getPs(request),
Page<User> userList = userProxy.findUserInOrgans(organs.keySet(), PageRequest.of(super.getP(request), super.getPs(request),
Direction.DESC, "createtime"));
Map<String, Boolean> onlines = new HashMap<>();
if (userList != null) {
@ -571,7 +573,7 @@ public class ChatServiceController extends Handler {
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParent(currentOrgan);
Page<LeaveMsg> leaveMsgs = leaveMsgRes.findBySkill(organs.keySet(), new PageRequest(super.getP(request), super.getPs(request),
Page<LeaveMsg> leaveMsgs = leaveMsgRes.findBySkill(organs.keySet(), PageRequest.of(super.getP(request), super.getPs(request),
Direction.DESC, "createtime"));
logger.info("[leavemsg] current organ {}, find message size {}", currentOrgan.getId(), leaveMsgs.getSize());
for (final LeaveMsg l : leaveMsgs) {
@ -586,7 +588,7 @@ public class ChatServiceController extends Handler {
@Menu(type = "service", subtype = "leavemsg", admin = true)
public ModelAndView leavemsg(ModelMap map, HttpServletRequest request, @Valid String id) {
if (StringUtils.isNotBlank(id)) {
leaveMsgRes.delete(id);
leaveMsgRes.deleteById(id);
}
return request(super.createView("redirect:/service/leavemsg/index"));
}

View File

@ -30,8 +30,8 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.util.Map;
@Controller
@ -48,7 +48,7 @@ public class CommentController extends Handler {
public ModelAndView index(ModelMap map, HttpServletRequest request, String userid, String agentservice, @Valid String channel) {
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParent(currentOrgan);
Page<AgentService> agentServiceList = agentServiceRes.findBySatisfactionAndSkillIn(true, organs.keySet(), new PageRequest(super.getP(request), super.getPs(request)));
Page<AgentService> agentServiceList = agentServiceRes.findBySatisfactionAndSkillIn(true, organs.keySet(), PageRequest.of(super.getP(request), super.getPs(request)));
map.addAttribute("serviceList", agentServiceList);
return request(super.createView("/apps/service/comment/index"));
}

View File

@ -38,8 +38,8 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.util.List;
@Controller
@ -134,9 +134,9 @@ public class OnlineUserController extends Handler {
agentUserContactsRes.findOneByUserid(
userid).ifPresent(p -> {
map.put("contacts", contactsRes.findOne(p.getContactsid()));
map.put("contacts", contactsRes.getReferenceById(p.getContactsid()));
});
AgentService service = agentServiceRes.findById(agentservice);
AgentService service = agentServiceRes.getReferenceById(agentservice);
if (service != null) {
map.addAttribute(
"tags", tagRes.findByTagtypeAndSkill(MainContext.ModelType.USER.toString(), service.getSkill()));
@ -150,7 +150,7 @@ public class OnlineUserController extends Handler {
map.put(
"agentUserMessageList",
chatMessageRepository.findByAgentserviceid(agentService.getId(),
new PageRequest(
PageRequest.of(
0, 50, Direction.DESC,
"updatetime")));
}
@ -162,7 +162,7 @@ public class OnlineUserController extends Handler {
map.put("weiXinUser", passportWechatUser);
}
} else if (MainContext.ChannelType.WEBIM.toString().equals(channel)) {
PassportWebIMUser passportWebIMUser = onlineUserRes.findOne(userid);
PassportWebIMUser passportWebIMUser = onlineUserRes.getReferenceById(userid);
if (passportWebIMUser != null) {
map.put("onlineUser", passportWebIMUser);
}
@ -181,7 +181,7 @@ public class OnlineUserController extends Handler {
@RequestMapping("/online/chatmsg")
@Menu(type = "service", subtype = "chatmsg", admin = true)
public ModelAndView onlinechat(ModelMap map, HttpServletRequest request, String id, String title) {
AgentService agentService = agentServiceRes.getOne(id);
AgentService agentService = agentServiceRes.getReferenceById(id);
map.put("curAgentService", agentService);
cache.findOneAgentUserByUserId(agentService.getUserid()).ifPresent(p -> {
map.put("curagentuser", p);
@ -207,7 +207,7 @@ public class OnlineUserController extends Handler {
map.put(
"agentUserMessageList",
chatMessageRepository.findByAgentserviceid(agentService.getId(),
new PageRequest(0, 50, Direction.DESC,
PageRequest.of(0, 50, Direction.DESC,
"updatetime")));
return request(super.createView("/apps/service/online/chatmsg"));
@ -223,7 +223,7 @@ public class OnlineUserController extends Handler {
if (StringUtils.isNotBlank(sessionid)) {
map.addAttribute(
"traceHisList", userEventRes.findBySessionid(sessionid,
new PageRequest(0, 100)));
PageRequest.of(0, 100)));
}
return request(super.createView("/apps/service/online/trace"));
}

View File

@ -39,10 +39,10 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.persistence.criteria.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import jakarta.persistence.criteria.*;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
@ -110,7 +110,7 @@ public class ProcessedSummaryController extends Handler {
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}, new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
}, PageRequest.of(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
map.addAttribute("summaryList", page);
map.addAttribute("ani", ani);
map.addAttribute("called", called);
@ -126,14 +126,14 @@ public class ProcessedSummaryController extends Handler {
@RequestMapping(value = "/process")
@Menu(type = "agent", subtype = "processed")
public ModelAndView process(ModelMap map, HttpServletRequest request, @Valid final String id) {
AgentServiceSummary summary = serviceSummaryRes.findById(id);
AgentServiceSummary summary = serviceSummaryRes.getReferenceById(id);
map.addAttribute("summary", summary);
map.put("summaryTags", tagRes.findByTagtype(MainContext.ModelType.SUMMARY.toString()));
if (summary != null && !StringUtils.isBlank(summary.getAgentserviceid())) {
AgentService service = agentServiceRes.findById(summary.getAgentserviceid());
AgentService service = agentServiceRes.getReferenceById(summary.getAgentserviceid());
map.addAttribute("service", service);
if (!StringUtils.isBlank(summary.getContactsid())) {
Contacts contacts = contactsRes.findOne(summary.getContactsid());
Contacts contacts = contactsRes.getReferenceById(summary.getContactsid());
map.addAttribute("contacts", contacts);
}
}
@ -144,7 +144,7 @@ public class ProcessedSummaryController extends Handler {
@RequestMapping(value = "/save")
@Menu(type = "agent", subtype = "processed")
public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid final AgentServiceSummary summary) {
AgentServiceSummary oldSummary = serviceSummaryRes.findById(summary.getId());
AgentServiceSummary oldSummary = serviceSummaryRes.getReferenceById(summary.getId());
if (oldSummary != null) {
oldSummary.setProcess(true);
oldSummary.setUpdatetime(new Date());
@ -160,7 +160,7 @@ public class ProcessedSummaryController extends Handler {
@Menu(type = "agent", subtype = "processed")
public void expids(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String[] ids) throws IOException {
if (ids != null && ids.length > 0) {
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findAll(Arrays.asList(ids));
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findAllById(Arrays.asList(ids));
MetadataTable table = metadataRes.findByTablename("uk_servicesummary");
List<Map<String, Object>> values = new ArrayList<>();
for (AgentServiceSummary event : statusEventList) {
@ -182,7 +182,7 @@ public class ProcessedSummaryController extends Handler {
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParent(currentOrgan);
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findByChannelNotAndProcessTrueAndSkillIn(
MainContext.ChannelType.PHONE.toString(), organs.keySet(), new PageRequest(0, 10000));
MainContext.ChannelType.PHONE.toString(), organs.keySet(), PageRequest.of(0, 10000));
MetadataTable table = metadataRes.findByTablename("uk_servicesummary");
List<Map<String, Object>> values = new ArrayList<>();
@ -221,7 +221,7 @@ public class ProcessedSummaryController extends Handler {
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}, new PageRequest(0, 10000, Sort.Direction.DESC, "createtime"));
}, PageRequest.of(0, 10000, Sort.Direction.DESC, "createtime"));
List<Map<String, Object>> values = new ArrayList<>();
for (AgentServiceSummary summary : page) {

View File

@ -39,9 +39,9 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

View File

@ -37,10 +37,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.util.Date;
import java.util.List;

View File

@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
/**
* Token验证失败

View File

@ -31,13 +31,13 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaBuilder.In;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaBuilder.In;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.util.ArrayList;
import java.util.List;

View File

@ -30,8 +30,8 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
@Controller
public class ContactsResourceController extends Handler {
@ -46,7 +46,7 @@ public class ContactsResourceController extends Handler {
if (q == null) {
q = "";
}
Page<Contacts> contactsList = contactsRes.findByCreaterAndSharesAndDatastatus(super.getUser(request).getId(), super.getUser(request).getId(), false, new PageRequest(0, 10));
Page<Contacts> contactsList = contactsRes.findByCreaterAndSharesAndDatastatus(super.getUser(request).getId(), super.getUser(request).getId(), false, PageRequest.of(0, 10));
JSONArray result = new JSONArray();
for (Contacts contact : contactsList.getContent()) {

View File

@ -19,27 +19,26 @@ package com.cskefu.cc.controller.resource;
import com.cskefu.cc.controller.Handler;
import com.cskefu.cc.util.Menu;
import org.springframework.stereotype.Controller;
import org.springframework.util.MimeTypeUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.IOException;
@Controller
public class CssResourceController extends Handler{
@RequestMapping("/res/css")
@RequestMapping(value = "/res/css")
@Menu(type = "resouce" , subtype = "css" , access = true)
public ModelAndView index(HttpServletResponse response, @Valid String id) throws IOException {
response.setContentType("text/css ; charset=UTF-8");
return request(super.createView("/resource/css/ukefu"));
}
@RequestMapping("/res/css/system")
@RequestMapping(value = "/res/css/system")
@Menu(type = "resouce" , subtype = "css" , access = true)
public ModelAndView system(HttpServletResponse response, @Valid String id) throws IOException {
response.setContentType("text/css ; charset=UTF-8");
return request(super.createView("/resource/css/system"));
}
}

View File

@ -41,9 +41,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.util.regex.Pattern;
import java.io.File;
import java.io.IOException;
@ -77,7 +77,7 @@ public class MediaController extends Handler {
@Valid String id,
@RequestParam(value = "original", required = false) boolean original,
@RequestParam(value = "cooperation", required = false) boolean cooperation) throws IOException, SQLException {
StreamingFile sf = streamingFileRes.findOne(id);
StreamingFile sf = streamingFileRes.getReferenceById(id);
if (sf != null) {
response.setHeader("Content-Type", sf.getMime());
response.setContentType(sf.getMime());
@ -149,9 +149,9 @@ public class MediaController extends Handler {
@Menu(type = "resouce", subtype = "file")
public void file(HttpServletResponse response, HttpServletRequest request, @Valid String id) throws IOException, SQLException {
if (StringUtils.isNotBlank(id)) {
AttachmentFile attachmentFile = attachementRes.findById(id);
AttachmentFile attachmentFile = attachementRes.getReferenceById(id);
if (attachmentFile != null && attachmentFile.getFileid() != null) {
StreamingFile sf = streamingFileRes.findOne(attachmentFile.getFileid());
StreamingFile sf = streamingFileRes.getReferenceById(attachmentFile.getFileid());
if (sf != null) {
response.setContentType(attachmentFile.getFiletype());
response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(attachmentFile.getTitle(), "UTF-8"));

View File

@ -25,8 +25,8 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

View File

@ -33,8 +33,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.util.List;
@Controller
@ -99,7 +99,7 @@ public class UsersResourceController extends Handler {
if (q == null) {
q = "";
}
Page<User> list = userRes.findByDatastatusAndUsernameLike(false, "%" + q + "%", new PageRequest(0, 10));
Page<User> list = userRes.findByDatastatusAndUsernameLike(false, "%" + q + "%", PageRequest.of(0, 10));
return list;
}

View File

@ -18,12 +18,12 @@ package com.cskefu.cc.interceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
public class CrossInterceptorHandler extends HandlerInterceptorAdapter {
public class CrossInterceptorHandler implements HandlerInterceptor {
private final static Logger logger = LoggerFactory.getLogger(CrossInterceptorHandler.class);
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)

View File

@ -31,8 +31,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.Enumeration;

View File

@ -21,15 +21,15 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
/**
* 用户体验计划
*/
public class UserExperiencePlanInterceptorHandler extends HandlerInterceptorAdapter {
public class UserExperiencePlanInterceptorHandler implements HandlerInterceptor {
private static final Logger logger = LoggerFactory.getLogger(UserExperiencePlanInterceptorHandler.class);
public final static String FLAG_KEY = "cskefu:global:user-experience-plan";
private static RedisCommand redis;

View File

@ -32,15 +32,15 @@ import com.cskefu.cc.util.PugHelper;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.web.BasicErrorController;
import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
public class UserInterceptorHandler extends HandlerInterceptorAdapter {
public class UserInterceptorHandler implements HandlerInterceptor {
private final static Logger logger = LoggerFactory.getLogger(UserInterceptorHandler.class);
private static UserProxy userProxy;
private static OrganProxy organProxy;

View File

@ -20,12 +20,12 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
public class ViewsInterceptorHandler extends HandlerInterceptorAdapter {
public class ViewsInterceptorHandler implements HandlerInterceptor {
private final static Logger logger = LoggerFactory.getLogger(ViewsInterceptorHandler.class);
@Override

View File

@ -20,7 +20,7 @@ package com.cskefu.cc.model;
import com.cskefu.cc.basic.MainUtils;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import jakarta.persistence.*;
import java.util.Date;
@Entity

View File

@ -18,7 +18,7 @@ package com.cskefu.cc.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import jakarta.persistence.*;
import java.util.Date;
@Entity

View File

@ -18,7 +18,7 @@ package com.cskefu.cc.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import jakarta.persistence.*;
import java.util.Date;
@Entity

View File

@ -19,7 +19,7 @@ package com.cskefu.cc.model;
import com.cskefu.cc.basic.MainUtils;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import jakarta.persistence.*;
import java.text.SimpleDateFormat;
import java.util.Date;

View File

@ -21,7 +21,7 @@ import com.cskefu.cc.basic.MainUtils;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Proxy;
import javax.persistence.*;
import jakarta.persistence.*;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

View File

@ -19,7 +19,7 @@ package com.cskefu.cc.model;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Proxy;
import javax.persistence.*;
import jakarta.persistence.*;
import java.io.Serializable;
import java.util.Date;

View File

@ -19,7 +19,7 @@ package com.cskefu.cc.model;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Proxy;
import javax.persistence.*;
import jakarta.persistence.*;
import java.io.Serializable;
import java.util.Date;

View File

@ -20,7 +20,7 @@ import com.cskefu.cc.acd.ACDServiceRouter;
import com.cskefu.cc.basic.MainContext;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import jakarta.persistence.*;
import java.util.Date;
import java.util.HashMap;

View File

@ -20,7 +20,7 @@ import com.cskefu.cc.basic.MainUtils;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Proxy;
import javax.persistence.*;
import jakarta.persistence.*;
import java.io.Serializable;
import java.util.Date;

View File

@ -19,7 +19,7 @@ package com.cskefu.cc.model;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Proxy;
import javax.persistence.*;
import jakarta.persistence.*;
import java.io.Serializable;
import java.util.Date;

View File

@ -19,7 +19,7 @@ package com.cskefu.cc.model;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Proxy;
import javax.persistence.*;
import jakarta.persistence.*;
import java.util.Date;
@Entity

View File

@ -18,7 +18,7 @@ package com.cskefu.cc.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import jakarta.persistence.*;
import java.util.Date;
@Entity

Some files were not shown because too many files have changed in this diff Show More