微服务版后端初始化

This commit is contained in:
yaoyn
2025-02-08 17:51:37 +08:00
parent 54af6be188
commit da009a7cc4
1897 changed files with 429541 additions and 81 deletions

View File

@ -0,0 +1,16 @@
# 基础镜像
FROM nexus.gdyditc.com:8082/openjdk:11-arm64
# author
MAINTAINER xjrsoft
# 挂载目录
VOLUME /home/xjrsoft
# 创建目录
RUN mkdir -p /home/xjrsoft
# 指定路径
WORKDIR /home/xjrsoft
# 复制jar文件到路径
RUN ls
COPY ./target/xjrsoft-service-magicapi.jar /home/xjrsoft/xjrsoft-service-magicapi.jar
# 启动认证服务
ENTRYPOINT ["java","-Dfile.encoding=utf-8","--add-opens","java.base/java.lang.reflect=ALL-UNNAMED","-jar","xjrsoft-service-magicapi.jar"]

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>xjrsoft-service</artifactId>
<groupId>com.xjrsoft</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>xjrsoft-service-magicapi</artifactId>
<properties>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.xjrsoft</groupId>
<artifactId>xjrsoft-common-core</artifactId>
<version>${xjrsoft.framework.version}</version>
</dependency>
<dependency>
<groupId>com.xjrsoft</groupId>
<artifactId>xjrsoft-common-mybatis</artifactId>
<version>${xjrsoft.framework.version}</version>
</dependency>
<dependency>
<groupId>com.xjrsoft</groupId>
<artifactId>xjrsoft-service-magicapi-api</artifactId>
<version>${xjrsoft.framework.version}</version>
</dependency>
<dependency>
<groupId>com.xjrsoft</groupId>
<artifactId>xjrsoft-service-organization-api</artifactId>
<version>${xjrsoft.framework.version}</version>
</dependency>
<dependency>
<groupId>com.xjrsoft</groupId>
<artifactId>xjrsoft-service-system-api</artifactId>
<version>${xjrsoft.framework.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<dependency>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,25 @@
package com.xjrsoft.magicapi;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
/**
* @Author: tzx
* @Date: 2023/10/10 17:20
*/
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = "com.xjrsoft")
@MapperScan(value = "com.xjrsoft.**.mapper")
@ComponentScan(value = "com.xjrsoft")
public class MagicApiApplication {
public static void main(String[] args) {
SpringApplication.run(MagicApiApplication.class, args);
}
}

View File

