diff --git a/shardingspherejamijiemi/.gitignore b/shardingspherejamijiemi/.gitignore new file mode 100644 index 0000000..682d4ed --- /dev/null +++ b/shardingspherejamijiemi/.gitignore @@ -0,0 +1,27 @@ +# Created by .ignore support plugin (hsz.mobi) +### Java template +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +/.idea/ +/target/ diff --git a/shardingspherejamijiemi/fanfu-web.iml b/shardingspherejamijiemi/fanfu-web.iml new file mode 100644 index 0000000..4fb2f38 --- /dev/null +++ b/shardingspherejamijiemi/fanfu-web.iml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/shardingspherejamijiemi/pom.xml b/shardingspherejamijiemi/pom.xml new file mode 100644 index 0000000..2aae918 --- /dev/null +++ b/shardingspherejamijiemi/pom.xml @@ -0,0 +1,140 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.3.9.RELEASE + + + + com.ayi + woniu-web + 0.0.1-SNAPSHOT + woniou-web + create by woniu + + jar + + + 1.8 + + + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.google.guava + guava + 30.0-jre + + + org.projectlombok + lombok + + + org.assertj + assertj-core + + + + org.springframework.boot + spring-boot-starter-validation + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.apache.shardingsphere + sharding-jdbc-spring-boot-starter + 4.1.1 + + + + mysql + mysql-connector-java + runtime + + + + com.baomidou + mybatis-plus-boot-starter + 3.5.1 + + + + com.baomidou + mybatis-plus-generator + 3.5.1 + + + + org.freemarker + freemarker + 2.3.31 + + + + io.springfox + springfox-swagger2 + 2.7.0 + + + io.springfox + springfox-swagger-ui + 2.7.0 + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + org.projectlombok + lombok + true + + + + com.alibaba + fastjson + 1.2.79 + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/shardingspherejamijiemi/src/main/java/com/woniu/WoNiuApplication.java b/shardingspherejamijiemi/src/main/java/com/woniu/WoNiuApplication.java new file mode 100644 index 0000000..6ffef78 --- /dev/null +++ b/shardingspherejamijiemi/src/main/java/com/woniu/WoNiuApplication.java @@ -0,0 +1,23 @@ +package com.woniu; + +import lombok.extern.slf4j.Slf4j; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +@SpringBootApplication +@Slf4j +@MapperScan("com.woniu.service.mapper") +public class WoNiuApplication { + + public static void main(String[] args) { + SpringApplication.run(WoNiuApplication.class, args); + log.info("test_info"); + log.error("test_error"); + log.warn("test_warn"); + } + + + +} diff --git a/shardingspherejamijiemi/src/main/java/com/woniu/service/config/MyShardingEncryptor.java b/shardingspherejamijiemi/src/main/java/com/woniu/service/config/MyShardingEncryptor.java new file mode 100644 index 0000000..9c17316 --- /dev/null +++ b/shardingspherejamijiemi/src/main/java/com/woniu/service/config/MyShardingEncryptor.java @@ -0,0 +1,122 @@ +package com.woniu.service.config; + +import com.google.common.base.Preconditions; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.codec.binary.StringUtils; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.shardingsphere.encrypt.strategy.impl.AESEncryptor; +import org.apache.shardingsphere.encrypt.strategy.spi.Encryptor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Configuration; + +import javax.crypto.Cipher; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.spec.SecretKeySpec; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.Properties; + +/** + *

+ * + *

