237 changed files with 11440 additions and 2 deletions
@ -0,0 +1,21 @@
|
||||
# http://editorconfig.org |
||||
root = true |
||||
|
||||
# 空格替代Tab缩进在各种编辑工具下效果一致 |
||||
[*] |
||||
indent_style = space |
||||
indent_size = 4 |
||||
charset = utf-8 |
||||
end_of_line = lf |
||||
trim_trailing_whitespace = true |
||||
insert_final_newline = true |
||||
|
||||
[*.java] |
||||
indent_style = tab |
||||
|
||||
[*.{json,yml}] |
||||
indent_size = 2 |
||||
|
||||
[*.md] |
||||
insert_final_newline = false |
||||
trim_trailing_whitespace = false |
@ -0,0 +1,27 @@
|
||||
# maven # |
||||
target |
||||
|
||||
logs |
||||
|
||||
# windows # |
||||
Thumbs.db |
||||
|
||||
# Mac # |
||||
.DS_Store |
||||
|
||||
# eclipse # |
||||
.settings |
||||
.project |
||||
.classpath |
||||
.log |
||||
*.class |
||||
|
||||
# idea # |
||||
.idea |
||||
*.iml |
||||
|
||||
# Package Files # |
||||
*.jar |
||||
*.war |
||||
*.ear |
||||
/target |
@ -0,0 +1,32 @@
|
||||
BladeX商业授权许可协议 |
||||
|
||||
一、 知识产权: |
||||
BladeX系列产品知识产权归如梦技术团队独立所有 |
||||
|
||||
二、 许可: |
||||
1. 在您完全接受并遵守本协议的基础上,本协议授予您使用BladeX的某些权利和非独占性许可。 |
||||
2. 本协议中,将本产品使用用途分为“专业版用途”和“企业版用途”。 |
||||
3. “专业版用途”定义:指个人在非团体机构中使用本产品并用于商业目的。 |
||||
4. “企业版用途”定义:指团体机构(例如公司企业、政府、学校、军队、医院、社会团体等各类组织)出于任何目的使用本产品(任何目的包括商业目的或非盈利目的)。 |
||||
|
||||
三、 约束和限制: |
||||
1. 本产品只能由您为本协议许可的目的而使用,您不得透露给任何第三方; |
||||
2. 从本产品取得的任何信息、软件、产品或服务,您不得对其进行修改、改编或基于以上内容创建衍生产品并售卖。 |
||||
3. 您不得对本产品以及与之关联的商业授权进行发布、出租、销售、分销、抵押、转让、许可或发放子许可证。 |
||||
4. 本产品商业授权版可能包含一些独立功能或特性,这些功能只有在您购买商业授权后才可以使用。在未取得商业授权的情况下,您不得使用、尝试使用或复制这些授权版独立功能。 |
||||
|
||||
四、 不得用于非法或禁止的用途: |
||||
您在使用本产品或服务时,不得将本产品产品或服务用于任何非法用途或本协议条款、条件和声明禁止的用途。 |
||||
|
||||
五、 免责说明: |
||||
1. 本产品按“现状”授予许可,您须自行承担使用本产品的风险。如梦技术团队不对此提供任何明示、暗示或任何其它形式的担保和表示。在任何情况下,对于因使用或无法使用本软件而导致的任何损失(包括但不仅限于商业利润损失、业务中断或业务信息丢失),如梦技术团队无需向您或任何第三方负责,即使如梦技术团队已被告知可能会造成此类损失。在任何情况下, 如梦技术团队均不就任何直接的、间接的、附带的、后果性的、特别的、惩戒性的和处罚性的损害赔偿承担任何责任,无论该主张是基于保证、合同、侵权(包括疏忽)或是基于其他原因作出。 |
||||
2. 本产品可能内置有第三方服务,您应自行评估使用这些第三方服务的风险,由使用此类第三方服务而产生的纠纷,全部责任由您自行承担。 |
||||
3. 如梦技术团队不对使用本产品构建的网站中任何信息内容以及导致的任何版权纠纷、法律争议和后果承担任何责任,全部责任由您自行承担。 |
||||
4. 如梦技术团队可能会经常提供产品更新或升级,但如梦技术团队没有为根据本协议许可的产品提供维护或更新的责任。 |
||||
|
||||
六、 权利和所有权的保留: |
||||
如梦技术团队保留所有未在本协议中明确授予您的所有权利。如梦技术团队保留随时更新本协议的权利,并只需公示于对应产品项目的LICENSE文件,无需征得您的事先同意且无需另行通知,更新后的内容应于公示即时生效。您可以随时访问产品地址并查阅最新版许可条款,在更新生效后您继续使用本产品则被视作您已接受了新的条款。 |
||||
|
||||
七、 协议终止 |
||||
1. 您一旦开始复制、下载、安装或者使用本产品,即被视为完全理解并接受本协议的各项条款,在享有上述条款授予的许可权力同时,也受到相关的约束和限制,本协议许可范围以外的行为,将直接违反本协议并构成侵权。 |
||||
2. 一旦您违反本协议的条款,如梦技术团队随时可能终止本协议、收回许可和授权,并要求您承担相应法律和经济责任。 |
@ -1,3 +1,126 @@
|
||||
# BladeX |
||||
## BladeX是什么 |
||||
* BladeX 是一个基于 Spring Boot 2 & Spring Cloud Greenwich & Mybatis 等核心技术,用于快速构建中大型系统的基础框架 |
||||
* 已稳定生产近一年,经历了从Camden->Greenwich的技术架构,也经历了从FatJar->Docker->K8S+Jenkins的部署架构 |
||||
* 采用前后端分离的模式,前端开发两个框架:Sword(基于React、Ant Design)、Saber(基于Vue、ElementUI) |
||||
* 后端采用SpringCloud系列,对其基础组件做了高度的封装,单独出一个后端核心框架:BladeX-Tool |
||||
* BladeX-Tool已推送至Maven私有库,直接引入减少工程的模块与依赖,可更注重于业务开发 |
||||
* 集成Sentinel从流量控制、熔断降级、系统负载保护等多个维度保护服务的稳定性 |
||||
* 注册中心、配置中心选型Nacos,为工程瘦身的同时加强各模块之间的联动 |
||||
* 使用Traefik进行反向代理,监听后台变化自动化应用新的配置文件 |
||||
* 集成Oauth2协议,完美支持了多终端的接入与认证授权 |
||||
* 集成工作流Flowable,复杂流程需求不再难办 |
||||
* 创建多租户模式,发布简单,数据隔离轻松 |
||||
* 项目分包明确,规范微服务的开发模式 |
||||
|
||||
周末即将开放 |
||||
## 官网 |
||||
* 官网地址:[https://bladex.vip](https://bladex.vip) |
||||
|
||||
## 在线演示 |
||||
* Sword演示地址:[https://sword.bladex.vip](https://sword.bladex.vip) |
||||
* Saber演示地址:[https://saber.avue.top](https://saber.avue.top) |
||||
|
||||
## 后端项目地址 |
||||
* [BladeX](https://gitee.ltd/blade/BladeX) |
||||
|
||||
## 单工程SpringBoot版 |
||||
* [BladeX-Boot](https://gitee.ltd/blade/BladeX-Boot) |
||||
|
||||
## 前端项目地址 |
||||
* [Sword--基于React](https://gitee.ltd/blade/Sword) |
||||
* [Saber--基于Vue](https://gitee.ltd/blade/Saber) |
||||
|
||||
## 会员计划及交流群 |
||||
* [会员计划及交流群](https://gitee.com/smallc/SpringBlade/wikis/SpringBlade会员计划) |
||||
|
||||
## 技术文档 |
||||
* [Blade开发手册](https://www.kancloud.cn/smallchill/blade) |
||||
|
||||
## 工程结构 |
||||
``` |
||||
BladeX |
||||
├── blade-auth -- 授权服务提供 |
||||
├── blade-common -- 常用工具封装包 |
||||
├── blade-gateway -- Spring Cloud 网关 |
||||
├── blade-ops -- 运维中心 |
||||
├ ├── blade-admin -- spring-cloud后台管理 |
||||
├ ├── blade-develop -- 代码生成 |
||||
├── blade-service -- 业务模块 |
||||
├ ├── blade-desk -- 工作台模块 |
||||
├ ├── blade-log -- 日志模块 |
||||
├ ├── blade-system -- 系统模块 |
||||
├ └── blade-user -- 用户模块 |
||||
├── blade-service-api -- 业务模块api封装 |
||||
├ ├── blade-desk-api -- 工作台api |
||||
├ ├── blade-dict-api -- 字典api |
||||
├ ├── blade-system-api -- 系统api |
||||
└── └── blade-user-api -- 用户api |
||||
``` |
||||
|
||||
# 界面 |
||||
## 监控界面一览 |
||||
<table> |
||||
<tr> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-k8s1.png"/></td> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-k8s2.png"/></td> |
||||
</tr> |
||||
<tr> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-grafana.png"/></td> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-harbor.png"/></td> |
||||
</tr> |
||||
<tr> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-traefik.png"/></td> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-traefik-health.png"/></td> |
||||
</tr> |
||||
<tr> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-nacos.png"/></td> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-sentinel.png"/></td> |
||||
</tr> |
||||
<tr> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-admin1.png"/></td> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-admin2.png"/></td> |
||||
</tr> |
||||
<tr> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-swagger1.png"/></td> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-swagger2.png"/></td> |
||||
</tr> |
||||
</table> |
||||
|
||||
## Sword界面一览 |
||||
<table> |
||||
<tr> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-main.png"/></td> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-menu.png"/></td> |
||||
</tr> |
||||
<tr> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-menu-edit.png"/></td> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-menu-icon.png"/></td> |
||||
</tr> |
||||
<tr> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-role.png"/></td> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-user.png"/></td> |
||||
</tr> |
||||
<tr> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-dict.png "/></td> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-log.png"/></td> |
||||
</tr> |
||||
<tr> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-locale-cn.png"/></td> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-locale-us.png"/></td> |
||||
</tr> |
||||
</table> |
||||
|
||||
## Saber界面一览 |
||||
<table> |
||||
<tr> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-user.png"/></td> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-role.png"/></td> |
||||
</tr> |
||||
<tr> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-dict.png"/></td> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-dict-select.png"/></td> |
||||
</tr> |
||||
<tr> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-log.png"/></td> |
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-code.png"/></td> |
||||
</tr> |
||||
</table> |
@ -0,0 +1,15 @@
|
||||
FROM anapsix/alpine-java:8_server-jre_unlimited |
||||
|
||||
MAINTAINER smallchill@163.com |
||||
|
||||
RUN mkdir -p /blade/auth |
||||
|
||||
WORKDIR /blade/auth |
||||
|
||||
EXPOSE 8010 |
||||
|
||||
ADD ./target/blade-auth.jar ./app.jar |
||||
|
||||
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"] |
||||
|
||||
CMD ["--spring.profiles.active=test"] |
@ -0,0 +1,78 @@
|
||||
<?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"> |
||||
|
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<parent> |
||||
<artifactId>BladeX</artifactId> |
||||
<groupId>org.springblade</groupId> |
||||
<version>2.0.0.RC1</version> |
||||
</parent> |
||||
|
||||
<artifactId>blade-auth</artifactId> |
||||
<name>${project.artifactId}</name> |
||||
<version>${bladex.project.version}</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
<dependencies> |
||||
<!--Blade--> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-common</artifactId> |
||||
<version>${bladex.project.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-cloud</artifactId> |
||||
<version>${bladex.tool.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-secure</artifactId> |
||||
<version>${bladex.tool.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-starter-log</artifactId> |
||||
<version>${bladex.tool.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-user-api</artifactId> |
||||
<version>${bladex.project.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-starter-swagger</artifactId> |
||||
<version>${bladex.tool.version}</version> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>com.spotify</groupId> |
||||
<artifactId>docker-maven-plugin</artifactId> |
||||
<version>${docker.plugin.version}</version> |
||||
<configuration> |
||||
<imageName>${docker.registry.url}/blade/${project.artifactId}:${project.version}</imageName> |
||||
<dockerDirectory>${project.basedir}</dockerDirectory> |
||||
<dockerHost>${docker.registry.host}</dockerHost> |
||||
<resources> |
||||
<resource> |
||||
<targetPath>/</targetPath> |
||||
<directory>${project.build.directory}</directory> |
||||
<include>${project.build.finalName}.jar</include> |
||||
</resource> |
||||
</resources> |
||||
<registryUrl>${docker.registry.url}</registryUrl> |
||||
<serverId>${docker.registry.url}</serverId> |
||||
<pushImage>true</pushImage> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
|
||||
</project> |
@ -0,0 +1,38 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.auth; |
||||
|
||||
|
||||
import org.springblade.core.launch.BladeApplication; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springframework.cloud.client.SpringCloudApplication; |
||||
import org.springframework.cloud.openfeign.EnableFeignClients; |
||||
|
||||
/** |
||||
* 用户认证服务器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@SpringCloudApplication |
||||
@EnableFeignClients(AppConstant.BASE_PACKAGES) |
||||
public class AuthApplication { |
||||
|
||||
public static void main(String[] args) { |
||||
BladeApplication.run(AppConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,40 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.auth.config; |
||||
|
||||
|
||||
import org.springblade.core.secure.registry.SecureRegistry; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||
|
||||
/** |
||||
* secure模块api放行配置 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Configuration |
||||
public class RegistryConfiguration implements WebMvcConfigurer { |
||||
|
||||
@Bean |
||||
public SecureRegistry secureRegistry() { |
||||
SecureRegistry secureRegistry = new SecureRegistry(); |
||||
secureRegistry.excludePathPatterns("/token/**"); |
||||
return secureRegistry; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,94 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.auth.controller; |
||||
|
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.log.annotation.ApiLog; |
||||
import org.springblade.core.secure.AuthInfo; |
||||
import org.springblade.core.secure.utils.SecureUtil; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.DigestUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.system.user.entity.User; |
||||
import org.springblade.system.user.entity.UserInfo; |
||||
import org.springblade.system.user.feign.IUserClient; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 认证模块 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@Api(value = "用户授权认证", tags = "授权接口") |
||||
public class AuthController { |
||||
|
||||
IUserClient client; |
||||
|
||||
@ApiLog("登录用户验证") |
||||
@PostMapping("token") |
||||
@ApiOperation(value = "获取认证token", notes = "传入账号:account,密码:password") |
||||
public R<AuthInfo> token(@ApiParam(value = "账号", required = true) @RequestParam String account, |
||||
@ApiParam(value = "密码", required = true) @RequestParam String password) { |
||||
|
||||
if (Func.hasEmpty(account, password)) { |
||||
return R.fail("接口调用不合法"); |
||||
} |
||||
|
||||
R<UserInfo> res = client.userInfo(account, DigestUtil.encrypt(password)); |
||||
|
||||
User user = res.getData().getUser(); |
||||
|
||||
//验证用户
|
||||
if (user == null) { |
||||
return R.fail("用户名或密码不正确"); |
||||
} |
||||
|
||||
//设置jwt参数
|
||||
Map<String, String> param = new HashMap<>(16); |
||||
param.put(SecureUtil.USER_ID, Func.toStr(user.getId())); |
||||
param.put(SecureUtil.ROLE_ID, user.getRoleId()); |
||||
param.put(SecureUtil.ACCOUNT, user.getAccount()); |
||||
param.put(SecureUtil.USER_NAME, user.getRealName()); |
||||
param.put(SecureUtil.ROLE_NAME, Func.join(res.getData().getRoles())); |
||||
|
||||
//拼装accessToken
|
||||
String accessToken = SecureUtil.createJWT(param, "audience", "issuser", true); |
||||
|
||||
//返回accessToken
|
||||
AuthInfo authInfo = new AuthInfo(); |
||||
authInfo.setAccount(user.getAccount()); |
||||
authInfo.setUserName(user.getRealName()); |
||||
authInfo.setAuthority(Func.join(res.getData().getRoles())); |
||||
authInfo.setAccessToken(accessToken); |
||||
authInfo.setTokenType(SecureUtil.BEARER); |
||||
//设置token过期时间
|
||||
authInfo.setExpiresIn(SecureUtil.getExpire()); |
||||
return R.data(authInfo); |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,52 @@
|
||||
<?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>BladeX</artifactId> |
||||
<groupId>org.springblade</groupId> |
||||
<version>2.0.0.RC1</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>blade-common</artifactId> |
||||
<name>${project.artifactId}</name> |
||||
<version>${bladex.project.version}</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-launch</artifactId> |
||||
<version>${bladex.tool.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-auto</artifactId> |
||||
<version>${bladex.tool.version}</version> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
<configuration> |
||||
<skip>true</skip> |
||||
<finalName>${project.name}</finalName> |
||||
</configuration> |
||||
</plugin> |
||||
<plugin> |
||||
<groupId>com.spotify</groupId> |
||||
<artifactId>docker-maven-plugin</artifactId> |
||||
<version>${docker.plugin.version}</version> |
||||
<configuration> |
||||
<skipDockerBuild>true</skipDockerBuild> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
|
||||
</project> |
@ -0,0 +1,31 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.common.cache; |
||||
|
||||
/** |
||||
* 缓存名 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface CacheNames { |
||||
|
||||
String NOTICE_ONE = "NOTICE_ONE"; |
||||
|
||||
String DICT_VALUE = "DICT_VALUE"; |
||||
String DICT_LIST = "DICT_LIST"; |
||||
|
||||
} |
@ -0,0 +1,32 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.common.config; |
||||
|
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
/** |
||||
* 公共封装包配置类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Configuration |
||||
@AllArgsConstructor |
||||
public class BladeCommonConfiguration { |
||||
|
||||
} |
@ -0,0 +1,46 @@
|
||||
package org.springblade.common.constant; |
||||
|
||||
/** |
||||
* 通用常量 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface CommonConstant { |
||||
|
||||
/** |
||||
* nacos dev 地址 |
||||
*/ |
||||
String NACOS_DEV_ADDR = "127.0.0.1:8848"; |
||||
|
||||
/** |
||||
* nacos prod 地址 |
||||
*/ |
||||
String NACOS_PROD_ADDR = "192.168.186.129:8848"; |
||||
|
||||
/** |
||||
* sentinel dev 地址 |
||||
*/ |
||||
String SENTINEL_DEV_ADDR = "127.0.0.1:8858"; |
||||
|
||||
/** |
||||
* sentinel prod 地址 |
||||
*/ |
||||
String SENTINEL_PROD_ADDR = "192.168.186.129:8858"; |
||||
|
||||
/** |
||||
* 顶级父节点id |
||||
*/ |
||||
Integer TOP_PARENT_ID = 0; |
||||
|
||||
/** |
||||
* 顶级父节点名称 |
||||
*/ |
||||
String TOP_PARENT_NAME = "顶级"; |
||||
|
||||
|
||||
/** |
||||
* 默认密码 |
||||
*/ |
||||
String DEFAULT_PASSWORD = "123456"; |
||||
|
||||
} |
@ -0,0 +1,43 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.common.launch; |
||||
|
||||
import org.springblade.common.constant.CommonConstant; |
||||
import org.springblade.core.auto.service.AutoService; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.launch.service.LauncherService; |
||||
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||
|
||||
import java.util.Properties; |
||||
|
||||
/** |
||||
* 启动参数拓展 |
||||
* |
||||
* @author smallchil |
||||
*/ |
||||
@AutoService(LauncherService.class) |
||||
public class LauncherServiceImpl implements LauncherService { |
||||
|
||||
@Override |
||||
public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) { |
||||
Properties props = System.getProperties(); |
||||
props.setProperty("spring.cloud.nacos.discovery.server-addr", profile.equals(AppConstant.DEV_CDOE) ? CommonConstant.NACOS_DEV_ADDR : CommonConstant.NACOS_PROD_ADDR); |
||||
props.setProperty("spring.cloud.nacos.config.server-addr", profile.equals(AppConstant.DEV_CDOE) ? CommonConstant.NACOS_DEV_ADDR : CommonConstant.NACOS_PROD_ADDR); |
||||
props.setProperty("spring.cloud.sentinel.transport.dashboard", profile.equals(AppConstant.DEV_CDOE) ? CommonConstant.SENTINEL_DEV_ADDR : CommonConstant.SENTINEL_PROD_ADDR); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,26 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.common.tool; |
||||
|
||||
/** |
||||
* 通用工具类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public class CommonUtil { |
||||
|
||||
} |
@ -0,0 +1,8 @@
|
||||
${AnsiColor.BLUE} ______ _ _ ___ ___ |
||||
${AnsiColor.BLUE} | ___ \| | | | \ \ / / |
||||
${AnsiColor.BLUE} | |_/ /| | __ _ __| | ___ \ V / |
||||
${AnsiColor.BLUE} | ___ \| | / _` | / _` | / _ \ > < |
||||
${AnsiColor.BLUE} | |_/ /| || (_| || (_| || __/ / . \ |
||||
${AnsiColor.BLUE} \____/ |_| \__,_| \__,_| \___|/__/ \__\ |
||||
|
||||
${AnsiColor.BLUE}:: BladeX :: ${spring.application.name}:${AnsiColor.RED}${blade.env}${AnsiColor.BLUE} :: Running SpringBoot ${spring-boot.version} :: ${AnsiColor.BRIGHT_BLACK} |
@ -0,0 +1,15 @@
|
||||
FROM anapsix/alpine-java:8_server-jre_unlimited |
||||
|
||||
MAINTAINER smallchill@163.com |
||||
|
||||
RUN mkdir -p /blade/gateway |
||||
|
||||
WORKDIR /blade/gateway |
||||
|
||||
EXPOSE 80 |
||||
|
||||
ADD ./target/blade-gateway.jar ./app.jar |
||||
|
||||
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"] |
||||
|
||||
CMD ["--spring.profiles.active=test"] |
@ -0,0 +1,123 @@
|
||||
<?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>BladeX</artifactId> |
||||
<groupId>org.springblade</groupId> |
||||
<version>2.0.0.RC1</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>blade-gateway</artifactId> |
||||
<name>${project.artifactId}</name> |
||||
<version>${bladex.project.version}</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
<dependencies> |
||||
<!--Blade--> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-launch</artifactId> |
||||
<version>${bladex.tool.version}</version> |
||||
<exclusions> |
||||
<exclusion> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-web</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-undertow</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-common</artifactId> |
||||
<version>${bladex.project.version}</version> |
||||
<exclusions> |
||||
<exclusion> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-launch</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
<!--Spring--> |
||||
<dependency> |
||||
<groupId>org.springframework.cloud</groupId> |
||||
<artifactId>spring-cloud-starter-gateway</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-data-redis-reactive</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>de.codecentric</groupId> |
||||
<artifactId>spring-boot-admin-starter-client</artifactId> |
||||
<version>${spring.boot.admin.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.cloud</groupId> |
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
||||
<version>${alibaba.cloud.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.cloud</groupId> |
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
||||
<version>${alibaba.cloud.version}</version> |
||||
</dependency> |
||||
<!--Swagger--> |
||||
<dependency> |
||||
<groupId>io.springfox</groupId> |
||||
<artifactId>springfox-swagger2</artifactId> |
||||
<version>${swagger.version}</version> |
||||
<exclusions> |
||||
<exclusion> |
||||
<groupId>io.swagger</groupId> |
||||
<artifactId>swagger-models</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.swagger</groupId> |
||||
<artifactId>swagger-models</artifactId> |
||||
<version>${swagger.models.version}</version> |
||||
</dependency> |
||||
<!--<dependency> |
||||
<groupId>io.springfox</groupId> |
||||
<artifactId>springfox-swagger-ui</artifactId> |
||||
<version>${swagger.version}</version> |
||||
</dependency>--> |
||||
<dependency> |
||||
<groupId>com.github.xiaoymin</groupId> |
||||
<artifactId>swagger-bootstrap-ui</artifactId> |
||||
<version>${swagger.bootstrapui.version}</version> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>com.spotify</groupId> |
||||
<artifactId>docker-maven-plugin</artifactId> |
||||
<version>${docker.plugin.version}</version> |
||||
<configuration> |
||||
<imageName>${docker.registry.url}/blade/${project.artifactId}:${project.version}</imageName> |
||||
<dockerDirectory>${project.basedir}</dockerDirectory> |
||||
<dockerHost>${docker.registry.host}</dockerHost> |
||||
<resources> |
||||
<resource> |
||||
<targetPath>/</targetPath> |
||||
<directory>${project.build.directory}</directory> |
||||
<include>${project.build.finalName}.jar</include> |
||||
</resource> |
||||
</resources> |
||||
<registryUrl>${docker.registry.url}</registryUrl> |
||||
<serverId>${docker.registry.url}</serverId> |
||||
<pushImage>true</pushImage> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
|
||||
</project> |
@ -0,0 +1,39 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.gateway; |
||||
|
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.launch.BladeApplication; |
||||
import org.springframework.cloud.client.SpringCloudApplication; |
||||
import org.springframework.cloud.netflix.hystrix.EnableHystrix; |
||||
import org.springframework.scheduling.annotation.EnableScheduling; |
||||
|
||||
/** |
||||
* 项目启动 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@EnableHystrix |
||||
@EnableScheduling |
||||
@SpringCloudApplication |
||||
public class GateWayApplication { |
||||
|
||||
public static void main(String[] args) { |
||||
BladeApplication.run(AppConstant.APPLICATION_GATEWAY_NAME, GateWayApplication.class, args); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,86 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.gateway.config; |
||||
|
||||
|
||||
import org.springblade.gateway.handler.ErrorExceptionHandler; |
||||
import org.springframework.beans.factory.ObjectProvider; |
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore; |
||||
import org.springframework.boot.autoconfigure.web.ResourceProperties; |
||||
import org.springframework.boot.autoconfigure.web.ServerProperties; |
||||
import org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.boot.web.reactive.error.ErrorAttributes; |
||||
import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler; |
||||
import org.springframework.context.ApplicationContext; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.core.Ordered; |
||||
import org.springframework.core.annotation.Order; |
||||
import org.springframework.http.codec.ServerCodecConfigurer; |
||||
import org.springframework.web.reactive.result.view.ViewResolver; |
||||
|
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 异常处理配置类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Configuration |
||||
@AutoConfigureBefore(ErrorWebFluxAutoConfiguration.class) |
||||
@EnableConfigurationProperties({ServerProperties.class, ResourceProperties.class}) |
||||
public class ErrorHandlerConfiguration { |
||||
|
||||
private final ServerProperties serverProperties; |
||||
|
||||
private final ApplicationContext applicationContext; |
||||
|
||||
private final ResourceProperties resourceProperties; |
||||
|
||||
private final List<ViewResolver> viewResolvers; |
||||
|
||||
private final ServerCodecConfigurer serverCodecConfigurer; |
||||
|
||||
public ErrorHandlerConfiguration(ServerProperties serverProperties, |
||||
ResourceProperties resourceProperties, |
||||
ObjectProvider<List<ViewResolver>> viewResolversProvider, |
||||
ServerCodecConfigurer serverCodecConfigurer, |
||||
ApplicationContext applicationContext) { |
||||
this.serverProperties = serverProperties; |
||||
this.applicationContext = applicationContext; |
||||
this.resourceProperties = resourceProperties; |
||||
this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList); |
||||
this.serverCodecConfigurer = serverCodecConfigurer; |
||||
} |
||||
|
||||
@Bean |
||||
@Order(Ordered.HIGHEST_PRECEDENCE) |
||||
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) { |
||||
ErrorExceptionHandler exceptionHandler = new ErrorExceptionHandler( |
||||
errorAttributes, |
||||
this.resourceProperties, |
||||
this.serverProperties.getError(), |
||||
this.applicationContext); |
||||
exceptionHandler.setViewResolvers(this.viewResolvers); |
||||
exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters()); |
||||
exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders()); |
||||
return exceptionHandler; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,38 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
|
||||
package org.springblade.gateway.config; |
||||
|
||||
import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import reactor.core.publisher.Mono; |
||||
|
||||
/** |
||||
* 路由限流配置 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Configuration |
||||
public class RateLimiterConfiguration { |
||||
|
||||
@Bean(value = "remoteAddrKeyResolver") |
||||
public KeyResolver remoteAddrKeyResolver() { |
||||
return exchange -> Mono.just(exchange.getRequest().getRemoteAddress().getAddress().getHostAddress()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,115 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
|
||||
package org.springblade.gateway.config; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.gateway.handler.*; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.http.HttpHeaders; |
||||
import org.springframework.http.HttpMethod; |
||||
import org.springframework.http.HttpStatus; |
||||
import org.springframework.http.MediaType; |
||||
import org.springframework.http.server.reactive.ServerHttpRequest; |
||||
import org.springframework.http.server.reactive.ServerHttpResponse; |
||||
import org.springframework.web.cors.reactive.CorsUtils; |
||||
import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; |
||||
import org.springframework.web.reactive.function.server.RequestPredicates; |
||||
import org.springframework.web.reactive.function.server.RouterFunction; |
||||
import org.springframework.web.reactive.function.server.RouterFunctions; |
||||
import org.springframework.web.server.ServerWebExchange; |
||||
import org.springframework.web.server.WebFilter; |
||||
import org.springframework.web.server.WebFilterChain; |
||||
import reactor.core.publisher.Mono; |
||||
|
||||
/** |
||||
* 路由配置信息 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Slf4j |
||||
@Configuration |
||||
@AllArgsConstructor |
||||
public class RouterFunctionConfiguration { |
||||
|
||||
/** |
||||
* 这里为支持的请求头,如果有自定义的header字段请自己添加 |
||||
*/ |
||||
private static final String ALLOWED_HEADERS = "x-requested-with, blade-auth, Content-Type, Authorization, credential, X-XSRF-TOKEN, token, username, client"; |
||||
private static final String ALLOWED_METHODS = "*"; |
||||
private static final String ALLOWED_ORIGIN = "*"; |
||||
private static final String ALLOWED_EXPOSE = "*"; |
||||
private static final String MAX_AGE = "18000L"; |
||||
|
||||
private final HystrixFallbackHandler hystrixFallbackHandler; |
||||
private final SwaggerResourceHandler swaggerResourceHandler; |
||||
private final SwaggerSecurityHandler swaggerSecurityHandler; |
||||
private final SwaggerUiHandler swaggerUiHandler; |
||||
|
||||
@Bean |
||||
public WebFilter corsFilter() { |
||||
return (ServerWebExchange ctx, WebFilterChain chain) -> { |
||||
ServerHttpRequest request = ctx.getRequest(); |
||||
if (CorsUtils.isCorsRequest(request)) { |
||||
ServerHttpResponse response = ctx.getResponse(); |
||||
HttpHeaders headers = response.getHeaders(); |
||||
headers.add("Access-Control-Allow-Headers", ALLOWED_HEADERS); |
||||
headers.add("Access-Control-Allow-Methods", ALLOWED_METHODS); |
||||
headers.add("Access-Control-Allow-Origin", ALLOWED_ORIGIN); |
||||
headers.add("Access-Control-Expose-Headers", ALLOWED_EXPOSE); |
||||
headers.add("Access-Control-Max-Age", MAX_AGE); |
||||
headers.add("Access-Control-Allow-Credentials", "true"); |
||||
if (request.getMethod() == HttpMethod.OPTIONS) { |
||||
response.setStatusCode(HttpStatus.OK); |
||||
return Mono.empty(); |
||||
} |
||||
} |
||||
return chain.filter(ctx); |
||||
}; |
||||
} |
||||
|
||||
@Bean |
||||
public RouterFunction routerFunction() { |
||||
return RouterFunctions.route( |
||||
RequestPredicates.path("/fallback") |
||||
.and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), hystrixFallbackHandler) |
||||
.andRoute(RequestPredicates.GET("/swagger-resources") |
||||
.and(RequestPredicates.accept(MediaType.ALL)), swaggerResourceHandler) |
||||
.andRoute(RequestPredicates.GET("/swagger-resources/configuration/ui") |
||||
.and(RequestPredicates.accept(MediaType.ALL)), swaggerUiHandler) |
||||
.andRoute(RequestPredicates.GET("/swagger-resources/configuration/security") |
||||
.and(RequestPredicates.accept(MediaType.ALL)), swaggerSecurityHandler); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 解决springboot2.0.5版本出现的 Only one connection receive subscriber allowed. |
||||
* 参考:https://github.com/spring-cloud/spring-cloud-gateway/issues/541
|
||||
*/ |
||||
@Bean |
||||
public HiddenHttpMethodFilter hiddenHttpMethodFilter() { |
||||
return new HiddenHttpMethodFilter() { |
||||
@Override |
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) { |
||||
return chain.filter(exchange); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,58 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.gateway.controller; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.cloud.client.ServiceInstance; |
||||
import org.springframework.cloud.client.discovery.DiscoveryClient; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 服务发现控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Slf4j |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/discovery") |
||||
public class DiscoveryClientController { |
||||
|
||||
private final DiscoveryClient discoveryClient; |
||||
|
||||
/** |
||||
* 获取服务实例 |
||||
*/ |
||||
@GetMapping("/instances") |
||||
public Map<String, List<ServiceInstance>> instances() { |
||||
Map<String, List<ServiceInstance>> instances = new HashMap<>(16); |
||||
List<String> services = discoveryClient.getServices(); |
||||
services.forEach(s -> { |
||||
List<ServiceInstance> list = discoveryClient.getInstances(s); |
||||
instances.put(s, list); |
||||
}); |
||||
return instances; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,63 @@
|
||||
package org.springblade.gateway.filter; |
||||
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
||||
import org.springframework.cloud.gateway.filter.GlobalFilter; |
||||
import org.springframework.core.Ordered; |
||||
import org.springframework.http.server.reactive.ServerHttpRequest; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.util.StringUtils; |
||||
import org.springframework.web.server.ServerWebExchange; |
||||
import reactor.core.publisher.Mono; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.stream.Collectors; |
||||
|
||||
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR; |
||||
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.addOriginalRequestUrl; |
||||
|
||||
/** |
||||
* <p> |
||||
* 全局拦截器,作用所有的微服务 |
||||
* <p> |
||||
* 1. 对请求头中参数进行处理 from 参数进行清洗 |
||||
* 2. 重写StripPrefix = 1,支持全局 |
||||
* |
||||
* @author lengleng |
||||
*/ |
||||
@Component |
||||
public class RequestGlobalFilter implements GlobalFilter, Ordered { |
||||
|
||||
/** |
||||
* Process the Web request and (optionally) delegate to the next |
||||
* {@code WebFilter} through the given {@link GatewayFilterChain}. |
||||
* |
||||
* @param exchange the current server exchange |
||||
* @param chain provides a way to delegate to the next filter |
||||
* @return {@code Mono<Void>} to indicate when request processing is complete |
||||
*/ |
||||
@Override |
||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
||||
// 1. 清洗请求头中from 参数
|
||||
ServerHttpRequest request = exchange.getRequest().mutate() |
||||
.headers(httpHeaders -> httpHeaders.remove("X")) |
||||
.build(); |
||||
|
||||
// 2. 重写StripPrefix
|
||||
addOriginalRequestUrl(exchange, request.getURI()); |
||||
String rawPath = request.getURI().getRawPath(); |
||||
String newPath = "/" + Arrays.stream(StringUtils.tokenizeToStringArray(rawPath, "/")) |
||||
.skip(1L).collect(Collectors.joining("/")); |
||||
ServerHttpRequest newRequest = request.mutate() |
||||
.path(newPath) |
||||
.build(); |
||||
exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, newRequest.getURI()); |
||||
|
||||
return chain.filter(exchange.mutate().request(newRequest.mutate().build()).build()); |
||||
} |
||||
|
||||
@Override |
||||
public int getOrder() { |
||||
return -1000; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,116 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.gateway.handler; |
||||
|
||||
import org.springframework.boot.autoconfigure.web.ErrorProperties; |
||||
import org.springframework.boot.autoconfigure.web.ResourceProperties; |
||||
import org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler; |
||||
import org.springframework.boot.web.reactive.error.ErrorAttributes; |
||||
import org.springframework.cloud.gateway.support.NotFoundException; |
||||
import org.springframework.context.ApplicationContext; |
||||
import org.springframework.http.HttpStatus; |
||||
import org.springframework.web.reactive.function.server.*; |
||||
import org.springframework.web.server.ResponseStatusException; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 异常处理 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public class ErrorExceptionHandler extends DefaultErrorWebExceptionHandler { |
||||
|
||||
public ErrorExceptionHandler(ErrorAttributes errorAttributes, ResourceProperties resourceProperties, |
||||
ErrorProperties errorProperties, ApplicationContext applicationContext) { |
||||
super(errorAttributes, resourceProperties, errorProperties, applicationContext); |
||||
} |
||||
|
||||
/** |
||||
* 获取异常属性 |
||||
*/ |
||||
@Override |
||||
protected Map<String, Object> getErrorAttributes(ServerRequest request, boolean includeStackTrace) { |
||||
int code = 500; |
||||
Throwable error = super.getError(request); |
||||
if (error instanceof NotFoundException) { |
||||
code = 404; |
||||
} |
||||
if (error instanceof ResponseStatusException) { |
||||
code = ((ResponseStatusException) error).getStatus().value(); |
||||
} |
||||
return response(code, this.buildMessage(request, error)); |
||||
} |
||||
|
||||
/** |
||||
* 指定响应处理方法为JSON处理的方法 |
||||
* |
||||
* @param errorAttributes |
||||
*/ |
||||
@Override |
||||
protected RouterFunction<ServerResponse> getRoutingFunction(ErrorAttributes errorAttributes) { |
||||
return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse); |
||||
} |
||||
|
||||
/** |
||||
* 根据code获取对应的HttpStatus |
||||
* |
||||
* @param errorAttributes |
||||
*/ |
||||
@Override |
||||
protected HttpStatus getHttpStatus(Map<String, Object> errorAttributes) { |
||||
int statusCode = (int) errorAttributes.get("code"); |
||||
return HttpStatus.valueOf(statusCode); |
||||
} |
||||
|
||||
/** |
||||
* 构建异常信息 |
||||
* |
||||
* @param request |
||||
* @param ex |
||||
* @return |
||||
*/ |
||||
private String buildMessage(ServerRequest request, Throwable ex) { |
||||
StringBuilder message = new StringBuilder("Failed to handle request ["); |
||||
message.append(request.methodName()); |
||||
message.append(" "); |
||||
message.append(request.uri()); |
||||
message.append("]"); |
||||
if (ex != null) { |
||||
message.append(": "); |
||||
message.append(ex.getMessage()); |
||||
} |
||||
return message.toString(); |
||||
} |
||||
|
||||
/** |
||||
* 构建返回的JSON数据格式 |
||||
* |
||||
* @param status 状态码 |
||||
* @param errorMessage 异常信息 |
||||
* @return |
||||
*/ |
||||
public static Map<String, Object> response(int status, String errorMessage) { |
||||
Map<String, Object> map = new HashMap<>(16); |
||||
map.put("code", status); |
||||
map.put("message", errorMessage); |
||||
map.put("data", null); |
||||
return map; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,44 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
|
||||
package org.springblade.gateway.handler; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.http.HttpStatus; |
||||
import org.springframework.http.MediaType; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.reactive.function.BodyInserters; |
||||
import org.springframework.web.reactive.function.server.HandlerFunction; |
||||
import org.springframework.web.reactive.function.server.ServerRequest; |
||||
import org.springframework.web.reactive.function.server.ServerResponse; |
||||
import reactor.core.publisher.Mono; |
||||
|
||||
/** |
||||
* Hystrix 降级处理 |
||||
* |
||||
* @author lengleng |
||||
*/ |
||||
@Slf4j |
||||
@Component |
||||
public class HystrixFallbackHandler implements HandlerFunction<ServerResponse> { |
||||
@Override |
||||
public Mono<ServerResponse> handle(ServerRequest serverRequest) { |
||||
log.error("网关执行请求:{}失败,hystrix服务降级处理", serverRequest.uri()); |
||||
return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR.value()) |
||||
.contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromObject("服务异常")); |
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
|
||||
package org.springblade.gateway.handler; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.http.HttpStatus; |
||||
import org.springframework.http.MediaType; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.reactive.function.BodyInserters; |
||||
import org.springframework.web.reactive.function.server.HandlerFunction; |
||||
import org.springframework.web.reactive.function.server.ServerRequest; |
||||
import org.springframework.web.reactive.function.server.ServerResponse; |
||||
import reactor.core.publisher.Mono; |
||||
import springfox.documentation.swagger.web.SwaggerResourcesProvider; |
||||
|
||||
/** |
||||
* SwaggerResourceHandler |
||||
* |
||||
* @author lengleng |
||||
*/ |
||||
@Slf4j |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class SwaggerResourceHandler implements HandlerFunction<ServerResponse> { |
||||
private final SwaggerResourcesProvider swaggerResources; |
||||
|
||||
/** |
||||
* Handle the given request. |
||||
* |
||||
* @param request the request to handler |
||||
* @return the response |
||||
*/ |
||||
@Override |
||||
public Mono<ServerResponse> handle(ServerRequest request) { |
||||
return ServerResponse.status(HttpStatus.OK) |
||||
.contentType(MediaType.APPLICATION_JSON_UTF8) |
||||
.body(BodyInserters.fromObject(swaggerResources.get())); |
||||
} |
||||
} |
@ -0,0 +1,60 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
|
||||
package org.springblade.gateway.handler; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.http.HttpStatus; |
||||
import org.springframework.http.MediaType; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.reactive.function.BodyInserters; |
||||
import org.springframework.web.reactive.function.server.HandlerFunction; |
||||
import org.springframework.web.reactive.function.server.ServerRequest; |
||||
import org.springframework.web.reactive.function.server.ServerResponse; |
||||
import reactor.core.publisher.Mono; |
||||
import springfox.documentation.swagger.web.SecurityConfiguration; |
||||
import springfox.documentation.swagger.web.SecurityConfigurationBuilder; |
||||
|
||||
import java.util.Optional; |
||||
|
||||
/** |
||||
* SwaggerSecurityHandler |
||||
* |
||||
* @author lengleng |
||||
*/ |
||||
@Slf4j |
||||
@Component |
||||
public class SwaggerSecurityHandler implements HandlerFunction<ServerResponse> { |
||||
@Autowired(required = false) |
||||
private SecurityConfiguration securityConfiguration; |
||||
|
||||
/** |
||||
* Handle the given request. |
||||
* |
||||
* @param request the request to handler |
||||
* @return the response |
||||
*/ |
||||
@Override |
||||
public Mono<ServerResponse> handle(ServerRequest request) { |
||||
return ServerResponse.status(HttpStatus.OK) |
||||
.contentType(MediaType.APPLICATION_JSON_UTF8) |
||||
.body(BodyInserters.fromObject( |
||||
Optional.ofNullable(securityConfiguration) |
||||
.orElse(SecurityConfigurationBuilder.builder().build()))); |
||||
} |
||||
} |
@ -0,0 +1,60 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
|
||||
package org.springblade.gateway.handler; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.http.HttpStatus; |
||||
import org.springframework.http.MediaType; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.reactive.function.BodyInserters; |
||||
import org.springframework.web.reactive.function.server.HandlerFunction; |
||||
import org.springframework.web.reactive.function.server.ServerRequest; |
||||
import org.springframework.web.reactive.function.server.ServerResponse; |
||||
import reactor.core.publisher.Mono; |
||||
import springfox.documentation.swagger.web.UiConfiguration; |
||||
import springfox.documentation.swagger.web.UiConfigurationBuilder; |
||||
|
||||
import java.util.Optional; |
||||
|
||||
/** |
||||
* SwaggerUiHandler |
||||
* |
||||
* @author lengleng |
||||
*/ |
||||
@Slf4j |
||||
@Component |
||||
public class SwaggerUiHandler implements HandlerFunction<ServerResponse> { |
||||
@Autowired(required = false) |
||||
private UiConfiguration uiConfiguration; |
||||
|
||||
/** |
||||
* Handle the given request. |
||||
* |
||||
* @param request the request to handler |
||||
* @return the response |
||||
*/ |
||||
@Override |
||||
public Mono<ServerResponse> handle(ServerRequest request) { |
||||
return ServerResponse.status(HttpStatus.OK) |
||||
.contentType(MediaType.APPLICATION_JSON_UTF8) |
||||
.body(BodyInserters.fromObject( |
||||
Optional.ofNullable(uiConfiguration) |
||||
.orElse(UiConfigurationBuilder.builder().build()))); |
||||
} |
||||
} |
@ -0,0 +1,78 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
|
||||
package org.springblade.gateway.provider; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springframework.cloud.gateway.config.GatewayProperties; |
||||
import org.springframework.cloud.gateway.route.RouteLocator; |
||||
import org.springframework.cloud.gateway.support.NameUtils; |
||||
import org.springframework.context.annotation.Primary; |
||||
import org.springframework.stereotype.Component; |
||||
import springfox.documentation.swagger.web.SwaggerResource; |
||||
import springfox.documentation.swagger.web.SwaggerResourcesProvider; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 聚合接口文档注册 |
||||
* |
||||
* @author Sywd |
||||
*/ |
||||
@Primary |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class SwaggerProvider implements SwaggerResourcesProvider { |
||||
public static final String API_URI = "/v2/api-docs-ext"; |
||||
private final RouteLocator routeLocator; |
||||
private final GatewayProperties gatewayProperties; |
||||
|
||||
private static Map<String, String> routeMap = new HashMap<>(); |
||||
|
||||
static { |
||||
routeMap.put(AppConstant.APPLICATION_AUTH_NAME, "授权模块"); |
||||
routeMap.put(AppConstant.APPLICATION_DESK_NAME, "工作台模块"); |
||||
routeMap.put(AppConstant.APPLICATION_SYSTEM_NAME, "系统模块"); |
||||
} |
||||
|
||||
@Override |
||||
public List<SwaggerResource> get() { |
||||
List<SwaggerResource> resources = new ArrayList<>(); |
||||
List<String> routes = new ArrayList<>(); |
||||
routeLocator.getRoutes().subscribe(route -> routes.add(route.getId())); |
||||
gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId())) |
||||
.forEach(routeDefinition -> routeDefinition.getPredicates().stream() |
||||
.filter(predicateDefinition -> "Path".equalsIgnoreCase(predicateDefinition.getName())) |
||||
.forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(), |
||||
predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0") |
||||
.replace("/**", API_URI))))); |
||||
return resources; |
||||
} |
||||
|
||||
private SwaggerResource swaggerResource(String name, String location) { |
||||
SwaggerResource swaggerResource = new SwaggerResource(); |
||||
swaggerResource.setName((routeMap.get(name) == null ? name : routeMap.get(name))); |
||||
swaggerResource.setLocation(location); |
||||
swaggerResource.setSwaggerVersion("2.0"); |
||||
return swaggerResource; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,47 @@
|
||||
server: |
||||
port: 80 |
||||
|
||||
# 需要配置的服务名 |
||||
blade: |
||||
service: |
||||
blade-auth: blade-auth |
||||
blade-desk: blade-desk |
||||
blade-system: blade-system |
||||
|
||||
spring: |
||||
cloud: |
||||
gateway: |
||||
routes: |
||||
# 认证中心 |
||||
- id: ${blade.service.blade-auth} |
||||
uri: lb://${blade.service.blade-auth} |
||||
predicates: |
||||
- Path=/${blade.service.blade-auth}/** |
||||
filters: |
||||
- name: RequestRateLimiter |
||||
args: |
||||
# 使用SpEL按名称引用bean |
||||
key-resolver: '#{@remoteAddrKeyResolver}' |
||||
# 允许用户每秒处理多少个请求 |
||||
redis-rate-limiter.replenishRate: 10 |
||||
# 允许在一秒钟内完成的最大请求数 |
||||
redis-rate-limiter.burstCapacity: 20 |
||||
- StripPrefix=1 |
||||
# 首页模块 |
||||
- id: ${blade.service.blade-desk} |
||||
uri: lb://${blade.service.blade-desk} |
||||
predicates: |
||||
- Path=/${blade.service.blade-desk}/** |
||||
# 系统模块 |
||||
- id: ${blade.service.blade-system} |
||||
uri: lb://${blade.service.blade-system} |
||||
predicates: |
||||
- Path=/${blade.service.blade-system}/** |
||||
discovery: |
||||
locator: |
||||
enabled: true |
||||
loadbalancer: |
||||
retry: |
||||
enabled: true |
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
FROM anapsix/alpine-java:8_server-jre_unlimited |
||||
|
||||
MAINTAINER smallchill@163.com |
||||
|
||||
RUN mkdir -p /blade/admin |
||||
|
||||
WORKDIR /blade/admin |
||||
|
||||
EXPOSE 7002 |
||||
|
||||
ADD ./target/blade-admin.jar ./app.jar |
||||
|
||||
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"] |
||||
|
||||
CMD ["--spring.profiles.active=test"] |
@ -0,0 +1,67 @@
|
||||
<?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>blade-ops</artifactId> |
||||
<groupId>org.springblade</groupId> |
||||
<version>2.0.0.RC1</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>blade-admin</artifactId> |
||||
<name>${project.artifactId}</name> |
||||
<version>${bladex.project.version}</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
<dependencies> |
||||
<!--Blade--> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-common</artifactId> |
||||
<version>${bladex.project.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-launch</artifactId> |
||||
<version>${bladex.tool.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-cloud</artifactId> |
||||
<version>${bladex.tool.version}</version> |
||||
</dependency> |
||||
<!--Admin-Server--> |
||||
<dependency> |
||||
<groupId>de.codecentric</groupId> |
||||
<artifactId>spring-boot-admin-starter-server</artifactId> |
||||
<version>${spring.boot.admin.version}</version> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>com.spotify</groupId> |
||||
<artifactId>docker-maven-plugin</artifactId> |
||||
<version>${docker.plugin.version}</version> |
||||
<configuration> |
||||
<imageName>${docker.registry.url}/blade/${project.artifactId}:${project.version}</imageName> |
||||
<dockerDirectory>${project.basedir}</dockerDirectory> |
||||
<dockerHost>${docker.registry.host}</dockerHost> |
||||
<resources> |
||||
<resource> |
||||
<targetPath>/</targetPath> |
||||
<directory>${project.build.directory}</directory> |
||||
<include>${project.build.finalName}.jar</include> |
||||
</resource> |
||||
</resources> |
||||
<registryUrl>${docker.registry.url}</registryUrl> |
||||
<serverId>${docker.registry.url}</serverId> |
||||
<pushImage>true</pushImage> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
|
||||
</project> |
@ -0,0 +1,37 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.admin; |
||||
|
||||
import de.codecentric.boot.admin.server.config.EnableAdminServer; |
||||
import org.springblade.core.launch.BladeApplication; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springframework.cloud.client.SpringCloudApplication; |
||||
|
||||
/** |
||||
* admin启动器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@EnableAdminServer |
||||
@SpringCloudApplication |
||||
public class AdminApplication { |
||||
|
||||
public static void main(String[] args) { |
||||
BladeApplication.run(AppConstant.APPLICATION_ADMIN_NAME, AdminApplication.class, args); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,17 @@
|
||||
server: |
||||
port: 7002 |
||||
undertow: |
||||
# 设置IO线程数, 它主要执行非阻塞的任务,它们会负责多个连接, 默认设置每个CPU核心一个线程 |
||||
io-threads: 4 |
||||
# 阻塞任务线程池, 当执行类似servlet请求阻塞操作, undertow会从这个线程池中取得线程,它的值设置取决于系统的负载 |
||||
worker-threads: 20 |
||||
# 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理 |
||||
buffer-size: 1024 |
||||
# 是否分配的直接内存 |
||||
direct-buffers: true |
||||
|
||||
spring: |
||||
boot: |
||||
admin: |
||||
discovery: |
||||
ignored-services: consul |
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0"?> |
||||
<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> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-ops</artifactId> |
||||
<version>2.0.0.RC1</version> |
||||
</parent> |
||||
|
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>blade-develop</artifactId> |
||||
<name>${project.artifactId}</name> |
||||
<version>${bladex.project.version}</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
<dependencies> |
||||
<!--Blade--> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-boot</artifactId> |
||||
<version>${bladex.tool.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-common</artifactId> |
||||
<version>${bladex.project.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.baomidou</groupId> |
||||
<artifactId>mybatis-plus-generator</artifactId> |
||||
<version>${mybatis.plus.version}</version> |
||||
</dependency> |
||||
<!--Velocity--> |
||||
<dependency> |
||||
<groupId>org.apache.velocity</groupId> |
||||
<artifactId>velocity</artifactId> |
||||
<version>1.7</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-dict-api</artifactId> |
||||
<version>${bladex.project.version}</version> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>com.spotify</groupId> |
||||
<artifactId>docker-maven-plugin</artifactId> |
||||
<version>${docker.plugin.version}</version> |
||||
<configuration> |
||||
<skipDockerBuild>true</skipDockerBuild> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
|
||||
</project> |
@ -0,0 +1,38 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.develop; |
||||
|
||||
import org.springblade.core.launch.BladeApplication; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springframework.cloud.client.SpringCloudApplication; |
||||
import org.springframework.cloud.openfeign.EnableFeignClients; |
||||
|
||||
/** |
||||
* Develop启动器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@SpringCloudApplication |
||||
@EnableFeignClients(AppConstant.BASE_PACKAGES) |
||||
public class DevelopApplication { |
||||
|
||||
public static void main(String[] args) { |
||||
BladeApplication.run(AppConstant.APPLICATION_DEVELOP_NAME, DevelopApplication.class, args); |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,117 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.develop.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import io.swagger.annotations.*; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.develop.entity.Code; |
||||
import org.springblade.develop.service.ICodeService; |
||||
import org.springblade.develop.support.BladeGenerator; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import javax.validation.Valid; |
||||
import java.util.Collection; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 控制器 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/code") |
||||
@Api(value = "代码生成", tags = "代码生成") |
||||
public class CodeController extends BladeController { |
||||
|
||||
private ICodeService codeService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperation(value = "详情", notes = "传入code", position = 1) |
||||
public R<Code> detail(Code code) { |
||||
Code detail = codeService.getOne(Condition.getQueryWrapper(code)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiImplicitParams({ |
||||
@ApiImplicitParam(name = "codeName", value = "模块名", paramType = "query", dataType = "string"), |
||||
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "query", dataType = "string"), |
||||
@ApiImplicitParam(name = "modelName", value = "实体名", paramType = "query", dataType = "string") |
||||
}) |
||||
@ApiOperation(value = "分页", notes = "传入code", position = 2) |
||||
public R<IPage<Code>> list(@ApiIgnore @RequestParam Map<String, Object> code, Query query) { |
||||
IPage<Code> pages = codeService.page(Condition.getPage(query), Condition.getQueryWrapper(code, Code.class)); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperation(value = "新增或修改", notes = "传入code", position = 6) |
||||
public R submit(@Valid @RequestBody Code code) { |
||||
return R.status(codeService.saveOrUpdate(code)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperation(value = "物理删除", notes = "传入ids", position = 7) |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(codeService.removeByIds(Func.toIntList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 代码生成 |
||||
*/ |
||||
@PostMapping("/gen-code") |
||||
@ApiOperation(value = "代码生成", notes = "传入ids", position = 8) |
||||
public R genCode(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
Collection<Code> codes = codeService.listByIds(Func.toIntList(ids)); |
||||
codes.forEach(code -> { |
||||
BladeGenerator generator = new BladeGenerator(); |
||||
generator.setServiceName(code.getServiceName()); |
||||
generator.setPackageName(code.getPackageName()); |
||||
generator.setPackageDir(code.getApiPath()); |
||||
generator.setPackageWebDir(code.getWebPath()); |
||||
generator.setTablePrefix(Func.toStrArray(code.getTablePrefix())); |
||||
generator.setIncludeTables(Func.toStrArray(code.getTableName())); |
||||
// 设置是否继承基础业务字段
|
||||
generator.setHasSuperEntity(false); |
||||
generator.run(); |
||||
}); |
||||
return R.success("代码生成成功"); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,105 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.develop.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableLogic; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@TableName("blade_code") |
||||
@ApiModel(value = "Code对象", description = "Code对象") |
||||
public class Code implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
/** |
||||
* 模块名称 |
||||
*/ |
||||
@ApiModelProperty(value = "服务名称") |
||||
private String serviceName; |
||||
|
||||
/** |
||||
* 模块名称 |
||||
*/ |
||||
@ApiModelProperty(value = "模块名称") |
||||
private String codeName; |
||||
|
||||
/** |
||||
* 表名 |
||||
*/ |
||||
@ApiModelProperty(value = "表名") |
||||
private String tableName; |
||||
|
||||
/** |
||||
* 实体名 |
||||
*/ |
||||
@ApiModelProperty(value = "表前缀") |
||||
private String tablePrefix; |
||||
|
||||
/** |
||||
* 主键名 |
||||
*/ |
||||
@ApiModelProperty(value = "主键名") |
||||
private String pkName; |
||||
|
||||
/** |
||||
* 后端包名 |
||||
*/ |
||||
@ApiModelProperty(value = "后端包名") |
||||
private String packageName; |
||||
|
||||
/** |
||||
* 后端路径 |
||||
*/ |
||||
@ApiModelProperty(value = "后端路径") |
||||
private String apiPath; |
||||
|
||||
/** |
||||
* 前端路径 |
||||
*/ |
||||
@ApiModelProperty(value = "前端路径") |
||||
private String webPath; |
||||
|
||||
/** |
||||
* 是否已删除 |
||||
*/ |
||||
@TableLogic |
||||
@ApiModelProperty(value = "是否已删除") |
||||
private Integer isDeleted; |
||||
|
||||
|
||||
} |
@ -0,0 +1,30 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.develop.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.develop.entity.Code; |
||||
|
||||
/** |
||||
* Mapper 接口 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
public interface CodeMapper extends BaseMapper<Code> { |
||||
|
||||
} |
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="org.springblade.develop.mapper.CodeMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="codeResultMap" type="org.springblade.develop.entity.Code"> |
||||
<id column="id" property="id"/> |
||||
<result column="service_name" property="serviceName"/> |
||||
<result column="code_name" property="codeName"/> |
||||
<result column="table_name" property="tableName"/> |
||||
<result column="pk_name" property="pkName"/> |
||||
<result column="table_prefix" property="tablePrefix"/> |
||||
<result column="package_name" property="packageName"/> |
||||
<result column="api_path" property="apiPath"/> |
||||
<result column="web_path" property="webPath"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
</resultMap> |
||||
|
||||
<!-- 通用查询结果列 --> |
||||
<sql id="baseColumnList"> |
||||
select |
||||
id, service_name, code_name, table_name, pk_name, model_name, package_name, api_path, web_path, is_deleted |
||||
</sql> |
||||
|
||||
</mapper> |
@ -0,0 +1,31 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.develop.service; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import org.springblade.develop.entity.Code; |
||||
|
||||
/** |
||||
* 服务类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
public interface ICodeService extends IService<Code> { |
||||
|
||||
} |
@ -0,0 +1,34 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.develop.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springblade.develop.entity.Code; |
||||
import org.springblade.develop.mapper.CodeMapper; |
||||
import org.springblade.develop.service.ICodeService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 服务实现类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Service |
||||
public class CodeServiceImpl extends ServiceImpl<CodeMapper, Code> implements ICodeService { |
||||
|
||||
} |
@ -0,0 +1,293 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.develop.support; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType; |
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool; |
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||
import com.baomidou.mybatisplus.generator.AutoGenerator; |
||||
import com.baomidou.mybatisplus.generator.InjectionConfig; |
||||
import com.baomidou.mybatisplus.generator.config.*; |
||||
import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert; |
||||
import com.baomidou.mybatisplus.generator.config.converts.PostgreSqlTypeConvert; |
||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo; |
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; |
||||
import lombok.Data; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springframework.core.io.ClassPathResource; |
||||
import org.springframework.core.io.Resource; |
||||
import org.springframework.core.io.support.PropertiesLoaderUtils; |
||||
|
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.util.*; |
||||
|
||||
/** |
||||
* 代码生成器配置类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@Slf4j |
||||
public class BladeGenerator { |
||||
/** |
||||
* 代码所在服务名 |
||||
*/ |
||||
private String serviceName = "blade-service"; |
||||
/** |
||||
* 代码生成的包名 |
||||
*/ |
||||
private String packageName = "org.springblade.test"; |
||||
/** |
||||
* 代码后端生成的地址 |
||||
*/ |
||||
private String packageDir; |
||||
/** |
||||
* 代码前端生成的地址 |
||||
*/ |
||||
private String packageWebDir; |
||||
/** |
||||
* 需要去掉的表前缀 |
||||
*/ |
||||
private String[] tablePrefix = {"blade_"}; |
||||
/** |
||||
* 需要生成的表名(两者只能取其一) |
||||
*/ |
||||
private String[] includeTables = {"blade_test"}; |
||||
/** |
||||
* 需要排除的表名(两者只能取其一) |
||||
*/ |
||||
private String[] excludeTables = {}; |
||||
/** |
||||
* 是否包含基础业务字段 |
||||
*/ |
||||
private Boolean hasSuperEntity = Boolean.FALSE; |
||||
/** |
||||
* 基础业务字段 |
||||
*/ |
||||
private String[] superEntityColumns = {"id", "create_time", "create_user", "update_time", "update_user", "status", "is_deleted"}; |
||||
/** |
||||
* 是否启用swagger |
||||
*/ |
||||
private Boolean isSwagger2 = Boolean.TRUE; |
||||
|
||||
public void run() { |
||||
Properties props = getProperties(); |
||||
AutoGenerator mpg = new AutoGenerator(); |
||||
GlobalConfig gc = new GlobalConfig(); |
||||
String outputDir = getOutputDir(); |
||||
String author = props.getProperty("author"); |
||||
gc.setOutputDir(outputDir); |
||||
gc.setAuthor(author); |
||||
gc.setFileOverride(true); |
||||
gc.setOpen(false); |
||||
gc.setActiveRecord(false); |
||||
gc.setEnableCache(false); |
||||
gc.setBaseResultMap(true); |
||||
gc.setBaseColumnList(true); |
||||
gc.setMapperName("%sMapper"); |
||||
gc.setXmlName("%sMapper"); |
||||
gc.setServiceName("I%sService"); |
||||
gc.setServiceImplName("%sServiceImpl"); |
||||
gc.setControllerName("%sController"); |
||||
gc.setSwagger2(isSwagger2); |
||||
mpg.setGlobalConfig(gc); |
||||
DataSourceConfig dsc = new DataSourceConfig(); |
||||
String driverName = props.getProperty("spring.datasource.driver-class-name"); |
||||
if (StringUtil.containsAny(driverName, DbType.MYSQL.getDb())) { |
||||
dsc.setDbType(DbType.MYSQL); |
||||
dsc.setTypeConvert(new MySqlTypeConvert()); |
||||
} else { |
||||
dsc.setDbType(DbType.POSTGRE_SQL); |
||||
dsc.setTypeConvert(new PostgreSqlTypeConvert()); |
||||
} |
||||
dsc.setUrl(props.getProperty("spring.datasource.url")); |
||||
dsc.setDriverName(driverName); |
||||
dsc.setUsername(props.getProperty("spring.datasource.username")); |
||||
dsc.setPassword(props.getProperty("spring.datasource.password")); |
||||
mpg.setDataSource(dsc); |
||||
// 策略配置
|
||||
StrategyConfig strategy = new StrategyConfig(); |
||||
// strategy.setCapitalMode(true);// 全局大写命名
|
||||
// strategy.setDbColumnUnderline(true);//全局下划线命名
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel); |
||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel); |
||||
strategy.setTablePrefix(tablePrefix); |
||||
if (includeTables.length > 0) { |
||||
strategy.setInclude(includeTables); |
||||
} |
||||
if (excludeTables.length > 0) { |
||||
strategy.setExclude(excludeTables); |
||||
} |
||||
if (hasSuperEntity) { |
||||
strategy.setSuperEntityClass("org.springblade.core.mp.base.BaseEntity"); |
||||
strategy.setSuperEntityColumns(superEntityColumns); |
||||
strategy.setSuperServiceClass("org.springblade.core.mp.base.BaseService"); |
||||
strategy.setSuperServiceImplClass("org.springblade.core.mp.base.BaseServiceImpl"); |
||||
} else { |
||||
strategy.setSuperServiceClass("com.baomidou.mybatisplus.extension.service.IService"); |
||||
strategy.setSuperServiceImplClass("com.baomidou.mybatisplus.extension.service.impl.ServiceImpl"); |
||||
} |
||||
// 自定义 controller 父类
|
||||
strategy.setSuperControllerClass("org.springblade.core.boot.ctrl.BladeController"); |
||||
strategy.setEntityBuilderModel(false); |
||||
strategy.setEntityLombokModel(true); |
||||
strategy.setControllerMappingHyphenStyle(true); |
||||
mpg.setStrategy(strategy); |
||||
// 包配置
|
||||
PackageConfig pc = new PackageConfig(); |
||||
// 控制台扫描
|
||||
pc.setModuleName(null); |
||||
pc.setParent(packageName); |
||||
pc.setController("controller"); |
||||
pc.setEntity("entity"); |
||||
pc.setXml("mapper"); |
||||
mpg.setPackageInfo(pc); |
||||
mpg.setCfg(getInjectionConfig()); |
||||
mpg.execute(); |
||||
} |
||||
|
||||
private InjectionConfig getInjectionConfig() { |
||||
String servicePackage = serviceName.split("-").length > 1 ? serviceName.split("-")[1] : serviceName; |
||||
// 自定义配置
|
||||
InjectionConfig cfg = new InjectionConfig() { |
||||
@Override |
||||
public void initMap() { |
||||
Map<String, Object> map = new HashMap<>(16); |
||||
map.put("serviceName", serviceName); |
||||
map.put("servicePackage", servicePackage); |
||||
this.setMap(map); |
||||
} |
||||
}; |
||||
List<FileOutConfig> focList = new ArrayList<>(); |
||||
focList.add(new FileOutConfig("/templates/entityVO.java.vm") { |
||||
@Override |
||||
public String outputFile(TableInfo tableInfo) { |
||||
return getOutputDir() + "/" + packageName.replace(".", "/") + "/" + "vo" + "/" + tableInfo.getEntityName() + "VO" + StringPool.DOT_JAVA; |
||||
} |
||||
}); |
||||
focList.add(new FileOutConfig("/templates/entityDTO.java.vm") { |
||||
@Override |
||||
public String outputFile(TableInfo tableInfo) { |
||||
return getOutputDir() + "/" + packageName.replace(".", "/") + "/" + "dto" + "/" + tableInfo.getEntityName() + "DTO" + StringPool.DOT_JAVA; |
||||
} |
||||
}); |
||||
focList.add(new FileOutConfig("/templates/wrapper.java.vm") { |
||||
@Override |
||||
public String outputFile(TableInfo tableInfo) { |
||||
return getOutputDir() + "/" + packageName.replace(".", "/") + "/" + "wrapper" + "/" + tableInfo.getEntityName() + "Wrapper" + StringPool.DOT_JAVA; |
||||
} |
||||
}); |
||||
if (Func.isNotBlank(packageWebDir)) { |
||||
focList.add(new FileOutConfig("/templates/sword/action.js.vm") { |
||||
@Override |
||||
public String outputFile(TableInfo tableInfo) { |
||||
return getOutputWebDir() + "/actions" + "/" + tableInfo.getEntityName().toLowerCase() + ".js"; |
||||
} |
||||
}); |
||||
focList.add(new FileOutConfig("/templates/sword/model.js.vm") { |
||||
@Override |
||||
public String outputFile(TableInfo tableInfo) { |
||||
return getOutputWebDir() + "/models" + "/" + tableInfo.getEntityName().toLowerCase() + ".js"; |
||||
} |
||||
}); |
||||
focList.add(new FileOutConfig("/templates/sword/service.js.vm") { |
||||
@Override |
||||
public String outputFile(TableInfo tableInfo) { |
||||
return getOutputWebDir() + "/services" + "/" + tableInfo.getEntityName().toLowerCase() + ".js"; |
||||
} |
||||
}); |
||||
focList.add(new FileOutConfig("/templates/sword/list.js.vm") { |
||||
@Override |
||||
public String outputFile(TableInfo tableInfo) { |
||||
return getOutputWebDir() + "/pages" + "/" + StringUtil.firstCharToUpper(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + ".js"; |
||||
} |
||||
}); |
||||
focList.add(new FileOutConfig("/templates/sword/add.js.vm") { |
||||
@Override |
||||
public String outputFile(TableInfo tableInfo) { |
||||
return getOutputWebDir() + "/pages" + "/" + StringUtil.firstCharToUpper(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + "Add.js"; |
||||
} |
||||
}); |
||||
focList.add(new FileOutConfig("/templates/sword/edit.js.vm") { |
||||
@Override |
||||
public String outputFile(TableInfo tableInfo) { |
||||
return getOutputWebDir() + "/pages" + "/" + StringUtil.firstCharToUpper(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + "Edit.js"; |
||||
} |
||||
}); |
||||
focList.add(new FileOutConfig("/templates/sword/view.js.vm") { |
||||
@Override |
||||
public String outputFile(TableInfo tableInfo) { |
||||
return getOutputWebDir() + "/pages" + "/" + StringUtil.firstCharToUpper(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + "View.js"; |
||||
} |
||||
}); |
||||
} |
||||
cfg.setFileOutConfigList(focList); |
||||
return cfg; |
||||
} |
||||
|
||||
/** |
||||
* 获取配置文件 |
||||
* |
||||
* @return 配置Props |
||||
*/ |
||||
private Properties getProperties() { |
||||
// 读取配置文件
|
||||
Resource resource = new ClassPathResource("/templates/props/generator.properties"); |
||||
Properties props = new Properties(); |
||||
try { |
||||
props = PropertiesLoaderUtils.loadProperties(resource); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return props; |
||||
} |
||||
|
||||
/** |
||||
* 生成到项目中 |
||||
* |
||||
* @return outputDir |
||||
*/ |
||||
public String getOutputDir() { |
||||
return Func.isBlank(packageDir) ? System.getProperty("user.dir") : packageDir + "/src/main/java"; |
||||
} |
||||
|
||||
/** |
||||
* 生成到Web项目中 |
||||
* |
||||
* @return outputDir |
||||
*/ |
||||
public String getOutputWebDir() { |
||||
return Func.isBlank(packageWebDir) ? System.getProperty("user.dir") : packageWebDir + "/src"; |
||||
} |
||||
|
||||
/** |
||||
* 页面生成的文件名 |
||||
*/ |
||||
private String getGeneratorViewPath(String viewOutputDir, TableInfo tableInfo, String suffixPath) { |
||||
String name = StringUtils.firstToLowerCase(tableInfo.getEntityName()); |
||||
String path = viewOutputDir + "/" + name + "/" + name + suffixPath; |
||||
File viewDir = new File(path).getParentFile(); |
||||
if (!viewDir.exists()) { |
||||
viewDir.mkdirs(); |
||||
} |
||||
return path; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,71 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.develop.support; |
||||
|
||||
|
||||
/** |
||||
* 代码生成器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public class CodeGenerator { |
||||
|
||||
/** |
||||
* 代码生成的包名 |
||||
*/ |
||||
public static String PACKAGE_NAME = "org.springblade.demo"; |
||||
/** |
||||
* 代码生成的地址 |
||||
*/ |
||||
public static String PACKAGE_DIR = "/blade-ops/blade-codegen/src/main/java"; |
||||
/** |
||||
* 需要去掉的表前缀 |
||||
*/ |
||||
public static String[] TABLE_PREFIX = {"blade_"}; |
||||
/** |
||||
* 需要生成的表名(两者只能取其一) |
||||
*/ |
||||
public static String[] INCLUDE_TABLES = {"blade_blog"}; |
||||
/** |
||||
* 需要排除的表名(两者只能取其一) |
||||
*/ |
||||
public static String[] EXCLUDE_TABLES = {}; |
||||
/** |
||||
* 是否包含基础业务字段 |
||||
*/ |
||||
public static Boolean HAS_SUPER_ENTITY = Boolean.FALSE; |
||||
/** |
||||
* 基础业务字段 |
||||
*/ |
||||
public static String[] SUPER_ENTITY_COLUNMS = {"id", "create_time", "create_user", "update_time", "update_user", "status", "is_deleted"}; |
||||
|
||||
/** |
||||
* RUN THIS |
||||
*/ |
||||
public static void generate() { |
||||
BladeGenerator generator = new BladeGenerator(); |
||||
generator.setPackageName(PACKAGE_NAME); |
||||
generator.setPackageDir(PACKAGE_DIR); |
||||
generator.setTablePrefix(TABLE_PREFIX); |
||||
generator.setIncludeTables(INCLUDE_TABLES); |
||||
generator.setExcludeTables(EXCLUDE_TABLES); |
||||
generator.setHasSuperEntity(HAS_SUPER_ENTITY); |
||||
generator.setSuperEntityColumns(SUPER_ENTITY_COLUNMS); |
||||
generator.run(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,10 @@
|
||||
#服务器端口 |
||||
server: |
||||
port: 7007 |
||||
|
||||
#数据源配置 |
||||
spring: |
||||
datasource: |
||||
url: ${blade.datasource.dev.url} |
||||
username: ${blade.datasource.dev.username} |
||||
password: ${blade.datasource.dev.password} |
@ -0,0 +1,10 @@
|
||||
#服务器端口 |
||||
server: |
||||
port: 7007 |
||||
|
||||
#数据源配置 |
||||
spring: |
||||
datasource: |
||||
url: ${blade.datasource.prod.url} |
||||
username: ${blade.datasource.prod.username} |
||||
password: ${blade.datasource.prod.password} |
@ -0,0 +1,10 @@
|
||||
#服务器端口 |
||||
server: |
||||
port: 7007 |
||||
|
||||
#数据源配置 |
||||
spring: |
||||
datasource: |
||||
url: ${blade.datasource.test.url} |
||||
username: ${blade.datasource.test.username} |
||||
password: ${blade.datasource.test.password} |
@ -0,0 +1,151 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package $!{package.Controller}; |
||||
|
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import javax.validation.Valid; |
||||
|
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.system.feign.IDictClient; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springframework.web.bind.annotation.*; |
||||
#if($!{superEntityClass}) |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
#end |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import $!{package.Entity}.$!{entity}; |
||||
#set($voPackage=$package.Entity.replace("entity","vo")) |
||||
import $!{voPackage}.$!{entity}VO; |
||||
#set($wrapperPackage=$package.Entity.replace("entity","wrapper")) |
||||
import $!{wrapperPackage}.$!{entity}Wrapper; |
||||
import $!{package.Service}.$!{table.serviceName}; |
||||
#if($!{superControllerClassPackage}) |
||||
import $!{superControllerClassPackage}; |
||||
#end |
||||
#if(!$!{superEntityClass}) |
||||
#end |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* $!{table.comment} 控制器 |
||||
* |
||||
* @author $!{author} |
||||
* @since $!{date} |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("#if($!{package.ModuleName})/$!{package.ModuleName}#end/$!{table.entityPath}") |
||||
@Api(value = "$!{table.comment}", tags = "$!{table.comment}接口") |
||||
#if($!{superControllerClass}) |
||||
public class $!{table.controllerName} extends $!{superControllerClass} { |
||||
#else |
||||
public class $!{table.controllerName} { |
||||
#end |
||||
|
||||
private $!{table.serviceName} $!{table.entityPath}Service; |
||||
|
||||
private IDictClient dictClient; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperation(value = "详情", notes = "传入$!{table.entityPath}", position = 1) |
||||
public R<$!{entity}VO> detail($!{entity} $!{table.entityPath}) { |
||||
$!{entity} detail = $!{table.entityPath}Service.getOne(Condition.getQueryWrapper($!{table.entityPath})); |
||||
$!{entity}Wrapper $!{table.entityPath}Wrapper = new $!{entity}Wrapper(dictClient); |
||||
return R.data($!{table.entityPath}Wrapper.entityVO(detail)); |
||||
} |
||||
|
||||
/** |
||||
* 分页 $!{table.comment} |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperation(value = "分页", notes = "传入$!{table.entityPath}", position = 2) |
||||
public R<IPage<$!{entity}VO>> list($!{entity} $!{table.entityPath}, Query query) { |
||||
IPage<$!{entity}> pages = $!{table.entityPath}Service.page(Condition.getPage(query), Condition.getQueryWrapper($!{table.entityPath})); |
||||
$!{entity}Wrapper $!{table.entityPath}Wrapper = new $!{entity}Wrapper(dictClient); |
||||
return R.data($!{table.entityPath}Wrapper.pageVO(pages)); |
||||
} |
||||
|
||||
/** |
||||
* 自定义分页 $!{table.comment} |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperation(value = "分页", notes = "传入$!{table.entityPath}", position = 3) |
||||
public R<IPage<$!{entity}VO>> page($!{entity}VO $!{table.entityPath}, Query query) { |
||||
IPage<$!{entity}VO> pages = $!{table.entityPath}Service.select$!{entity}Page(Condition.getPage(query), $!{table.entityPath}); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 $!{table.comment} |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperation(value = "新增", notes = "传入$!{table.entityPath}", position = 4) |
||||
public R save(@Valid @RequestBody $!{entity} $!{table.entityPath}) { |
||||
return R.status($!{table.entityPath}Service.save($!{table.entityPath})); |
||||
} |
||||
|
||||
/** |
||||
* 修改 $!{table.comment} |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperation(value = "修改", notes = "传入$!{table.entityPath}", position = 5) |
||||
public R update(@Valid @RequestBody $!{entity} $!{table.entityPath}) { |
||||
return R.status($!{table.entityPath}Service.updateById($!{table.entityPath})); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 $!{table.comment} |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperation(value = "新增或修改", notes = "传入$!{table.entityPath}", position = 6) |
||||
public R submit(@Valid @RequestBody $!{entity} $!{table.entityPath}) { |
||||
return R.status($!{table.entityPath}Service.saveOrUpdate($!{table.entityPath})); |
||||
} |
||||
|
||||
#if($!{superEntityClass}) |
||||
|
||||
/** |
||||
* 删除 $!{table.comment} |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids", position = 7) |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status($!{table.entityPath}Service.deleteLogic(Func.toIntList(ids))); |
||||
} |
||||
|
||||
#else |
||||
|
||||
/** |
||||
* 删除 $!{table.comment} |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperation(value = "物理删除", notes = "传入ids", position = 7) |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status($!{table.entityPath}Service.removeByIds(Func.toIntList(ids))); |
||||
} |
||||
|
||||
#end |
||||
|
||||
} |
@ -0,0 +1,162 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package $!{package.Entity}; |
||||
|
||||
#foreach($pkg in $!{table.importPackages}) |
||||
import $!{pkg}; |
||||
#end |
||||
#if($!{entityLombokModel}) |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
#end |
||||
#if($!{swagger2}) |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
#end |
||||
|
||||
/** |
||||
* $!{table.comment}实体类 |
||||
* |
||||
* @author $!{author} |
||||
* @since $!{date} |
||||
*/ |
||||
#if($!{entityLombokModel}) |
||||
@Data |
||||
#end |
||||
#if($!{table.convert}) |
||||
@TableName("$!{table.name}") |
||||
#end |
||||
#if($!{superEntityClass}) |
||||
@EqualsAndHashCode(callSuper = true) |
||||
#end |
||||
#if($!{swagger2}) |
||||
@ApiModel(value = "$!{entity}对象", description = #if ("$!{table.comment}"=="")"$!{entity}对象"#else"$!{table.comment}"#end) |
||||
#end |
||||
#if($!{superEntityClass}) |
||||
public class $!{entity} extends $!{superEntityClass}#if($!{activeRecord})<$!{entity}>#end { |
||||
#elseif($!{activeRecord}) |
||||
@Accessors(chain = true) |
||||
public class $!{entity} extends Model<$!{entity}> { |
||||
#else |
||||
public class $!{entity} implements Serializable { |
||||
#end |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
## ---------- BEGIN 字段循环遍历 ---------- |
||||
#foreach($field in $!{table.fields}) |
||||
#if($!{field.keyFlag}) |
||||
#set($keyPropertyName=$!{field.propertyName}) |
||||
#end |
||||
#if("$!field.comment" != "") |
||||
/** |
||||
* $!{field.comment} |
||||
*/ |
||||
#if($!{swagger2}) |
||||
@ApiModelProperty(value = "$!{field.comment}") |
||||
#end |
||||
#end |
||||
#if($!{field.keyFlag}) |
||||
## 主键 |
||||
#if($!{field.keyIdentityFlag}) |
||||
@TableId(value = "$!{field.name}", type = IdType.AUTO) |
||||
#elseif(!$null.isNull($!{idType}) && "$!idType" != "") |
||||
@TableId(value = "$!{field.name}", type = IdType.$!{idType}) |
||||
#elseif($!{field.convert}) |
||||
@TableId("$!{field.name}") |
||||
#end |
||||
## 普通字段 |
||||
#elseif($!{field.fill}) |
||||
## ----- 存在字段填充设置 ----- |
||||
#if($!{field.convert}) |
||||
@TableField(value = "$!{field.name}", fill = FieldFill.$!{field.fill}) |
||||
#else |
||||
@TableField(fill = FieldFill.$!{field.fill}) |
||||
#end |
||||
#elseif($!{field.convert}) |
||||
@TableField("$!{field.name}") |
||||
#end |
||||
## 乐观锁注解 |
||||
#if($!{versionFieldName}==$!{field.name}) |
||||
@Version |
||||
#end |
||||
## 逻辑删除注解 |
||||
#if($!{logicDeleteFieldName}==$!{field.name}) |
||||
@TableLogic |
||||
#end |
||||
private $!{field.propertyType} $!{field.propertyName}; |
||||
|
||||
#end |
||||
## ---------- END 字段循环遍历 ---------- |
||||
|
||||
#if(!$!{entityLombokModel}) |
||||
#foreach($field in $!{table.fields}) |
||||
#if($!{field.propertyType.equals("boolean")}) |
||||
#set($getprefix="is") |
||||
#else |
||||
#set($getprefix="get") |
||||
#end |
||||
|
||||
public $!{field.propertyType} $!{getprefix}$!{field.capitalName}() { |
||||
return $!{field.propertyName}; |
||||
} |
||||
|
||||
#if($!{entityBuilderModel}) |
||||
public $!{entity} set$!{field.capitalName}($!{field.propertyType} $!{field.propertyName}) { |
||||
#else |
||||
public void set$!{field.capitalName}($!{field.propertyType} $!{field.propertyName}) { |
||||
#end |
||||
this.$!{field.propertyName} = $!{field.propertyName}; |
||||
#if($!{entityBuilderModel}) |
||||
return this; |
||||
#end |
||||
} |
||||
#end |
||||
#end |
||||
|
||||
#if($!{entityColumnConstant}) |
||||
#foreach($field in $!{table.fields}) |
||||
public static final String $!{field.name.toUpperCase()} = "$!{field.name}"; |
||||
|
||||
#end |
||||
#end |
||||
#if($!{activeRecord}) |
||||
@Override |
||||
protected Serializable pkVal() { |
||||
#if($!{keyPropertyName}) |
||||
return this.$!{keyPropertyName}; |
||||
#else |
||||
return this.id; |
||||
#end |
||||
} |
||||
|
||||
#end |
||||
#if(!$!{entityLombokModel}) |
||||
@Override |
||||
public String toString() { |
||||
return "$!{entity}{" + |
||||
#foreach($field in $!{table.fields}) |
||||
#if($!{velocityCount}==1) |
||||
"$!{field.propertyName}=" + $!{field.propertyName} + |
||||
#else |
||||
", $!{field.propertyName}=" + $!{field.propertyName} + |
||||
#end |
||||
#end |
||||
"}"; |
||||
} |
||||
#end |
||||
} |
@ -0,0 +1,39 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
#set($dtoPackage=$package.Entity.replace("entity","dto")) |
||||
package $!{dtoPackage}; |
||||
|
||||
import $!{package.Entity}.$!{entity}; |
||||
#if($!{entityLombokModel}) |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
#end |
||||
|
||||
/** |
||||
* $!{table.comment}数据传输对象实体类 |
||||
* |
||||
* @author $!{author} |
||||
* @since $!{date} |
||||
*/ |
||||
#if($!{entityLombokModel}) |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
#end |
||||
public class $!{entity}DTO extends $!{entity} { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,45 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
#set($voPackage=$package.Entity.replace("entity","vo")) |
||||
package $!{voPackage}; |
||||
|
||||
import $!{package.Entity}.$!{entity}; |
||||
#if($!{entityLombokModel}) |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
#end |
||||
#if($!{swagger2}) |
||||
import io.swagger.annotations.ApiModel; |
||||
#end |
||||
|
||||
/** |
||||
* $!{table.comment}视图实体类 |
||||
* |
||||
* @author $!{author} |
||||
* @since $!{date} |
||||
*/ |
||||
#if($!{entityLombokModel}) |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
#end |
||||
#if($!{swagger2}) |
||||
@ApiModel(value = "$!{entity}VO对象", description = #if ("$!{table.comment}"=="")"$!{entity}VO对象"#else"$!{table.comment}"#end) |
||||
#end |
||||
public class $!{entity}VO extends $!{entity} { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,47 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package $!{package.Mapper}; |
||||
|
||||
import $!{package.Entity}.$!{entity}; |
||||
#set($voPackage=$package.Entity.replace("entity","vo")) |
||||
import $!{voPackage}.$!{entity}VO; |
||||
import $!{superMapperClassPackage}; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* $!{table.comment} Mapper 接口 |
||||
* |
||||
* @author $!{author} |
||||
* @since $!{date} |
||||
*/ |
||||
#if($!{kotlin}) |
||||
interface $!{table.mapperName} : $!{superMapperClass}<$!{entity}> |
||||
#else |
||||
public interface $!{table.mapperName} extends $!{superMapperClass}<$!{entity}> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param $!{table.entityPath} |
||||
* @return |
||||
*/ |
||||
List<$!{entity}VO> select$!{entity}Page(IPage page, $!{entity}VO $!{table.entityPath}); |
||||
|
||||
} |
||||
#end |
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="$!{package.Mapper}.$!{table.mapperName}"> |
||||
|
||||
#if($!{enableCache}) |
||||
<!-- 开启二级缓存 --> |
||||
<cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> |
||||
|
||||
#end |
||||
#if($!{baseResultMap}) |
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="$!{table.entityPath}ResultMap" type="$!{package.Entity}.$!{entity}"> |
||||
#foreach($field in $!{table.fields}) |
||||
#if($!{field.keyFlag})##生成主键排在第一位 |
||||
<id column="$!{field.name}" property="$!{field.propertyName}"/> |
||||
#end |
||||
#end |
||||
#foreach($field in $!{table.commonFields})##生成公共字段 |
||||
<result column="$!{field.name}" property="$!{field.propertyName}"/> |
||||
#end |
||||
#foreach($field in $!{table.fields}) |
||||
#if(!$!{field.keyFlag})##生成普通字段 |
||||
<result column="$!{field.name}" property="$!{field.propertyName}"/> |
||||
#end |
||||
#end |
||||
</resultMap> |
||||
|
||||
#end |
||||
#if($!{baseColumnList}) |
||||
<!-- 通用查询结果列 --> |
||||
<sql id="baseColumnList"> |
||||
select |
||||
#foreach($field in $!{table.commonFields}) |
||||
#if($!{field.name} == $!{field.propertyName})$!{field.name}#else$!{field.name} AS $!{field.propertyName}#end, |
||||
#end |
||||
$!{table.fieldNames} |
||||
</sql> |
||||
|
||||
<select id="select$!{entity}Page" resultMap="$!{table.entityPath}ResultMap"> |
||||
select * from $!{table.name} where is_deleted = 0 |
||||
</select> |
||||
|
||||
#end |
||||
</mapper> |
@ -0,0 +1,5 @@
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver |
||||
spring.datasource.url=jdbc:mysql://localhost:3306/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false |
||||
spring.datasource.username=root |
||||
spring.datasource.password=root |
||||
author=BladeX |
@ -0,0 +1,46 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package $!{package.Service}; |
||||
|
||||
import $!{package.Entity}.$!{entity}; |
||||
#set($voPackage=$package.Entity.replace("entity","vo")) |
||||
import $!{voPackage}.$!{entity}VO; |
||||
import $!{superServiceClassPackage}; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
||||
/** |
||||
* $!{table.comment} 服务类 |
||||
* |
||||
* @author $!{author} |
||||
* @since $!{date} |
||||
*/ |
||||
#if($!{kotlin}) |
||||
interface $!{table.serviceName} : $!{superServiceClass}<$!{entity}> |
||||
#else |
||||
public interface $!{table.serviceName} extends $!{superServiceClass}<$!{entity}> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param $!{table.entityPath} |
||||
* @return |
||||
*/ |
||||
IPage<$!{entity}VO> select$!{entity}Page(IPage<$!{entity}VO> page, $!{entity}VO $!{table.entityPath}); |
||||
|
||||
} |
||||
#end |
@ -0,0 +1,48 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package $!{package.ServiceImpl}; |
||||
|
||||
import $!{package.Entity}.$!{entity}; |
||||
#set($voPackage=$package.Entity.replace("entity","vo")) |
||||
import $!{voPackage}.$!{entity}VO; |
||||
import $!{package.Mapper}.$!{table.mapperName}; |
||||
import $!{package.Service}.$!{table.serviceName}; |
||||
import $!{superServiceImplClassPackage}; |
||||
import org.springframework.stereotype.Service; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
||||
/** |
||||
* $!{table.comment} 服务实现类 |
||||
* |
||||
* @author $!{author} |
||||
* @since $!{date} |
||||
*/ |
||||
@Service |
||||
#if($!{kotlin}) |
||||
open class $!{table.serviceImplName} : $!{superServiceImplClass}<$!{table.mapperName}, $!{entity}>(), $!{table.serviceName} { |
||||
|
||||
} |
||||
#else |
||||
public class $!{table.serviceImplName} extends $!{superServiceImplClass}<$!{table.mapperName}, $!{entity}> implements $!{table.serviceName} { |
||||
|
||||
@Override |
||||
public IPage<$!{entity}VO> select$!{entity}Page(IPage<$!{entity}VO> page, $!{entity}VO $!{table.entityPath}) { |
||||
return page.setRecords(baseMapper.select$!{entity}Page(page, $!{table.entityPath})); |
||||
} |
||||
|
||||
} |
||||
#end |
@ -0,0 +1,37 @@
|
||||
#set($upperEntityPath=$table.entityPath.toUpperCase()) |
||||
export const $!{upperEntityPath}_NAMESPACE = '$!{table.entityPath}'; |
||||
|
||||
export function $!{upperEntityPath}_LIST(payload) { |
||||
return { |
||||
type: `${$!{upperEntityPath}_NAMESPACE}/fetchList`, |
||||
payload, |
||||
}; |
||||
} |
||||
|
||||
export function $!{upperEntityPath}_DETAIL(id) { |
||||
return { |
||||
type: `${$!{upperEntityPath}_NAMESPACE}/fetchDetail`, |
||||
payload: { id }, |
||||
}; |
||||
} |
||||
|
||||
export function $!{upperEntityPath}_CLEAR_DETAIL() { |
||||
return { |
||||
type: `${$!{upperEntityPath}_NAMESPACE}/clearDetail`, |
||||
payload: {}, |
||||
}; |
||||
} |
||||
|
||||
export function $!{upperEntityPath}_SUBMIT(payload) { |
||||
return { |
||||
type: `${$!{upperEntityPath}_NAMESPACE}/submit`, |
||||
payload, |
||||
}; |
||||
} |
||||
|
||||
export function $!{upperEntityPath}_REMOVE(payload) { |
||||
return { |
||||
type: `${$!{upperEntityPath}_NAMESPACE}/remove`, |
||||
payload, |
||||
}; |
||||
} |
@ -0,0 +1,73 @@
|
||||
#set($upperEntityPath=$table.entityPath.toUpperCase()) |
||||
import React, { PureComponent } from 'react'; |
||||
import { Form, Input, Card, Button } from 'antd'; |
||||
import { connect } from 'dva'; |
||||
import Panel from '../../../components/Panel'; |
||||
import styles from '../../../layouts/Sword.less'; |
||||
import { $!{upperEntityPath}_SUBMIT } from '../../../actions/$!{table.entityPath}'; |
||||
|
||||
const FormItem = Form.Item; |
||||
|
||||
@connect(({ loading }) => ({ |
||||
submitting: loading.effects['$!{table.entityPath}/submit'], |
||||
})) |
||||
@Form.create() |
||||
class $!{entity}Add extends PureComponent { |
||||
handleSubmit = e => { |
||||
e.preventDefault(); |
||||
const { dispatch, form } = this.props; |
||||
form.validateFieldsAndScroll((err, values) => { |
||||
if (!err) { |
||||
dispatch($!{upperEntityPath}_SUBMIT(values)); |
||||
} |
||||
}); |
||||
}; |
||||
|
||||
render() { |
||||
const { |
||||
form: { getFieldDecorator }, |
||||
submitting, |
||||
} = this.props; |
||||
|
||||
const formItemLayout = { |
||||
labelCol: { |
||||
xs: { span: 24 }, |
||||
sm: { span: 7 }, |
||||
}, |
||||
wrapperCol: { |
||||
xs: { span: 24 }, |
||||
sm: { span: 12 }, |
||||
md: { span: 10 }, |
||||
}, |
||||
}; |
||||
|
||||
const action = ( |
||||
<Button type="primary" onClick={this.handleSubmit} loading={submitting}> |
||||
提交 |
||||
</Button> |
||||
); |
||||
|
||||
return ( |
||||
<Panel title="新增" back="/$!{cfg.servicePackage}/$!{table.entityPath}" action={action}> |
||||
<Form hideRequiredMark style={{ marginTop: 8 }}> |
||||
<Card className={styles.card} bordered={false}> |
||||
#foreach($field in $!{table.fields}) |
||||
<FormItem {...formItemLayout} label="$!{field.comment}"> |
||||
{getFieldDecorator('$!{field.propertyName}', { |
||||
rules: [ |
||||
{ |
||||
required: true, |
||||
message: '请输入$!{field.comment}', |
||||
}, |
||||
], |
||||
})(<Input placeholder="请输入$!{field.comment}" />)} |
||||
</FormItem> |
||||
#end |
||||
</Card> |
||||
</Form> |
||||
</Panel> |
||||
); |
||||
} |
||||
} |
||||
|
||||
export default $!{entity}Add; |
@ -0,0 +1,97 @@
|
||||
#set($upperEntityPath=$table.entityPath.toUpperCase()) |
||||
import React, { PureComponent } from 'react'; |
||||
import { Form, Input, Card, Button } from 'antd'; |
||||
import { connect } from 'dva'; |
||||
import Panel from '../../../components/Panel'; |
||||
import styles from '../../../layouts/Sword.less'; |
||||
import { $!{upperEntityPath}_DETAIL, $!{upperEntityPath}_SUBMIT } from '../../../actions/$!{table.entityPath}'; |
||||
|
||||
const FormItem = Form.Item; |
||||
|
||||
@connect(({ $!{table.entityPath}, loading }) => ({ |
||||
$!{table.entityPath}, |
||||
submitting: loading.effects['code/submit'], |
||||
})) |
||||
@Form.create() |
||||
class $!{entity}Edit extends PureComponent { |
||||
componentWillMount() { |
||||
const { |
||||
dispatch, |
||||
match: { |
||||
params: { id }, |
||||
}, |
||||
} = this.props; |
||||
dispatch($!{upperEntityPath}_DETAIL(id)); |
||||
} |
||||
|
||||
handleSubmit = e => { |
||||
e.preventDefault(); |
||||
const { |
||||
dispatch, |
||||
match: { |
||||
params: { id }, |
||||
}, |
||||
form, |
||||
} = this.props; |
||||
form.validateFieldsAndScroll((err, values) => { |
||||
if (!err) { |
||||
const params = { |
||||
id, |
||||
...values, |
||||
}; |
||||
console.log(params); |
||||
dispatch($!{upperEntityPath}_SUBMIT(params)); |
||||
} |
||||
}); |
||||
}; |
||||
|
||||
render() { |
||||
const { |
||||
form: { getFieldDecorator }, |
||||
$!{table.entityPath}: { detail }, |
||||
submitting, |
||||
} = this.props; |
||||
|
||||
const formItemLayout = { |
||||
labelCol: { |
||||
xs: { span: 24 }, |
||||
sm: { span: 7 }, |
||||
}, |
||||
wrapperCol: { |
||||
xs: { span: 24 }, |
||||
sm: { span: 12 }, |
||||
md: { span: 10 }, |
||||
}, |
||||
}; |
||||
|
||||
const action = ( |
||||
<Button type="primary" onClick={this.handleSubmit} loading={submitting}> |
||||
提交 |
||||
</Button> |
||||
); |
||||
|
||||
return ( |
||||
<Panel title="修改" back="/$!{cfg.servicePackage}/$!{table.entityPath}" action={action}> |
||||
<Form hideRequiredMark style={{ marginTop: 8 }}> |
||||
<Card className={styles.card} bordered={false}> |
||||
#foreach($field in $!{table.fields}) |
||||
<FormItem {...formItemLayout} label="$!{field.comment}"> |
||||
{getFieldDecorator('$!{field.propertyName}', { |
||||
rules: [ |
||||
{ |
||||
required: true, |
||||
message: '请输入$!{field.comment}', |
||||
}, |
||||
], |
||||
initialValue: detail.$!{field.propertyName}, |
||||
})(<Input placeholder="请输入$!{field.comment}" />)} |
||||
</FormItem> |
||||
#end |
||||
</Card> |
||||
</Form> |
||||
</Panel> |
||||
); |
||||
} |
||||
} |
||||
|
||||
export default $!{entity}Edit; |
@ -0,0 +1,82 @@
|
||||
#set($upperEntityPath=$table.entityPath.toUpperCase()) |
||||
import React, { PureComponent } from 'react'; |
||||
import { connect } from 'dva'; |
||||
import { Button, Col, Form, Input, Row } from 'antd'; |
||||
import Panel from '../../../components/Panel'; |
||||
import { $!{upperEntityPath}_LIST } from '../../../actions/$!{table.entityPath}'; |
||||
import Grid from '../../../components/Sword/Grid'; |
||||
|
||||
const FormItem = Form.Item; |
||||
|
||||
@connect(({ $!{table.entityPath}, loading }) => ({ |
||||
$!{table.entityPath}, |
||||
loading: loading.models.param, |
||||
})) |
||||
@Form.create() |
||||
class $!{entity} extends PureComponent { |
||||
// ============ 查询 =============== |
||||
handleSearch = params => { |
||||
const { dispatch } = this.props; |
||||
dispatch($!{upperEntityPath}_LIST(params)); |
||||
}; |
||||
|
||||
// ============ 查询表单 =============== |
||||
renderSearchForm = onReset => { |
||||
const { form } = this.props; |
||||
const { getFieldDecorator } = form; |
||||
|
||||
return ( |
||||
<Row gutter={{ md: 8, lg: 24, xl: 48 }}> |
||||
<Col md={6} sm={24}> |
||||
<FormItem label="查询名称"> |
||||
{getFieldDecorator('name')(<Input placeholder="查询名称" />)} |
||||
</FormItem> |
||||
</Col> |
||||
<Col> |
||||
<div style={{ float: 'right' }}> |
||||
<Button type="primary" htmlType="submit"> |
||||
查询 |
||||
</Button> |
||||
<Button style={{ marginLeft: 8 }} onClick={onReset}> |
||||
重置 |
||||
</Button> |
||||
</div> |
||||
</Col> |
||||
</Row> |
||||
); |
||||
}; |
||||
|
||||
render() { |
||||
const code = '$!{table.entityPath}'; |
||||
|
||||
const { |
||||
form, |
||||
loading, |
||||
$!{table.entityPath}: { data }, |
||||
} = this.props; |
||||
|
||||
const columns = [ |
||||
#foreach($field in $!{table.fields}) |
||||
{ |
||||
title: '$!{field.comment}', |
||||
dataIndex: '$!{field.propertyName}', |
||||
}, |
||||
#end |
||||
]; |
||||
|
||||
return ( |
||||
<Panel> |
||||
<Grid |
||||
code={code} |
||||
form={form} |
||||
onSearch={this.handleSearch} |
||||
renderSearchForm={this.renderSearchForm} |
||||
loading={loading} |
||||
data={data} |
||||
columns={columns} |
||||
/> |
||||
</Panel> |
||||
); |
||||
} |
||||
} |
||||
export default $!{entity}; |
@ -0,0 +1,84 @@
|
||||
#set($upperEntityPath=$table.entityPath.toUpperCase()) |
||||
import { message } from 'antd'; |
||||
import router from 'umi/router'; |
||||
import { $!{upperEntityPath}_NAMESPACE } from '../actions/$!{table.entityPath}'; |
||||
import { list, submit, detail, remove } from '../services/$!{table.entityPath}'; |
||||
|
||||
export default { |
||||
namespace: $!{upperEntityPath}_NAMESPACE, |
||||
state: { |
||||
data: { |
||||
list: [], |
||||
pagination: false, |
||||
}, |
||||
detail: {}, |
||||
}, |
||||
effects: { |
||||
*fetchList({ payload }, { call, put }) { |
||||
const response = yield call(list, payload); |
||||
if (response.success) { |
||||
yield put({ |
||||
type: 'saveList', |
||||
payload: { |
||||
list: response.data, |
||||
pagination: false, |
||||
}, |
||||
}); |
||||
} |
||||
}, |
||||
*fetchDetail({ payload }, { call, put }) { |
||||
const response = yield call(detail, payload); |
||||
if (response.success) { |
||||
yield put({ |
||||
type: 'saveDetail', |
||||
payload: { |
||||
detail: response.data, |
||||
}, |
||||
}); |
||||
} |
||||
}, |
||||
*clearDetail({ payload }, { put }) { |
||||
yield put({ |
||||
type: 'removeDetail', |
||||
payload: { payload }, |
||||
}); |
||||
}, |
||||
*submit({ payload }, { call }) { |
||||
const response = yield call(submit, payload); |
||||
if (response.success) { |
||||
message.success('提交成功'); |
||||
router.push('/$!{cfg.servicePackage}/$!{table.entityPath}'); |
||||
} |
||||
}, |
||||
*remove({ payload }, { call }) { |
||||
const { |
||||
data: { keys }, |
||||
success, |
||||
} = payload; |
||||
const response = yield call(remove, { ids: keys }); |
||||
if (response.success) { |
||||
success(); |
||||
} |
||||
}, |
||||
}, |
||||
reducers: { |
||||
saveList(state, action) { |
||||
return { |
||||
...state, |
||||
data: action.payload, |
||||
}; |
||||
}, |
||||
saveDetail(state, action) { |
||||
return { |
||||
...state, |
||||
detail: action.payload.detail, |
||||
}; |
||||
}, |
||||
removeDetail(state) { |
||||
return { |
||||
...state, |
||||
detail: {}, |
||||
}; |
||||
}, |
||||
}, |
||||
}; |
@ -0,0 +1,26 @@
|
||||
#set($params="$" + "{stringify" + "(params)" + "}") |
||||
import { stringify } from 'qs'; |
||||
import func from '../utils/Func'; |
||||
import request from '../utils/request'; |
||||
|
||||
export async function list(params) { |
||||
return request(`/api/$!{cfg.serviceName}/$!{table.entityPath}/list?$!{params}`); |
||||
} |
||||
|
||||
export async function submit(params) { |
||||
return request('/api/$!{cfg.serviceName}/$!{table.entityPath}/submit', { |
||||
method: 'POST', |
||||
body: params, |
||||
}); |
||||
} |
||||
|
||||
export async function detail(params) { |
||||
return request(`/api/$!{cfg.serviceName}/$!{table.entityPath}/detail?$!{params}`); |
||||
} |
||||
|
||||
export async function remove(params) { |
||||
return request('/api/$!{cfg.serviceName}/$!{table.entityPath}/remove', { |
||||
method: 'POST', |
||||
body: func.toFormData(params), |
||||
}); |
||||
} |
@ -0,0 +1,74 @@
|
||||
#set($upperEntityPath=$table.entityPath.toUpperCase()) |
||||
import React, { PureComponent } from 'react'; |
||||
import router from 'umi/router'; |
||||
import { Form, Card, Button } from 'antd'; |
||||
import { connect } from 'dva'; |
||||
import Panel from '../../../components/Panel'; |
||||
import styles from '../../../layouts/Sword.less'; |
||||
import { $!{upperEntityPath}_DETAIL } from '../../../actions/$!{table.entityPath}'; |
||||
|
||||
const FormItem = Form.Item; |
||||
|
||||
@connect(({ $!{table.entityPath} }) => ({ |
||||
$!{table.entityPath}, |
||||
})) |
||||
@Form.create() |
||||
class $!{entity}View extends PureComponent { |
||||
componentWillMount() { |
||||
const { |
||||
dispatch, |
||||
match: { |
||||
params: { id }, |
||||
}, |
||||
} = this.props; |
||||
dispatch($!{upperEntityPath}_DETAIL(id)); |
||||
} |
||||
|
||||
handleEdit = () => { |
||||
const { |
||||
match: { |
||||
params: { id }, |
||||
}, |
||||
} = this.props; |
||||
router.push(`/$!{cfg.servicePackage}/$!{table.entityPath}/edit/$!{id}`); |
||||
}; |
||||
|
||||
render() { |
||||
const { |
||||
$!{table.entityPath}: { detail }, |
||||
} = this.props; |
||||
|
||||
const formItemLayout = { |
||||
labelCol: { |
||||
xs: { span: 24 }, |
||||
sm: { span: 7 }, |
||||
}, |
||||
wrapperCol: { |
||||
xs: { span: 24 }, |
||||
sm: { span: 12 }, |
||||
md: { span: 10 }, |
||||
}, |
||||
}; |
||||
|
||||
const action = ( |
||||
<Button type="primary" onClick={this.handleEdit}> |
||||
修改 |
||||
</Button> |
||||
); |
||||
|
||||
return ( |
||||
<Panel title="查看" back="/$!{cfg.servicePackage}/$!{table.entityPath}" action={action}> |
||||
<Form hideRequiredMark style={{ marginTop: 8 }}> |
||||
<Card className={styles.card} bordered={false}> |
||||
#foreach($field in $!{table.fields}) |
||||
<FormItem {...formItemLayout} label="$!{field.comment}"> |
||||
<span>{detail.$!{field.propertyName}}</span> |
||||
</FormItem> |
||||
#end |
||||
</Card> |
||||
</Form> |
||||
</Panel> |
||||
); |
||||
} |
||||
} |
||||
export default $!{entity}View; |
@ -0,0 +1,52 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
#set($wrapperPackage=$package.Entity.replace("entity","wrapper")) |
||||
package $!{wrapperPackage}; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.mp.support.BaseEntityWrapper; |
||||
import org.springblade.core.tool.utils.BeanUtil; |
||||
import org.springblade.system.feign.IDictClient; |
||||
import $!{package.Entity}.$!{entity}; |
||||
#set($voPackage=$package.Entity.replace("entity","vo")) |
||||
import $!{voPackage}.$!{entity}VO; |
||||
|
||||
/** |
||||
* $!{table.comment}包装类,返回视图层所需的字段 |
||||
* |
||||
* @author $!{author} |
||||
* @since $!{date} |
||||
*/ |
||||
@AllArgsConstructor |
||||
public class $!{entity}Wrapper extends BaseEntityWrapper<$!{entity}, $!{entity}VO> { |
||||
|
||||
private IDictClient dictClient; |
||||
|
||||
@Override |
||||
public $!{entity}VO entityVO($!{entity} $!{table.entityPath}) { |
||||
$!{entity}VO $!{table.entityPath}VO = BeanUtil.copy($!{table.entityPath}, $!{entity}VO.class); |
||||
|
||||
/*R<String> dict = dictClient.getValue("$!{table.entityPath}" , $!{table.entityPath}VO.getCategory()); |
||||
if (dict.isSuccess()) { |
||||
String categoryName = dict.getData(); |
||||
$!{table.entityPath}VO.setCategoryName(categoryName); |
||||
}*/ |
||||
|
||||
return $!{table.entityPath}VO; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,19 @@
|
||||
<?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>BladeX</artifactId> |
||||
<groupId>org.springblade</groupId> |
||||
<version>2.0.0.RC1</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>blade-ops</artifactId> |
||||
<packaging>pom</packaging> |
||||
<modules> |
||||
<module>blade-admin</module> |
||||
<module>blade-develop</module> |
||||
</modules> |
||||
|
||||
</project> |
@ -0,0 +1,17 @@
|
||||
<?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>blade-service-api</artifactId> |
||||
<groupId>org.springblade</groupId> |
||||
<version>2.0.0.RC1</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>blade-desk-api</artifactId> |
||||
<name>${project.artifactId}</name> |
||||
<version>${bladex.project.version}</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
</project> |
@ -0,0 +1,64 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.desk.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 实体类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@TableName("blade_notice") |
||||
public class Notice extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 标题 |
||||
*/ |
||||
@ApiModelProperty(value = "标题") |
||||
private String title; |
||||
|
||||
/** |
||||
* 通知类型 |
||||
*/ |
||||
@ApiModelProperty(value = "通知类型") |
||||
private Integer category; |
||||
|
||||
/** |
||||
* 发布日期 |
||||
*/ |
||||
@ApiModelProperty(value = "发布日期") |
||||
private Date date; |
||||
|
||||
/** |
||||
* 内容 |
||||
*/ |
||||
@ApiModelProperty(value = "内容") |
||||
private String content; |
||||
|
||||
|
||||
} |
@ -0,0 +1,49 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.desk.feign; |
||||
|
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.desk.entity.Notice; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Notice Feign接口类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@FeignClient( |
||||
value = AppConstant.APPLICATION_DESK_NAME |
||||
) |
||||
public interface INoticeClient { |
||||
|
||||
String API_PREFIX = "/dashboard"; |
||||
|
||||
/** |
||||
* 获取notice列表 |
||||
* |
||||
* @param number |
||||
* @return |
||||
*/ |
||||
@GetMapping(API_PREFIX + "/top") |
||||
R<List<Notice>> top(@RequestParam("number") Integer number); |
||||
|
||||
} |
@ -0,0 +1,20 @@
|
||||
package org.springblade.desk.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.desk.entity.Notice; |
||||
|
||||
/** |
||||
* 通知公告视图类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class NoticeVO extends Notice { |
||||
|
||||
@ApiModelProperty(value = "通知类型名") |
||||
private String categoryName; |
||||
|
||||
} |
@ -0,0 +1,18 @@
|
||||
<?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>blade-service-api</artifactId> |
||||
<groupId>org.springblade</groupId> |
||||
<version>2.0.0.RC1</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>blade-dict-api</artifactId> |
||||
<name>${project.artifactId}</name> |
||||
<version>${bladex.project.version}</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
|
||||
</project> |
@ -0,0 +1,36 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.config; |
||||
|
||||
import org.springblade.system.feign.IDictClientFallback; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
/** |
||||
* 字典feign失败配置 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Configuration |
||||
public class DictFeignConfiguration { |
||||
|
||||
@Bean |
||||
public IDictClientFallback dictClientFallback() { |
||||
return new IDictClientFallback(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,34 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.dto; |
||||
|
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.system.entity.Dict; |
||||
|
||||
/** |
||||
* 数据传输对象实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class DictDTO extends Dict { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,93 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableLogic; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@TableName("blade_dict") |
||||
@ApiModel(value = "Dict对象", description = "Dict对象") |
||||
public class Dict implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
/** |
||||
* 父主键 |
||||
*/ |
||||
@ApiModelProperty(value = "父主键") |
||||
private Integer parentId; |
||||
|
||||
/** |
||||
* 字典码 |
||||
*/ |
||||
@ApiModelProperty(value = "字典码") |
||||
private String code; |
||||
|
||||
/** |
||||
* 字典值 |
||||
*/ |
||||
@ApiModelProperty(value = "字典值") |
||||
private Integer dictKey; |
||||
|
||||
/** |
||||
* 字典名称 |
||||
*/ |
||||
@ApiModelProperty(value = "字典名称") |
||||
private String dictValue; |
||||
|
||||
/** |
||||
* 排序 |
||||
*/ |
||||
@ApiModelProperty(value = "排序") |
||||
private Integer sort; |
||||
|
||||
/** |
||||
* 字典备注 |
||||
*/ |
||||
@ApiModelProperty(value = "字典备注") |
||||
private String remark; |
||||
|
||||
/** |
||||
* 是否已删除 |
||||
*/ |
||||
@TableLogic |
||||
@ApiModelProperty(value = "是否已删除") |
||||
private Integer isDeleted; |
||||
|
||||
|
||||
} |
@ -0,0 +1,61 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.feign; |
||||
|
||||
|
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.system.entity.Dict; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Feign接口类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@FeignClient( |
||||
value = AppConstant.APPLICATION_SYSTEM_NAME, |
||||
fallback = IDictClientFallback.class |
||||
) |
||||
public interface IDictClient { |
||||
|
||||
String API_PREFIX = "/dict"; |
||||
|
||||
/** |
||||
* 获取字典表对应值 |
||||
* |
||||
* @param code 字典编号 |
||||
* @param dictKey 字典序号 |
||||
* @return |
||||
*/ |
||||
@GetMapping(API_PREFIX + "/getValue") |
||||
R<String> getValue(@RequestParam("code") String code, @RequestParam("dictKey") Integer dictKey); |
||||
|
||||
/** |
||||
* 获取字典表 |
||||
* |
||||
* @param code 字典编号 |
||||
* @return |
||||
*/ |
||||
@GetMapping(API_PREFIX + "/getList") |
||||
R<List<Dict>> getList(@RequestParam("code") String code); |
||||
|
||||
} |
@ -0,0 +1,39 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.feign; |
||||
|
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.system.entity.Dict; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Feign失败配置 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public class IDictClientFallback implements IDictClient { |
||||
@Override |
||||
public R<String> getValue(String code, Integer dictKey) { |
||||
return R.fail("获取数据失败"); |
||||
} |
||||
|
||||
@Override |
||||
public R<List<Dict>> getList(String code) { |
||||
return R.fail("获取数据失败"); |
||||
} |
||||
} |
@ -0,0 +1,68 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.vo; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import io.swagger.annotations.ApiModel; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.tool.node.INode; |
||||
import org.springblade.system.entity.Dict; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 视图实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "DictVO对象", description = "DictVO对象") |
||||
public class DictVO extends Dict implements INode { |
||||
private static final long serialVersionUID = 1L; |
||||
/** |
||||
* 主键ID |
||||
*/ |
||||
private Integer id; |
||||
|
||||
/** |
||||
* 父节点ID |
||||
*/ |
||||
private Integer parentId; |
||||
|
||||
/** |
||||
* 子孙节点 |
||||
*/ |
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
||||
private List<INode> children; |
||||
|
||||
@Override |
||||
public List<INode> getChildren() { |
||||
if (this.children == null) { |
||||
this.children = new ArrayList<>(); |
||||
} |
||||
return this.children; |
||||
} |
||||
|
||||
/** |
||||
* 上级字典 |
||||
*/ |
||||
private String parentName; |
||||
} |
@ -0,0 +1,18 @@
|
||||
<?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>blade-service-api</artifactId> |
||||
<groupId>org.springblade</groupId> |
||||
<version>2.0.0.RC1</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>blade-system-api</artifactId> |
||||
<name>${project.artifactId}</name> |
||||
<version>${bladex.project.version}</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
|
||||
</project> |
@ -0,0 +1,34 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.dto; |
||||
|
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.system.entity.Dept; |
||||
|
||||
/** |
||||
* 数据传输对象实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class DeptDTO extends Dept { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,34 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.dto; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 数据传输对象实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
public class MenuDTO implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
private String alias; |
||||
private String path; |
||||
} |
@ -0,0 +1,34 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.dto; |
||||
|
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.system.entity.Param; |
||||
|
||||
/** |
||||
* 数据传输对象实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-28 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class ParamDTO extends Param { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,34 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.dto; |
||||
|
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.system.entity.Role; |
||||
|
||||
/** |
||||
* 数据传输对象实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class RoleDTO extends Role { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,34 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.dto; |
||||
|
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.system.entity.RoleMenu; |
||||
|
||||
/** |
||||
* 数据传输对象实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class RoleMenuDTO extends RoleMenu { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,87 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableLogic; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@TableName("blade_dept") |
||||
@ApiModel(value = "Dept对象", description = "Dept对象") |
||||
public class Dept implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
/** |
||||
* 父主键 |
||||
*/ |
||||
@ApiModelProperty(value = "父主键") |
||||
private Integer parentId; |
||||
|
||||
/** |
||||
* 部门名 |
||||
*/ |
||||
@ApiModelProperty(value = "部门名") |
||||
private String deptName; |
||||
|
||||
/** |
||||
* 部门全程 |
||||
*/ |
||||
@ApiModelProperty(value = "部门全程") |
||||
private String fullName; |
||||
|
||||
/** |
||||
* 排序 |
||||
*/ |
||||
@ApiModelProperty(value = "排序") |
||||
private Integer sort; |
||||
|
||||
/** |
||||
* 备注 |
||||
*/ |
||||
@ApiModelProperty(value = "备注") |
||||
private String remark; |
||||
|
||||
/** |
||||
* 是否已删除 |
||||
*/ |
||||
@TableLogic |
||||
@ApiModelProperty(value = "是否已删除") |
||||
private Integer isDeleted; |
||||
|
||||
|
||||
} |
@ -0,0 +1,139 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableLogic; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import org.springblade.core.tool.utils.Func; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@TableName("blade_menu") |
||||
@ApiModel(value = "Menu对象", description = "Menu对象") |
||||
public class Menu implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
/** |
||||
* 菜单父主键 |
||||
*/ |
||||
@ApiModelProperty(value = "菜单父主键") |
||||
private Integer parentId; |
||||
|
||||
/** |
||||
* 菜单编号 |
||||
*/ |
||||
@ApiModelProperty(value = "菜单编号") |
||||
private String code; |
||||
|
||||
/** |
||||
* 菜单名称 |
||||
*/ |
||||
@ApiModelProperty(value = "菜单名称") |
||||
private String name; |
||||
|
||||
/** |
||||
* 菜单别名 |
||||
*/ |
||||
@ApiModelProperty(value = "菜单别名") |
||||
private String alias; |
||||
|
||||
/** |
||||
* 请求地址 |
||||
*/ |
||||
@ApiModelProperty(value = "请求地址") |
||||
private String path; |
||||
|
||||
/** |
||||
* 菜单资源 |
||||
*/ |
||||
@ApiModelProperty(value = "菜单资源") |
||||
private String source; |
||||
|
||||
/** |
||||
* 排序 |
||||
*/ |
||||
@ApiModelProperty(value = "排序") |
||||
private Integer sort; |
||||
|
||||
/** |
||||
* 菜单类型 |
||||
*/ |
||||
@ApiModelProperty(value = "菜单类型") |
||||
private Integer category; |
||||
|
||||
/** |
||||
* 操作按钮类型 |
||||
*/ |
||||
@ApiModelProperty(value = "操作按钮类型") |
||||
private Integer action; |
||||
|
||||
/** |
||||
* 是否打开新页面 |
||||
*/ |
||||
@ApiModelProperty(value = "是否打开新页面") |
||||
private Integer isOpen; |
||||
|
||||
/** |
||||
* 备注 |
||||
*/ |
||||
@ApiModelProperty(value = "备注") |
||||
private String remark; |
||||
|
||||
/** |
||||
* 是否已删除 |
||||
*/ |
||||
@TableLogic |
||||
@ApiModelProperty(value = "是否已删除") |
||||
private Integer isDeleted; |
||||
|
||||
|
||||
@Override |
||||
public boolean equals(Object obj) { |
||||
if (this == obj) { |
||||
return true; |
||||
} |
||||
if (obj == null) { |
||||
return false; |
||||
} |
||||
Menu other = (Menu) obj; |
||||
if (Func.equals(this.getId(), other.getId())) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,65 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
|
||||
/** |
||||
* 实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-28 |
||||
*/ |
||||
@Data |
||||
@TableName("blade_param") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "Param对象", description = "Param对象") |
||||
public class Param extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 参数名 |
||||
*/ |
||||
@ApiModelProperty(value = "参数名") |
||||
private String paramName; |
||||
|
||||
/** |
||||
* 参数键 |
||||
*/ |
||||
@ApiModelProperty(value = "参数键") |
||||
private String paramKey; |
||||
|
||||
/** |
||||
* 参数值 |
||||
*/ |
||||
@ApiModelProperty(value = "参数值") |
||||
private String paramValue; |
||||
|
||||
/** |
||||
* 备注 |
||||
*/ |
||||
@ApiModelProperty(value = "备注") |
||||
private String remark; |
||||
|
||||
|
||||
} |
@ -0,0 +1,81 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableLogic; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@TableName("blade_role") |
||||
@ApiModel(value = "Role对象", description = "Role对象") |
||||
public class Role implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
/** |
||||
* 父主键 |
||||
*/ |
||||
@ApiModelProperty(value = "父主键") |
||||
private Integer parentId; |
||||
|
||||
/** |
||||
* 角色名 |
||||
*/ |
||||
@ApiModelProperty(value = "角色名") |
||||
private String roleName; |
||||
|
||||
/** |
||||
* 排序 |
||||
*/ |
||||
@ApiModelProperty(value = "排序") |
||||
private Integer sort; |
||||
|
||||
/** |
||||
* 角色别名 |
||||
*/ |
||||
@ApiModelProperty(value = "角色别名") |
||||
private String roleAlias; |
||||
|
||||
/** |
||||
* 是否已删除 |
||||
*/ |
||||
@TableLogic |
||||
@ApiModelProperty(value = "是否已删除") |
||||
private Integer isDeleted; |
||||
|
||||
|
||||
} |
@ -0,0 +1,61 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@TableName("blade_role_menu") |
||||
@ApiModel(value = "RoleMenu对象", description = "RoleMenu对象") |
||||
public class RoleMenu implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
/** |
||||
* 菜单id |
||||
*/ |
||||
@ApiModelProperty(value = "菜单id") |
||||
private Integer menuId; |
||||
|
||||
/** |
||||
* 角色id |
||||
*/ |
||||
@ApiModelProperty(value = "角色id") |
||||
private Integer roleId; |
||||
|
||||
|
||||
} |
@ -0,0 +1,70 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.vo; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import io.swagger.annotations.ApiModel; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.tool.node.INode; |
||||
import org.springblade.system.entity.Dept; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 视图实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "DeptVO对象", description = "DeptVO对象") |
||||
public class DeptVO extends Dept implements INode { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键ID |
||||
*/ |
||||
private Integer id; |
||||
|
||||
/** |
||||
* 父节点ID |
||||
*/ |
||||
private Integer parentId; |
||||
|
||||
/** |
||||
* 子孙节点 |
||||
*/ |
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
||||
private List<INode> children; |
||||
|
||||
@Override |
||||
public List<INode> getChildren() { |
||||
if (this.children == null) { |
||||
this.children = new ArrayList<>(); |
||||
} |
||||
return this.children; |
||||
} |
||||
|
||||
/** |
||||
* 上级部门 |
||||
*/ |
||||
private String parentName; |
||||
|
||||
} |
@ -0,0 +1,84 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.vo; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import io.swagger.annotations.ApiModel; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.tool.node.INode; |
||||
import org.springblade.system.entity.Menu; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 视图实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "MenuVO对象", description = "MenuVO对象") |
||||
public class MenuVO extends Menu implements INode { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键ID |
||||
*/ |
||||
private Integer id; |
||||
|
||||
/** |
||||
* 父节点ID |
||||
*/ |
||||
private Integer parentId; |
||||
|
||||
/** |
||||
* 子孙节点 |
||||
*/ |
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
||||
private List<INode> children; |
||||
|
||||
@Override |
||||
public List<INode> getChildren() { |
||||
if (this.children == null) { |
||||
this.children = new ArrayList<>(); |
||||
} |
||||
return this.children; |
||||
} |
||||
|
||||
/** |
||||
* 上级菜单 |
||||
*/ |
||||
private String parentName; |
||||
|
||||
/** |
||||
* 菜单类型 |
||||
*/ |
||||
private String categoryName; |
||||
|
||||
/** |
||||
* 按钮功能 |
||||
*/ |
||||
private String actionName; |
||||
|
||||
/** |
||||
* 是否新窗口打开 |
||||
*/ |
||||
private String isOpenName; |
||||
} |
@ -0,0 +1,36 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.vo; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.system.entity.Param; |
||||
|
||||
/** |
||||
* 视图实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-28 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "ParamVO对象", description = "ParamVO对象") |
||||
public class ParamVO extends Param { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,36 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.vo; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.system.entity.RoleMenu; |
||||
|
||||
/** |
||||
* 视图实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "RoleMenuVO对象", description = "RoleMenuVO对象") |
||||
public class RoleMenuVO extends RoleMenu { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,69 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.vo; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import io.swagger.annotations.ApiModel; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.tool.node.INode; |
||||
import org.springblade.system.entity.Role; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 视图实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "RoleVO对象", description = "RoleVO对象") |
||||
public class RoleVO extends Role implements INode { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键ID |
||||
*/ |
||||
private Integer id; |
||||
|
||||
/** |
||||
* 父节点ID |
||||
*/ |
||||
private Integer parentId; |
||||
|
||||
/** |
||||
* 子孙节点 |
||||
*/ |
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
||||
private List<INode> children; |
||||
|
||||
@Override |
||||
public List<INode> getChildren() { |
||||
if (this.children == null) { |
||||
this.children = new ArrayList<>(); |
||||
} |
||||
return this.children; |
||||
} |
||||
|
||||
/** |
||||
* 上级角色 |
||||
*/ |
||||
private String parentName; |
||||
} |
@ -0,0 +1,17 @@
|
||||
<?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>blade-service-api</artifactId> |
||||
<groupId>org.springblade</groupId> |
||||
<version>2.0.0.RC1</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>blade-user-api</artifactId> |
||||
<name>${project.artifactId}</name> |
||||
<version>${bladex.project.version}</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
</project> |
@ -0,0 +1,80 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.user.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
|
||||
import java.time.LocalDateTime; |
||||
|
||||
/** |
||||
* 实体类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@TableName("blade_user") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class User extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 账号 |
||||
*/ |
||||
private String account; |
||||
/** |
||||
* 密码 |
||||
*/ |
||||
private String password; |
||||
/** |
||||
* 昵称 |
||||
*/ |
||||
private String name; |
||||
/** |
||||
* 真名 |
||||
*/ |
||||
private String realName; |
||||
/** |
||||
* 邮箱 |
||||
*/ |
||||
private String email; |
||||
/** |
||||
* 手机 |
||||
*/ |
||||
private String phone; |
||||
/** |
||||
* 生日 |
||||
*/ |
||||
private LocalDateTime birthday; |
||||
/** |
||||
* 性别 |
||||
*/ |
||||
private Integer sex; |
||||
/** |
||||
* 角色id |
||||
*/ |
||||
private String roleId; |
||||
/** |
||||
* 部门id |
||||
*/ |
||||
private String deptId; |
||||
|
||||
|
||||
} |
@ -0,0 +1,55 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.user.entity; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 用户信息 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@ApiModel(description = "用户信息") |
||||
public class UserInfo implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 用户基础信息 |
||||
*/ |
||||
@ApiModelProperty(value = "用户") |
||||
private User user; |
||||
|
||||
/** |
||||
* 权限标识集合 |
||||
*/ |
||||
@ApiModelProperty(value = "权限集合") |
||||
private List<String> permissions; |
||||
|
||||
/** |
||||
* 角色集合 |
||||
*/ |
||||
@ApiModelProperty(value = "角色集合") |
||||
private List<String> roles; |
||||
|
||||
} |
@ -0,0 +1,48 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.user.feign; |
||||
|
||||
|
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.system.user.entity.UserInfo; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
||||
/** |
||||
* User Feign接口类 |
||||
* @author Chill |
||||
*/ |
||||
@FeignClient( |
||||
value = AppConstant.APPLICATION_USER_NAME |
||||
) |
||||
public interface IUserClient { |
||||
|
||||
String API_PREFIX = "/user"; |
||||
|
||||
/** |
||||
* 获取用户信息 |
||||
* |
||||
* @param account 账号 |
||||
* @param password 密码 |
||||
* @return |
||||
*/ |
||||
@GetMapping(API_PREFIX + "/userInfo") |
||||
R<UserInfo> userInfo(@RequestParam("account") String account, @RequestParam("password") String password); |
||||
|
||||
} |
@ -0,0 +1,79 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.user.vo; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import io.swagger.annotations.ApiModel; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.tool.node.INode; |
||||
import org.springblade.system.user.entity.User; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 视图实体类 |
||||
* |
||||
* @author Chill |
||||
* @since 2018-12-24 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "UserVO对象", description = "UserVO对象") |
||||
public class UserVO extends User implements INode { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键ID |
||||
*/ |
||||
private Integer id; |
||||
|
||||
/** |
||||
* 父节点ID |
||||
*/ |
||||
private Integer parentId; |
||||
|
||||
/** |
||||
* 子孙节点 |
||||
*/ |
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
||||
private List<INode> children; |
||||
|
||||
@Override |
||||
public List<INode> getChildren() { |
||||
if (this.children == null) { |
||||
this.children = new ArrayList<>(); |
||||
} |
||||
return this.children; |
||||
} |
||||
|
||||
/** |
||||
* 角色名 |
||||
*/ |
||||
private String roleName; |
||||
|
||||
/** |
||||
* 部门名 |
||||
*/ |
||||
private String deptName; |
||||
|
||||
/** |
||||
* 性别 |
||||
*/ |
||||
private String sexName; |
||||
} |
@ -0,0 +1,80 @@
|
||||
<?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>BladeX</artifactId> |
||||
<groupId>org.springblade</groupId> |
||||
<version>2.0.0.RC1</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>blade-service-api</artifactId> |
||||
<name>${project.artifactId}</name> |
||||
<version>2.0.0.RC1</version> |
||||
<packaging>pom</packaging> |
||||
<description>SpringBlade 微服务API集合</description> |
||||
|
||||
<modules> |
||||
<module>blade-desk-api</module> |
||||
<module>blade-dict-api</module> |
||||
<module>blade-system-api</module> |
||||
<module>blade-user-api</module> |
||||
</modules> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-starter-mybatis</artifactId> |
||||
<version>${bladex.tool.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.cloud</groupId> |
||||
<artifactId>spring-cloud-starter-openfeign</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.springfox</groupId> |
||||
<artifactId>springfox-swagger2</artifactId> |
||||
<version>${swagger.version}</version> |
||||
<exclusions> |
||||
<exclusion> |
||||
<groupId>io.swagger</groupId> |
||||
<artifactId>swagger-models</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.swagger</groupId> |
||||
<artifactId>swagger-models</artifactId> |
||||
<version>${swagger.models.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-auto</artifactId> |
||||
<version>${bladex.tool.version}</version> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
<configuration> |
||||
<skip>true</skip> |
||||
<finalName>${project.name}</finalName> |
||||
</configuration> |
||||
</plugin> |
||||
<plugin> |
||||
<groupId>com.spotify</groupId> |
||||
<artifactId>docker-maven-plugin</artifactId> |
||||
<version>${docker.plugin.version}</version> |
||||
<configuration> |
||||
<skipDockerBuild>true</skipDockerBuild> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
|
||||
</project> |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue