项目初始化
parent
8eb78f7908
commit
3a72b233ff
16
pom.xml
16
pom.xml
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.3.RELEASE</version>
|
||||
<version>2.5.14</version>
|
||||
</parent>
|
||||
<groupId>com.jwl.driver.server</groupId>
|
||||
<artifactId>driver-server</artifactId>
|
||||
|
@ -32,9 +32,14 @@
|
|||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-security</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
|
@ -103,6 +108,13 @@
|
|||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
|
|
@ -3,13 +3,21 @@ package com.jwl.driver.server;
|
|||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@ComponentScan(basePackages = {"com.jwl.driver.server.*"})
|
||||
@SpringBootApplication
|
||||
public class DriverServerApplication {
|
||||
public class DriverServerApplication implements WebMvcConfigurer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DriverServerApplication.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package com.jwl.driver.server.config;
|
||||
|
||||
import com.jwl.driver.server.interceptor.AuthInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.reactive.CorsWebFilter;
|
||||
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* @author 曹林
|
||||
* @description 跨域配置类
|
||||
* @create 2023/8/11 22:39
|
||||
*/
|
||||
@Configuration
|
||||
public class CorsConfig implements WebMvcConfigurer {
|
||||
|
||||
@Bean
|
||||
public AuthInterceptor initAuthInterceptor(){
|
||||
return new AuthInterceptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/driver-api/**")
|
||||
.excludePathPatterns("/login/**");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
// 设置允许跨域的路径
|
||||
registry.addMapping("/**")
|
||||
// 设置允许跨域请求的域名
|
||||
.allowedOriginPatterns("*")
|
||||
// 是否允许cookie
|
||||
.allowCredentials(true)
|
||||
// 设置允许的请求方式
|
||||
.allowedMethods("GET", "POST", "DELETE", "PUT")
|
||||
// 设置允许的header属性
|
||||
.allowedHeaders("*")
|
||||
// 跨域允许时间
|
||||
.maxAge(3600);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CorsWebFilter corsWebFilter(){
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
|
||||
CorsConfiguration corsConfiguration = new CorsConfiguration();
|
||||
//1、配置跨域
|
||||
corsConfiguration.addAllowedHeader("*");//允许哪些头进行跨域
|
||||
corsConfiguration.addAllowedMethod("*");//允许哪些请求方式进行跨域
|
||||
corsConfiguration.addAllowedOriginPattern("*");//允许哪些请求来源进行跨域
|
||||
corsConfiguration.setAllowCredentials(true);//是否允许携带cookie进行跨域,否则跨域请求会丢失cookie信息
|
||||
|
||||
source.registerCorsConfiguration("/**",corsConfiguration);
|
||||
|
||||
return new CorsWebFilter(source);
|
||||
}
|
||||
|
||||
}
|
|
@ -47,9 +47,9 @@ public class SwaggerConfig {
|
|||
.title("管理中心")
|
||||
.description("管理中心接口文档")
|
||||
.termsOfServiceUrl("http://127.0.0.1")
|
||||
.contact(new Contact("jslx",
|
||||
.contact(new Contact("jwl",
|
||||
"http://www.jslx.com",
|
||||
"jslx@equ-tech.com"))
|
||||
"1149034574@qq.com"))
|
||||
.version("1.0")
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,19 @@
|
|||
package com.jwl.driver.server.controller;
|
||||
|
||||
|
||||
import com.jwl.driver.server.dto.LoginUserDto;
|
||||
import com.jwl.driver.server.response.BaseResponse;
|
||||
import com.jwl.driver.server.service.ITdSysUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -13,8 +23,21 @@ import org.springframework.stereotype.Controller;
|
|||
* @author Automated procedures
|
||||
* @since 2023-08-10
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("//tdSysUser")
|
||||
@RestController
|
||||
@Api(tags = "用户管理")
|
||||
@RequestMapping("/tdSysUser")
|
||||
@Slf4j
|
||||
public class TdSysUserController {
|
||||
|
||||
@Autowired
|
||||
private ITdSysUserService userService;
|
||||
|
||||
|
||||
@ApiOperation("用户登陆")
|
||||
@PostMapping("/login")
|
||||
public BaseResponse login(@RequestBody LoginUserDto loginUserDto) throws Exception {
|
||||
log.info("用户登录======>loginUserDto:{}", loginUserDto);
|
||||
return BaseResponse.success(userService.login(loginUserDto));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.jwl.driver.server.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @author 曹林
|
||||
* @description 登陆入参
|
||||
* @create 2023/8/11 22:21
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class LoginUserDto {
|
||||
|
||||
@ApiModelProperty("登陆手机号")
|
||||
@NotBlank(message = "登陆手机号不能为空")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty("登陆验证码")
|
||||
@NotBlank(message = "登陆验证码不能为空")
|
||||
private String code;
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.jwl.driver.server.interceptor;
|
||||
|
||||
import com.jwl.driver.server.redis.RedisCache;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author 曹林
|
||||
* @description
|
||||
* @create 2023/8/11 18:05
|
||||
*/
|
||||
|
||||
public class AuthInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
String token = request.getHeader("token");
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
response.getWriter().print("用户未登录,请登录后操作!");
|
||||
return false;
|
||||
}
|
||||
Object loginStatus = redisCache.getCacheObject(token);
|
||||
if( Objects.isNull(loginStatus)){
|
||||
response.getWriter().print("登陆异常,请查看!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,296 @@
|
|||
package com.jwl.driver.server.redis;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* spring redis 工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
**/
|
||||
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
||||
@Component
|
||||
@Slf4j
|
||||
public class RedisCache {
|
||||
@Autowired
|
||||
public RedisTemplate redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> stringRedisTemplate;
|
||||
|
||||
public boolean hasKey(final String key) {
|
||||
return Boolean.TRUE.equals(redisTemplate.hasKey(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param value 缓存的值
|
||||
*/
|
||||
public <T> void setCacheObject(final String key, final T value) {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param value 缓存的值
|
||||
* @param timeout 时间
|
||||
* @param timeUnit 时间颗粒度
|
||||
*/
|
||||
public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) {
|
||||
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param value 缓存的值
|
||||
* @param timeout 时间
|
||||
*/
|
||||
public <T> void setCacheObject(final String key, final T value, final long timeout) {
|
||||
redisTemplate.opsForValue().set(key, value, timeout, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置有效时间
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param timeout 超时时间
|
||||
* @return true=设置成功;false=设置失败
|
||||
*/
|
||||
public boolean expire(final String key, final long timeout) {
|
||||
return expire(key, timeout, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置有效时间
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param timeout 超时时间
|
||||
* @param unit 时间单位
|
||||
* @return true=设置成功;false=设置失败
|
||||
*/
|
||||
public boolean expire(final String key, final long timeout, final TimeUnit unit) {
|
||||
return redisTemplate.expire(key, timeout, unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的基本对象。
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @return 缓存键值对应的数据
|
||||
*/
|
||||
public <T> T getCacheObject(final String key) {
|
||||
ValueOperations<String, T> operation = redisTemplate.opsForValue();
|
||||
return operation.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单个对象
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public boolean deleteObject(final String key) {
|
||||
return redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除集合对象
|
||||
*
|
||||
* @param collection 多个对象
|
||||
* @return
|
||||
*/
|
||||
public long deleteObject(final Collection collection) {
|
||||
return redisTemplate.delete(collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单个对象
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public void deleteObjectLike(final String key) {
|
||||
Set<String> keys = redisTemplate.keys(key + "*");
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存List数据
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param dataList 待缓存的List数据
|
||||
* @return 缓存的对象
|
||||
*/
|
||||
public <T> long setCacheList(final String key, final List<T> dataList) {
|
||||
Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
|
||||
return count == null ? 0 : count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的list对象
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @return 缓存键值对应的数据
|
||||
*/
|
||||
public <T> List<T> getCacheList(final String key) {
|
||||
return redisTemplate.opsForList().range(key, 0, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存Set
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @param dataSet 缓存的数据
|
||||
* @return 缓存数据的对象
|
||||
*/
|
||||
public BoundSetOperations<String, String> setCacheSet(final String key, final Set<String> dataSet) {
|
||||
BoundSetOperations<String, String> setOperation = stringRedisTemplate.boundSetOps(key);
|
||||
Iterator<String> it = dataSet.iterator();
|
||||
while (it.hasNext()) {
|
||||
setOperation.add(it.next());
|
||||
}
|
||||
return setOperation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的set
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Set<String> getCacheSet(final String key) {
|
||||
return stringRedisTemplate.opsForSet().members(key);
|
||||
}
|
||||
|
||||
public Long addCacheSet(final String key, String... value) {
|
||||
SetOperations<String, String> setOperations = stringRedisTemplate.opsForSet();
|
||||
return setOperations.add(key, value);
|
||||
}
|
||||
|
||||
public Long removeCacheSet(final String key, Object... value) {
|
||||
return stringRedisTemplate.opsForSet().remove(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存Map
|
||||
*
|
||||
* @param key
|
||||
* @param dataMap
|
||||
*/
|
||||
public <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
|
||||
if (dataMap != null) {
|
||||
redisTemplate.opsForHash().putAll(key, dataMap);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的Map
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public <T> Map<String, T> getCacheMap(final String key) {
|
||||
return redisTemplate.opsForHash().entries(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 往Hash中存入数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKey Hash键
|
||||
* @param value 值
|
||||
*/
|
||||
public <T> void setCacheMapValue(final String key, final String hKey, final T value) {
|
||||
redisTemplate.opsForHash().put(key, hKey, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Hash中的数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKey Hash键
|
||||
* @return Hash中的对象
|
||||
*/
|
||||
public <T> T getCacheMapValue(final String key, final String hKey) {
|
||||
HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
|
||||
return opsForHash.get(key, hKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除Hash中的数据
|
||||
*
|
||||
* @param key
|
||||
* @param hkey
|
||||
*/
|
||||
public void delCacheMapValue(final String key, final String hkey) {
|
||||
HashOperations hashOperations = redisTemplate.opsForHash();
|
||||
hashOperations.delete(key, hkey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多个Hash中的数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKeys Hash键集合
|
||||
* @return Hash对象集合
|
||||
*/
|
||||
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) {
|
||||
return redisTemplate.opsForHash().multiGet(key, hKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的基本对象列表
|
||||
*
|
||||
* @param pattern 字符串前缀
|
||||
* @return 对象列表
|
||||
*/
|
||||
public Collection<String> keys(final String pattern) {
|
||||
return redisTemplate.keys(pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key获取过期时间
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Long getExpire(final String key) {
|
||||
return redisTemplate.getExpire(key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* value 增加
|
||||
*/
|
||||
public Long addKeyValue(String key, Long addValue) {
|
||||
if (addValue == null || addValue == 0) {
|
||||
addValue = 1L;
|
||||
}
|
||||
return redisTemplate.getConnectionFactory().getConnection().incrBy(
|
||||
redisTemplate.getKeySerializer().serialize(key), addValue
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* value 增加
|
||||
*/
|
||||
public Long increment(final String key, final Integer value, final Long timeout, final TimeUnit timeUnit) {
|
||||
Long count = redisTemplate.opsForValue().increment(key, value);
|
||||
redisTemplate.expire(key, timeout, timeUnit);
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
package com.jwl.driver.server.service;
|
||||
|
||||
import com.jwl.driver.server.dto.LoginUserDto;
|
||||
import com.jwl.driver.server.entity.TdSysUser;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jwl.driver.server.vo.LoginUserVo;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
*/
|
||||
public interface ITdSysUserService extends IService<TdSysUser> {
|
||||
|
||||
LoginUserVo login(LoginUserDto loginUserDto);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
package com.jwl.driver.server.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jwl.driver.server.dto.LoginUserDto;
|
||||
import com.jwl.driver.server.entity.TdSysUser;
|
||||
import com.jwl.driver.server.mapper.TdSysUserMapper;
|
||||
import com.jwl.driver.server.redis.RedisCache;
|
||||
import com.jwl.driver.server.service.ITdSysUserService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jwl.driver.server.vo.LoginUserVo;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户表; 服务实现类
|
||||
|
@ -17,4 +25,28 @@ import org.springframework.stereotype.Service;
|
|||
@Service
|
||||
public class TdSysUserServiceImpl extends ServiceImpl<TdSysUserMapper, TdSysUser> implements ITdSysUserService {
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Override
|
||||
public LoginUserVo login(LoginUserDto loginUserDto) {
|
||||
//XI
|
||||
LambdaQueryWrapper<TdSysUser> cond = new LambdaQueryWrapper<TdSysUser>()
|
||||
.eq(TdSysUser::getPhone,"18255439337");
|
||||
TdSysUser tdSysUser = this.baseMapper.selectOne(cond);
|
||||
if (tdSysUser == null){
|
||||
//创建用户
|
||||
}
|
||||
|
||||
String token = UUID.randomUUID().toString();
|
||||
redisCache.setCacheObject(token,"123456",365*24*60*60);
|
||||
LoginUserVo loginUserVo = new LoginUserVo();
|
||||
BeanUtils.copyProperties(tdSysUser,loginUserVo);
|
||||
loginUserVo.setToken(token);
|
||||
|
||||
return loginUserVo;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package com.jwl.driver.server.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author 曹林
|
||||
* @description 登陆用户出参
|
||||
* @create 2023/8/11 22:49
|
||||
*/
|
||||
@ApiModel("登陆用户出参")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class LoginUserVo {
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@ApiModelProperty("用户名")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@ApiModelProperty("手机号码")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
@ApiModelProperty("头像")
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 驾校标识
|
||||
*/
|
||||
@ApiModelProperty("驾校标识")
|
||||
private Long schoolId;
|
||||
|
||||
|
||||
/**
|
||||
* 驾校名称
|
||||
*/
|
||||
@ApiModelProperty("驾校名称")
|
||||
private String schoolName;
|
||||
|
||||
/**
|
||||
* 驾校名称
|
||||
*/
|
||||
@ApiModelProperty("用户token")
|
||||
private String token;
|
||||
|
||||
|
||||
}
|
|
@ -5,12 +5,12 @@ spring:
|
|||
port: 6379
|
||||
database: 8
|
||||
timeout: 5000
|
||||
password: caolin123
|
||||
auth: caolin123
|
||||
|
||||
|
||||
# 数据库 配置
|
||||
datasource:
|
||||
url: jdbc:mysql://127.0.0.1:3306/driver_test?characterEncoding=utf-8&autoReconnect=true&maxReconnects=2&useSSL=false&failOverReadOnly=false&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://127.0.0.1:3306/driver_server?characterEncoding=utf-8&autoReconnect=true&maxReconnects=2&useSSL=false&failOverReadOnly=false&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: 123456
|
||||
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration debug="false">
|
||||
|
||||
<!-- 日志保存路径 可根据项目修改 -->
|
||||
<property name="LOG_HOME" value="logs" />
|
||||
<!-- 模块名 根据项目修改 -->
|
||||
<property name="application_name" value="driver-server" />
|
||||
<!-- 日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="%red(%date{yyyy-MM-dd HH:mm:ss}) %highlight(%-5level) %red([%thread]) %boldMagenta(%logger{50}) %cyan(%msg%n)"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 按照每天生成日志文件 -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender" additivity="false">
|
||||
<file>${LOG_HOME}/${application_name}/${application_name}.log</file>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||
</encoder>
|
||||
<!--每个文件限制 50MB,每日滚动,最多30个文件,归档文件限制5G-->
|
||||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<MaxFileSize>50MB</MaxFileSize>
|
||||
<fileNamePattern>${LOG_HOME}/${application_name}/${application_name}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
|
||||
<maxHistory>30</maxHistory>
|
||||
<totalSizeCap>2GB</totalSizeCap>
|
||||
</triggeringPolicy>
|
||||
</appender>
|
||||
|
||||
<!-- 按照每天生成日志文件 -->
|
||||
<appender name="FILE-ROOT" class="ch.qos.logback.core.rolling.RollingFileAppender" additivity="false">
|
||||
<file>${LOG_HOME}/${application_name}/${application_name}-root.log</file>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
|
||||
</filter>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||
</encoder>
|
||||
<!--每个文件限制 50MB,每日滚动,最多30个文件,归档文件限制5G-->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<MaxFileSize>50MB</MaxFileSize>
|
||||
<fileNamePattern>${LOG_HOME}/${application_name}/${application_name}-root.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
|
||||
<maxHistory>30</maxHistory>
|
||||
<totalSizeCap>2GB</totalSizeCap>
|
||||
</rollingPolicy >
|
||||
</appender>
|
||||
|
||||
|
||||
<!-- 日志包名 根据项目修改 -->
|
||||
<logger name="com.jwl.driver.server" level="debug" additivity="false">
|
||||
<appender-ref ref="FILE"/>
|
||||
<appender-ref ref="STDOUT" />
|
||||
</logger>
|
||||
|
||||
|
||||
<!-- 日志输出级别 -->
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="FILE-ROOT"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -4,7 +4,7 @@ import org.junit.Test;
|
|||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class DriverServerApplicationTests {
|
||||
class DriverServerApplicationTest {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
Loading…
Reference in New Issue