添加购物车

This commit is contained in:
Bunny 2023-12-28 12:47:25 +08:00
parent 66692990c5
commit 329d74a21c
17 changed files with 248 additions and 79 deletions

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">

View File

@ -4,8 +4,24 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="6ee93b58-a7e0-45a0-9e98-4c363b192afb" name="Changes" comment="获取用户信息并跳转">
<list default="true" id="6ee93b58-a7e0-45a0-9e98-4c363b192afb" name="Changes" comment="创建购物车">
<change afterPath="$PROJECT_DIR$/spzx-server-gateway/src/main/java/cn/bunny/getway/config/RedisConfig.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/spzx-service/service-cart/src/main/java/cn/bunny/web/controller/CartController.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/spzx-service/service-cart/src/main/java/cn/bunny/web/service/CartService.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/spzx-service/service-cart/src/main/java/cn/bunny/web/service/impl/CartServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/spzx-common/common-service/src/main/java/cn/bunny/anno/EnableUserLoginAuthInterceptor.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-common/common-service/src/main/java/cn/bunny/anno/EnableUserWebMvcConfiguration.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/spzx-common/common-service/src/main/java/cn/bunny/interceptor/UserLoginAuthInterceptor.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-common/common-service/src/main/java/cn/bunny/interceptor/UserLoginAuthInterceptor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/spzx-server-gateway/src/main/java/cn/bunny/getway/filter/AuthGlobalFilter.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-server-gateway/src/main/java/cn/bunny/getway/filter/AuthGlobalFilter.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/spzx-server-gateway/src/main/resources/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-server-gateway/src/main/resources/application-dev.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/spzx-service/service-cart/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-cart/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/spzx-service/service-cart/src/main/resources/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-cart/src/main/resources/application-dev.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/spzx-service/service-product/src/main/resources/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/resources/application-dev.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/spzx-service/service-user/src/main/java/cn/bunny/user/User.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-user/src/main/java/cn/bunny/user/User.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/spzx-service/service-user/src/main/java/cn/bunny/user/controller/UserinfoController.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-user/src/main/java/cn/bunny/user/controller/UserinfoController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/spzx-service/service-user/src/main/java/cn/bunny/user/service/impl/UserinfoServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-user/src/main/java/cn/bunny/user/service/impl/UserinfoServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/spzx-service/service-user/src/main/resources/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-user/src/main/resources/application-dev.yml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -15,8 +31,8 @@
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Interface" />
<option value="mybatis-mapper" />
<option value="Interface" />
<option value="Class" />
</list>
</option>
@ -56,48 +72,48 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RequestMappingsPanelOrder0": "0",
"RequestMappingsPanelOrder1": "1",
"RequestMappingsPanelWidth0": "75",
"RequestMappingsPanelWidth1": "75",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"WebServerToolWindowFactoryState": "false",
"code.cleanup.on.save": "true",
"git-widget-placeholder": "master",
"jdk.selected.JAVA_MODULE": "21",
"last_opened_file_path": "F:/File/Java/spzx-parent/spzx-service/service-user/src/main/resources",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"project.structure.last.edited": "Project",
"project.structure.proportion": "0.15",
"project.structure.side.proportion": "0.2",
"rearrange.code.on.save": "true",
"settings.editor.selected.configurable": "preferences.pluginManager",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RequestMappingsPanelOrder0&quot;: &quot;0&quot;,
&quot;RequestMappingsPanelOrder1&quot;: &quot;1&quot;,
&quot;RequestMappingsPanelWidth0&quot;: &quot;75&quot;,
&quot;RequestMappingsPanelWidth1&quot;: &quot;75&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;code.cleanup.on.save&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;jdk.selected.JAVA_MODULE&quot;: &quot;corretto-17&quot;,
&quot;last_opened_file_path&quot;: &quot;F:/File/Java/spzx-parent/spzx-service/service-cart/src/main/resources&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;project.structure.last.edited&quot;: &quot;Project&quot;,
&quot;project.structure.proportion&quot;: &quot;0.15&quot;,
&quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
&quot;rearrange.code.on.save&quot;: &quot;true&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;MavenSettings&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
},
"keyToStringList": {
"DatabaseDriversLRU": [
"mysql"
&quot;keyToStringList&quot;: {
&quot;DatabaseDriversLRU&quot;: [
&quot;mysql&quot;
]
}
}]]></component>
}</component>
<component name="ReactorSettings">
<option name="notificationShown" value="true" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="F:\File\Java\spzx-parent\spzx-service\service-cart\src\main\resources" />
<recent name="F:\File\Java\spzx-parent\spzx-service\service-user\src\main\resources" />
<recent name="F:\File\Java\spzx-parent\spzx-service\service-user\src\main\java\cn\bunny\user" />
<recent name="F:\File\Java\spzx-parent\spzx-service\service-product\src\main\java\cn\bunny\web\product" />
<recent name="F:\File\Java\spzx-parent\spzx-server-gateway\src\main\resources" />
<recent name="F:\File\Java\spzx-parent\spzx-service\service-product\src\main\resources" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="F:\File\Java\spzx-parent\spzx-service\service-product\src\main\resources" />
@ -112,7 +128,7 @@
</set>
</option>
</component>
<component name="RunManager" selected="Spring Boot.User">
<component name="RunManager" selected="Spring Boot.ServerGetWayApplication">
<configuration name="ProductApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" temporary="true" nameIsGenerated="true">
<module name="service-product" />
<option name="SPRING_BOOT_MAIN_CLASS" value="cn.bunny.web.product.ProductApplication" />
@ -154,9 +170,9 @@
</configuration>
<recent_temporary>
<list>
<item itemvalue="Spring Boot.ServerGetWayApplication" />
<item itemvalue="Spring Boot.User" />
<item itemvalue="Spring Boot.ProductApplication" />
<item itemvalue="Spring Boot.ServerGetWayApplication" />
</list>
</recent_temporary>
</component>
@ -171,7 +187,9 @@
<workItem from="1703487757122" duration="903000" />
<workItem from="1703488670206" duration="5932000" />
<workItem from="1703549556395" duration="26425000" />
<workItem from="1703654409796" duration="10240000" />
<workItem from="1703654409796" duration="10591000" />
<workItem from="1703684112039" duration="2403000" />
<workItem from="1703722925328" duration="9980000" />
</task>
<task id="LOCAL-00001" summary="前端接口初始化;显示商品页面">
<option name="closed" value="true" />
@ -293,7 +311,15 @@
<option name="project" value="LOCAL" />
<updated>1703664991364</updated>
</task>
<option name="localTasksCounter" value="16" />
<task id="LOCAL-00016" summary="创建购物车">
<option name="closed" value="true" />
<created>1703667374773</created>
<option name="number" value="00016" />
<option name="presentableId" value="LOCAL-00016" />
<option name="project" value="LOCAL" />
<updated>1703667374773</updated>
</task>
<option name="localTasksCounter" value="17" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -323,7 +349,8 @@
<MESSAGE value="会员登录" />
<MESSAGE value="获取用户信息-未测试" />
<MESSAGE value="获取用户信息并跳转" />
<option name="LAST_COMMIT_MESSAGE" value="获取用户信息并跳转" />
<MESSAGE value="创建购物车" />
<option name="LAST_COMMIT_MESSAGE" value="创建购物车" />
</component>
<component name="XDebuggerManager">
<pin-to-top-manager>