@ -0,0 +1,78 @@
package com.xjrsoft.magicapi.client;
import cn.hutool.core.bean.BeanUtil;
import com.xjrsoft.common.core.constant.GlobalConstant;
import com.xjrsoft.magicapi.vo.MagicApiExecuteResponseVo;
import com.xjrsoft.magicapi.vo.MagicApiInfoFeighVo;
import com.xjrsoft.magicapi.vo.MagicApiInfoVo;
import io.swagger.v3.oas.annotations.Hidden;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.ssssssss.magicapi.core.model.ApiInfo;
import org.ssssssss.magicapi.core.model.BaseDefinition;
import org.ssssssss.magicapi.core.model.MagicEntity;
import org.ssssssss.magicapi.core.service.MagicAPIService;
import org.ssssssss.magicapi.core.service.MagicResourceService;
import java.util.HashMap;
import java.util.Map;
/**
* @Author: tzx
* @Date: 2023/10/10 17:43
*/
@Hidden
@RestController
@AllArgsConstructor
public class MagicApiClient implements IMagicApiClient{
private final MagicResourceService magicResourceService;
private MagicAPIService magicAPIService;
@Override
@GetMapping(GlobalConstant.CLIENT_API_PRE + GlobalConstant.MODULE_MAGICAPI_NAME + "/executeApiFeign")
public Object executeApiFeign(String id) {
MagicEntity entity = magicResourceService.file(id);
BaseDefinition requestBodyDefinition = ((ApiInfo) entity).getRequestBodyDefinition();
MagicApiInfoVo magicApiInfoVo = BeanUtil.toBean(entity, MagicApiInfoVo.class);
String groupId = entity.getGroupId();
if (StringUtils.isNotEmpty(groupId)) {
String groupPath = magicResourceService.getGroupPath(groupId);
magicApiInfoVo.setPath(groupPath + magicApiInfoVo.getPath());
}
magicApiInfoVo.setRequestBodyDefinition(requestBodyDefinition);
return magicAPIService.execute(magicApiInfoVo.getMethod(), magicApiInfoVo.getPath(), new HashMap<>());
}
@Override
@GetMapping(GlobalConstant.CLIENT_API_PRE + GlobalConstant.MODULE_MAGICAPI_NAME + "/getMagicApiInfoFeign")
public MagicApiInfoFeighVo getMagicApiInfoFeign(String id) {
MagicEntity entity = magicResourceService.file(id);
BaseDefinition requestBodyDefinition = ((ApiInfo) entity).getRequestBodyDefinition();
MagicApiInfoFeighVo magicApiInfoVo = BeanUtil.toBean(entity, MagicApiInfoFeighVo.class);
String groupId = entity.getGroupId();
if (StringUtils.isNotEmpty(groupId)) {
String groupPath = magicResourceService.getGroupPath(groupId);
magicApiInfoVo.setPath(groupPath + magicApiInfoVo.getPath());
}
return magicApiInfoVo;
}
@Override
@PostMapping(GlobalConstant.CLIENT_API_PRE + GlobalConstant.MODULE_MAGICAPI_NAME + "/executeApiByParamFeign")
public MagicApiExecuteResponseVo executeApiByParamFeign(String method, String path,@RequestBody Map<String, Object> context) {
MagicApiExecuteResponseVo vo = new MagicApiExecuteResponseVo();
vo.setResponse(magicAPIService.execute(method, path, context));
return vo;
}
}

View File

@ -0,0 +1,64 @@
package com.xjrsoft.magicapi.controller;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.common.core.constant.GlobalConstant;
import com.xjrsoft.common.core.domain.result.R;
import com.xjrsoft.magicapi.service.IInterfaceAuthService;
import com.xjrsoft.system.dto.InterfaceAuthDto;
import com.xjrsoft.system.entity.InterfaceAuth;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
* 接口权限表 前端控制器
* </p>
*
* @author zlf
* @since 2022-11-03
*/
@RestController
@RequestMapping(GlobalConstant.MAGICAPI_MODULE_PREFIX + "/auth")
@Tag(name = GlobalConstant.MAGICAPI_MODULE_PREFIX + "/auth", description = "接口权限模块接口")
@AllArgsConstructor
public class InterfaceAuthController {
private final IInterfaceAuthService authService;
@GetMapping(value = "/role")
@Operation(summary = "查询角色所授权的接口id集合")
public R role(@RequestParam Long roleId) {
List<InterfaceAuth> authList = authService.list(Wrappers.<InterfaceAuth>query().lambda()
.eq(InterfaceAuth::getRoleId, roleId));
List<String> resultIdList = null;
if (CollectionUtil.isNotEmpty(authList)) {
resultIdList = authList.stream().map(InterfaceAuth::getInterfaceId).collect(Collectors.toList());
}
return R.ok(resultIdList);
}
@PostMapping
@Operation(summary = "角色接口授权")
public R authorize(@RequestBody InterfaceAuthDto dto) {
// 删除原有的接口权限
authService.remove(Wrappers.<InterfaceAuth>query().lambda().eq(InterfaceAuth::getRoleId, dto.getRoleId()));
if (CollectionUtil.isNotEmpty(dto.getInterfaceIds())) {
List<InterfaceAuth> savedList = new ArrayList<>();
for (String interfaceId : dto.getInterfaceIds()) {
InterfaceAuth auth = new InterfaceAuth();
auth.setRoleId(dto.getRoleId());
auth.setInterfaceId(interfaceId);
savedList.add(auth);
}
authService.saveBatch(savedList);
}
return R.ok();
}
}

