完善online
This commit is contained in:
parent
ea548c1987
commit
d4334a3149
@ -3,12 +3,15 @@ package com.ruoyi.online.controller;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
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;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
@ -30,19 +33,32 @@ public class OnLineController extends BaseController {
|
||||
private IOnlineMbService onlineMbService;
|
||||
|
||||
@RequestMapping("/api/**")
|
||||
public Object api(@RequestBody(required = false) Map<String, Object> data, HttpServletResponse response,
|
||||
HttpServletRequest request) {
|
||||
public Object api(@RequestParam(required = false) HashMap<String,Object> params,@RequestBody(required = false) HashMap<String,Object> data,HttpServletRequest request,HttpServletResponse response) {
|
||||
OnlineMb selectOnlineMb = new OnlineMb();
|
||||
selectOnlineMb.setPath(request.getRequestURI().replace("/online/api", ""));
|
||||
selectOnlineMb.setMethod(request.getMethod());
|
||||
Map<String, Object> object = new HashMap<>();
|
||||
Map<String, String[]> params = request.getParameterMap();
|
||||
HashMap<String, Object> object_params = new HashMap<String, Object>();
|
||||
String keyregex = "params\\[(.*?)\\]";
|
||||
Pattern pattern = Pattern.compile(keyregex);
|
||||
if (params != null) {
|
||||
object.putAll(params);
|
||||
params.keySet().forEach(key -> {
|
||||
Matcher matcher = pattern.matcher(key);
|
||||
if(matcher.find()){
|
||||
object_params.put(matcher.group(1), object.get(key));
|
||||
}else{
|
||||
object.put(key, params.get(key));
|
||||
}
|
||||
});
|
||||
}
|
||||
if (data != null) {
|
||||
if(data.containsKey("params")){
|
||||
object_params.putAll((HashMap<String, Object>) object.get("params"));
|
||||
data.remove("params");
|
||||
}
|
||||
object.putAll(data);
|
||||
}
|
||||
object.put("params", object_params);
|
||||
List<OnlineMb> selectOnlineMbList = onlineMbService.selectOnlineMbList(selectOnlineMb);
|
||||
if (selectOnlineMbList.size() == 0) {
|
||||
return error("没有相关接口");
|
||||
|
@ -1,17 +1,17 @@
|
||||
DROP TABLE IF EXISTS `online_mb`;
|
||||
DROP TABLE IF EXISTS online_mb;
|
||||
|
||||
CREATE TABLE `online_mb` (
|
||||
`mb_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`tag` varchar(255) NULL COMMENT '标签名',
|
||||
`tag_id` varchar(255) NULL COMMENT '标签id',
|
||||
`parameterType` varchar(255) NULL COMMENT '参数类型',
|
||||
`resultMap` varchar(255) NULL COMMENT '结果类型',
|
||||
`sql` varchar(255) NULL COMMENT 'sql语句',
|
||||
`path` varchar(255) NULL COMMENT '请求路径',
|
||||
`method` varchar(255) NULL COMMENT '请求方式',
|
||||
`resultType` varchar(255) NULL COMMENT '响应类型',
|
||||
`actuator` varchar(255) NULL COMMENT '执行器',
|
||||
PRIMARY KEY (`mb_id`)
|
||||
CREATE TABLE online_mb (
|
||||
mb_id bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
tag varchar(255) NULL COMMENT '标签名',
|
||||
tag_id varchar(255) NULL COMMENT '标签id',
|
||||
parameterType varchar(255) NULL COMMENT '参数类型',
|
||||
resultMap varchar(255) NULL COMMENT '结果类型',
|
||||
sql varchar(255) NULL COMMENT 'sql语句',
|
||||
path varchar(255) NULL COMMENT '请求路径',
|
||||
method varchar(255) NULL COMMENT '请求方式',
|
||||
resultType varchar(255) NULL COMMENT '响应类型',
|
||||
actuator varchar(255) NULL COMMENT '执行器',
|
||||
PRIMARY KEY (mb_id)
|
||||
) ENGINE = InnoDB COMMENT = '在线接口';
|
||||
|
||||
-- 菜单 SQL
|
||||
@ -35,4 +35,25 @@ insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame
|
||||
values('mybatis在线接口删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', 'online:mb:remove', '#', 'admin', sysdate(), '', null, '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('mybatis在线接口导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', 'online:mb:export', '#', 'admin', sysdate(), '', null, '');
|
||||
values('mybatis在线接口导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', 'online:mb:export', '#', 'admin', sysdate(), '', null, '');
|
||||
|
||||
|
||||
INSERT INTO sys_dict_type ( dict_name, dict_type, status, create_by, create_time, update_by, update_time, remark) VALUES ( '请求方式', 'online_api_method', '0', 'admin', '2024-02-21 18:22:03', 'admin', '2024-02-21 18:22:13', NULL);
|
||||
INSERT INTO sys_dict_type ( dict_name, dict_type, status, create_by, create_time, update_by, update_time, remark) VALUES ( '标签名', 'online_api_tag', '0', 'admin', '2024-02-21 18:22:29', '', NULL, NULL);
|
||||
INSERT INTO sys_dict_type ( dict_name, dict_type, status, create_by, create_time, update_by, update_time, remark) VALUES ( '响应类型', 'online_api_result', '0', 'admin', '2024-02-21 18:22:46', '', NULL, NULL);
|
||||
INSERT INTO sys_dict_type ( dict_name, dict_type, status, create_by, create_time, update_by, update_time, remark) VALUES ( '执行器', 'online_api_actuator', '0', 'admin', '2024-02-21 18:23:03', '', NULL, NULL);
|
||||
|
||||
|
||||
INSERT INTO sys_dict_data ( dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES ( 0, 'POST', 'POST', 'online_api_method', NULL, 'default', 'N', '0', 'admin', '2024-02-21 18:23:23', '', NULL, NULL);
|
||||
INSERT INTO sys_dict_data ( dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES ( 0, 'GET', 'GET', 'online_api_method', NULL, 'default', 'N', '0', 'admin', '2024-02-21 18:23:30', '', NULL, NULL);
|
||||
INSERT INTO sys_dict_data ( dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES ( 0, 'PUT', 'PUT', 'online_api_method', NULL, 'default', 'N', '0', 'admin', '2024-02-21 18:23:37', '', NULL, NULL);
|
||||
INSERT INTO sys_dict_data ( dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES ( 0, 'DELETE', 'DELETE', 'online_api_method', NULL, 'default', 'N', '0', 'admin', '2024-02-21 18:23:49', '', NULL, NULL);
|
||||
INSERT INTO sys_dict_data ( dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES ( 0, 'select', 'select', 'online_api_tag', NULL, 'default', 'N', '0', 'admin', '2024-02-21 18:24:06', '', NULL, NULL);
|
||||
INSERT INTO sys_dict_data ( dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES ( 0, 'update', 'update', 'online_api_tag', NULL, 'default', 'N', '0', 'admin', '2024-02-21 18:24:12', '', NULL, NULL);
|
||||
INSERT INTO sys_dict_data ( dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES ( 0, 'insert', 'insert', 'online_api_tag', NULL, 'default', 'N', '0', 'admin', '2024-02-21 18:24:18', '', NULL, NULL);
|
||||
INSERT INTO sys_dict_data ( dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES ( 0, 'delete', 'delete', 'online_api_tag', NULL, 'default', 'N', '0', 'admin', '2024-02-21 18:24:26', '', NULL, NULL);
|
||||
INSERT INTO sys_dict_data ( dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES ( 0, 'selectList', 'selectList', 'online_api_actuator', NULL, 'default', 'N', '0', 'admin', '2024-02-21 18:25:00', '', NULL, NULL);
|
||||
INSERT INTO sys_dict_data ( dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES ( 0, 'insert', 'insert', 'online_api_actuator', NULL, 'default', 'N', '0', 'admin', '2024-02-21 18:25:05', '', NULL, NULL);
|
||||
INSERT INTO sys_dict_data ( dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES ( 0, 'selectOne', 'selectOne', 'online_api_actuator', NULL, 'default', 'N', '0', 'admin', '2024-02-21 18:25:11', '', NULL, NULL);
|
||||
INSERT INTO sys_dict_data ( dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES ( 0, 'update', 'update', 'online_api_actuator', NULL, 'default', 'N', '0', 'admin', '2024-02-21 18:25:16', '', NULL, NULL);
|
||||
INSERT INTO sys_dict_data ( dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES ( 0, 'delete', 'delete', 'online_api_actuator', NULL, 'default', 'N', '0', 'admin', '2024-02-21 18:25:21', '', NULL, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user