View File

@ -12,5 +12,5 @@ import java.lang.annotation.Target;
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = ElementType.TYPE)
@Import(value = {UserLoginAuthInterceptor.class, UserWebMvcConfiguration.class})
public @interface EnableUserLoginAuthInterceptor {
public @interface EnableUserWebMvcConfiguration {
}

View File

@ -11,13 +11,14 @@ import org.springframework.web.servlet.HandlerInterceptor;
public class UserLoginAuthInterceptor implements HandlerInterceptor {
@Resource
private RedisTemplate redisTemplate;
private RedisTemplate<String, String> redisTemplate;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 如果token不为空那么此时验证token的合法性
String userInfoJSON = (String) redisTemplate.opsForValue().get("user:spzx:" + request.getHeader("token"));
String userInfoJSON = redisTemplate.opsForValue().get("user:spzx:" + request.getHeader("token"));
AuthContextUtil.setUserInfo(JSON.parseObject(userInfoJSON, UserInfo.class));
return true;
}

View File

@ -0,0 +1,32 @@
package cn.bunny.getway.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
public class RedisConfig {
@Bean
@Primary
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory);
// String的序列化方式
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
// 序列号key value
redisTemplate.setKeySerializer(stringRedisSerializer);
redisTemplate.setValueSerializer(genericJackson2JsonRedisSerializer);
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
}

View File