View File

@ -0,0 +1,59 @@
package com.xjrsoft.magicapi.controller;
import com.xjrsoft.common.core.constant.GlobalConstant;
import com.xjrsoft.common.core.domain.result.R;
import com.xjrsoft.magicapi.service.IMagicApiService;
import com.xjrsoft.magicapi.vo.MagicApiTreeVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* magic-api模块接口
* </p>
*
* @author tzx
* @since 2022-10-30
*/
@RestController
@RequestMapping(GlobalConstant.MAGICAPI_MODULE_PREFIX)
@Tag(name = GlobalConstant.MAGICAPI_MODULE_PREFIX, description = "magic-api模块接口")
@AllArgsConstructor
public class MagicApiController {
private final IMagicApiService magicApiService;
@GetMapping(value = "/tree")
@Operation(summary = "查询所有分组以及api 树结构")
public R tree(@RequestParam(required = false) String keyword ) {
List<MagicApiTreeVo> tree = magicApiService.tree(keyword);
return R.ok(tree);
}
@GetMapping(value = "/group/tree")
@Operation(summary = "查询所有树结构分组")
public R groupTree(){
return R.ok(magicApiService.groupTree());
}
@GetMapping(value = "/info")
@Operation(summary = "查询api详情")
public R info(@RequestParam String id){
return R.ok(magicApiService.info(id));
}
@GetMapping(value = "/list")
@Operation(summary = "根据分组id 查询所有api")
public R list(@RequestParam String groupId){
return R.ok(magicApiService.list(groupId));
}
}

View File

@ -0,0 +1,63 @@
package com.xjrsoft.magicapi.interceptor;
import cn.dev33.satoken.session.SaSession;
import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.strategy.SaStrategy;
import com.xjrsoft.common.core.constant.GlobalConstant;
import com.xjrsoft.common.core.domain.result.R;
import com.xjrsoft.common.core.enums.ResponseCode;
import com.xjrsoft.tenant.util.SecureUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.ssssssss.magicapi.core.context.RequestEntity;
import org.ssssssss.magicapi.core.interceptor.RequestInterceptor;
import java.util.ArrayList;
import java.util.List;
/**
* magic-api 接口鉴权
*
* @author tzx
*/
@Component
@Slf4j
public class MagicApiRequestInterceptor implements RequestInterceptor {
/***
* 接口请求之前
* @param requestEntity
* @return
*/
@Override
public Object preHandle(RequestEntity requestEntity) {
if(!StpUtil.isLogin()){
return R.error(ResponseCode.UN_AUTHORIZED.getCode(),ResponseCode.UN_AUTHORIZED.getMessage());
}
SaSession tokenSession = StpUtil.getTokenSession();
List<Long> roleIds = tokenSession.get(GlobalConstant.LOGIN_USER_ROLE_ID_KEY, new ArrayList<>());
//非管理员需要进行权限验证
if(!SecureUtil.isAdmin(roleIds)) {
if (!SaStrategy.me.hasElement.apply(tokenSession.get(GlobalConstant.LOGIN_USER_INTERFACE_AUTH_CODE_KEY, new ArrayList<>()), requestEntity.getApiInfo().getId())) {
return R.error(ResponseCode.MAGIC_API_UN_AUTHORIZED.getCode(), ResponseCode.MAGIC_API_UN_AUTHORIZED.getMessage());
}
}
return null;
}
/**
* 接口执行之后
* @param requestEntity
* @param returnValue
* @return
*/
@Override
public Object postHandle(RequestEntity requestEntity, Object returnValue) {
log.info("{} 执行完毕,返回结果:{}", requestEntity.getApiInfo().getName(), returnValue);
return null;
}
}

View File

