🎉 2.5.0.RELEASE 集成seata支持分布式事务

This commit is contained in:
smallchill 2019-09-23 17:56:34 +08:00
parent 8f182fc863
commit 7179e48db0
49 changed files with 703 additions and 89 deletions

View File

@ -1,7 +1,7 @@
<p align="center">
<img src="https://img.shields.io/badge/license-Apache%202-blue.svg" alt="Build Status">
<img src="https://img.shields.io/badge/Spring%20Cloud-Greenwich.SR2-blue.svg" alt="Coverage Status">
<img src="https://img.shields.io/badge/Spring%20Boot-2.1.7.RELEASE-blue.svg" alt="Downloads">
<img src="https://img.shields.io/badge/Spring%20Cloud-Greenwich.SR3-blue.svg" alt="Coverage Status">
<img src="https://img.shields.io/badge/Spring%20Boot-2.1.8.RELEASE-blue.svg" alt="Downloads">
</p>
## SpringBlade微服务开发平台
@ -62,6 +62,7 @@ SpringBlade
## 技术文档
* [SpringBlade开发手册](https://gitee.com/smallc/SpringBlade/wikis/SpringBlade开发手册)
* [SpringBlade常见问题集锦](https://sns.bladex.vip/article-14966.html)
# 开源协议
Apache Licence 2.0 [英文原文](http://www.apache.org/licenses/LICENSE-2.0.html)

View File

@ -8,7 +8,7 @@
<parent>
<artifactId>SpringBlade</artifactId>
<groupId>org.springblade</groupId>
<version>2.4.1</version>
<version>2.5.0</version>
</parent>
<artifactId>blade-auth</artifactId>
@ -89,6 +89,7 @@
</goals>
<configuration>
<tasks>
<!--suppress UnresolvedMavenProperty -->
<copy overwrite="true"
tofile="${session.executionRootDirectory}/target/${artifactId}.jar"
file="${project.build.directory}/${artifactId}.jar" />

View File

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

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>SpringBlade</artifactId>
<groupId>org.springblade</groupId>
<version>2.4.1</version>
<version>2.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -139,6 +139,7 @@
</goals>
<configuration>
<tasks>
<!--suppress UnresolvedMavenProperty -->
<copy overwrite="true"
tofile="${session.executionRootDirectory}/target/${artifactId}.jar"
file="${project.build.directory}/${artifactId}.jar" />

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-ops</artifactId>
<groupId>org.springblade</groupId>
<version>2.4.1</version>
<version>2.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -72,6 +72,7 @@
</goals>
<configuration>
<tasks>
<!--suppress UnresolvedMavenProperty -->
<copy overwrite="true"
tofile="${session.executionRootDirectory}/target/${artifactId}.jar"
file="${project.build.directory}/${artifactId}.jar" />

View File

@ -6,7 +6,7 @@
<parent>
<groupId>org.springblade</groupId>
<artifactId>blade-ops</artifactId>
<version>2.4.1</version>
<version>2.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -78,6 +78,7 @@
</goals>
<configuration>
<tasks>
<!--suppress UnresolvedMavenProperty -->
<copy overwrite="true"
tofile="${session.executionRootDirectory}/target/${artifactId}.jar"
file="${project.build.directory}/${artifactId}.jar" />

View File

@ -5,13 +5,13 @@
<parent>
<artifactId>blade-ops</artifactId>
<groupId>org.springblade</groupId>
<version>2.4.1</version>
<version>2.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-resource</artifactId>
<name>${project.artifactId}</name>
<version>${bladex.project.version}</version>
<version>${blade.project.version}</version>
<packaging>jar</packaging>
<dependencies>

View File

@ -0,0 +1,30 @@
-- 创建 order库、业务表、undo_log表
create database seata_order;
use seata_order;
DROP TABLE IF EXISTS `tb_order`;
CREATE TABLE `tb_order` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` varchar(255) DEFAULT NULL,
`commodity_code` varchar(255) DEFAULT NULL,
`count` int(11) DEFAULT 0,
`money` int(11) DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `undo_log`
(
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`branch_id` BIGINT(20) NOT NULL,
`xid` VARCHAR(100) NOT NULL,
`context` VARCHAR(128) NOT NULL,
`rollback_info` LONGBLOB NOT NULL,
`log_status` INT(11) NOT NULL,
`log_created` DATETIME NOT NULL,
`log_modified` DATETIME NOT NULL,
`ext` VARCHAR(100) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8;

View File

@ -0,0 +1,30 @@
<?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.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-seata-order</artifactId>
<name>${project.artifactId}</name>
<version>${blade.project.version}</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-boot</artifactId>
<version>${blade.tool.version}</version>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-transaction</artifactId>
<version>${blade.tool.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,37 @@
/**
* 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.seata.order;
import org.springblade.core.launch.BladeApplication;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.transaction.annotation.SeataCloudApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* Order启动器
*
* @author Chill
*/
@SeataCloudApplication
@EnableFeignClients(AppConstant.BASE_PACKAGES)
public class SeataOrderApplication {
public static void main(String[] args) {
BladeApplication.run("blade-seata-order", SeataOrderApplication.class, args);
}
}

View File

@ -0,0 +1,39 @@
/**
* 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.seata.order.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 OrderConfiguration implements WebMvcConfigurer {
@Bean
public SecureRegistry secureRegistry() {
SecureRegistry secureRegistry = new SecureRegistry();
secureRegistry.excludePathPatterns("/order/create/**");
return secureRegistry;
}
}

View File

@ -0,0 +1,34 @@
package org.springblade.seata.order.controller;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.seata.order.service.IOrderService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* OrderController
*
* @author Chill
*/
@RestController
@RequestMapping("order")
@AllArgsConstructor
public class OrderController {
private IOrderService orderService;
/**
* 创建订单
*
* @param userId 用户id
* @param commodityCode 商品代码
* @param count 数量
* @return boolean
*/
@RequestMapping("/create")
public R createOrder(String userId, String commodityCode, Integer count) {
return R.status(orderService.createOrder(userId, commodityCode, count));
}
}

View File

@ -0,0 +1,31 @@
package org.springblade.seata.order.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* Order
*
* @author Chill
*/
@Data
@Accessors(chain = true)
@TableName("tb_order")
public class Order implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String userId;
private String commodityCode;
private Integer count;
private BigDecimal money;
}

View File

@ -0,0 +1,25 @@
package org.springblade.seata.order.feign;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* StorageClient
*
* @author Chill
*/
@FeignClient(name = "blade-seata-storage", fallback = StorageClientFallback.class)
public interface IStorageClient {
/**
* 减库存
*
* @param commodityCode 商品代码
* @param count 数量
* @return boolean
*/
@GetMapping("/deduct")
int deduct(@RequestParam("commodityCode") String commodityCode, @RequestParam("count") Integer count);
}

View File

@ -0,0 +1,18 @@
package org.springblade.seata.order.feign;
import org.springframework.stereotype.Component;
/**
* StorageClientFallback
*
* @author Chill
*/
@Component
public class StorageClientFallback implements IStorageClient {
@Override
public int deduct(String commodityCode, Integer count) {
return -1;
}
}

View File

@ -0,0 +1,12 @@
package org.springblade.seata.order.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.seata.order.entity.Order;
/**
* OrderMapper
*
* @author Chill
*/
public interface OrderMapper extends BaseMapper<Order> {
}

View File

@ -0,0 +1,5 @@
<?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.seata.order.mapper.OrderMapper">
</mapper>

View File

@ -0,0 +1,23 @@
package org.springblade.seata.order.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.seata.order.entity.Order;
/**
* IOrderService
*
* @author Chill
*/
public interface IOrderService extends IService<Order> {
/**
* 创建订单
*
* @param userId 用户id
* @param commodityCode 商品代码
* @param count 数量
* @return boolean
*/
boolean createOrder(String userId, String commodityCode, Integer count);
}

View File

@ -0,0 +1,48 @@
package org.springblade.seata.order.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.seata.order.entity.Order;
import org.springblade.seata.order.feign.IStorageClient;
import org.springblade.seata.order.mapper.OrderMapper;
import org.springblade.seata.order.service.IOrderService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
/**
* OrderServiceImpl
*
* @author Chill
*/
@Service
@AllArgsConstructor
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {
private IStorageClient storageClient;
@Override
@GlobalTransactional
@Transactional(rollbackFor = Exception.class)
public boolean createOrder(String userId, String commodityCode, Integer count) {
int maxCount = 100;
BigDecimal orderMoney = new BigDecimal(count).multiply(new BigDecimal(5));
Order order = new Order()
.setUserId(userId)
.setCommodityCode(commodityCode)
.setCount(count)
.setMoney(orderMoney);
int cnt1 = baseMapper.insert(order);
int cnt2 = storageClient.deduct(commodityCode, count);
if (cnt2 < 0) {
throw new ServiceException("创建订单失败");
} else if (count > maxCount) {
throw new ServiceException("超过订单最大值,创建订单失败");
}
return cnt1 > 0 && cnt2 > 0;
}
}

View File

@ -0,0 +1,10 @@
#服务器端口
server:
port: 8501
#数据源配置
spring:
datasource:
url: jdbc:mysql://localhost:3306/seata_order?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: root
password: root

View File

@ -0,0 +1,20 @@
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "nacos"
nacos {
serverAddr = "localhost"
namespace = ""
cluster = "default"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "nacos"
nacos {
serverAddr = "localhost"
namespace = ""
}
}

View File

@ -0,0 +1,33 @@
-- 创建 storage库、业务表、undo_log表
create database seata_storage;
use seata_storage;
DROP TABLE IF EXISTS `tb_storage`;
CREATE TABLE `tb_storage` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`commodity_code` varchar(255) DEFAULT NULL,
`count` int(11) DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY (`commodity_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `undo_log`
(
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`branch_id` BIGINT(20) NOT NULL,
`xid` VARCHAR(100) NOT NULL,
`context` VARCHAR(128) NOT NULL,
`rollback_info` LONGBLOB NOT NULL,
`log_status` INT(11) NOT NULL,
`log_created` DATETIME NOT NULL,
`log_modified` DATETIME NOT NULL,
`ext` VARCHAR(100) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8;
-- 初始化库存模拟数据
INSERT INTO seata_storage.tb_storage (id, commodity_code, count) VALUES (1, 'product-1', 9999999);
INSERT INTO seata_storage.tb_storage (id, commodity_code, count) VALUES (2, 'product-2', 0);

View File

@ -0,0 +1,31 @@
<?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.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-seata-storage</artifactId>
<name>${project.artifactId}</name>
<version>${blade.project.version}</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-boot</artifactId>
<version>${blade.tool.version}</version>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-transaction</artifactId>
<version>${blade.tool.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,41 @@
/**
* 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.seata.storage;
import org.springblade.core.launch.BladeApplication;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.transaction.annotation.SeataCloudApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* Storage启动器
*
* @author Chill
*/
@SeataCloudApplication
@EnableFeignClients(AppConstant.BASE_PACKAGES)
public class SeataStorageApplication {
public static void main(String[] args) {
BladeApplication.run("blade-seata-storage", SeataStorageApplication.class, args);
}
}

View File

@ -0,0 +1,39 @@
/**
* 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.seata.storage.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 StorageConfiguration implements WebMvcConfigurer {
@Bean
public SecureRegistry secureRegistry() {
SecureRegistry secureRegistry = new SecureRegistry();
secureRegistry.excludePathPatterns("/deduct/**");
return secureRegistry;
}
}

View File

@ -0,0 +1,30 @@
package org.springblade.seata.storage.controller;
import lombok.AllArgsConstructor;
import org.springblade.seata.storage.service.IStorageService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* StorageController
*
* @author Chill
*/
@RestController
@AllArgsConstructor
public class StorageController {
private IStorageService storageService;
/**
* 减库存
*
* @param commodityCode 商品代码
* @param count 数量
*/
@RequestMapping(path = "/deduct")
public int deduct(String commodityCode, Integer count) {
return storageService.deduct(commodityCode, count);
}
}

View File

@ -0,0 +1,24 @@
package org.springblade.seata.storage.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
/**
* storage
*
* @author Chill
*/
@Data
@TableName("tb_storage")
public class Storage implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private String commodityCode;
private Long count;
}

View File

@ -0,0 +1,12 @@
package org.springblade.seata.storage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.seata.storage.entity.Storage;
/**
* StorageMapper
*
* @author Chill
*/
public interface StorageMapper extends BaseMapper<Storage> {
}

View File

@ -0,0 +1,5 @@
<?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.seata.storage.mapper.StorageMapper">
</mapper>

View File

@ -0,0 +1,22 @@
package org.springblade.seata.storage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.seata.storage.entity.Storage;
/**
* IStorageService
*
* @author Chill
*/
public interface IStorageService extends IService<Storage> {
/**
* 减库存
*
* @param commodityCode 商品代码
* @param count 数量
* @return boolean
*/
int deduct(String commodityCode, int count);
}

View File

@ -0,0 +1,30 @@
package org.springblade.seata.storage.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.seata.storage.entity.Storage;
import org.springblade.seata.storage.mapper.StorageMapper;
import org.springblade.seata.storage.service.IStorageService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* StorageServiceImpl
*
* @author Chill
*/
@Service
public class StorageServiceImpl extends ServiceImpl<StorageMapper, Storage> implements IStorageService {
@Override
@Transactional(rollbackFor = Exception.class)
public int deduct(String commodityCode, int count) {
Storage storage = baseMapper.selectOne(Wrappers.<Storage>query().lambda().eq(Storage::getCommodityCode, commodityCode));
if (storage.getCount() < count) {
throw new RuntimeException("超过库存数,扣除失败!");
}
storage.setCount(storage.getCount() - count);
return baseMapper.updateById(storage);
}
}

View File

@ -0,0 +1,10 @@
#服务器端口
server:
port: 8502
#数据源配置
spring:
datasource:
url: jdbc:mysql://localhost:3306/seata_storage?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: root
password: root

View File

@ -0,0 +1,20 @@
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "nacos"
nacos {
serverAddr = "localhost"
namespace = ""
cluster = "default"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "nacos"
nacos {
serverAddr = "localhost"
namespace = ""
}
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>SpringBlade</artifactId>
<groupId>org.springblade</groupId>
<version>2.4.1</version>
<version>2.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -15,6 +15,8 @@
<module>blade-admin</module>
<module>blade-develop</module>
<module>blade-resource</module>
<module>blade-seata-order</module>
<module>blade-seata-storage</module>
</modules>
</project>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.4.1</version>
<version>2.5.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.4.1</version>
<version>2.5.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.4.1</version>
<version>2.5.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.4.1</version>
<version>2.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -23,7 +23,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.TenantEntity;
import java.time.LocalDateTime;
import java.util.Date;
/**
* 实体类
@ -71,7 +71,7 @@ public class User extends TenantEntity {
/**
* 生日
*/
private LocalDateTime birthday;
private Date birthday;
/**
* 性别
*/

View File

@ -5,13 +5,13 @@
<parent>
<artifactId>SpringBlade</artifactId>
<groupId>org.springblade</groupId>
<version>2.4.1</version>
<version>2.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-service-api</artifactId>
<name>${project.artifactId}</name>
<version>2.4.1</version>
<version>2.5.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.4.1</version>
<version>2.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -58,6 +58,7 @@
</goals>
<configuration>
<tasks>
<!--suppress UnresolvedMavenProperty -->
<copy overwrite="true"
tofile="${session.executionRootDirectory}/target/${artifactId}.jar"
file="${project.build.directory}/${artifactId}.jar" />

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service</artifactId>
<groupId>org.springblade</groupId>
<version>2.4.1</version>
<version>2.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -36,6 +36,7 @@
</goals>
<configuration>
<tasks>
<!--suppress UnresolvedMavenProperty -->
<copy overwrite="true"
tofile="${session.executionRootDirectory}/target/${artifactId}.jar"
file="${project.build.directory}/${artifactId}.jar" />

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service</artifactId>
<groupId>org.springblade</groupId>
<version>2.4.1</version>
<version>2.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -45,6 +45,7 @@
</goals>
<configuration>
<tasks>
<!--suppress UnresolvedMavenProperty -->
<copy overwrite="true"
tofile="${session.executionRootDirectory}/target/${artifactId}.jar"
file="${project.build.directory}/${artifactId}.jar" />

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service</artifactId>
<groupId>org.springblade</groupId>
<version>2.4.1</version>
<version>2.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -46,6 +46,7 @@
</goals>
<configuration>
<tasks>
<!--suppress UnresolvedMavenProperty -->
<copy overwrite="true"
tofile="${session.executionRootDirectory}/target/${artifactId}.jar"
file="${project.build.directory}/${artifactId}.jar" />

View File

@ -21,6 +21,7 @@ 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.DateUtil;
import org.springblade.core.tool.utils.DigestUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.user.entity.User;
@ -29,7 +30,6 @@ import org.springblade.system.user.mapper.UserMapper;
import org.springblade.system.user.service.IUserService;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
/**
@ -92,7 +92,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
public boolean resetPassword(String userIds) {
User user = new User();
user.setPassword(DigestUtil.encrypt(CommonConstant.DEFAULT_PASSWORD));
user.setUpdateTime(LocalDateTime.now());
user.setUpdateTime(DateUtil.now());
return this.update(user, Wrappers.<User>update().lambda().in(User::getId, Func.toIntList(userIds)));
}

View File

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

View File

@ -1,56 +0,0 @@
-- ----------------------------
-- 创建数据源配置表
-- ----------------------------
CREATE TABLE `blade_datasource` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(100) NULL COMMENT '名称',
`driver_class` varchar(100) NULL COMMENT '驱动类',
`url` varchar(500) NULL COMMENT '连接地址',
`username` varchar(50) NULL COMMENT '用户名',
`password` varchar(50) NULL COMMENT '密码',
`remark` varchar(255) NULL COMMENT '备注',
`create_user` bigint(64) NULL DEFAULT NULL COMMENT '创建人',
`create_dept` bigint(64) NULL DEFAULT NULL COMMENT '创建部门',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_user` bigint(64) 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 NULL COMMENT '是否已删除',
PRIMARY KEY (`id`) USING BTREE
) COMMENT = '数据源配置表' ;
-- ----------------------------
-- 插入数据源默认数据
-- ----------------------------
INSERT INTO `blade_datasource`(`id`, `name`, `driver_class`, `url`, `username`, `password`, `remark`, `create_user`, `create_dept`, `create_time`, `update_user`, `update_time`, `status`, `is_deleted`) VALUES (1, 'mysql', 'com.mysql.cj.jdbc.Driver', 'jdbc:mysql://localhost:3306/blade?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true', 'root', 'root', 'mysql', 1, 1, '2019-08-14 11:43:06', 1, '2019-08-14 11:43:06', 1, 0);
INSERT INTO `blade_datasource`(`id`, `name`, `driver_class`, `url`, `username`, `password`, `remark`, `create_user`, `create_dept`, `create_time`, `update_user`, `update_time`, `status`, `is_deleted`) VALUES (2, 'postgresql', 'org.postgresql.Driver', 'jdbc:postgresql://127.0.0.1:5432/blade', 'postgres', '123456', 'postgresql', 1, 1, '2019-08-14 11:43:41', 1, '2019-08-14 11:43:41', 1, 0);
INSERT INTO `blade_datasource`(`id`, `name`, `driver_class`, `url`, `username`, `password`, `remark`, `create_user`, `create_dept`, `create_time`, `update_user`, `update_time`, `status`, `is_deleted`) VALUES (3, 'oracle', 'oracle.jdbc.OracleDriver', 'jdbc:oracle:thin:@127.0.0.1:49161:orcl', 'BLADE', 'blade', 'oracle', 1, 1, '2019-08-14 11:44:03', 1, '2019-08-14 11:44:03', 1, 0);
-- ----------------------------
-- 插入数据源菜单数据
-- ----------------------------
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (17, 'datasource', '数据源管理', 'menu', '/tool/datasource', 'iconfont icon-caidanguanli', 2, 1, 0, 1, NULL, 0);
set @parentid = (SELECT LAST_INSERT_ID());
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, 'datasource_add', '新增', 'add', '/tool/datasource/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, 'datasource_edit', '修改', 'edit', '/tool/datasource/edit', 'form', 2, 2, 2, 2, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, 'datasource_delete', '删除', 'delete', '/api/blade-develop/datasource/remove', 'delete', 3, 2, 3, 3, NULL, 0);
INSERT INTO `blade_menu`(`parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
VALUES (@parentid, 'datasource_view', '查看', 'view', '/tool/datasource/view', 'file-text', 4, 2, 2, 2, NULL, 0);
-- ----------------------------
-- 代码生成表增加数据源字段
-- ----------------------------
ALTER TABLE `blade_code`
ADD COLUMN `datasource_id` bigint(64) NULL COMMENT '数据源主键' AFTER `id`,
ADD COLUMN `base_mode` int(2) NULL COMMENT '基础业务模式' AFTER `package_name`,
ADD COLUMN `wrap_mode` int(2) NULL COMMENT '包装器模式' AFTER `base_mode`;
-- ----------------------------
-- 代码生成记录增加数据源字段
-- ----------------------------
UPDATE `blade_code` SET `datasource_id` = 1, `base_mode` = 1, `wrap_mode` = 1 WHERE `id` = 1;

12
pom.xml
View File

@ -5,17 +5,17 @@
<groupId>org.springblade</groupId>
<artifactId>SpringBlade</artifactId>
<version>2.4.1</version>
<version>2.5.0</version>
<packaging>pom</packaging>
<properties>
<blade.tool.version>2.4.1</blade.tool.version>
<blade.project.version>2.4.1</blade.project.version>
<blade.tool.version>2.5.0</blade.tool.version>
<blade.project.version>2.5.0</blade.project.version>
<java.version>1.8</java.version>
<swagger.version>2.9.2</swagger.version>
<swagger.models.version>1.5.21</swagger.models.version>
<swagger.bootstrapui.version>1.9.4</swagger.bootstrapui.version>
<swagger.bootstrapui.version>1.9.6</swagger.bootstrapui.version>
<mybatis.plus.version>3.1.2</mybatis.plus.version>
<curator.framework.version>4.0.1</curator.framework.version>
<protostuff.version>1.6.0</protostuff.version>
@ -23,8 +23,8 @@
<alibaba.cloud.version>2.1.0.RELEASE</alibaba.cloud.version>
<spring.boot.admin.version>2.1.5</spring.boot.admin.version>
<spring.boot.version>2.1.7.RELEASE</spring.boot.version>
<spring.cloud.version>Greenwich.SR2</spring.cloud.version>
<spring.boot.version>2.1.8.RELEASE</spring.boot.version>
<spring.cloud.version>Greenwich.SR3</spring.cloud.version>
<spring.platform.version>Cairo-SR8</spring.platform.version>
<!-- 推荐使用Harbor -->

View File

@ -1,2 +1,2 @@
REGISTER=192.168.0.157/blade
TAG=2.4.1
TAG=2.5.0