解决online连接数爆炸的严重bug
This commit is contained in:
parent
27c826567a
commit
4c1d7ab978
@ -0,0 +1,21 @@
|
||||
package com.ruoyi.online.config;
|
||||
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.ruoyi.online.utils.SqlMapper;
|
||||
|
||||
@Configuration
|
||||
public class SqlMapperConfiguration {
|
||||
@Autowired
|
||||
private SqlSessionFactory sqlSessionFactory;
|
||||
|
||||
@Bean
|
||||
public SqlMapper getSqlMapper() {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession();
|
||||
return new SqlMapper(sqlSession);
|
||||
}
|
||||
}
|
@ -6,8 +6,6 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -31,13 +29,14 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
@Anonymous
|
||||
@RequestMapping("/online")
|
||||
public class OnLineController extends BaseController {
|
||||
@Autowired
|
||||
private SqlSessionFactory sqlSessionFactory;
|
||||
@Autowired
|
||||
private IOnlineMbService onlineMbService;
|
||||
@Resource(name = "ss")
|
||||
private PermissionService permissionService;
|
||||
|
||||
@Autowired
|
||||
private SqlMapper sqlMapper;
|
||||
|
||||
@RequestMapping("/api/**")
|
||||
public Object api(@RequestParam(required = false) HashMap<String, Object> params,
|
||||
@RequestBody(required = false) HashMap<String, Object> data, HttpServletRequest request,
|
||||
@ -97,8 +96,6 @@ public class OnLineController extends BaseController {
|
||||
}
|
||||
|
||||
String sql = "<script>\n" + onlineMb.getSql() + "\n</script>";
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession();
|
||||
SqlMapper sqlMapper = new SqlMapper(sqlSession);
|
||||
return switch (onlineMb.getActuator()) {
|
||||
case "selectList" -> getDataTable(sqlMapper.selectList(sql, object));
|
||||
case "insert" -> toAjax(sqlMapper.insert(sql, object));
|
||||
|
Loading…
Reference in New Issue
Block a user