@ -0,0 +1,19 @@
package com.xjrsoft.magicapi.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xjrsoft.system.entity.InterfaceAuth;
import java.util.List;
/**
* <p>
* 接口权限表 服务类
* </p>
*
* @author zlf
* @since 2022-11-03
*/
public interface IInterfaceAuthService extends IService<InterfaceAuth> {
List<String> loadAuthInterfaceIdsOfUser(Long userId);
}

View File

@ -0,0 +1,44 @@
package com.xjrsoft.magicapi.service;
import com.xjrsoft.magicapi.vo.MagicApiGroupTreeVo;
import com.xjrsoft.magicapi.vo.MagicApiInfoVo;
import com.xjrsoft.magicapi.vo.MagicApiTreeVo;
import java.util.List;
public interface IMagicApiService {
/**
* 分组以及api 树结构
* @return
*/
List<MagicApiTreeVo> tree(String keyword);
/**
* 分组树
* @return
*/
List<MagicApiGroupTreeVo> groupTree();
/**
* 根据 id 获取 接口信息
* @param id
* @return
*/
MagicApiInfoVo info(String id);
/**
* 根据分组查询所有接口
* @param groupId
* @return
*/
List<MagicApiInfoVo> list(String groupId);
/**
* 执行API
* @param id 接口id
* @param <T>
* @return
*/
<T> T executeApi(String id);
}

View File

@ -0,0 +1,26 @@
package com.xjrsoft.magicapi.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjrsoft.magicapi.service.IInterfaceAuthService;
import com.xjrsoft.system.entity.InterfaceAuth;
import com.xjrsoft.system.mapper.InterfaceAuthMapper;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 接口权限表 服务实现类
* </p>
*
* @author zlf
* @since 2022-11-03
*/
@Service
public class InterfaceAuthServiceImpl extends ServiceImpl<InterfaceAuthMapper, InterfaceAuth> implements IInterfaceAuthService {
@Override
public List<String> loadAuthInterfaceIdsOfUser(Long userId) {
return null;
}
}

View File

