删除不需要的模块
This commit is contained in:
parent
15f3e25acc
commit
628a63a250
4
pom.xml
4
pom.xml
@ -19,7 +19,7 @@
|
|||||||
<module>system-common</module>
|
<module>system-common</module>
|
||||||
<module>system-dynamic-datasource</module>
|
<module>system-dynamic-datasource</module>
|
||||||
<module>system-admin</module>
|
<module>system-admin</module>
|
||||||
<module>system-api</module>
|
<!-- <module>system-api</module>-->
|
||||||
<!-- <module>renren-generator</module>-->
|
<!-- <module>renren-generator</module>-->
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
@ -32,7 +32,7 @@
|
|||||||
<sqlserver.version>4.0</sqlserver.version>
|
<sqlserver.version>4.0</sqlserver.version>
|
||||||
<oracle.version>11.2.0.3</oracle.version>
|
<oracle.version>11.2.0.3</oracle.version>
|
||||||
<dameng.version>8.1.2.141</dameng.version>
|
<dameng.version>8.1.2.141</dameng.version>
|
||||||
<hutool.version>5.8.29</hutool.version>
|
<hutool.version>5.8.40</hutool.version>
|
||||||
<jsoup.version>1.15.3</jsoup.version>
|
<jsoup.version>1.15.3</jsoup.version>
|
||||||
<knife4j.version>4.5.0</knife4j.version>
|
<knife4j.version>4.5.0</knife4j.version>
|
||||||
<springdoc.version>2.8.4</springdoc.version>
|
<springdoc.version>2.8.4</springdoc.version>
|
||||||
|
|||||||
@ -1,23 +0,0 @@
|
|||||||
FROM eclipse-temurin:17-jre-alpine
|
|
||||||
|
|
||||||
LABEL maintainer="weather-data"
|
|
||||||
LABEL description="Weather Data System - API Service"
|
|
||||||
|
|
||||||
RUN apk add --no-cache tzdata curl && \
|
|
||||||
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
|
||||||
echo "Asia/Shanghai" > /etc/timezone
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
EXPOSE 8081
|
|
||||||
|
|
||||||
ARG JAR_FILE=target/system-api.jar
|
|
||||||
COPY ${JAR_FILE} /app/app.jar
|
|
||||||
|
|
||||||
ENV JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC -Djava.security.egd=file:/dev/./urandom"
|
|
||||||
ENV SPRING_PROFILES_ACTIVE=prod
|
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=60s \
|
|
||||||
CMD curl -f http://localhost:8081/renren-api/actuator/health || exit 1
|
|
||||||
|
|
||||||
ENTRYPOINT exec java ${JAVA_OPTS} -jar /app/app.jar
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
<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>
|
|
||||||
<groupId>com.weather</groupId>
|
|
||||||
<artifactId>weather-data</artifactId>
|
|
||||||
<version>5.5.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>system-api</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
<description>system-api</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.weather</groupId>
|
|
||||||
<artifactId>system-common</artifactId>
|
|
||||||
<version>5.5.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.weather</groupId>
|
|
||||||
<artifactId>system-dynamic-datasource</artifactId>
|
|
||||||
<version>5.5.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<finalName>${project.artifactId}</finalName>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<skipTests>true</skipTests>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.weather;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
||||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* weather-api
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@SpringBootApplication
|
|
||||||
public class ApiApplication extends SpringBootServletInitializer {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(ApiApplication.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
|
||||||
return application.sources(ApiApplication.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.weather.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录效验
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Documented
|
|
||||||
public @interface Login {
|
|
||||||
}
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.weather.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录用户信息
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@Target(ElementType.PARAMETER)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface LoginUser {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.weather.config;
|
|
||||||
|
|
||||||
import com.weather.common.xss.XssFilter;
|
|
||||||
import jakarta.servlet.DispatcherType;
|
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter配置
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class FilterConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public FilterRegistrationBean xssFilterRegistration() {
|
|
||||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
|
||||||
registration.setDispatcherTypes(DispatcherType.REQUEST);
|
|
||||||
registration.setFilter(new XssFilter());
|
|
||||||
registration.addUrlPatterns("/*");
|
|
||||||
registration.setName("xssFilter");
|
|
||||||
return registration;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.weather.config;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* mybatis-plus配置
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class MybatisPlusConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 配置分页等
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
|
||||||
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
|
|
||||||
// 分页插件
|
|
||||||
mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
|
|
||||||
// 乐观锁
|
|
||||||
mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
|
|
||||||
// 防止全表更新与删除
|
|
||||||
mybatisPlusInterceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
|
|
||||||
|
|
||||||
return mybatisPlusInterceptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
|
|
||||||
package com.weather.config;
|
|
||||||
|
|
||||||
import com.weather.common.constant.Constant;
|
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
|
||||||
import io.swagger.v3.oas.models.info.Info;
|
|
||||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class SwaggerConfig {
|
|
||||||
@Bean
|
|
||||||
public OpenAPI createRestApi() {
|
|
||||||
return new OpenAPI()
|
|
||||||
.info(apiInfo())
|
|
||||||
.security(security());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Info apiInfo() {
|
|
||||||
return new Info()
|
|
||||||
.title("人人开源")
|
|
||||||
.description("weather-api文档")
|
|
||||||
.version("5.x");
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<SecurityRequirement> security() {
|
|
||||||
SecurityRequirement key = new SecurityRequirement();
|
|
||||||
key.addList(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER);
|
|
||||||
|
|
||||||
List<SecurityRequirement> list = new ArrayList<>();
|
|
||||||
list.add(key);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,79 +0,0 @@
|
|||||||
|
|
||||||
package com.weather.config;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
|
||||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
|
||||||
import com.weather.common.utils.DateUtils;
|
|
||||||
import com.weather.interceptor.AuthorizationInterceptor;
|
|
||||||
import com.weather.resolver.LoginUserHandlerMethodArgumentResolver;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
|
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
|
||||||
import org.springframework.http.converter.ResourceHttpMessageConverter;
|
|
||||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
|
||||||
import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter;
|
|
||||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MVC配置
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class WebMvcConfig implements WebMvcConfigurer {
|
|
||||||
@Resource
|
|
||||||
private AuthorizationInterceptor authorizationInterceptor;
|
|
||||||
@Resource
|
|
||||||
private LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
|
||||||
registry.addInterceptor(authorizationInterceptor).addPathPatterns("/api/**");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
|
||||||
argumentResolvers.add(loginUserHandlerMethodArgumentResolver);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
|
||||||
converters.add(new ByteArrayHttpMessageConverter());
|
|
||||||
converters.add(new StringHttpMessageConverter());
|
|
||||||
converters.add(new ResourceHttpMessageConverter());
|
|
||||||
converters.add(new AllEncompassingFormHttpMessageConverter());
|
|
||||||
converters.add(new StringHttpMessageConverter());
|
|
||||||
converters.add(jackson2HttpMessageConverter());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public MappingJackson2HttpMessageConverter jackson2HttpMessageConverter() {
|
|
||||||
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
|
|
||||||
//日期格式转换
|
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
mapper.setDateFormat(new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN));
|
|
||||||
mapper.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
|
||||||
|
|
||||||
//Long类型转String类型
|
|
||||||
SimpleModule simpleModule = new SimpleModule();
|
|
||||||
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
|
||||||
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
|
|
||||||
mapper.registerModule(simpleModule);
|
|
||||||
|
|
||||||
converter.setObjectMapper(mapper);
|
|
||||||
return converter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
|
|
||||||
package com.weather.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import com.weather.annotation.Login;
|
|
||||||
import com.weather.common.utils.Result;
|
|
||||||
import com.weather.common.validator.ValidatorUtils;
|
|
||||||
import com.weather.dto.LoginDTO;
|
|
||||||
import com.weather.service.TokenService;
|
|
||||||
import com.weather.service.UserService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录接口
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api")
|
|
||||||
@Tag(name = "登录接口")
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class ApiLoginController {
|
|
||||||
private final UserService userService;
|
|
||||||
private final TokenService tokenService;
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("login")
|
|
||||||
@Operation(summary = "登录")
|
|
||||||
public Result<Map<String, Object>> login(@RequestBody LoginDTO dto) {
|
|
||||||
//表单校验
|
|
||||||
ValidatorUtils.validateEntity(dto);
|
|
||||||
|
|
||||||
//用户登录
|
|
||||||
Map<String, Object> map = userService.login(dto);
|
|
||||||
|
|
||||||
return new Result().ok(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Login
|
|
||||||
@PostMapping("logout")
|
|
||||||
@Operation(summary = "退出")
|
|
||||||
public Result logout(@Parameter(hidden = true) @RequestAttribute("userId") Long userId) {
|
|
||||||
tokenService.expireToken(userId);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,47 +0,0 @@
|
|||||||
|
|
||||||
package com.weather.controller;
|
|
||||||
|
|
||||||
import cn.hutool.crypto.digest.DigestUtil;
|
|
||||||
import com.weather.common.utils.Result;
|
|
||||||
import com.weather.common.validator.ValidatorUtils;
|
|
||||||
import com.weather.dto.RegisterDTO;
|
|
||||||
import com.weather.entity.UserEntity;
|
|
||||||
import com.weather.service.UserService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册接口
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api")
|
|
||||||
@Tag(name = "注册接口")
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class ApiRegisterController {
|
|
||||||
private final UserService userService;
|
|
||||||
|
|
||||||
@PostMapping("register")
|
|
||||||
@Operation(summary = "注册")
|
|
||||||
public Result register(@RequestBody RegisterDTO dto) {
|
|
||||||
//表单校验
|
|
||||||
ValidatorUtils.validateEntity(dto);
|
|
||||||
|
|
||||||
UserEntity user = new UserEntity();
|
|
||||||
user.setMobile(dto.getMobile());
|
|
||||||
user.setUsername(dto.getMobile());
|
|
||||||
user.setPassword(DigestUtil.sha256Hex(dto.getPassword()));
|
|
||||||
user.setCreateDate(new Date());
|
|
||||||
userService.insert(user);
|
|
||||||
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
|
|
||||||
package com.weather.controller;
|
|
||||||
|
|
||||||
import com.weather.annotation.Login;
|
|
||||||
import com.weather.annotation.LoginUser;
|
|
||||||
import com.weather.common.utils.Result;
|
|
||||||
import com.weather.entity.UserEntity;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试接口
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api")
|
|
||||||
@Tag(name = "测试接口")
|
|
||||||
public class ApiTestController {
|
|
||||||
|
|
||||||
@Login
|
|
||||||
@GetMapping("userInfo")
|
|
||||||
@Operation(summary = "获取用户信息")
|
|
||||||
public Result<UserEntity> userInfo(@Parameter(hidden = true) @LoginUser UserEntity user) {
|
|
||||||
return new Result<UserEntity>().ok(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Login
|
|
||||||
@GetMapping("userId")
|
|
||||||
@Operation(summary = "获取用户ID")
|
|
||||||
public Result<Long> userInfo(@Parameter(hidden = true) @RequestAttribute("userId") Long userId) {
|
|
||||||
return new Result<Long>().ok(userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("notToken")
|
|
||||||
@Operation(summary = "忽略Token验证测试")
|
|
||||||
public Result<String> notToken() {
|
|
||||||
return new Result<String>().ok("无需token也能访问。。。");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.weather.dao;
|
|
||||||
|
|
||||||
import com.weather.common.dao.BaseDao;
|
|
||||||
import com.weather.entity.TokenEntity;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户Token
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface TokenDao extends BaseDao<TokenEntity> {
|
|
||||||
TokenEntity getByToken(String token);
|
|
||||||
|
|
||||||
TokenEntity getByUserId(Long userId);
|
|
||||||
}
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.weather.dao;
|
|
||||||
|
|
||||||
import com.weather.common.dao.BaseDao;
|
|
||||||
import com.weather.entity.UserEntity;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface UserDao extends BaseDao<UserEntity> {
|
|
||||||
UserEntity getUserByMobile(String mobile);
|
|
||||||
|
|
||||||
UserEntity getUserByUserId(Long userId);
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
package com.weather.dto;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Schema(title = "登录表单")
|
|
||||||
public class LoginDTO {
|
|
||||||
@Schema(title = "手机号")
|
|
||||||
@NotBlank(message = "手机号不能为空")
|
|
||||||
private String mobile;
|
|
||||||
|
|
||||||
@Schema(title = "密码")
|
|
||||||
@NotBlank(message = "密码不能为空")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.weather.dto;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册表单
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Schema(title = "注册表单")
|
|
||||||
public class RegisterDTO {
|
|
||||||
@Schema(title = "手机号")
|
|
||||||
@NotBlank(message="手机号不能为空")
|
|
||||||
private String mobile;
|
|
||||||
|
|
||||||
@Schema(title = "密码")
|
|
||||||
@NotBlank(message="密码不能为空")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.weather.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户Token
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName("tb_token")
|
|
||||||
public class TokenEntity implements Serializable {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@TableId
|
|
||||||
private Long id;
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
private Long userId;
|
|
||||||
/**
|
|
||||||
* 用户token
|
|
||||||
*/
|
|
||||||
private String token;
|
|
||||||
/**
|
|
||||||
* 过期时间
|
|
||||||
*/
|
|
||||||
private Date expireDate;
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
private Date updateDate;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.weather.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName("tb_user")
|
|
||||||
public class UserEntity implements Serializable {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
@TableId
|
|
||||||
private Long id;
|
|
||||||
/**
|
|
||||||
* 用户名
|
|
||||||
*/
|
|
||||||
private String username;
|
|
||||||
/**
|
|
||||||
* 手机号
|
|
||||||
*/
|
|
||||||
private String mobile;
|
|
||||||
/**
|
|
||||||
* 密码
|
|
||||||
*/
|
|
||||||
@JsonIgnore
|
|
||||||
private String password;
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private Date createDate;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.weather.exception;
|
|
||||||
|
|
||||||
import com.weather.common.exception.ErrorCode;
|
|
||||||
import com.weather.common.exception.CommonException;
|
|
||||||
import com.weather.common.utils.Result;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.dao.DuplicateKeyException;
|
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 异常处理器
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
@RestControllerAdvice
|
|
||||||
public class RenExceptionHandler {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RenExceptionHandler.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理自定义异常
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(CommonException.class)
|
|
||||||
public Result handleRenException(CommonException ex){
|
|
||||||
Result result = new Result();
|
|
||||||
result.error(ex.getCode(), ex.getMsg());
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ExceptionHandler(DuplicateKeyException.class)
|
|
||||||
public Result handleDuplicateKeyException(DuplicateKeyException ex){
|
|
||||||
Result result = new Result();
|
|
||||||
result.error(ErrorCode.DB_RECORD_EXISTS);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ExceptionHandler(Exception.class)
|
|
||||||
public Result handleException(Exception ex){
|
|
||||||
logger.error(ex.getMessage(), ex);
|
|
||||||
|
|
||||||
return new Result().error();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,65 +0,0 @@
|
|||||||
|
|
||||||
package com.weather.interceptor;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.weather.annotation.Login;
|
|
||||||
import com.weather.common.exception.ErrorCode;
|
|
||||||
import com.weather.common.exception.CommonException;
|
|
||||||
import com.weather.entity.TokenEntity;
|
|
||||||
import com.weather.service.TokenService;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.method.HandlerMethod;
|
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限(Token)验证
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class AuthorizationInterceptor implements HandlerInterceptor {
|
|
||||||
@Resource
|
|
||||||
private TokenService tokenService;
|
|
||||||
|
|
||||||
public static final String USER_KEY = "userId";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
||||||
Login annotation;
|
|
||||||
if (handler instanceof HandlerMethod) {
|
|
||||||
annotation = ((HandlerMethod) handler).getMethodAnnotation(Login.class);
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (annotation == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//从header中获取token
|
|
||||||
String token = request.getHeader("token");
|
|
||||||
//如果header中不存在token,则从参数中获取token
|
|
||||||
if (StrUtil.isBlank(token)) {
|
|
||||||
token = request.getParameter("token");
|
|
||||||
}
|
|
||||||
|
|
||||||
//token为空
|
|
||||||
if (StrUtil.isBlank(token)) {
|
|
||||||
throw new CommonException(ErrorCode.TOKEN_NOT_EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
//查询token信息
|
|
||||||
TokenEntity tokenEntity = tokenService.getByToken(token);
|
|
||||||
if (tokenEntity == null || tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()) {
|
|
||||||
throw new CommonException(ErrorCode.TOKEN_INVALID);
|
|
||||||
}
|
|
||||||
|
|
||||||
//设置userId到request里,后续根据userId,获取用户信息
|
|
||||||
request.setAttribute(USER_KEY, tokenEntity.getUserId());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
|
|
||||||
package com.weather.resolver;
|
|
||||||
|
|
||||||
import com.weather.annotation.LoginUser;
|
|
||||||
import com.weather.entity.UserEntity;
|
|
||||||
import com.weather.interceptor.AuthorizationInterceptor;
|
|
||||||
import com.weather.service.UserService;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.springframework.core.MethodParameter;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.bind.support.WebDataBinderFactory;
|
|
||||||
import org.springframework.web.context.request.NativeWebRequest;
|
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
|
||||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
|
||||||
import org.springframework.web.method.support.ModelAndViewContainer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 有@LoginUser注解的方法参数,注入当前登录用户
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {
|
|
||||||
private final UserService userService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supportsParameter(MethodParameter parameter) {
|
|
||||||
return parameter.getParameterType().isAssignableFrom(UserEntity.class) && parameter.hasParameterAnnotation(LoginUser.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer container,
|
|
||||||
NativeWebRequest request, WebDataBinderFactory factory) throws Exception {
|
|
||||||
//获取用户ID
|
|
||||||
Object object = request.getAttribute(AuthorizationInterceptor.USER_KEY, RequestAttributes.SCOPE_REQUEST);
|
|
||||||
if (object == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取用户信息
|
|
||||||
UserEntity user = userService.getUserByUserId((Long) object);
|
|
||||||
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.weather.service;
|
|
||||||
|
|
||||||
import com.weather.common.service.BaseService;
|
|
||||||
import com.weather.entity.TokenEntity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户Token
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
public interface TokenService extends BaseService<TokenEntity> {
|
|
||||||
|
|
||||||
TokenEntity getByToken(String token);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成token
|
|
||||||
* @param userId 用户ID
|
|
||||||
* @return 返回token信息
|
|
||||||
*/
|
|
||||||
TokenEntity createToken(Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置token过期
|
|
||||||
* @param userId 用户ID
|
|
||||||
*/
|
|
||||||
void expireToken(Long userId);
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.weather.service;
|
|
||||||
|
|
||||||
import com.weather.common.service.BaseService;
|
|
||||||
import com.weather.entity.UserEntity;
|
|
||||||
import com.weather.dto.LoginDTO;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户
|
|
||||||
*
|
|
||||||
* @author 123
|
|
||||||
*/
|
|
||||||
public interface UserService extends BaseService<UserEntity> {
|
|
||||||
|
|
||||||
UserEntity getByMobile(String mobile);
|
|
||||||
|
|
||||||
UserEntity getUserByUserId(Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户登录
|
|
||||||
* @param dto 登录表单
|
|
||||||
* @return 返回登录信息
|
|
||||||
*/
|
|
||||||
Map<String, Object> login(LoginDTO dto);
|
|
||||||
}
|
|
||||||
@ -1,92 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.weather.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
||||||
import com.weather.common.service.impl.BaseServiceImpl;
|
|
||||||
import com.weather.dao.TokenDao;
|
|
||||||
import com.weather.entity.TokenEntity;
|
|
||||||
import com.weather.service.TokenService;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class TokenServiceImpl extends BaseServiceImpl<TokenDao, TokenEntity> implements TokenService {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private TokenDao tokenDao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 12小时后过期
|
|
||||||
*/
|
|
||||||
private final static int EXPIRE = 3600 * 12;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TokenEntity getByToken(String token) {
|
|
||||||
return baseDao.getByToken(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TokenEntity createToken(Long userId) {
|
|
||||||
//当前时间
|
|
||||||
Date now = new Date();
|
|
||||||
//过期时间
|
|
||||||
Date expireTime = new Date(now.getTime() + EXPIRE * 1000);
|
|
||||||
|
|
||||||
//用户token
|
|
||||||
String token;
|
|
||||||
|
|
||||||
//判断是否生成过token
|
|
||||||
TokenEntity tokenEntity = baseDao.getByUserId(userId);
|
|
||||||
if(tokenEntity == null){
|
|
||||||
//生成一个token
|
|
||||||
token = generateToken();
|
|
||||||
|
|
||||||
tokenEntity = new TokenEntity();
|
|
||||||
tokenEntity.setUserId(userId);
|
|
||||||
tokenEntity.setToken(token);
|
|
||||||
tokenEntity.setUpdateDate(now);
|
|
||||||
tokenEntity.setExpireDate(expireTime);
|
|
||||||
|
|
||||||
//保存token
|
|
||||||
this.insert(tokenEntity);
|
|
||||||
}else{
|
|
||||||
//判断token是否过期
|
|
||||||
if(tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()){
|
|
||||||
//token过期,重新生成token
|
|
||||||
token = generateToken();
|
|
||||||
}else {
|
|
||||||
token = tokenEntity.getToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
tokenEntity.setToken(token);
|
|
||||||
tokenEntity.setUpdateDate(now);
|
|
||||||
tokenEntity.setExpireDate(expireTime);
|
|
||||||
|
|
||||||
//更新token
|
|
||||||
this.updateById(tokenEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
return tokenEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void expireToken(Long userId){
|
|
||||||
Date now = new Date();
|
|
||||||
|
|
||||||
LambdaUpdateWrapper<TokenEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
|
||||||
updateWrapper.eq(TokenEntity::getUserId, userId);
|
|
||||||
updateWrapper.set(TokenEntity::getExpireDate, now);
|
|
||||||
updateWrapper.set(TokenEntity::getUpdateDate, now);
|
|
||||||
|
|
||||||
tokenDao.update(updateWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String generateToken(){
|
|
||||||
return UUID.randomUUID().toString().replace("-", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,56 +0,0 @@
|
|||||||
|
|
||||||
package com.weather.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.crypto.digest.DigestUtil;
|
|
||||||
import com.weather.common.exception.ErrorCode;
|
|
||||||
import com.weather.common.exception.CommonException;
|
|
||||||
import com.weather.common.service.impl.BaseServiceImpl;
|
|
||||||
import com.weather.common.validator.AssertUtils;
|
|
||||||
import com.weather.dao.UserDao;
|
|
||||||
import com.weather.dto.LoginDTO;
|
|
||||||
import com.weather.entity.TokenEntity;
|
|
||||||
import com.weather.entity.UserEntity;
|
|
||||||
import com.weather.service.TokenService;
|
|
||||||
import com.weather.service.UserService;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implements UserService {
|
|
||||||
private final TokenService tokenService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserEntity getByMobile(String mobile) {
|
|
||||||
return baseDao.getUserByMobile(mobile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserEntity getUserByUserId(Long userId) {
|
|
||||||
return baseDao.getUserByUserId(userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> login(LoginDTO dto) {
|
|
||||||
UserEntity user = getByMobile(dto.getMobile());
|
|
||||||
AssertUtils.isNull(user, ErrorCode.ACCOUNT_PASSWORD_ERROR);
|
|
||||||
|
|
||||||
//密码错误
|
|
||||||
if (!user.getPassword().equals(DigestUtil.sha256Hex(dto.getPassword()))) {
|
|
||||||
throw new CommonException(ErrorCode.ACCOUNT_PASSWORD_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取登录token
|
|
||||||
TokenEntity tokenEntity = tokenService.createToken(user.getId());
|
|
||||||
|
|
||||||
Map<String, Object> map = new HashMap<>(2);
|
|
||||||
map.put("token", tokenEntity.getToken());
|
|
||||||
map.put("expire", tokenEntity.getExpireDate().getTime() - System.currentTimeMillis());
|
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
spring:
|
|
||||||
data:
|
|
||||||
redis:
|
|
||||||
database: 0
|
|
||||||
host: 192.168.10.10
|
|
||||||
port: 6379
|
|
||||||
password: # 密码(默认为空)
|
|
||||||
timeout: 6000ms # 连接超时时长(毫秒)
|
|
||||||
lettuce:
|
|
||||||
pool:
|
|
||||||
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
|
|
||||||
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
|
||||||
max-idle: 10 # 连接池中的最大空闲连接
|
|
||||||
min-idle: 5 # 连接池中的最小空闲连接
|
|
||||||
datasource:
|
|
||||||
druid:
|
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
|
||||||
url: jdbc:mysql://localhost:3306/weather_data_system?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
|
||||||
username: root
|
|
||||||
password: root
|
|
||||||
initial-size: 10
|
|
||||||
max-active: 100
|
|
||||||
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
|
|
||||||
#Oracle需要打开注释
|
|
||||||
#validation-query: SELECT 1 FROM DUAL
|
|
||||||
test-while-idle: true
|
|
||||||
test-on-borrow: false
|
|
||||||
test-on-return: false
|
|
||||||
stat-view-servlet:
|
|
||||||
enabled: true
|
|
||||||
url-pattern: /druid/*
|
|
||||||
#login-username: admin
|
|
||||||
#login-password: admin
|
|
||||||
filter:
|
|
||||||
stat:
|
|
||||||
log-slow-sql: true
|
|
||||||
slow-sql-millis: 1000
|
|
||||||
merge-sql: false
|
|
||||||
wall:
|
|
||||||
config:
|
|
||||||
multi-statement-allow: true
|
|
||||||
|
|
||||||
renren:
|
|
||||||
redis:
|
|
||||||
open: false # 是否开启redis缓存 true开启 false关闭
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
spring:
|
|
||||||
data:
|
|
||||||
redis:
|
|
||||||
database: 0
|
|
||||||
host: 127.0.0.1
|
|
||||||
port: 6379
|
|
||||||
password: # 生产环境请设置密码
|
|
||||||
timeout: 6000ms # 连接超时时长(毫秒)
|
|
||||||
lettuce:
|
|
||||||
pool:
|
|
||||||
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
|
|
||||||
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
|
||||||
max-idle: 10 # 连接池中的最大空闲连接
|
|
||||||
min-idle: 5 # 连接池中的最小空闲连接
|
|
||||||
datasource:
|
|
||||||
druid:
|
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
|
||||||
url: jdbc:mysql://localhost:3306/weather_data_system?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
|
||||||
username: root
|
|
||||||
password: root
|
|
||||||
initial-size: 10
|
|
||||||
max-active: 100
|
|
||||||
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
|
|
||||||
#Oracle需要打开注释
|
|
||||||
#validation-query: SELECT 1 FROM DUAL
|
|
||||||
test-while-idle: true
|
|
||||||
test-on-borrow: false
|
|
||||||
test-on-return: false
|
|
||||||
stat-view-servlet:
|
|
||||||
enabled: true
|
|
||||||
url-pattern: /druid/*
|
|
||||||
#login-username: admin
|
|
||||||
#login-password: admin
|
|
||||||
filter:
|
|
||||||
stat:
|
|
||||||
log-slow-sql: true
|
|
||||||
slow-sql-millis: 1000
|
|
||||||
merge-sql: false
|
|
||||||
wall:
|
|
||||||
config:
|
|
||||||
multi-statement-allow: true
|
|
||||||
|
|
||||||
renren:
|
|
||||||
redis:
|
|
||||||
open: true # 是否开启redis缓存 true开启 false关闭
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
spring:
|
|
||||||
data:
|
|
||||||
redis:
|
|
||||||
database: 0
|
|
||||||
host: 127.0.0.1
|
|
||||||
port: 6379
|
|
||||||
password: # 密码(默认为空)
|
|
||||||
timeout: 6000ms # 连接超时时长(毫秒)
|
|
||||||
lettuce:
|
|
||||||
pool:
|
|
||||||
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
|
|
||||||
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
|
||||||
max-idle: 10 # 连接池中的最大空闲连接
|
|
||||||
min-idle: 5 # 连接池中的最小空闲连接
|
|
||||||
datasource:
|
|
||||||
druid:
|
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
|
||||||
url: jdbc:mysql://localhost:3306/weather_data_system?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
|
||||||
username: weather
|
|
||||||
password: 123456
|
|
||||||
initial-size: 10
|
|
||||||
max-active: 100
|
|
||||||
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
|
|
||||||
#Oracle需要打开注释
|
|
||||||
#validation-query: SELECT 1 FROM DUAL
|
|
||||||
test-while-idle: true
|
|
||||||
test-on-borrow: false
|
|
||||||
test-on-return: false
|
|
||||||
stat-view-servlet:
|
|
||||||
enabled: true
|
|
||||||
url-pattern: /druid/*
|
|
||||||
#login-username: admin
|
|
||||||
#login-password: admin
|
|
||||||
filter:
|
|
||||||
stat:
|
|
||||||
log-slow-sql: true
|
|
||||||
slow-sql-millis: 1000
|
|
||||||
merge-sql: false
|
|
||||||
wall:
|
|
||||||
config:
|
|
||||||
multi-statement-allow: true
|
|
||||||
|
|
||||||
renren:
|
|
||||||
redis:
|
|
||||||
open: false # 是否开启redis缓存 true开启 false关闭
|
|
||||||
@ -1,64 +0,0 @@
|
|||||||
# Tomcat
|
|
||||||
server:
|
|
||||||
tomcat:
|
|
||||||
uri-encoding: UTF-8
|
|
||||||
threads:
|
|
||||||
max: 1000
|
|
||||||
min-spare: 30
|
|
||||||
port: 8081
|
|
||||||
servlet:
|
|
||||||
context-path: /renren-api
|
|
||||||
session:
|
|
||||||
cookie:
|
|
||||||
http-only: true
|
|
||||||
|
|
||||||
knife4j:
|
|
||||||
enable: true
|
|
||||||
basic:
|
|
||||||
enable: false
|
|
||||||
username: admin
|
|
||||||
password: admin
|
|
||||||
setting:
|
|
||||||
enableFooter: false
|
|
||||||
|
|
||||||
spring:
|
|
||||||
# 环境 dev|test|prod
|
|
||||||
profiles:
|
|
||||||
active: dev
|
|
||||||
messages:
|
|
||||||
encoding: UTF-8
|
|
||||||
basename: i18n/messages
|
|
||||||
# jackson时间格式化
|
|
||||||
jackson:
|
|
||||||
time-zone: GMT+8
|
|
||||||
date-format: yyyy-MM-dd HH:mm:ss
|
|
||||||
mvc:
|
|
||||||
pathmatch:
|
|
||||||
matching-strategy: ANT_PATH_MATCHER
|
|
||||||
servlet:
|
|
||||||
multipart:
|
|
||||||
max-file-size: 100MB
|
|
||||||
max-request-size: 100MB
|
|
||||||
enabled: true
|
|
||||||
|
|
||||||
#mybatis
|
|
||||||
mybatis-plus:
|
|
||||||
mapper-locations: classpath*:/mapper/**/*.xml
|
|
||||||
#实体扫描,多个package用逗号或者分号分隔
|
|
||||||
typeAliasesPackage: io.renren.entity
|
|
||||||
global-config:
|
|
||||||
#数据库相关配置
|
|
||||||
db-config:
|
|
||||||
#主键类型
|
|
||||||
id-type: ASSIGN_ID
|
|
||||||
banner: false
|
|
||||||
#原生配置
|
|
||||||
configuration:
|
|
||||||
map-underscore-to-camel-case: true
|
|
||||||
cache-enabled: false
|
|
||||||
call-setters-on-nulls: true
|
|
||||||
jdbc-type-for-null: 'null'
|
|
||||||
configuration-properties:
|
|
||||||
prefix:
|
|
||||||
blobType: BLOB
|
|
||||||
boolValue: TRUE
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
====================================================================================================================
|
|
||||||
|
|
||||||
欢迎使用 renren-api - Powered By https://www.renren.io
|
|
||||||
|
|
||||||
====================================================================================================================
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration>
|
|
||||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
|
||||||
<logger name="org.springframework.web" level="INFO"/>
|
|
||||||
<logger name="org.springboot.sample" level="TRACE" />
|
|
||||||
|
|
||||||
<!-- 开发、测试环境 -->
|
|
||||||
<springProfile name="dev,test">
|
|
||||||
<logger name="org.springframework.web" level="INFO"/>
|
|
||||||
<logger name="org.springboot.sample" level="INFO" />
|
|
||||||
<logger name="io.renren" level="DEBUG" />
|
|
||||||
</springProfile>
|
|
||||||
|
|
||||||
<!-- 生产环境 -->
|
|
||||||
<springProfile name="prod">
|
|
||||||
<logger name="org.springframework.web" level="ERROR"/>
|
|
||||||
<logger name="org.springboot.sample" level="ERROR" />
|
|
||||||
<logger name="io.renren" level="ERROR" />
|
|
||||||
</springProfile>
|
|
||||||
|
|
||||||
</configuration>
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
<?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="com.weather.dao.TokenDao">
|
|
||||||
|
|
||||||
<select id="getByToken" resultType="com.weather.entity.TokenEntity">
|
|
||||||
select * from tb_token where token = #{value}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getByUserId" resultType="com.weather.entity.TokenEntity">
|
|
||||||
select * from tb_token where user_id = #{value}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
<?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="com.weather.dao.UserDao">
|
|
||||||
|
|
||||||
<select id="getUserByMobile" resultType="com.weather.entity.UserEntity">
|
|
||||||
select * from tb_user where mobile = #{value}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getUserByUserId" resultType="com.weather.entity.UserEntity">
|
|
||||||
select * from tb_user where id = #{value}
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
Loading…
Reference in New Issue
Block a user