feat(新增): 首页数据显示
This commit is contained in:
parent
b53976500a
commit
619f774f52
|
@ -40,6 +40,7 @@
|
|||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.resource.type" value="Deployment" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
|
@ -53,6 +54,7 @@
|
|||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.resource.type" value="Deployment" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
|
@ -64,6 +66,21 @@
|
|||
<remarks>$PROJECT_DIR$/service/service-activity/src/main/resources/application.yml</remarks>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://106.15.251.123:3305/shequ-activity?serverTimezone=GMT</jdbc-url>
|
||||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.resource.type" value="Deployment" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
<data-source source="LOCAL" name="shequ-user@106.15.251.123" uuid="8b2549c2-e3f6-45f4-b269-7f3611e86c69">
|
||||
<driver-ref>mysql.8</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<imported>true</imported>
|
||||
<remarks>$PROJECT_DIR$/service/service-user/src/main/resources/application.yml</remarks>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://106.15.251.123:3305/shequ-user?serverTimezone=GMT</jdbc-url>
|
||||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
|
|
|
@ -16,11 +16,14 @@
|
|||
<file url="file://$PROJECT_DIR$/model/src/main/resources-filtered" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/service-client/service-product-client/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/service-client/service-region-client/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/service-client/service-search-client/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/service-client/service-user-client/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/service-client/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/service-client/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/service-gateway/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/service/service-acl/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/service/service-activity/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/service/service-home/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/service/service-product/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/service/service-search/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/service/service-sys/src/main/java" charset="UTF-8" />
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,5 @@
|
|||
### 小程序申请
|
||||
|
||||
申请地址:https://mp.weixin.qq.com/wxamp/sandbox?doc=1
|
||||
|
||||
地址:https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html
|
|
@ -40,5 +40,11 @@
|
|||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -16,7 +16,7 @@ public class JwtHelper {
|
|||
.setExpiration(new Date(System.currentTimeMillis() + tokenExpiration))
|
||||
.claim("userId", userId)
|
||||
.claim("userName", userName)
|
||||
.signWith(SignatureAlgorithm.HS512, tokenSignKey)
|
||||
.signWith(SignatureAlgorithm.HS256, tokenSignKey)
|
||||
.compressWith(CompressionCodecs.GZIP)
|
||||
.compact();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
|||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
@ -58,15 +59,14 @@ public class RedisConfiguration {
|
|||
public CacheManager cacheManager(RedisConnectionFactory factory) {
|
||||
log.info("RedisConfiguration===>解决cache(@Cacheable)把数据缓存到redis中的value是乱码问题");
|
||||
|
||||
StringRedisSerializer redisSerializer = new StringRedisSerializer();
|
||||
// 配置序列化
|
||||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
|
||||
RedisCacheConfiguration redisCacheConfiguration = config
|
||||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer))
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jsonRedisSerializer()));
|
||||
config.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()))
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jsonRedisSerializer()))
|
||||
.entryTtl(Duration.ofDays(365));
|
||||
|
||||
RedisCacheManager cacheManager = RedisCacheManager.builder(factory)
|
||||
.cacheDefaults(redisCacheConfiguration).build();
|
||||
.cacheDefaults(config).build();
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,25 @@
|
|||
package com.atguigu.ssyx.common.config;
|
||||
|
||||
import com.atguigu.ssyx.common.interceptor.UserLoginInterceptor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class WebMvcConfiguration implements WebMvcConfigurer {
|
||||
@Autowired
|
||||
private UserLoginInterceptor userLoginAuthInterceptor;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
log.info("WebMvcConfiguration===>开始注册自定义拦截器...");
|
||||
|
||||
String[] userLoginExcludes = {"/api/user/weixin/wxLogin/*"};
|
||||
registry.addInterceptor(userLoginAuthInterceptor)
|
||||
.addPathPatterns("/api/**")
|
||||
.excludePathPatterns(userLoginExcludes);
|
||||
}
|
||||
}
|
|
@ -1,27 +1,78 @@
|
|||
package com.atguigu.ssyx.common.context;
|
||||
|
||||
|
||||
import com.atguigu.ssyx.vo.acl.AdminLoginVo;
|
||||
import com.atguigu.ssyx.vo.user.UserLoginVo;
|
||||
|
||||
public class BaseContext {
|
||||
public static ThreadLocal<Long> threadLocal = new ThreadLocal<>();
|
||||
private static final ThreadLocal<Long> userId = new ThreadLocal<>();
|
||||
private static final ThreadLocal<Long> wareId = new ThreadLocal<>();
|
||||
private static final ThreadLocal<Long> adminId = new ThreadLocal<>();
|
||||
private static final ThreadLocal<AdminLoginVo> adminLoginVo = new ThreadLocal<>();
|
||||
private static final ThreadLocal<UserLoginVo> userLoginVo = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* 获取当前用户id
|
||||
*/
|
||||
// 用户id相关
|
||||
public static Long getUserId() {
|
||||
return threadLocal.get();
|
||||
return userId.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户id
|
||||
*/
|
||||
public static void setUserId(Long userId) {
|
||||
threadLocal.set(userId);
|
||||
public static void setUserId(Long _userId) {
|
||||
userId.set(_userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移出当前id
|
||||
*/
|
||||
public static void remove() {
|
||||
threadLocal.remove();
|
||||
public static void removeUserId() {
|
||||
userId.remove();
|
||||
}
|
||||
|
||||
// wareId相关
|
||||
public static Long getWareId() {
|
||||
return wareId.get();
|
||||
}
|
||||
|
||||
public static void setWareId(Long _wareId) {
|
||||
wareId.set(_wareId);
|
||||
}
|
||||
|
||||
public static void removeWareId() {
|
||||
wareId.remove();
|
||||
}
|
||||
|
||||
// adminId 相关
|
||||
public static Long getAdminId() {
|
||||
return adminId.get();
|
||||
}
|
||||
|
||||
public static void setAdminId(Long _adminId) {
|
||||
adminId.set(_adminId);
|
||||
}
|
||||
|
||||
public static void removeAdminId() {
|
||||
adminId.remove();
|
||||
}
|
||||
|
||||
// adminLoginVo相关
|
||||
public static AdminLoginVo getAdminLoginVo() {
|
||||
return adminLoginVo.get();
|
||||
}
|
||||
|
||||
public static void setAdminLoginVo(AdminLoginVo _adminLoginVo) {
|
||||
adminLoginVo.set(_adminLoginVo);
|
||||
}
|
||||
|
||||
public static void removeAdminLoginVo() {
|
||||
adminLoginVo.remove();
|
||||
}
|
||||
|
||||
// userLoginVo相关
|
||||
public static UserLoginVo getUserLoginVo() {
|
||||
return userLoginVo.get();
|
||||
}
|
||||
|
||||
public static void setUserLoginVo(UserLoginVo _userLoginVo) {
|
||||
userLoginVo.set(_userLoginVo);
|
||||
}
|
||||
|
||||
public static void removeUserLoginVo() {
|
||||
userLoginVo.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class GlobalExceptionHandler {
|
|||
public Result<Object> error(Exception exception) {
|
||||
log.error("GlobalExceptionHandler===>系统异常信息:{}", exception.getMessage());
|
||||
|
||||
return Result.error(null, 500, exception.getMessage());
|
||||
return Result.error(null, 500, "系统异常");
|
||||
}
|
||||
|
||||
// 特定异常处理
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package com.atguigu.ssyx.common.interceptor;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.atguigu.common.utils.JwtHelper;
|
||||
import com.atguigu.ssyx.common.constant.RedisConst;
|
||||
import com.atguigu.ssyx.common.context.BaseContext;
|
||||
import com.atguigu.ssyx.vo.user.UserLoginVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class UserLoginInterceptor implements HandlerInterceptor {
|
||||
@Autowired
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
String token = request.getHeader("token");
|
||||
log.info("UserLoginInterceptor===>{}", token);
|
||||
if (!StringUtils.isEmpty(token)) {
|
||||
Long userId = JwtHelper.getUserId(token);
|
||||
Object userIdObject = redisTemplate.opsForValue().get(RedisConst.USER_LOGIN_KEY_PREFIX + userId);
|
||||
if (userIdObject != null) {
|
||||
UserLoginVo userLoginVo = JSON.parseObject(JSON.toJSONString(userIdObject), UserLoginVo.class);
|
||||
BaseContext.setUserId(userLoginVo.getUserId());
|
||||
BaseContext.setWareId(userLoginVo.getWareId());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler, @Nullable Exception ex) throws Exception {
|
||||
BaseContext.removeUserId();
|
||||
BaseContext.removeWareId();
|
||||
}
|
||||
}
|
6
pom.xml
6
pom.xml
|
@ -129,6 +129,12 @@
|
|||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.25</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<!-- <repositories> -->
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
<modules>
|
||||
<module>service-product-client</module>
|
||||
<module>service-region-client</module>
|
||||
<module>service-user-client</module>
|
||||
<module>service-search-client</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -32,4 +32,12 @@ public interface ProductFeignClient {
|
|||
// 批量获取分类信息
|
||||
@PostMapping("inner/findCategoryList")
|
||||
List<Category> findCategoryList(@RequestBody List<Long> rangeIdList);
|
||||
|
||||
// 获取全部商品分类
|
||||
@GetMapping("findAllList")
|
||||
Result<List<Category>> findAllCategoryList();
|
||||
|
||||
// 获取新人专享
|
||||
@GetMapping("inner/findNewPersonSkuInfoList")
|
||||
Result<List<SkuInfo>> findNewPersonSkuInfoList();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<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>
|
||||
<groupId>com.atguigu</groupId>
|
||||
<artifactId>service-client</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>service-search-client</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>service-search-client</name>
|
||||
<url>https://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,14 @@
|
|||
package com.atguigu.ssyx.client.search;
|
||||
|
||||
import com.atguigu.ssyx.model.search.SkuEs;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(value = "service-search", path = "/api/search/sku")
|
||||
public interface SearchFeignClient {
|
||||
// 获取爆品商品
|
||||
@GetMapping("inner/findHotSkuList")
|
||||
List<SkuEs> findHotSkuList();
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<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>
|
||||
<groupId>com.atguigu</groupId>
|
||||
<artifactId>service-client</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>service-user-client</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>service-user-client</name>
|
||||
<url>https://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
package com.atguigu.ssyx.client.user;
|
||||
|
||||
import com.atguigu.ssyx.vo.user.LeaderAddressVo;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
@FeignClient(value = "service-user", path = "/api/user/leader")
|
||||
public interface UserFeignClient {
|
||||
// 提货点地址信息
|
||||
@GetMapping("/inner/getUserAddressByUserId/{userId}")
|
||||
LeaderAddressVo getLeaderAddressByUserId(@PathVariable Long userId);
|
||||
}
|
|
@ -19,6 +19,7 @@
|
|||
<module>service-search</module>
|
||||
<module>service-activity</module>
|
||||
<module>service-user</module>
|
||||
<module>service-home</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
FROM openjdk:17
|
||||
MAINTAINER bunny
|
||||
|
||||
#系统编码
|
||||
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
|
||||
|
||||
# 设置时区,构建镜像时执行的命令
|
||||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
RUN echo "Asia/Shanghai" > /etc/timezone
|
||||
|
||||
# 设定工作目录
|
||||
WORKDIR /home/bunny
|
||||
|
||||
# 复制jar包
|
||||
COPY target/*.jar /home/bunny/app.jar
|
||||
|
||||
#启动容器时的进程
|
||||
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
||||
|
||||
#暴露 8080 端口
|
||||
EXPOSE 8080
|
|
@ -0,0 +1,37 @@
|
|||
<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>
|
||||
<groupId>com.atguigu</groupId>
|
||||
<artifactId>service</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>service-home</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>service-home</name>
|
||||
<url>https://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.atguigu</groupId>
|
||||
<artifactId>service-user-client</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.atguigu</groupId>
|
||||
<artifactId>service-product-client</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.atguigu</groupId>
|
||||
<artifactId>service-search-client</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,23 @@
|
|||
package com.atguigu.ssyx.home;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||
@EnableTransactionManagement
|
||||
@ComponentScan(basePackages = {
|
||||
"com.atguigu.ssyx.common",
|
||||
"com.atguigu.ssyx.home",
|
||||
})
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients(basePackages = "com.atguigu.ssyx.client")
|
||||
public class ServiceHomeApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ServiceHomeApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.atguigu.ssyx.home.controller;
|
||||
|
||||
import com.atguigu.ssyx.common.context.BaseContext;
|
||||
import com.atguigu.ssyx.common.result.Result;
|
||||
import com.atguigu.ssyx.home.service.HomeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
@Api(tags = "首页接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/home")
|
||||
public class HomeApiController {
|
||||
@Autowired
|
||||
private HomeService homeService;
|
||||
|
||||
@ApiOperation(value = "获取首页数据")
|
||||
@GetMapping("index")
|
||||
public Result<Map<String, Object>> index(HttpServletRequest request) {
|
||||
Long userId = BaseContext.getUserId();
|
||||
Map<String, Object> home = homeService.home(userId);
|
||||
return Result.success(home);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.atguigu.ssyx.home.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface HomeService {
|
||||
/**
|
||||
* 获取首页数据
|
||||
*
|
||||
* @param userId 用户Id
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> home(Long userId);
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.atguigu.ssyx.home.service.impl;
|
||||
|
||||
import com.atguigu.ssyx.client.product.ProductFeignClient;
|
||||
import com.atguigu.ssyx.client.search.SearchFeignClient;
|
||||
import com.atguigu.ssyx.client.user.UserFeignClient;
|
||||
import com.atguigu.ssyx.common.result.Result;
|
||||
import com.atguigu.ssyx.home.service.HomeService;
|
||||
import com.atguigu.ssyx.model.product.Category;
|
||||
import com.atguigu.ssyx.model.product.SkuInfo;
|
||||
import com.atguigu.ssyx.model.search.SkuEs;
|
||||
import com.atguigu.ssyx.vo.user.LeaderAddressVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class HomeServiceImpl implements HomeService {
|
||||
@Autowired
|
||||
private UserFeignClient userFeignClient;
|
||||
@Autowired
|
||||
private ProductFeignClient productFeignClient;
|
||||
@Autowired
|
||||
private SearchFeignClient searchFeignClient;
|
||||
|
||||
/**
|
||||
* 获取首页数据
|
||||
*
|
||||
* @param userId 用户Id
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> home(Long userId) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
// 远程调用模块获取需要数据
|
||||
LeaderAddressVo leaderAddressVo = userFeignClient.getLeaderAddressByUserId(userId);
|
||||
result.put("leaderAddress", leaderAddressVo);
|
||||
|
||||
// 获取全部商品分类
|
||||
List<Category> categoryList = productFeignClient.findAllCategoryList().getData();
|
||||
result.put("categoryList", categoryList);
|
||||
|
||||
// 获取新人专享
|
||||
Result<List<SkuInfo>> personSkuInfoList = productFeignClient.findNewPersonSkuInfoList();
|
||||
result.put("personSkuInfoList", personSkuInfoList);
|
||||
|
||||
// 使用评分查询-ES
|
||||
List<SkuEs> hotSkuList = searchFeignClient.findHotSkuList();
|
||||
result.put("hotSkuList", hotSkuList);
|
||||
|
||||
// 2.获取分类
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
server:
|
||||
port: 8207
|
||||
|
||||
bunny:
|
||||
redis:
|
||||
host: 47.120.65.66
|
||||
port: 6379
|
||||
database: 3
|
||||
password: "02120212"
|
||||
|
||||
nacos:
|
||||
server-addr: z-bunny.cn:8848
|
||||
discovery:
|
||||
namespace: ssyx
|
|
@ -0,0 +1,42 @@
|
|||
server:
|
||||
port: 8207
|
||||
spring:
|
||||
application:
|
||||
name: service-home
|
||||
profiles:
|
||||
active: dev
|
||||
|
||||
cloud:
|
||||
sentinel:
|
||||
log:
|
||||
dir: logs/${spring.application.name}/sentinel
|
||||
nacos:
|
||||
discovery:
|
||||
namespace: ${bunny.nacos.discovery.namespace}
|
||||
server-addr: ${bunny.nacos.server-addr}
|
||||
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
|
||||
redis:
|
||||
host: ${bunny.redis.host}
|
||||
port: ${bunny.redis.port}
|
||||
database: ${bunny.redis.database}
|
||||
password: ${bunny.redis.password}
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 20 #最大连接数
|
||||
max-wait: -1 #最大阻塞等待时间(负数表示没限制)
|
||||
max-idle: 5 #最大空闲
|
||||
min-idle: 0 #最小空闲
|
||||
|
||||
logging:
|
||||
level:
|
||||
com.atguigu.ssyx.activity.mapper: debug
|
||||
com.atguigu.ssyx.activity.controller: info
|
||||
com.atguigu.ssyx.activity.service: info
|
||||
pattern:
|
||||
dateformat: HH:mm:ss:SSS
|
||||
file:
|
||||
path: "logs/${spring.application.name}"
|
|
@ -0,0 +1,16 @@
|
|||
-----------------▄██-█▄---------
|
||||
-----------------███▄██▄--------
|
||||
-----------------███████--------
|
||||
-----------------▀███████-------
|
||||
-------------------██████▄▄-----
|
||||
-------------------█████████▄---
|
||||
-------------------██████▄████--
|
||||
-------▄███████████████████████-
|
||||
-----▄███████████████████████▀--
|
||||
---▄██████████████████████------
|
||||
---███████████████████████------
|
||||
---███████████████████████------
|
||||
-▄▄██████████████████████▀------
|
||||
-█████████████████▀█████--------
|
||||
-▀██████████████▀▀-▀█████▄------
|
||||
-------▀▀▀▀▀▀▀▀▀------▀▀▀▀------
|
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
|
@ -54,4 +54,18 @@ public class ProductInnerController {
|
|||
public List<Category> findCategoryList(@RequestBody List<Long> rangeIdList) {
|
||||
return categoryService.listByIds(rangeIdList);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取全部商品分类")
|
||||
@GetMapping("findAllList")
|
||||
public Result<List<Category>> findAllList() {
|
||||
List<Category> categoryList = categoryService.findAllList();
|
||||
return Result.success(categoryList);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取新人专享")
|
||||
@GetMapping("inner/findNewPersonSkuInfoList")
|
||||
public Result<List<SkuInfo>> findNewPersonSkuInfoList() {
|
||||
List<SkuInfo> newPersonList = skuInfoService.findNewPersonList();
|
||||
return Result.success(newPersonList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,4 +89,11 @@ public interface SkuInfoService extends IService<SkuInfo> {
|
|||
* @return List<SkuInfo>
|
||||
*/
|
||||
List<SkuInfo> findSkuInfoByKeyword(String keyword);
|
||||
|
||||
/**
|
||||
* * 获取新人专享
|
||||
*
|
||||
* @return 新人专享
|
||||
*/
|
||||
List<SkuInfo> findNewPersonList();
|
||||
}
|
||||
|
|
|
@ -259,4 +259,22 @@ public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoMapper, SkuInfo> impl
|
|||
public List<SkuInfo> findSkuInfoByKeyword(String keyword) {
|
||||
return list(Wrappers.<SkuInfo>lambdaQuery().like(SkuInfo::getSkuName, keyword));
|
||||
}
|
||||
|
||||
/**
|
||||
* * 获取新人专享
|
||||
*
|
||||
* @return 新人专享
|
||||
*/
|
||||
@Override
|
||||
public List<SkuInfo> findNewPersonList() {
|
||||
// 每页显示3条记录
|
||||
Page<SkuInfo> pageParam = new Page<>(1, 3);
|
||||
// 设置查询条件
|
||||
LambdaQueryWrapper<SkuInfo> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SkuInfo::getIsNewPerson, 1);
|
||||
wrapper.eq(SkuInfo::getPublishStatus, 1);
|
||||
wrapper.orderByDesc(SkuInfo::getStock);
|
||||
|
||||
return page(pageParam, wrapper).getRecords();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@ server:
|
|||
|
||||
bunny:
|
||||
rabbitmq:
|
||||
host: 192.168.1.4
|
||||
# host: 192.168.1.4
|
||||
host: 192.168.3.98
|
||||
port: 5672
|
||||
username: bunny
|
||||
password: "02120212"
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.atguigu.ssyx.search.controller;
|
|||
|
||||
import com.atguigu.ssyx.common.result.Result;
|
||||
import com.atguigu.ssyx.model.product.SkuInfo;
|
||||
import com.atguigu.ssyx.model.search.SkuEs;
|
||||
import com.atguigu.ssyx.search.service.SkuService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
@ -11,6 +12,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "商品添加到ES")
|
||||
@RestController
|
||||
@RequestMapping("/api/search/sku")
|
||||
|
@ -31,4 +34,10 @@ public class SkuApiController {
|
|||
skuService.lowerGoods(skuId);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取爆品商品")
|
||||
@GetMapping("inner/findHotSkuList")
|
||||
public List<SkuEs> findHotSkuList() {
|
||||
return skuService.findHotSkuList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.atguigu.ssyx.search.repository;
|
||||
|
||||
import com.atguigu.ssyx.model.search.SkuEs;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
|
||||
public interface SkuRepository extends ElasticsearchRepository<SkuEs,Long> {
|
||||
public interface SkuRepository extends ElasticsearchRepository<SkuEs, Long> {
|
||||
Page<SkuEs> findByOrderByHotScoreDesc(PageRequest pageRequest);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.atguigu.ssyx.search.service;
|
||||
|
||||
import com.atguigu.ssyx.model.search.SkuEs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SkuService {
|
||||
/**
|
||||
* 上架商品
|
||||
|
@ -14,4 +18,11 @@ public interface SkuService {
|
|||
* @param skuId 商品ID
|
||||
*/
|
||||
void lowerGoods(Long skuId);
|
||||
|
||||
/**
|
||||
* * 获取爆品商品
|
||||
*
|
||||
* @return 查询的商品
|
||||
*/
|
||||
List<SkuEs> findHotSkuList();
|
||||
}
|
||||
|
|
|
@ -8,8 +8,11 @@ import com.atguigu.ssyx.model.search.SkuEs;
|
|||
import com.atguigu.ssyx.search.repository.SkuRepository;
|
||||
import com.atguigu.ssyx.search.service.SkuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
|
@ -61,4 +64,16 @@ public class SkuServiceImpl implements SkuService {
|
|||
public void lowerGoods(Long skuId) {
|
||||
skuRepository.deleteById(skuId);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 获取爆品商品
|
||||
*
|
||||
* @return 查询的商品
|
||||
*/
|
||||
@Override
|
||||
public List<SkuEs> findHotSkuList() {
|
||||
PageRequest pageRequest = PageRequest.of(0, 10);
|
||||
Page<SkuEs> pageModel = skuRepository.findByOrderByHotScoreDesc(pageRequest);
|
||||
return pageModel.getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,15 @@ server:
|
|||
|
||||
bunny:
|
||||
rabbitmq:
|
||||
host: 192.168.1.4
|
||||
# host: 192.168.1.4
|
||||
host: 192.168.3.98
|
||||
port: 5672
|
||||
username: bunny
|
||||
password: "02120212"
|
||||
|
||||
elasticsearch:
|
||||
uris: http://192.168.1.4:9200
|
||||
#uris: http://192.168.1.4:9200
|
||||
uris: http://192.168.3.98:9200
|
||||
|
||||
nacos:
|
||||
server-addr: z-bunny.cn:8848
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<url>https://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<docker.repostory>192.168.1.4:1100</docker.repostory>
|
||||
<docker.registry.name>spzx</docker.registry.name>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
@ -29,4 +31,51 @@
|
|||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<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>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<!--将插件绑定在某个phase执行-->
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<!--将插件绑定在package这个phase(阶段)上。也就是说,用户只需执行mvn package,就会自动执行mvn docker:build-->
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
<goal>push</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<serverId>harbor</serverId>
|
||||
<registryUrl>http://${docker.repostory}</registryUrl>
|
||||
<!-- 配置docker主机地址 -->
|
||||
<dockerHost>http://192.168.1.4:2375</dockerHost>
|
||||
<!--指定生成的镜像名-->
|
||||
<imageName>
|
||||
${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
|
||||
</imageName>
|
||||
<!-- 指定 dockerfile 路径-->
|
||||
<dockerDirectory>${project.basedir}</dockerDirectory>
|
||||
<!-- 是否跳过docker构建 -->
|
||||
<skipDockerBuild>false</skipDockerBuild>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.atguigu.ssyx.user.api;
|
||||
|
||||
import com.atguigu.ssyx.user.service.UserService;
|
||||
import com.atguigu.ssyx.vo.user.LeaderAddressVo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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/user/leader")
|
||||
public class LeaderAddressApiController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@ApiOperation("提货点地址信息")
|
||||
@GetMapping("/inner/getUserAddressByUserId/{userId}")
|
||||
public LeaderAddressVo getLeaderAddressByUserId(@PathVariable Long userId) {
|
||||
return userService.getLeaderAddressVoByUserId(userId);
|
||||
}
|
||||
}
|
|
@ -1,14 +1,12 @@
|
|||
package com.atguigu.ssyx.user.controller;
|
||||
|
||||
import com.atguigu.ssyx.common.result.Result;
|
||||
import com.atguigu.ssyx.model.user.User;
|
||||
import com.atguigu.ssyx.user.service.WeiXinApiService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -25,4 +23,11 @@ public class WeiXinApiController {
|
|||
Map<String, Object> map = weChatService.callback(code);
|
||||
return Result.success(map);
|
||||
}
|
||||
|
||||
@PostMapping("/auth/updateUser")
|
||||
@ApiOperation(value = "更新用户昵称与头像")
|
||||
public Result<User> updateUser(@RequestBody User user) {
|
||||
weChatService.updateUser(user);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package com.atguigu.ssyx.user.service;
|
||||
|
||||
import com.atguigu.ssyx.model.user.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface WeiXinApiService {
|
||||
|
@ -9,4 +11,11 @@ public interface WeiXinApiService {
|
|||
* @param code 登录码
|
||||
*/
|
||||
Map<String, Object> callback(String code);
|
||||
|
||||
/**
|
||||
* * 更新用户昵称与头像
|
||||
*
|
||||
* @param user 用户信息
|
||||
*/
|
||||
void updateUser(User user);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.atguigu.ssyx.user.service.impl;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.atguigu.common.utils.JwtHelper;
|
||||
import com.atguigu.ssyx.common.constant.RedisConst;
|
||||
import com.atguigu.ssyx.common.context.BaseContext;
|
||||
import com.atguigu.ssyx.common.exception.BunnyException;
|
||||
import com.atguigu.ssyx.common.result.ResultCodeEnum;
|
||||
import com.atguigu.ssyx.enums.UserType;
|
||||
|
@ -76,4 +77,17 @@ public class WeiXinApiServiceImpl implements WeiXinApiService {
|
|||
throw new BunnyException(ResultCodeEnum.FETCH_ACCESSTOKEN_FAILD);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* * 更新用户昵称与头像
|
||||
*
|
||||
* @param user 用户信息
|
||||
*/
|
||||
@Override
|
||||
public void updateUser(User user) {
|
||||
User userServiceById = userService.getById(BaseContext.getUserId());
|
||||
userServiceById.setNickName(user.getNickName().replaceAll("[ue000-uefff]", "*"));
|
||||
userServiceById.setPhotoUrl(user.getPhotoUrl());
|
||||
userService.updateById(userServiceById);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ spring:
|
|||
discovery:
|
||||
namespace: ${bunny.nacos.discovery.namespace}
|
||||
server-addr: ${bunny.nacos.server-addr}
|
||||
loadbalancer:
|
||||
ribbon:
|
||||
enabled: false
|
||||
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
|
|
Loading…
Reference in New Issue