@ -0,0 +1,171 @@
package com.xjrsoft.magicapi.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.xjrsoft.common.core.uitls.TreeUtil;
import com.xjrsoft.magicapi.service.IMagicApiService;
import com.xjrsoft.magicapi.vo.MagicApiGroupTreeVo;
import com.xjrsoft.magicapi.vo.MagicApiInfoVo;
import com.xjrsoft.magicapi.vo.MagicApiTreeVo;
import lombok.AllArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.ssssssss.magicapi.core.model.*;
import org.ssssssss.magicapi.core.service.MagicAPIService;
import org.ssssssss.magicapi.core.service.MagicResourceService;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* magic-api服务
*
* @author apple
*/
@Service
@AllArgsConstructor
public class MagicApiServiceImpl implements IMagicApiService {
private final MagicResourceService magicResourceService;
private final MagicAPIService magicAPIService;
@Override
public List<MagicApiTreeVo> tree(String keyword) {
TreeNode<Group> tree = magicResourceService.tree("api");
List<TreeNode<Group>> children = tree.getChildren();
return TreeUtil.build(buildTreeData(children, keyword));
}
@Override
public List<MagicApiGroupTreeVo> groupTree() {
TreeNode<Group> tree = magicResourceService.tree("api");
List<TreeNode<Group>> children = tree.getChildren();
List<MagicApiGroupTreeVo> treeVoList = new ArrayList<>();
buildGroupTreeData(treeVoList, children);
return TreeUtil.build(treeVoList);
}
@Override
public MagicApiInfoVo info(String id) {
MagicEntity entity = magicResourceService.file(id);
BaseDefinition requestBodyDefinition = ((ApiInfo) entity).getRequestBodyDefinition();
MagicApiInfoVo magicApiInfoVo = BeanUtil.toBean(entity, MagicApiInfoVo.class);
String groupId = entity.getGroupId();
if (StringUtils.isNotEmpty(groupId)) {
String groupPath = magicResourceService.getGroupPath(groupId);
magicApiInfoVo.setPath(groupPath + magicApiInfoVo.getPath());
}
magicApiInfoVo.setRequestBodyDefinition(requestBodyDefinition);
return magicApiInfoVo;
}
@Override
public List<MagicApiInfoVo> list(String groupId) {
String groupPath = magicResourceService.getGroupPath(groupId);
List<MagicEntity> magicEntities = magicResourceService.listFiles(groupId);
List<MagicApiInfoVo> magicApiInfoVos = BeanUtil.copyToList(magicEntities, MagicApiInfoVo.class);
for (MagicApiInfoVo magicApiInfoVo : magicApiInfoVos) {
magicApiInfoVo.setPath(groupPath + magicApiInfoVo.getPath());
}
return magicApiInfoVos;
}
public <T> T executeApi(String id) {
MagicApiInfoVo info = info(id);
return magicAPIService.execute(info.getMethod(), info.getPath(), new HashMap<>());
}
/**
* 查询分组以及api 树结构
*
* @param treeNodes
* @return
*/
private List<MagicApiTreeVo> buildTreeData(List<TreeNode<Group>> treeNodes, String keyword) {
List<MagicApiTreeVo> treeVoList = new ArrayList<>();
for (TreeNode<Group> treeNode : treeNodes) {
Group node = treeNode.getNode();
List<MagicEntity> nodeEntity = magicResourceService.listFiles(node.getId());
if(StringUtils.isNotBlank(keyword) && !node.getName().contains(keyword) && nodeEntity.stream().noneMatch(x -> x.getName().contains(keyword) || ((ApiInfo)x).getPath().contains(keyword))){
continue;
}
MagicApiTreeVo groupVo = new MagicApiTreeVo();
groupVo.setId(node.getId());
groupVo.setParentId(node.getParentId());
groupVo.setType("group");
groupVo.setName(node.getName());
treeVoList.add(groupVo);
for (MagicEntity magicEntity : nodeEntity) {
MagicApiTreeVo vo = new MagicApiTreeVo();
ApiInfo apiInfo = (ApiInfo) magicEntity;
if(StringUtils.isNotBlank(keyword) && !magicEntity.getName().contains(keyword) && !apiInfo.getPath().contains(keyword)){
continue;
}
vo.setId(magicEntity.getId());
vo.setType("api");
vo.setParentId(magicEntity.getGroupId());
vo.setName(magicEntity.getName());
String groupPath = StringUtils.isEmpty(node.getPath()) ? StringPool.EMPTY : node.getPath();
vo.setPath(groupPath + apiInfo.getPath());
vo.setMethod(apiInfo.getMethod());
treeVoList.add(vo);
}
if (treeNode.getChildren().size() > 0) {
treeVoList.addAll(buildTreeData(treeNode.getChildren(), keyword));
}
}
return treeVoList;
}
/**
* 构建 分组树结构
*
* @param treeNodes
* @return
*/
private void buildGroupTreeData(List<MagicApiGroupTreeVo> treeVoList, List<TreeNode<Group>> treeNodes) {
for (TreeNode<Group> treeNode : treeNodes) {
Group node = treeNode.getNode();
MagicApiGroupTreeVo groupVo = new MagicApiGroupTreeVo();
groupVo.setId(node.getId());
groupVo.setParentId(node.getParentId());
groupVo.setName(node.getName());
treeVoList.add(groupVo);
List<TreeNode<Group>> children = treeNode.getChildren();
if (CollectionUtils.isNotEmpty(children)) {
buildGroupTreeData(treeVoList, children);
}
}
}
}

View File

@ -0,0 +1,4 @@
spring:
profiles:
active: public

View File

