服务启动

This commit is contained in:
2025-12-05 18:24:21 +08:00
parent a8233ceb72
commit 133209691e
39 changed files with 2526 additions and 30 deletions

View File

@@ -14,7 +14,7 @@ import java.util.List;
* @author yslg
*/
@Component
@ConfigurationProperties(prefix = "urban-lifeline.auth")
@ConfigurationProperties(prefix = "auth")
public class AuthProperties {
/**

View File

@@ -23,10 +23,10 @@ import java.util.Map;
@Component
public class JwtTokenUtil {
@Value("${urban-lifeline.auth.jwt-secret:schoolNewsDefaultSecretKeyForJWT2025}")
@Value("${auth.jwt-secret:urbanLifelineDefaultSecretKeyForJWT2025}")
private String secret;
@Value("${urban-lifeline.auth.jwt-expiration:86400}")
@Value("${auth.jwt-expiration:86400}")
private Long expiration;
private SecretKey getSigningKey() {

View File

@@ -0,0 +1,27 @@
package org.xyzh.common.core.exception;
public class BaseException extends RuntimeException{
private Integer code;
private String description;
public BaseException(Integer code, String description, String message) {
super(message);
this.code = code;
this.description = description;
}
public Integer getCode(){
return this.code;
}
public String getDescription(){
return this.description;
}
public String getMessage(){
return super.getMessage();
}
}

View File

@@ -13,7 +13,6 @@
<artifactId>common-utils</artifactId>
<version>${urban-lifeline.version}</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
@@ -44,5 +43,22 @@
<artifactId>spring-boot-starter</artifactId>
<scope>provided</scope>
</dependency>
<!-- Spring Mail for Email -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!-- Aliyun SMS Service -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<version>4.2.0</version>
</dependency>
<!-- FastJson2 Spring6 支持 -->
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension-spring6</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,50 @@
package org.xyzh.common.utils.config;
import com.alibaba.fastjson2.support.config.FastJsonConfig;
import com.alibaba.fastjson2.support.spring6.http.converter.FastJsonHttpMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
/**
* @description FastJson配置类 - 统一处理日期时间格式序列化
* @filename FastJsonConfig.java
* @author yslg
* @copyright xyzh
* @since 2025-11-28
*/
@Configuration
public class FastJsonConfiguration implements WebMvcConfigurer {
/**
* 配置FastJson消息转换器
*/
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
// FastJson配置
FastJsonConfig config = new FastJsonConfig();
// 设置日期格式
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
// 设置字符集
converter.setDefaultCharset(StandardCharsets.UTF_8);
// 设置支持的MediaType
converter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON));
// 应用配置
converter.setFastJsonConfig(config);
// 添加到转换器列表(添加到最前面,优先使用)
converters.add(0, converter);
}
}