@ -26,21 +26,20 @@ import java.util.List;
@Slf4j
@Component
public class AuthGlobalFilter implements GlobalFilter, Ordered {
private final AntPathMatcher antPathMatcher = new AntPathMatcher();
@Resource
private RedisTemplate redisTemplate;
private AntPathMatcher antPathMatcher;
private RedisTemplate<String, String> redisTemplate;
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
// 获取当前请求路径
ServerHttpRequest request = exchange.getRequest();
String path = request.getURI().getPath();
UserInfo userInfo = this.getUserInfo(request);
// 判断路径是否满足 /api/**/auth/**
// api接口异步请求校验用户必须登录
if (antPathMatcher.match("/api/**/auth/**", path)) {
// 登录校验
UserInfo userInfo = this.getUserinfo(request);
if (userInfo == null) {
if (null == userInfo) {
ServerHttpResponse response = exchange.getResponse();
return out(response, ResultCodeEnum.LOGIN_AUTH);
}
@ -54,26 +53,6 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
return 0;
}
private UserInfo getUserinfo(ServerHttpRequest request) {
String token = "";
List<String> tokenList = request.getHeaders().get("token");
if (tokenList != null) {
token = tokenList.get(0);
}
if (StringUtils.hasText(token)) {
String userJson = (String) redisTemplate.opsForValue().get("user:spzx" + token);
if (StringUtils.hasText(userJson)) {
return null;
} else {
return JSON.parseObject(userJson, UserInfo.class);
}
}
return null;
}
private Mono<Void> out(ServerHttpResponse response, ResultCodeEnum resultCodeEnum) {
Result result = Result.build(null, resultCodeEnum);
byte[] bits = JSONObject.toJSONString(result).getBytes(StandardCharsets.UTF_8);
@ -82,4 +61,21 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
response.getHeaders().add("Content-Type", "application/json;charset=UTF-8");
return response.writeWith(Mono.just(buffer));
}
private UserInfo getUserInfo(ServerHttpRequest request) {
String token = "";
List<String> tokenList = request.getHeaders().get("token");
if (null != tokenList) {
token = tokenList.get(0);
}
if (!StringUtils.isEmpty(token)) {
String userInfoJSON = redisTemplate.opsForValue().get("user:spzx:" + token);
if (StringUtils.isEmpty(userInfoJSON)) {
return null;
} else {
return JSON.parseObject(userInfoJSON, UserInfo.class);
}
}
return null;
}
}

View File

@ -7,6 +7,7 @@ spring:
nacos:
discovery:
server-addr: 192.168.2.82:8848
# server-addr: 192.168.31.202:8848
gateway:
discovery:
locator:
@ -40,6 +41,7 @@ spring:
data:
redis:
host: 192.168.2.82
# host: 192.168.31.202
port: 6379
mybatis:
config-location: classpath:mybatis-config.xml

View File

@ -1,4 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@ -25,5 +25,9 @@
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,27 @@
package cn.bunny.web.controller;
import cn.bunny.common.spzx.model.vo.common.Result;
import cn.bunny.common.spzx.model.vo.common.ResultCodeEnum;
import cn.bunny.web.service.CartService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("api/order/cart")
public class CartController {
@Resource
private CartService cartService;
@Operation(summary = "添加购物车")
@GetMapping("auth/addToCart/{skuId}/{skuNum}")
public Result addToCart(@PathVariable Long skuId,
@PathVariable Integer skuNum) {
cartService.addToCart(skuId, skuNum);
return Result.build(null, ResultCodeEnum.SUCCESS);
}
}

View File

@ -0,0 +1,6 @@
package cn.bunny.web.service;
public interface CartService {
// 添加购物车
void addToCart(Long skuId, Integer skuNum);
}

View File

@ -0,0 +1,63 @@
package cn.bunny.web.service.impl;
import cn.bunny.common.AuthContextUtil;
import cn.bunny.common.spzx.model.entity.h5.CartInfo;
import cn.bunny.common.spzx.model.entity.product.ProductSku;
import cn.bunny.web.service.CartService;
import com.alibaba.fastjson.JSON;
import jakarta.annotation.Resource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class CartServiceImpl implements CartService {
@Resource
private RedisTemplate redisTemplate;
// 定义key user:cart:userId
private String getCartKey(Long userId) {
return "user:cart:" + userId;
}
// 添加购物车
@Override
public void addToCart(Long skuId, Integer skuNum) {
// 1.必须是登录状态获取当前登录用户id从ThreadLocal获取用户信息就可以了
Long userId = AuthContextUtil.getUserInfo().getId();
String cartKey = this.getCartKey(userId);
// 2.因为购物车放到Redis里面从Redis里面获取购物车数据根据key值 + skuId获取(hash类型key+field)
// hash类型 keyuseId fileIdskuId valuesku信息CartInfo
Object cartInfoObj = redisTemplate.opsForHash().get(cartKey, String.valueOf(skuId));
// 3.如果购物车存在添加商品把商品数量相加
CartInfo cartInfo = null;
if (cartInfoObj != null) {
cartInfo = JSON.parseObject(cartInfoObj.toString(), CartInfo.class);
// 数量相加
cartInfo.setSkuNum(cartInfo.getSkuNum() + skuNum);
// 购物车商品是选中状态
cartInfo.setIsChecked(1);
cartInfo.setUpdateTime(new Date());
} else {
// 4.如果购物车没有商品直接商品添加购物车(添加到Redis里面)
// 远程调用实现通过nacos + openFeign 实现根据skuId获取商品sku信息
cartInfo = new CartInfo();
// 远程调用实现根据skuId获取商品sku信息
ProductSku productSku = null;
cartInfo.setCartPrice(productSku.getSalePrice());
cartInfo.setSkuNum(skuNum);
cartInfo.setSkuId(skuId);
cartInfo.setUserId(userId);
cartInfo.setImgUrl(productSku.getThumbImg());
cartInfo.setSkuName(productSku.getSkuName());
cartInfo.setIsChecked(1);
cartInfo.setCreateTime(new Date());
cartInfo.setUpdateTime(new Date());
}
redisTemplate.opsForHash().put(cartKey, String.valueOf(skuId), JSON.toJSONString(cartInfo));
}
}

View File

@ -11,4 +11,8 @@ spring:
data:
redis:
host: 192.168.2.82
# host: 192.168.31.202
port: 6379
mvc:
pathmatch:
matching-strategy: ant_path_matcher

View File

@ -8,6 +8,7 @@ spring:
nacos:
discovery:
server-addr: 192.168.2.82:8848
# server-addr: 192.168.31.202:8848
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
@ -18,6 +19,7 @@ spring:
redis:
port: 6379
host: 192.168.2.82
# host: 192.168.31.202
mybatis:
config-location: classpath:mybatis-config.xml

View File

@ -1,13 +1,13 @@
package cn.bunny.user;
import cn.bunny.anno.EnableUserLoginAuthInterceptor;
import cn.bunny.anno.EnableUserWebMvcConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan(basePackages = {"cn.bunny"})
@EnableUserLoginAuthInterceptor
@EnableUserWebMvcConfiguration
public class User {
public static void main(String[] args) {
SpringApplication.run(User.class, args);

View File

@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.*;
@Tag(name = "会员用户接口")
@RestController
@RequestMapping("api/user/userInfo")
@RequestMapping("/api/user/userInfo")
public class UserinfoController {
@Resource
private UserinfoService userinfoService;

View File

@ -1,5 +1,6 @@
package cn.bunny.user.service.impl;
import cn.bunny.common.AuthContextUtil;
import cn.bunny.common.exception.BunnyException;
import cn.bunny.common.spzx.model.dto.h5.UserLoginDto;
import cn.bunny.common.spzx.model.dto.h5.UserRegisterDto;
@ -14,7 +15,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@ -29,7 +29,7 @@ public class UserinfoServiceImpl implements UserinfoService {
// 获取当前登录用户信息
@Override
public UserInfoVo getCurrentUserInfo(String token) {
// 从Redis根据token获取用户信息
/* // 从Redis根据token获取用户信息
String userJson = (String) redisTemplate.opsForValue().get("user:spzx" + token);
if (!StringUtils.hasText(userJson)) {
throw new BunnyException(ResultCodeEnum.LOGIN_ERROR);
@ -40,6 +40,10 @@ public class UserinfoServiceImpl implements UserinfoService {
UserInfoVo userInfoVo = new UserInfoVo();
BeanUtils.copyProperties(userinfo, userInfoVo);
return userInfoVo; */
UserInfo userInfo = AuthContextUtil.getUserInfo();
UserInfoVo userInfoVo = new UserInfoVo();
BeanUtils.copyProperties(userInfo, userInfoVo);
return userInfoVo;
}

View File

@ -8,6 +8,7 @@ spring:
nacos:
discovery:
server-addr: 192.168.2.82:8848
# server-addr: 192.168.31.202:8848
datasource:
@ -20,6 +21,7 @@ spring:
redis:
port: 6379
host: 192.168.2.82
# host: 192.168.31.202
mybatis:
config-location: classpath:mybatis-config.xml