@ -0,0 +1,125 @@
server:
port: 3006
spring:
application:
name: magicapi-service
main:
allow-bean-definition-overriding: true
autoconfigure:
#自动化配置 例外处理
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource:
type: com.alibaba.druid.pool.DruidDataSource
dynamic:
primary: master
datasource:
master:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://new-energy-mysqlt.itc.gdyd.com:3307/fcd2-msat-init?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
username: learun4dev
password: ABcd1234@
cloud:
nacos: #nacos监控
discovery:
server-addr: 10.0.252.1:8848
namespace: ITC
group: DNE
username: nacos
password: ABcd1234@
config:
server-addr: 10.0.252.1:8848 # nacos 配置中心地址
namespace: ITC
group: DNE
username: nacos
password: ABcd1234@
file-extension: yml # 指定格式 xjrsoft-demo-service-dev.yml
extension-configs:
- data-id: global-config.yml #导入全局配置
refresh: true
group: DNE
- data-id: mybatis-plus-config.yml #导入mybatisplus 配置
refresh: true
group: DNE
- data-id: sa-token-client-config.yml #导入sa-token配置
refresh: true
group: DNE
- data-id: redis-config.yml #导入redis配置
refresh: true
group: DNE
- data-id: seata-config.yml #导入seata配置
refresh: true
group: DNE
sentinel:
transport:
dashboard: localhost:8080 #sentinel dashboard 地址
port: 8719 #默认端口, 如果 被占用,会一直+1 直到未被占用为止
springdoc:
swagger-ui:
path: /swagger-ui.html
tags-sorter: alpha
operations-sorter: alpha
show-extensions: true
api-docs:
path: /magicapi/v3/api-docs
group-configs:
- group: 'default'
paths-to-match: '/magicapi/**'
packages-to-scan: com.xjrsoft.magicapi
default-flat-param-object: false
magic-api:
#配置web页面入口
web: /magic/web
resource: #配置存储方式
type: database # 配置存储在数据库中
tableName: magic_api_file # 数据库中的表名
# datasource: master #指定数据源(单数据源时无需配置,多数据源时默认使用主数据源,如果存在其他数据源中需要指定。)
prefix: /magic-api # key前缀
readonly: false # 是否是只读模式
# security: # 安全配置
# username: admin # 登录用的用户名
# password: 123456 # 登录用的密码
prefix: /magic-api
editor-config: classpath:./magic-editor-config.js #编辑器配置
date-pattern: # 配置请求参数支持的日期格式
- yyyy-MM-dd
- yyyy-MM-dd HH:mm:ss
- yyyyMMddHHmmss
- yyyyMMdd
response: |- #配置JSON格式格式为magic-script中的表达式
{
code: code,
msg: message,
data,
timestamp,
requestTime,
executeTime,
}
response-code:
success: 0 #执行成功的code值
invalid: 10400 #参数验证未通过的code值
exception: 10500 #执行出现异常的code值
backup: #备份相关配置
enable: true #是否启用
max-history: -1 #备份保留天数,-1为永久保留
table-name: magic_api_backup #使用数据库存储备份时的表名
crud: # CRUD相关配置
logic-delete-column: delete_mark #逻辑删除列
logic-delete-value: 1 #逻辑删除值
page:
size: size # 页大小的参数名称
page: limit # 页码的参数名称
default-page: 1 # 未传页码时的默认首页
default-size: 10 # 未传页大小时的默认页大小
debug:
timeout: 60 # 断点超时时间默认60s
throw-exception: true # 执行出错时,异常将抛出处理
auto-import-module: db,http,log,request,response,env,magic #自动导入模块

View File

@ -0,0 +1,21 @@
var MAGIC_EDITOR_CONFIG = {
title: 'Admin Web IDE',
header: {
skin: true, // 屏蔽皮肤按钮
document: false, // 屏蔽文档按钮
repo: false, // 屏蔽gitee和github
qqGroup: false // 屏蔽加入QQ群
},
// 其它配置参考本页中其它配置项
request: {
beforeSend: function (config) {
// console.log('请求设置', window.location.href);
config.headers.Authorization = "Bearer " + window.location.href.split('Authorization=')[1];
return config;
},
onError: function (err) {
// console.log('请求出错');
return Promise.reject(err)
}
},
}