+ * + * @author woniu,公众号:【程序员蜗牛g】 + * @since 2023-03-30 + */ +@Configuration +public class MyShardingEncryptor implements Encryptor { + + private final Logger log = LoggerFactory.getLogger(MyShardingEncryptor.class); + + // AES KEY + private static final String AES_KEY = "aes.key.value"; + + private Properties properties = new Properties(); + + public MyShardingEncryptor(){ + + } + + @Override + public void init() { + + } + + @Override + public String encrypt(Object plaintext) { + try { + byte[] result = this.getCipher(1).doFinal(StringUtils.getBytesUtf8(String.valueOf(plaintext))); + log.debug("[MyShardingEncryptor]>>>> 加密: {}", Base64.encodeBase64String(result)); + return Base64.encodeBase64String(result); + } catch (Exception ex) { + log.error("[MyShardingEncryptor]>>>> 加密异常:", ex); + } + return null; + + } + + @Override + public Object decrypt(String ciphertext) { + try { + if (null == ciphertext) { + return null; + } else { + byte[] result = this.getCipher(2).doFinal(Base64.decodeBase64(ciphertext)); + log.debug("[MyShardingEncryptor]>>>> 解密: {}", new String(result)); + return new String(result); + } + } catch (Exception ex) { + log.error("[MyShardingEncryptor]>>>> 解密异常:", ex); + } + return null; + } + + @Override + public String getType() { + return "mySharding"; // 和yml配置一致 + } + + @Override + public Properties getProperties() { + return this.properties; + } + + @Override + public void setProperties(Properties properties) { + this.properties = properties; + } + + /** + * 加解密算法 + * @param decryptMode 1-加密,2-解密,还有其他类型可以点进去看源码。 + */ + private Cipher getCipher(int decryptMode) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException { + Preconditions.checkArgument(this.properties.containsKey("aes.key.value"), "No available secret key for `%s`.", + AESEncryptor.class.getName()); + Cipher result = Cipher.getInstance("AES"); + result.init(decryptMode, new SecretKeySpec(this.createSecretKey(), "AES")); + return result; + } + + /** + * 创建密钥,规则根据自己需要定义。 + * -- PS: 生产环境规范要求不能打印出密钥相关日志,以免发生意外泄露情况。 + */ + private byte[] createSecretKey() { + // yml中配置的原始密钥 + String oldKey = this.properties.get("aes.key.value").toString(); + Preconditions.checkArgument(null != oldKey, String.format("%s can not be null.", "aes.key.value")); + /* + * 将原始密钥和自定义的盐一起再次加密生成新的密钥返回. + * 注意,因为我们用的AES加解密方式最终密钥必须16位,否则AES会报错, + * 而application.yml中配置的aes.key.value是10位字符组合,所以这里才substring(0,5),否则最终没有返回16位会抛AES异常,可以自己试验下。 + */ + String secretKey = DigestUtils.sha1Hex(oldKey + AES_KEY).toUpperCase().substring(0, 5) + "!" + oldKey; + // 密钥打印在上线前一定要删掉,避免泄露引起安全事故。 + log.debug("[MyShardingEncryptor]>>>> 密钥: {}", secretKey); + return secretKey.getBytes(); + } + +} diff --git a/shardingspherejamijiemi/src/main/java/com/woniu/service/controller/OrderController.java b/shardingspherejamijiemi/src/main/java/com/woniu/service/controller/OrderController.java new file mode 100644 index 0000000..76751cd --- /dev/null +++ b/shardingspherejamijiemi/src/main/java/com/woniu/service/controller/OrderController.java @@ -0,0 +1,47 @@ +package com.woniu.service.controller; + +import com.alibaba.fastjson.JSONObject; +import com.woniu.service.entity.Order; +import com.woniu.service.service.IOrderService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * SpringBoot+ShardingSphere实现数据库字段加密存储和解密返回 + */ +@RestController +@RequestMapping("/order") +@Slf4j +public class OrderController { + + + @Autowired + private IOrderService orderService; + + + /** + * 查询订单 + */ + @GetMapping("/list") + public ResponseEntity> list() { + return ResponseEntity.ok().body(orderService.list()); + } + + /** + * 插入订单 + */ + @PostMapping("/save") + public ResponseEntity> save(@RequestBody Order order) { + order.setCreatedAt(new Date()); + order.setUpdatedAt(new Date()); + boolean ret = orderService.save(order); + return ret ? ResponseEntity.ok().body(orderService.list()) + : ResponseEntity.badRequest().body(new ArrayList<>()); + } +} diff --git a/shardingspherejamijiemi/src/main/java/com/woniu/service/entity/Order.java b/shardingspherejamijiemi/src/main/java/com/woniu/service/entity/Order.java new file mode 100644 index 0000000..c94b0a9 --- /dev/null +++ b/shardingspherejamijiemi/src/main/java/com/woniu/service/entity/Order.java @@ -0,0 +1,134 @@ +package com.woniu.service.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.util.Date; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + *

+ * + *

+ * + * @author woniu,公众号:【程序员蜗牛g】 + * @since 2023-03-30 + */ +@TableName("tb_order") +@ApiModel(value = "Order对象", description = "") +public class Order implements Serializable { + + private static final long serialVersionUID = 2132123l; + + @ApiModelProperty("主键id") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty("订单号") + private String orderId; + + @ApiModelProperty("用户姓名") + private String name; + + @ApiModelProperty("身份证号") + private String idCard; + + @ApiModelProperty("订单类型,1-挂号,2-门诊,3-住院。") + private String orderType; + + @ApiModelProperty("订单状态,0-待支付,1-支付成功,2-支付失败。") + private String orderStatus; + + @ApiModelProperty("订单金额") + private String amount; + + @ApiModelProperty("创建时间") + private Date createdAt; + + @ApiModelProperty("更新时间") + private Date updatedAt; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + public String getIdCard() { + return idCard; + } + + public void setIdCard(String idCard) { + this.idCard = idCard; + } + public String getOrderType() { + return orderType; + } + + public void setOrderType(String orderType) { + this.orderType = orderType; + } + public String getOrderStatus() { + return orderStatus; + } + + public void setOrderStatus(String orderStatus) { + this.orderStatus = orderStatus; + } + public String getAmount() { + return amount; + } + + public void setAmount(String amount) { + this.amount = amount; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + @Override + public String toString() { + return "Order{" + + "id=" + id + + ", orderId=" + orderId + + ", name=" + name + + ", idCard=" + idCard + + ", orderType=" + orderType + + ", orderStatus=" + orderStatus + + ", amount=" + amount + + ", createdAt=" + createdAt + + ", updatedAt=" + updatedAt + + "}"; + } +} diff --git a/shardingspherejamijiemi/src/main/java/com/woniu/service/enums/ResponseCodeEnum.java b/shardingspherejamijiemi/src/main/java/com/woniu/service/enums/ResponseCodeEnum.java new file mode 100644 index 0000000..ff1ddce --- /dev/null +++ b/shardingspherejamijiemi/src/main/java/com/woniu/service/enums/ResponseCodeEnum.java @@ -0,0 +1,39 @@ +package com.woniu.service.enums; + +/** + *

+ * 状态枚举类 + *

+ * + * @author 公众号:【程序员蜗牛g】 + */ +public enum ResponseCodeEnum { + + SUCCESS(0, "0", "成功"), + FAIL (-1, "-1", "失败"), + PARAMETER_ERROR(1,"1","参数错误"), + ERROR(500, "500", "错误"); + + private final int id; + private final String code; + private final String label; + + ResponseCodeEnum(final int id, final String code, final String label) { + this.id = id; + this.code = code; + this.label = label; + } + + public int getId() { + return id; + } + + public String getCode() { + return code; + } + + public String getLabel() { + return label; + } + +} diff --git a/shardingspherejamijiemi/src/main/java/com/woniu/service/generator/CodeGenerator.java b/shardingspherejamijiemi/src/main/java/com/woniu/service/generator/CodeGenerator.java new file mode 100644 index 0000000..5d7ccd2 --- /dev/null +++ b/shardingspherejamijiemi/src/main/java/com/woniu/service/generator/CodeGenerator.java @@ -0,0 +1,45 @@ +package com.woniu.service.generator; + +import com.baomidou.mybatisplus.generator.FastAutoGenerator; +import com.baomidou.mybatisplus.generator.config.OutputFile; +import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; + +import java.util.Collections; + +/** + *

+ * 状态枚举类 + *

+ * + * @author 公众号:【程序员蜗牛g】 + */ +public class CodeGenerator { + + private static final String url = "jdbc:mysql://localhost:3306/encrypt_demo?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&useSSL=false"; + private static final String username = "root"; + private static final String password = "123456"; + private static final String outputDir = "D:\\workspace\\workspace_blog\\encrypt-demo\\src\\main\\java"; // entity、mapper、service、controller生成的目录地址,换成自己项目的。 + private static final String xmlOutputDir = "D:\\workspace\\workspace_blog\\encrypt-demo\\src\\main\\resources\\mapper"; // xxMapper.xml生成的目录地址,换成自己项目的。 + + public static void main(String[] args) { + FastAutoGenerator.create(url, username, password) + .globalConfig(builder -> { + builder.author("福隆苑居士,公众号:【Java分享客栈】") // 设置作者 + .enableSwagger() // 开启 swagger 模式 + .fileOverride() // 覆盖已生成文件 + .outputDir(outputDir); // 指定输出目录 + }) + .packageConfig(builder -> { + builder.parent("com.example.encrypt") // 设置父包名,和自己项目的父包名一致即可。 + .moduleName("") // 设置父包模块名,为空就会直接生成在父包名目录下。 + .pathInfo(Collections.singletonMap(OutputFile.mapperXml, xmlOutputDir)); // 设置mapperXml生成路径 + }) + .strategyConfig(builder -> { + builder.addInclude("tb_order") // 设置需要生成的表名,多个用逗号隔开。 + .addTablePrefix("t_", "tb_", "c_"); // 设置过滤表前缀,多个用逗号隔开。 + }) + .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板 + .execute(); + } + +} diff --git a/shardingspherejamijiemi/src/main/java/com/woniu/service/mapper/OrderMapper.java b/shardingspherejamijiemi/src/main/java/com/woniu/service/mapper/OrderMapper.java new file mode 100644 index 0000000..3fa7a59 --- /dev/null +++ b/shardingspherejamijiemi/src/main/java/com/woniu/service/mapper/OrderMapper.java @@ -0,0 +1,15 @@ +package com.woniu.service.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.woniu.service.entity.Order; + +/** + *

+ * 状态枚举类 + *

+ * + * @author 公众号:【程序员蜗牛g】 + */ +public interface OrderMapper extends BaseMapper { + +} diff --git a/shardingspherejamijiemi/src/main/java/com/woniu/service/service/IOrderService.java b/shardingspherejamijiemi/src/main/java/com/woniu/service/service/IOrderService.java new file mode 100644 index 0000000..3784075 --- /dev/null +++ b/shardingspherejamijiemi/src/main/java/com/woniu/service/service/IOrderService.java @@ -0,0 +1,16 @@ +package com.woniu.service.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.woniu.service.entity.Order; + +/** + *

+ * 状态枚举类 + *

+ * + * @author 公众号:【程序员蜗牛g】 + */ +public interface IOrderService extends IService { + +} diff --git a/shardingspherejamijiemi/src/main/java/com/woniu/service/service/impl/OrderServiceImpl.java b/shardingspherejamijiemi/src/main/java/com/woniu/service/service/impl/OrderServiceImpl.java new file mode 100644 index 0000000..100d40f --- /dev/null +++ b/shardingspherejamijiemi/src/main/java/com/woniu/service/service/impl/OrderServiceImpl.java @@ -0,0 +1,20 @@ +package com.woniu.service.service.impl; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.woniu.service.entity.Order; +import com.woniu.service.mapper.OrderMapper; +import com.woniu.service.service.IOrderService; +import org.springframework.stereotype.Service; + +/** + *

+ * 状态枚举类 + *

+ * + * @author 公众号:【程序员蜗牛g】 + */ +@Service +public class OrderServiceImpl extends ServiceImpl implements IOrderService { + +} diff --git a/shardingspherejamijiemi/src/main/java/com/woniu/service/util/ResultEntity.java b/shardingspherejamijiemi/src/main/java/com/woniu/service/util/ResultEntity.java new file mode 100644 index 0000000..fdb8c9d --- /dev/null +++ b/shardingspherejamijiemi/src/main/java/com/woniu/service/util/ResultEntity.java @@ -0,0 +1,89 @@ +package com.woniu.service.util; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.woniu.service.enums.ResponseCodeEnum; +/** + *

+ * 状态枚举类 + *

+ * + * @author 公众号:【程序员蜗牛g】 + */ +public class ResultEntity { + + private String code; + + private String msg; + + private T data; + + public ResultEntity(){} + + public ResultEntity(String code, String msg){ + this.code = code; + this.msg = msg; + } + + public ResultEntity(String code, String msg, T data){ + this.code = code; + this.msg = msg; + this.data = data; + } + + @JsonIgnore + public boolean isSuccess() { + return ResponseCodeEnum.SUCCESS.getCode().equals(this.getCode()); + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + + public static ResultEntity fail(String code, String msg) { + return new ResultEntity(code, msg); + } + + public static ResultEntity fail(String code, String msg, T data) { + return new ResultEntity(code, msg, data); + } + + public static ResultEntity ok(String code, String msg) { + return new ResultEntity(code, msg); + } + + public static ResultEntity ok(String code, String msg, T data) { + return new ResultEntity(code, msg, data); + } + + public static ResultEntity ok(String msg) { + return new ResultEntity(ResponseCodeEnum.SUCCESS.getCode(), msg); + } + + public static ResultEntity ok(String msg, T data) { + return new ResultEntity(ResponseCodeEnum.SUCCESS.getCode(), msg, data); + } + + public static ResultEntity fail(String msg) { + return new ResultEntity(ResponseCodeEnum.FAIL.getCode(), msg); + } +} diff --git a/shardingspherejamijiemi/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.strategy.spi.Encryptor b/shardingspherejamijiemi/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.strategy.spi.Encryptor new file mode 100644 index 0000000..a3295f6 --- /dev/null +++ b/shardingspherejamijiemi/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.strategy.spi.Encryptor @@ -0,0 +1 @@ +com.woniu.service.config.MyShardingEncryptor \ No newline at end of file diff --git a/shardingspherejamijiemi/src/main/resources/application.properties b/shardingspherejamijiemi/src/main/resources/application.properties new file mode 100644 index 0000000..2aa1e98 --- /dev/null +++ b/shardingspherejamijiemi/src/main/resources/application.properties @@ -0,0 +1,14 @@ + +#mybatis.config-location=classpath:/mybatis-config.xml + +#context.initializer.classes +#context.initializer.classes=com.fanfu.config.MyApplicationContextInitializer + +#server.port=8088 +#mybatis-plus.mapper-locations=classpath*:/mapper/*.xml +# +# +#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai +#spring.datasource.username=root +#spring.datasource.password=123456 +#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver \ No newline at end of file diff --git a/shardingspherejamijiemi/src/main/resources/application.yml b/shardingspherejamijiemi/src/main/resources/application.yml new file mode 100644 index 0000000..1a2e8e4 --- /dev/null +++ b/shardingspherejamijiemi/src/main/resources/application.yml @@ -0,0 +1,58 @@ +server: + port: 8888 + +# 数据源 +spring: + shardingsphere: + props: + sql: + show: false + query: + with: + cipher: + column: true # 查询是否使用密文列 + datasource: + name: master + master: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + jdbc-url: jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&useSSL=false + username: root + password: 123456 + initial-size: 20 + max-active: 200 + min-idle: 10 + max-wait: 60000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + validation-query: SELECT 1 + test-while-idle: true + test-on-borrow: false + test-on-return: false + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true + # 加密配置 + encrypt: + encryptors: + my_encryptor: + type: mySharding # 声明加密处理器的类型,自定义。 + props: + aes.key.value: won13579@# # 加密处理器创建密钥会用到,10个数字英文字母组合,自定义。 + # 需要加密哪张表中的哪些字段,每个字段使用哪个加密处理器,这里的my_encryptor就是上面配置的处理器名称。 + tables: + tb_order: + columns: + id_card: + cipherColumn: id_card + encryptor: my_encryptor + name: + cipherColumn: name + encryptor: my_encryptor \ No newline at end of file diff --git a/shardingspherejamijiemi/src/main/resources/logback-spring.xml b/shardingspherejamijiemi/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..3d228f0 --- /dev/null +++ b/shardingspherejamijiemi/src/main/resources/logback-spring.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/shardingspherejamijiemi/src/main/resources/sql.sql b/shardingspherejamijiemi/src/main/resources/sql.sql new file mode 100644 index 0000000..9ca3834 --- /dev/null +++ b/shardingspherejamijiemi/src/main/resources/sql.sql @@ -0,0 +1,22 @@ +SET FOREIGN_KEY_CHECKS=0; +-- ---------------------------- +-- Table structure for tb_order +-- ---------------------------- +DROP TABLE IF EXISTS `tb_order`; +CREATE TABLE `tb_order` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键id', + `order_id` varchar(50) DEFAULT NULL COMMENT '订单号', + `name` varchar(100) DEFAULT NULL COMMENT '用户姓名', + `id_card` varchar(100) DEFAULT NULL COMMENT '身份证号', + `order_type` char(5) DEFAULT NULL COMMENT '订单类型,1-挂号,2-门诊,3-住院。', + `order_status` char(5) DEFAULT NULL COMMENT '订单状态,0-待支付,1-支付成功,2-支付失败。', + `amount` varchar(20) DEFAULT NULL COMMENT '订单金额', + `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updated_at` datetime DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb3; + +-- ---------------------------- +-- Records of tb_order +-- ---------------------------- +INSERT INTO `tb_order` VALUES ('5', 'wx2202210122003344763267816', '3qxlE2jBqAM+wkPYM2Drgg==', 'MPLHKUIwav77Ad+9xe+O9olTwNArU7thbEmljIkKtxY=', '1', '0', '15', '2022-02-21 09:23:45', '2022-02-21 09:23:45'); diff --git a/shardingspherejamijiemi/src/test/java/com/woniu/TestA.java b/shardingspherejamijiemi/src/test/java/com/woniu/TestA.java new file mode 100644 index 0000000..4906675 --- /dev/null +++ b/shardingspherejamijiemi/src/test/java/com/woniu/TestA.java @@ -0,0 +1,24 @@ +//package com.woniu; +// +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.junit4.SpringRunner; +// +// +//@SpringBootTest +//@RunWith(SpringRunner.class) +//public class TestA { +// +// +// @Autowired +// private OrderService orderService; +// +// +// @Test +// public void placeOrder() { +// OrderReqVO orderReqVO = new OrderReqVO(); +// orderService.saveOrder(orderReqVO); +// } +//} diff --git a/shardingspherejamijiemi/woniu-web.iml b/shardingspherejamijiemi/woniu-web.iml new file mode 100644 index 0000000..eb46bf6 --- /dev/null +++ b/shardingspherejamijiemi/woniu-web.iml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file