🎉 2.2.0.RELEASE

This commit is contained in:
smallchill 2019-04-01 22:56:46 +08:00
parent 3d734c7858
commit 39d8428f80
59 changed files with 716 additions and 234 deletions

View File

@ -7,7 +7,7 @@
## 在线演示
* Sword演示地址[https://sword.bladex.vip](https://sword.bladex.vip)
* Saber演示地址[https://saber.avue.top](https://saber.avue.top)
* Saber演示地址[https://saber.bladex.vip](https://saber.bladex.vip)
## 后端项目地址
* [Gitee地址](https://gitee.com/smallc/SpringBlade)

View File

@ -8,7 +8,7 @@
<parent>
<artifactId>SpringBlade</artifactId>
<groupId>org.springblade</groupId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<artifactId>blade-auth</artifactId>
@ -48,6 +48,12 @@
<artifactId>blade-core-swagger</artifactId>
<version>${blade.tool.version}</version>
</dependency>
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>

View File

@ -19,6 +19,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.launch.constant.TokenConstant;
import org.springblade.core.secure.AuthInfo;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.core.tool.api.R;
@ -48,7 +49,7 @@ public class AuthController {
@PostMapping("token")
@ApiOperation(value = "获取认证token", notes = "传入租户编号:tenantCode,账号:account,密码:password")
public R<AuthInfo> token(@ApiParam(value = "租户编号", required = true) @RequestParam String tenantCode,
public R<AuthInfo> token(@ApiParam(value = "租户编号", required = true) @RequestParam(defaultValue = "000000", required = false) String tenantCode,
@ApiParam(value = "账号", required = true) @RequestParam String account,
@ApiParam(value = "密码", required = true) @RequestParam String password) {
@ -67,12 +68,12 @@ public class AuthController {
//设置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.TENANT_CODE, user.getTenantCode());
param.put(SecureUtil.ACCOUNT, user.getAccount());
param.put(SecureUtil.USER_NAME, user.getRealName());
param.put(SecureUtil.ROLE_NAME, Func.join(res.getData().getRoles()));
param.put(TokenConstant.USER_ID, Func.toStr(user.getId()));
param.put(TokenConstant.ROLE_ID, user.getRoleId());
param.put(TokenConstant.TENANT_CODE, user.getTenantCode());
param.put(TokenConstant.ACCOUNT, user.getAccount());
param.put(TokenConstant.USER_NAME, user.getRealName());
param.put(TokenConstant.ROLE_NAME, Func.join(res.getData().getRoles()));
//拼装accessToken
String accessToken = SecureUtil.createJWT(param, "audience", "issuser", true);
@ -83,7 +84,7 @@ public class AuthController {
authInfo.setUserName(user.getRealName());
authInfo.setAuthority(Func.join(res.getData().getRoles()));
authInfo.setAccessToken(accessToken);
authInfo.setTokenType(SecureUtil.BEARER);
authInfo.setTokenType(TokenConstant.BEARER);
//设置token过期时间
authInfo.setExpiresIn(SecureUtil.getExpire());
return R.data(authInfo);

View File

@ -0,0 +1,11 @@
#服务器端口
server:
port: 8100
#数据源配置
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: ${blade.datasource.dev.url}
username: ${blade.datasource.dev.username}
password: ${blade.datasource.dev.password}

View File

@ -0,0 +1,11 @@
#服务器端口
server:
port: 8100
#数据源配置
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: ${blade.datasource.prod.url}
username: ${blade.datasource.prod.username}
password: ${blade.datasource.prod.password}

View File

@ -0,0 +1,11 @@
#服务器端口
server:
port: 8100
#数据源配置
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: ${blade.datasource.test.url}
username: ${blade.datasource.test.username}
password: ${blade.datasource.test.password}

View File

@ -1,2 +0,0 @@
server:
port: 8100

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>SpringBlade</artifactId>
<groupId>org.springblade</groupId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -15,7 +15,7 @@ public interface CommonConstant {
/**
* nacos prod 地址
*/
String NACOS_PROD_ADDR = "192.168.186.129:8848";
String NACOS_PROD_ADDR = "172.30.0.48:8848";
/**
* sentinel dev 地址
@ -25,7 +25,7 @@ public interface CommonConstant {
/**
* sentinel prod 地址
*/
String SENTINEL_PROD_ADDR = "192.168.186.129:8858";
String SENTINEL_PROD_ADDR = "172.30.0.58:8858";
/**
* sword 系统名

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>SpringBlade</artifactId>
<groupId>org.springblade</groupId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-ops</artifactId>
<groupId>org.springblade</groupId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>org.springblade</groupId>
<artifactId>blade-ops</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -1,4 +1,4 @@
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/blade?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=root

View File

@ -1,11 +1,11 @@
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', 0, '$!{cfg.entityKey}', '$!{cfg.codeName}', 'menu', '/$!{cfg.servicePackage}/$!{cfg.entityKey}', NULL, 1, 1, 0, 1, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (0, '$!{cfg.entityKey}', '$!{cfg.codeName}', 'menu', '/$!{cfg.servicePackage}/$!{cfg.entityKey}', NULL, 1, 1, 0, 1, NULL, 0);
set @parentid = (SELECT LAST_INSERT_ID());
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', @parentid, '$!{cfg.entityKey}_add', '新增', 'add', '/$!{cfg.servicePackage}/$!{cfg.entityKey}/add', 'plus', 1, 2, 1, 1, NULL, 0);
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', @parentid, '$!{cfg.entityKey}_edit', '修改', 'edit', '/$!{cfg.servicePackage}/$!{cfg.entityKey}/edit', 'form', 2, 2, 1, 2, NULL, 0);
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', @parentid, '$!{cfg.entityKey}_delete', '删除', 'delete', '/api/$!{cfg.serviceName}/$!{cfg.entityKey}/remove', 'delete', 3, 2, 1, 3, NULL, 0);
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', @parentid, '$!{cfg.entityKey}_view', '查看', 'view', '/$!{cfg.servicePackage}/$!{cfg.entityKey}/view', 'file-text', 4, 2, 1, 2, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, '$!{cfg.entityKey}_add', '新增', 'add', '/$!{cfg.servicePackage}/$!{cfg.entityKey}/add', 'plus', 1, 2, 1, 1, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, '$!{cfg.entityKey}_edit', '修改', 'edit', '/$!{cfg.servicePackage}/$!{cfg.entityKey}/edit', 'form', 2, 2, 1, 2, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, '$!{cfg.entityKey}_delete', '删除', 'delete', '/api/$!{cfg.serviceName}/$!{cfg.entityKey}/remove', 'delete', 3, 2, 1, 3, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, '$!{cfg.entityKey}_view', '查看', 'view', '/$!{cfg.servicePackage}/$!{cfg.entityKey}/view', 'file-text', 4, 2, 1, 2, NULL, 0);

View File

@ -1,4 +1,4 @@
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/blade?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=root

View File

@ -1,11 +1,11 @@
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', 0, '$!{cfg.entityKey}', '$!{cfg.codeName}', 'menu', '/$!{cfg.servicePackage}/$!{cfg.entityKey}', NULL, 1, 1, 0, 1, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (0, '$!{cfg.entityKey}', '$!{cfg.codeName}', 'menu', '/$!{cfg.servicePackage}/$!{cfg.entityKey}', NULL, 1, 1, 0, 1, NULL, 0);
set @parentid = (SELECT LAST_INSERT_ID());
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', @parentid, '$!{cfg.entityKey}_add', '新增', 'add', '/$!{cfg.servicePackage}/$!{cfg.entityKey}/add', 'plus', 1, 2, 1, 1, NULL, 0);
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', @parentid, '$!{cfg.entityKey}_edit', '修改', 'edit', '/$!{cfg.servicePackage}/$!{cfg.entityKey}/edit', 'form', 2, 2, 1, 2, NULL, 0);
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', @parentid, '$!{cfg.entityKey}_delete', '删除', 'delete', '/api/$!{cfg.serviceName}/$!{cfg.entityKey}/remove', 'delete', 3, 2, 1, 3, NULL, 0);
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', @parentid, '$!{cfg.entityKey}_view', '查看', 'view', '/$!{cfg.servicePackage}/$!{cfg.entityKey}/view', 'file-text', 4, 2, 1, 2, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, '$!{cfg.entityKey}_add', '新增', 'add', '/$!{cfg.servicePackage}/$!{cfg.entityKey}/add', 'plus', 1, 2, 1, 1, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, '$!{cfg.entityKey}_edit', '修改', 'edit', '/$!{cfg.servicePackage}/$!{cfg.entityKey}/edit', 'form', 2, 2, 1, 2, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, '$!{cfg.entityKey}_delete', '删除', 'delete', '/api/$!{cfg.serviceName}/$!{cfg.entityKey}/remove', 'delete', 3, 2, 1, 3, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, '$!{cfg.entityKey}_view', '查看', 'view', '/$!{cfg.servicePackage}/$!{cfg.entityKey}/view', 'file-text', 4, 2, 1, 2, NULL, 0);

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>SpringBlade</artifactId>
<groupId>org.springblade</groupId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -0,0 +1,96 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package 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 BladeX
* @since 2019-03-24
*/
@Data
@TableName("blade_client")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Client对象", description = "Client对象")
public class AuthClient extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 客户端id
*/
@ApiModelProperty(value = "客户端id")
private String clientId;
/**
* 客户端密钥
*/
@ApiModelProperty(value = "客户端密钥")
private String clientSecret;
/**
* 资源集合
*/
@ApiModelProperty(value = "资源集合")
private String resourceIds;
/**
* 授权范围
*/
@ApiModelProperty(value = "授权范围")
private String scope;
/**
* 授权类型
*/
@ApiModelProperty(value = "授权类型")
private String authorizedGrantTypes;
/**
* 回调地址
*/
@ApiModelProperty(value = "回调地址")
private String webServerRedirectUri;
/**
* 权限
*/
@ApiModelProperty(value = "权限")
private String authorities;
/**
* 令牌过期秒数
*/
@ApiModelProperty(value = "令牌过期秒数")
private Integer accessTokenValidity;
/**
* 刷新令牌过期秒数
*/
@ApiModelProperty(value = "刷新令牌过期秒数")
private Integer refreshTokenValidity;
/**
* 附加说明
*/
@ApiModelProperty(value = "附加说明")
private String additionalInformation;
/**
* 自动授权
*/
@ApiModelProperty(value = "自动授权")
private String autoapprove;
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,13 +5,13 @@
<parent>
<artifactId>SpringBlade</artifactId>
<groupId>org.springblade</groupId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-service-api</artifactId>
<name>${project.artifactId}</name>
<version>2.1.0</version>
<version>2.2.0</version>
<packaging>pom</packaging>
<description>SpringBlade 微服务API集合</description>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>org.springblade</groupId>
<artifactId>blade-service</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service</artifactId>
<groupId>org.springblade</groupId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service</artifactId>
<groupId>org.springblade</groupId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -0,0 +1,107 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.system.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
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.system.entity.AuthClient;
import org.springblade.system.service.IAuthClientService;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
/**
* 应用管理控制器
*
* @author Chill
*/
@RestController
@AllArgsConstructor
@RequestMapping("/client")
@ApiIgnore
@Api(value = "应用管理", tags = "接口")
public class AuthClientController extends BladeController {
private IAuthClientService clientService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperation(value = "详情", notes = "传入client", position = 1)
public R<AuthClient> detail(AuthClient authClient) {
AuthClient detail = clientService.getOne(Condition.getQueryWrapper(authClient));
return R.data(detail);
}
/**
* 分页
*/
@GetMapping("/list")
@ApiOperation(value = "分页", notes = "传入client", position = 2)
public R<IPage<AuthClient>> list(AuthClient authClient, Query query) {
IPage<AuthClient> pages = clientService.page(Condition.getPage(query), Condition.getQueryWrapper(authClient));
return R.data(pages);
}
/**
* 新增
*/
@PostMapping("/save")
@ApiOperation(value = "新增", notes = "传入client", position = 4)
public R save(@Valid @RequestBody AuthClient authClient) {
return R.status(clientService.save(authClient));
}
/**
* 修改
*/
@PostMapping("/update")
@ApiOperation(value = "修改", notes = "传入client", position = 5)
public R update(@Valid @RequestBody AuthClient authClient) {
return R.status(clientService.updateById(authClient));
}
/**
* 新增或修改
*/
@PostMapping("/submit")
@ApiOperation(value = "新增或修改", notes = "传入client", position = 6)
public R submit(@Valid @RequestBody AuthClient authClient) {
return R.status(clientService.saveOrUpdate(authClient));
}
/**
* 删除
*/
@PostMapping("/remove")
@ApiOperation(value = "逻辑删除", notes = "传入ids", position = 7)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status(clientService.deleteLogic(Func.toIntList(ids)));
}
}

View File

@ -0,0 +1,28 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.system.entity.AuthClient;
/**
* Mapper 接口
*
* @author Chill
*/
public interface AuthClientMapper extends BaseMapper<AuthClient> {
}

View File

@ -0,0 +1,27 @@
<?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.system.mapper.AuthClientMapper">
<!-- 通用查询映射结果 -->
<resultMap id="clientResultMap" type="org.springblade.system.entity.AuthClient">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="client_id" property="clientId"/>
<result column="client_secret" property="clientSecret"/>
<result column="resources_ids" property="resourceIds"/>
<result column="scope" property="scope"/>
<result column="authorized_grant_types" property="authorizedGrantTypes"/>
<result column="web_server_redirect_uri" property="webServerRedirectUri"/>
<result column="authorities" property="authorities"/>
<result column="access_token_validity" property="accessTokenValidity"/>
<result column="refresh_token_validity" property="refreshTokenValidity"/>
<result column="additional_information" property="additionalInformation"/>
<result column="autoapprove" property="autoapprove"/>
</resultMap>
</mapper>

View File

@ -35,18 +35,18 @@
<select id="getValue" resultType="java.lang.String">
select
dict_value
from blade_dict where code = #{param1} and dict_key = #{param2} limit 1
from blade_dict where code = #{param1} and dict_key = #{param2} and is_deleted = 0 limit 1
</select>
<!-- oracle 版本 -->
<!--<select id="getValue" resultType="java.lang.String">
select
dict_value
from blade_dict where code = #{param1, jdbcType=VARCHAR} and dict_key = #{param2} rownum 1
from blade_dict where code = #{param1, jdbcType=VARCHAR} and dict_key = #{param2} and dict_value >= 0 rownum 1
</select>-->
<select id="getList" resultMap="dictResultMap">
select code, dict_key, dict_value, sort, remark from blade_dict where code = #{param1}
select code, dict_key, dict_value, sort, remark from blade_dict where code = #{param1} and dict_key >= 0 and is_deleted = 0
</select>
<select id="tree" resultMap="treeNodeResultMap">

View File

@ -56,6 +56,7 @@ public interface MenuMapper extends BaseMapper<Menu> {
/**
* 授权树形结构
*
* @param roleId
* @return
*/
List<MenuVO> grantTreeByRole(List<Integer> roleId);
@ -93,6 +94,7 @@ public interface MenuMapper extends BaseMapper<Menu> {
/**
* 获取配置的角色权限
*
* @param roleIds
* @return
*/

View File

@ -30,7 +30,7 @@
<!-- 通用查询结果列 -->
<sql id="baseColumnList">
select
id, code, parent_code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted
id, code, parent_code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted
</sql>
<select id="selectMenuPage" resultMap="menuResultMap">
@ -46,7 +46,7 @@
</select>
<select id="roleMenu" resultMap="menuResultMap">
select * from blade_menu where is_deleted = 0 AND id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN
select * from blade_menu where is_deleted = 0 and id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach> )
@ -54,58 +54,58 @@
<select id="routes" resultMap="menuResultMap">
SELECT
*
*
FROM
blade_menu
blade_menu
WHERE
category = 1
AND id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach> )
is_deleted = 0 and category = 1
and id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach> )
</select>
<select id="buttons" resultMap="menuResultMap">
SELECT
id,
parent_id,
`code`,
`name`,
alias,
path,
source,
action,
sort
id,
parent_id,
`code`,
`name`,
alias,
path,
source,
action,
sort
FROM
blade_menu
blade_menu
WHERE
id IN (
SELECT parent_id FROM blade_menu
WHERE ( category = 2 AND id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
) ) )
is_deleted = 0 and id IN (
SELECT parent_id FROM blade_menu
WHERE ( category = 2 AND id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
) ) )
UNION ALL
SELECT
id,
parent_id,
`code`,
`name`,
alias,
path,
source,
action,
sort
id,
parent_id,
`code`,
`name`,
alias,
path,
source,
action,
sort
FROM
blade_menu
blade_menu
WHERE
( category = 2 AND id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>) )
is_deleted = 0 and category = 2 AND id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>)
</select>
<select id="grantTree" resultMap="treeNodeResultMap">
@ -129,19 +129,20 @@
<select id="authRoutes" resultType="org.springblade.system.dto.MenuDTO">
SELECT
GROUP_CONCAT(r.role_alias) as alias,
m.path
GROUP_CONCAT(r.role_alias) as alias,
m.path
FROM
blade_role_menu rm
LEFT JOIN blade_menu m ON rm.menu_id = m.id
LEFT JOIN blade_role r ON rm.role_id = r.id
blade_role_menu rm
LEFT JOIN blade_menu m ON rm.menu_id = m.id
LEFT JOIN blade_role r ON rm.role_id = r.id
WHERE
rm.role_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
AND m.path IS NOT NULL
rm.role_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
AND m.path IS NOT NULL and m.is_deleted = 0
GROUP BY m.path
</select>
</mapper>

View File

@ -42,8 +42,9 @@ public interface RoleMapper extends BaseMapper<Role> {
* 获取树形节点
*
* @param tenantCode
* @param excludeRole
* @return
*/
List<RoleVO> tree(String tenantCode);
List<RoleVO> tree(String tenantCode, String excludeRole);
}

View File

@ -32,8 +32,11 @@
<select id="tree" resultMap="treeNodeResultMap">
select id, parent_id, role_name as title, id as 'value', id as 'key' from blade_role where is_deleted = 0
<if test="_parameter!=null">
and tenant_code = #{_parameter}
<if test="param1!=null">
and tenant_code = #{param1}
</if>
<if test="param2!=null">
and role_alias &lt;&gt; #{param2}
</if>
</select>

View File

@ -0,0 +1,28 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.system.service;
import org.springblade.core.mp.base.BaseService;
import org.springblade.system.entity.AuthClient;
/**
* 服务类
*
* @author Chill
*/
public interface IAuthClientService extends BaseService<AuthClient> {
}

View File

@ -0,0 +1,32 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.system.service.impl;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.system.entity.AuthClient;
import org.springblade.system.mapper.AuthClientMapper;
import org.springblade.system.service.IAuthClientService;
import org.springframework.stereotype.Service;
/**
* 服务实现类
*
* @author Chill
*/
@Service
public class AuthClientServiceImpl extends BaseServiceImpl<AuthClientMapper, AuthClient> implements IAuthClientService {
}

View File

@ -19,7 +19,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.entity.Role;
import org.springblade.system.entity.RoleMenu;
import org.springblade.system.mapper.RoleMapper;
@ -52,7 +56,12 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
@Override
public List<RoleVO> tree(String tenantCode) {
return ForestNodeMerger.merge(baseMapper.tree(tenantCode));
String userRole = SecureUtil.getUserRole();
String excludeRole = null;
if (!CollectionUtil.contains(Func.toStrArray(userRole), RoleConstant.ADMIN)) {
excludeRole = RoleConstant.ADMIN;
}
return ForestNodeMerger.merge(baseMapper.tree(tenantCode, excludeRole));
}
@Override

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service</artifactId>
<groupId>org.springblade</groupId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -28,7 +28,6 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.DigestUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.feign.IDictClient;
import org.springblade.system.user.entity.User;
@ -88,10 +87,7 @@ public class UserController {
@PostMapping("/submit")
@ApiOperation(value = "新增或修改", notes = "传入User", position = 3)
public R submit(@Valid @RequestBody User user) {
if (Func.isNotEmpty(user.getPassword())) {
user.setPassword(DigestUtil.encrypt(user.getPassword()));
}
return R.status(userService.saveOrUpdate(user));
return R.status(userService.submit(user));
}
/**

View File

@ -46,7 +46,7 @@
FROM
blade_user
WHERE
tenant_code = #{param1} and account = #{param2} AND password = #{param3}
tenant_code = #{param1} and account = #{param2} and password = #{param3} and is_deleted = 0
</select>
<select id="getRoleName" resultType="java.lang.String">
@ -59,6 +59,7 @@
<foreach collection="array" item="ids" index="index" open="(" close=")" separator=",">
#{ids}
</foreach>
and is_deleted = 0
</select>
<select id="getRoleAlias" resultType="java.lang.String">
@ -71,6 +72,7 @@
<foreach collection="array" item="ids" index="index" open="(" close=")" separator=",">
#{ids}
</foreach>
and is_deleted = 0
</select>
<select id="getDeptName" resultType="java.lang.String">
@ -83,6 +85,7 @@
<foreach collection="array" item="ids" index="index" open="(" close=")" separator=",">
#{ids}
</foreach>
and is_deleted = 0
</select>
</mapper>

View File

@ -30,6 +30,13 @@ import java.util.List;
*/
public interface IUserService extends BaseService<User> {
/**
* 新增或修改用户
* @param user
* @return
*/
boolean submit(User user);
/**
* 自定义分页
*

View File

@ -18,6 +18,7 @@ package org.springblade.system.user.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.exceptions.ApiException;
import org.springblade.common.constant.CommonConstant;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.DigestUtil;
@ -39,6 +40,18 @@ import java.util.List;
@Service
public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implements IUserService {
@Override
public boolean submit(User user) {
if (Func.isNotEmpty(user.getPassword())) {
user.setPassword(DigestUtil.encrypt(user.getPassword()));
}
Integer cnt = baseMapper.selectCount(Wrappers.<User>query().lambda().eq(User::getTenantCode, user.getTenantCode()).eq(User::getAccount, user.getAccount()));
if (cnt > 0) {
throw new ApiException("当前用户已存在!");
}
return saveOrUpdate(user);
}
@Override
public IPage<User> selectUserPage(IPage<User> page, User user) {
return page.setRecords(baseMapper.selectUserPage(page, user));

View File

@ -7,12 +7,12 @@
<parent>
<groupId>org.springblade</groupId>
<artifactId>SpringBlade</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>
<artifactId>blade-service</artifactId>
<name>${project.artifactId}</name>
<version>2.1.0</version>
<version>2.2.0</version>
<packaging>pom</packaging>
<description>SpringBlade 微服务集合</description>

View File

@ -4,7 +4,7 @@
```
<servers>
<server>
<id>192.168.186.129</id>
<id>10.211.55.5</id>
<username>admin</username>
<password>Harbor12345</password>
<configuration>
@ -20,7 +20,7 @@
###2. docker开启远程访问
如果没有远程访问,会报 `Connect to 192.168.186.129:2375 [/192.168.186.129] failed: Connection refused: connect`
如果没有远程访问,会报 `Connect to 10.211.55.5:2375 [/10.211.55.5] failed: Connection refused: connect`
在`/usr/lib/systemd/system/docker.service`,配置远程访问。主要是在[Service]这个部分,加上下面两个参数:

View File

@ -1,3 +1,4 @@
* SpringBlade的注册中心
* 具体文档详见https://nacos.io/zh-cn/docs/quick-start.html
* docker部署详见https://github.com/nacos-group/nacos-docker
* docker部署详见https://github.com/nacos-group/nacos-docker
* SpringBlade配置详见https://www.kancloud.cn/smallchill/blade/913215

View File

@ -2,7 +2,7 @@
spring:
redis:
##redis 单机环境配置
host: 192.168.186.129
host: 10.211.55.5
port: 3379
password:
database: 0
@ -17,6 +17,6 @@ blade:
#通用开发生产环境数据库地址(特殊情况可在对应的子工程里配置覆盖)
datasource:
prod:
url: jdbc:mysql://192.168.186.129:3306/blade?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8
url: jdbc:mysql://10.211.55.5:3306/blade?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8
username: root
password: root

View File

@ -2,7 +2,7 @@
spring:
redis:
##redis 单机环境配置
host: 192.168.186.129
host: 10.211.55.5
port: 3379
password:
database: 0
@ -17,6 +17,6 @@ blade:
#通用开发生产环境数据库地址(特殊情况可在对应的子工程里配置覆盖)
datasource:
test:
url: jdbc:mysql://192.168.186.129:3306/blade?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8
url: jdbc:mysql://10.211.55.5:3306/blade?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8
username: root
password: root

View File

@ -66,9 +66,21 @@ management:
health:
show-details: always
# 租户表维护
#blade配置
blade:
secure:
url:
exclude-patterns:
- /test/**
client:
- client-id: sword
path-patterns:
- /sword/**
- client-id: saber
path-patterns:
- /saber/**
tenant:
column: tenant_code
tables:
- blade_notice

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,60 +0,0 @@
-- ----------------------------
-- 租户字段增加
-- ----------------------------
ALTER TABLE `blade`.`blade_notice`
ADD COLUMN `tenant_code` varchar(12) NULL DEFAULT '000000' COMMENT '租户编号' AFTER `id`;
ALTER TABLE `blade`.`blade_dept`
ADD COLUMN `tenant_code` varchar(12) NULL DEFAULT '000000' COMMENT '租户编号' AFTER `id`;
ALTER TABLE `blade`.`blade_role`
ADD COLUMN `tenant_code` varchar(12) NULL DEFAULT '000000' COMMENT '租户编号' AFTER `id`;
ALTER TABLE `blade`.`blade_user`
ADD COLUMN `tenant_code` varchar(12) NULL DEFAULT '000000' COMMENT '租户编号' AFTER `id`;
ALTER TABLE `blade`.`blade_log_api`
ADD COLUMN `tenant_code` varchar(12) NULL DEFAULT '000000' COMMENT '租户编号' AFTER `id`;
ALTER TABLE `blade`.`blade_log_error`
ADD COLUMN `tenant_code` varchar(12) NULL DEFAULT '000000' COMMENT '租户编号' AFTER `id`;
ALTER TABLE `blade`.`blade_log_usual`
ADD COLUMN `tenant_code` varchar(12) NULL DEFAULT '000000' COMMENT '租户编号' AFTER `id`;
-- ----------------------------
-- 租户菜单增加
-- ----------------------------
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', 56, 'tenant', '租户管理', 'menu', '/blade-system/tenant', NULL, 1, 1, 0, 1, NULL, 0);
set @parentid = (SELECT LAST_INSERT_ID());
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', @parentid, 'tenant_add', '新增', 'add', '/blade-system/tenant/add', 'plus', 1, 2, 1, 1, NULL, 0);
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', @parentid, 'tenant_edit', '修改', 'edit', '/blade-system/tenant/edit', 'form', 1, 2, 1, 1, NULL, 0);
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', @parentid, 'tenant_delete', '删除', 'delete', '/blade-system/tenant/delete', 'delete', 1, 2, 1, 1, NULL, 0);
INSERT INTO `blade_menu`(`tenant_code`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES ('000000', @parentid, 'tenant_view', '查看', 'view', '/blade-system/tenant/view', 'file-text', 1, 2, 1, 1, NULL, 0);
-- ----------------------------
-- 租户表创建
-- ----------------------------
DROP TABLE IF EXISTS `blade_tenant`;
CREATE TABLE `blade_tenant` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`tenant_code` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '租户编号',
`tenant_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '租户名称',
`linkman` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人',
`contact_number` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系电话',
`address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系地址',
`create_user` int(11) NULL DEFAULT NULL COMMENT '创建人',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_user` int(11) NULL DEFAULT NULL COMMENT '修改人',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
`status` int(2) NULL DEFAULT NULL COMMENT '状态',
`is_deleted` int(2) NULL DEFAULT 0 COMMENT '是否已删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci;
-- ----------------------------
-- 租户表数据插入
-- ----------------------------
BEGIN;
INSERT INTO `blade_tenant` VALUES (1, '000000', '管理组', 'admin', '666666', '管理组', 1, '2019-01-01 00:00:39', 1, '2019-01-01 00:00:39', 1, 0);
COMMIT;

View File

@ -5,12 +5,12 @@
<groupId>org.springblade</groupId>
<artifactId>SpringBlade</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
<packaging>pom</packaging>
<properties>
<blade.tool.version>2.1.0</blade.tool.version>
<blade.project.version>2.1.0</blade.project.version>
<blade.tool.version>2.2.0</blade.tool.version>
<blade.project.version>2.2.0</blade.project.version>
<java.version>1.8</java.version>
<swagger.version>2.9.2</swagger.version>
@ -28,7 +28,7 @@
<spring.platform.version>Cairo-SR7</spring.platform.version>
<!-- 推荐使用Harbor -->
<docker.registry.url>192.168.186.129</docker.registry.url>
<docker.registry.url>10.211.55.5</docker.registry.url>
<docker.registry.host>http://${docker.registry.url}:2375</docker.registry.host>
<docker.plugin.version>1.2.0</docker.plugin.version>
</properties>

View File

@ -1,2 +1,2 @@
REGISTER=192.168.186.129/blade
TAG=2.1.0
REGISTER=192.168.0.157/blade
TAG=2.0.0.RC8

View File

@ -1,7 +1,7 @@
#使用说明,用来提示输入参数
usage() {
echo "Usage: sh 执行脚本.sh [port|base|modules|stop|rm|rmiNoneTag]"
echo "Usage: sh 执行脚本.sh [port|mount|base|modules|stop|rm|rmiNoneTag]"
exit 1
}
@ -10,29 +10,38 @@ port(){
firewall-cmd --add-port=88/tcp --permanent
firewall-cmd --add-port=8000/tcp --permanent
firewall-cmd --add-port=8848/tcp --permanent
firewall-cmd --add-port=8858/tcp --permanent
firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --add-port=3379/tcp --permanent
firewall-cmd --add-port=7002/tcp --permanent
service firewalld restart
}
#启动基础模块
base(){
if test ! -f "/docker/nginx/gateway/nginx.conf" ;then
mkdir /docker/nginx/gateway
cp /nginx/gateway/nginx.conf /docker/nginx/gateway/nginx.conf
##放置挂载文件
mount(){
if test ! -f "/docker/nginx/api/nginx.conf" ;then
mkdir -p /docker/nginx/api
cp nginx/api/nginx.conf /docker/nginx/api/nginx.conf
fi
if test ! -f "/docker/nginx/web/nginx.conf" ;then
mkdir /docker/nginx/web
cp /nginx/web/nginx.conf /docker/nginx/web/nginx.conf
cp /nginx/web/html /docker/nginx/web/html
mkdir -p /docker/nginx/web
cp nginx/web/nginx.conf /docker/nginx/web/nginx.conf
cp -r nginx/web/html /docker/nginx/web/html
fi
docker-compose up -d blade-nginx blade-redis blade-gateway1 blade-gateway2 blade-gateway3 blade-admin
if test ! -f "/docker/nacos/init.d/custom.properties" ;then
mkdir -p /docker/nacos/init.d
cp nacos/init.d/custom.properties /docker/nacos/init.d/custom.properties
fi
}
#启动基础模块
base(){
docker-compose up -d nacos sentinel web-nginx blade-nginx blade-redis
}
#启动程序模块
modules(){
docker-compose up -d blade-auth blade-user blade-desk blade-system blade-log
docker-compose up -d blade-gateway1 blade-gateway2 blade-admin blade-auth1 blade-auth2 blade-user blade-desk blade-system blade-log
}
#关闭所有模块
@ -55,6 +64,9 @@ case "$1" in
"port")
port
;;
"mount")
mount
;;
"base")
base
;;

View File

@ -1,5 +1,28 @@
version: '3'
services:
nacos:
image: nacos/nacos-server:0.9.0
hostname: "nacos-standalone"
environment:
- MODE=standalone
volumes:
- /docker/nacos/standalone-logs/:/home/nacos/logs
- /docker/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties
ports:
- 8848:8848
networks:
blade_net:
ipv4_address: 172.30.0.48
sentinel:
image: bladex/sentinel-dashboard:1.5.0
hostname: "sentinel"
ports:
- 8858:8858
restart: on-failure
networks:
blade_net:
ipv4_address: 172.30.0.58
blade-nginx:
image: nginx:stable-alpine-perl
@ -30,7 +53,7 @@ services:
image: redis:5.0.2-alpine
hostname: "blade-redis"
ports:
- "3379:6379"
- 3379:6379
volumes:
- /docker/redis/data:/data
command: "redis-server --appendonly yes"
@ -40,7 +63,7 @@ services:
- blade_net
blade-admin:
image: "${REGISTER}/blade-admin:${TAG}"
image: "${REGISTER}/blade/blade-admin:${TAG}"
ports:
- 7002:7002
privileged: true
@ -49,7 +72,7 @@ services:
- blade_net
blade-gateway1:
image: "${REGISTER}/blade-gateway:${TAG}"
image: "${REGISTER}/blade/blade-gateway:${TAG}"
privileged: true
restart: always
networks:
@ -57,51 +80,52 @@ services:
ipv4_address: 172.30.0.81
blade-gateway2:
image: "${REGISTER}/blade-gateway:${TAG}"
image: "${REGISTER}/blade/blade-gateway:${TAG}"
privileged: true
restart: always
networks:
blade_net:
ipv4_address: 172.30.0.82
blade-gateway3:
image: "${REGISTER}/blade-gateway:${TAG}"
blade-auth1:
image: "${REGISTER}/blade/blade-auth:${TAG}"
privileged: true
restart: always
networks:
blade_net:
ipv4_address: 172.30.0.83
ipv4_address: 172.30.0.91
blade-auth:
image: "${REGISTER}/blade-auth:${TAG}"
blade-auth2:
image: "${REGISTER}/blade/blade-auth:${TAG}"
privileged: true
restart: always
networks:
- blade_net
blade_net:
ipv4_address: 172.30.0.92
blade-log:
image: "${REGISTER}/blade-log:${TAG}"
image: "${REGISTER}/blade/blade-log:${TAG}"
privileged: true
restart: always
networks:
- blade_net
blade-desk:
image: "${REGISTER}/blade-desk:${TAG}"
image: "${REGISTER}/blade/blade-desk:${TAG}"
privileged: true
restart: always
networks:
- blade_net
blade-user:
image: "${REGISTER}/blade-user:${TAG}"
image: "${REGISTER}/blade/blade-user:${TAG}"
privileged: true
restart: always
networks:
- blade_net
blade-system:
image: "${REGISTER}/blade-system:${TAG}"
image: "${REGISTER}/blade/blade-system:${TAG}"
privileged: true
restart: always
networks:

View File

@ -0,0 +1,19 @@
#spring.security.enabled=false
#management.security=false
#security.basic.enabled=false
#nacos.security.ignore.urls=/**
#management.metrics.export.elastic.host=http://localhost:9200
# metrics for prometheus
management.endpoints.web.exposure.include=*
# metrics for elastic search
#management.metrics.export.elastic.enabled=false
#management.metrics.export.elastic.host=http://localhost:9200
# metrics for influx
#management.metrics.export.influx.enabled=false
#management.metrics.export.influx.db=springboot
#management.metrics.export.influx.uri=http://localhost:8086
#management.metrics.export.influx.auto-create-db=true
#management.metrics.export.influx.consistency=one
#management.metrics.export.influx.compressed=true

View File

@ -33,9 +33,12 @@ http {
upstream gateway {
server 172.30.0.81;
server 172.30.0.82;
server 172.30.0.83;
}
upstream auth {
server 172.30.0.91;
server 172.30.0.92;
}
server {
listen 88;
@ -49,4 +52,16 @@ http {
}
}
server {
listen 9000;
server_name auth;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
proxy_pass http://auth;
}
}
}

View File

@ -2,9 +2,9 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello SpringBlade</title>
<title>Hello BladeX</title>
</head>
<body>
<div style="text-align: center">Hello SpringBlade !</div>
<div style="text-align: center">Hello BladeX !</div>
</body>
</html>

View File

@ -46,13 +46,15 @@ http {
}
location /api {
location ^~/api {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
rewrite ^/api/(.*)$ /$1 break;
proxy_pass http://gateway;
}
}
}