Skip to content

Commit

Permalink
feat: springboot 升级,代码格式调整
Browse files Browse the repository at this point in the history
  • Loading branch information
fuhouyu committed Oct 25, 2024
1 parent c616487 commit c0e10f4
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 69 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Base Framework

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=fuhouyu_base-framework&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=fuhouyu_base-framework) [![codecov](https://codecov.io/github/fuhouyu/base-framework/graph/badge.svg?token=VUT9BFMLK9)](https://codecov.io/github/fuhouyu/base-framework) [![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=fuhouyu_base-framework&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=fuhouyu_base-framework)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=fuhouyu_base-framework&metric=bugs&branch=develop)](https://sonarcloud.io/summary/new_code?id=fuhouyu_base-framework&branch=develop)
[![codecov](https://codecov.io/github/fuhouyu/base-framework/graph/badge.svg?token=VUT9BFMLK9)](https://codecov.io/github/fuhouyu/base-framework)
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
-------

### 简介
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ private Set<V> getSetByCache(K key) {
*/
private void addPolicyExpireTime(K key, V value, long timeout, TimeUnit unit) {
cache.policy().expireVariably()
.ifPresent(e -> {
V ignored = e.put(key, value, timeout, unit);
});
.ifPresent(e ->
e.put(key, value, timeout, unit)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public static byte[] decodeHex(String hexStr) {

private static void encodeHex(final byte[] data, final int dataLen,
final char[] out) {
for (int i = 0, j = 0; i < dataLen; i++) {
int j = 0;
for (int i = 0; i < dataLen; i++) {
out[j++] = HexUtil.DIGITS_LOWER[(0xF0 & data[i]) >>> 4];
out[j++] = HexUtil.DIGITS_LOWER[0x0F & data[i]];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package com.fuhouyu.framework.context;

import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;

/**
* <p>
* 上下文策略类
Expand All @@ -24,6 +27,7 @@
* @author fuhouyu
* @since 2024/8/14 10:08
*/
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public class ContextHolderStrategy {

private static final ThreadLocal<ContextFactory> THREAD_LOCAL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Objects;
import java.util.Optional;

/**
* <p>
Expand Down Expand Up @@ -163,7 +164,7 @@ private SM2 generatorSm2() {
throw new KmsException("sm2 公私钥未设置,且未启用自动生成");
}

String parentPath = sm2Properties.getAutoGenerateLocalPath();
String parentPath = Optional.ofNullable(sm2Properties.getAutoGenerateLocalPath()).orElse("/tmp/keypair");
Path publicKeyPath = Path.of(parentPath, "publicKey");
Path privateKeyPath = Path.of(parentPath, "privateKey");
if (Files.exists(publicKeyPath) && Files.exists(privateKeyPath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static class Sm2Properties {
/**
* 自动生成后存储的路径
*/
private String autoGenerateLocalPath = "/tmp/keypair";
private String autoGenerateLocalPath;

/**
* 公钥key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
@Slf4j
public class WechatAppletsPlatformProvider extends AbstractAuthenticationProvider<WechatAppletsUserInfo> {

// TODO 这里的restTemplate 后续待抽离
private final RestTemplate restTemplate;

private final UserDetailsService userDetailsService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,19 +360,6 @@ private byte[] serializeKey(String key) {
return (prefix + key).getBytes(StandardCharsets.UTF_8);
}

/**
* 从缓存中读取字节数组
*
* @param key key
* @return 字节数组
*/
private byte[] getCacheBytes(String key) {
String result = (String) cacheService.get(key);
if (Objects.isNull(result)) {
return null;
}
return Base64.decodeBase64(result);
}

/**
* 返回过期时间
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,29 @@ public RequestEntity() {
this.additionalInformation = new HashMap<>(2);
}

/**
* 认证信息
*/
private String authorization;

/**
* 请求ip
*/
private String requestIp;

/**
* 请求主机
*/
private String requestHost;

/**
* 请求目标
*/
private String requestTarget;

/**
* userAgent
*/
private String userAgent;

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,40 @@ public class UserEntity implements User {
@Serial
private static final long serialVersionUID = 2389708129078213719L;

/**
* 用户id
*/
private Long id;

/**
* 用户名
*/
private String username;

/**
* 真实姓名
*/
private String realName;

/**
* 昵称
*/
private String nickname;

/**
* 性别
*/
private String gender;

/**
* 所属的账号id
*/
private String refAccountId;

private Map<String, Object> additionalInformation;
/**
* 扩展信息
*/
private transient Map<String, Object> additionalInformation;

public UserEntity() {
this.additionalInformation = new HashMap<>();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.fuhouyu.framework.web.enums.ErrorLevelEnum;
import com.fuhouyu.framework.web.enums.ResponseCodeEnum;

import java.io.Serializable;

/**
* <p>
* 错误响应
Expand All @@ -27,7 +29,7 @@
* @author fuhouyu
* @since 2024/10/16 20:35
*/
public class ErrorResponse<T> implements BaseResponse<T> {
public class ErrorResponse<T extends Serializable> implements BaseResponse<T> {

private final Integer code;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static class HttpController {

@PostMapping("/v1/test/enc")
@PrepareHttpBody
public BaseResponse<Object> post(@RequestBody ObjectNode body) throws Exception {
public BaseResponse<Object> post(@RequestBody ObjectNode body) {
return ResponseHelper.success(body);
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<maven-easyj.version>1.1.5</maven-easyj.version>

<!--外部依赖项-->
<spring-boot-dependencies.version>3.3.4</spring-boot-dependencies.version>
<spring-boot-dependencies.version>3.3.5</spring-boot-dependencies.version>
<spring-cloud-dependencies.version>2023.0.3</spring-cloud-dependencies.version>
<spring-cloud-alibaba-dependencies.version>2023.0.1.2</spring-cloud-alibaba-dependencies.version>
<springdoc-openapi-starter-webmvc-api.version>2.6.0</springdoc-openapi-starter-webmvc-api.version>
Expand Down

0 comments on commit c0e10f4

Please sign in to comment.