Compare commits
No commits in common. "75de44cda0fb8dd35db4ba2c0fe501378ae9d9f6" and "fee9dab7857026344cc6663b6b4a3b21de301b3f" have entirely different histories.
75de44cda0
...
fee9dab785
|
@ -19,6 +19,11 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- 自己的模块 -->
|
<!-- 自己的模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.atguigu</groupId>
|
||||||
|
<artifactId>spzx-model</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.atguigu</groupId>
|
<groupId>com.atguigu</groupId>
|
||||||
<artifactId>common-util</artifactId>
|
<artifactId>common-util</artifactId>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.atguigu.config;
|
package com.atguigu.config;
|
||||||
|
|
||||||
import com.atguigu.interceptor.LoginAuthInterceptor;
|
import com.atguigu.interceptor.LoginAuthInterceptor;
|
||||||
|
import com.atguigu.properties.InterceptorsProperties;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -13,6 +14,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupp
|
||||||
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||||
@Autowired
|
@Autowired
|
||||||
private LoginAuthInterceptor loginAuthInterceptor;
|
private LoginAuthInterceptor loginAuthInterceptor;
|
||||||
|
@Autowired
|
||||||
|
private InterceptorsProperties interceptorsProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 解决跨域
|
* * 解决跨域
|
||||||
|
@ -38,6 +41,6 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||||
|
|
||||||
// 需要拦截的
|
// 需要拦截的
|
||||||
registry.addInterceptor(loginAuthInterceptor).addPathPatterns("/admin/**")
|
registry.addInterceptor(loginAuthInterceptor).addPathPatterns("/admin/**")
|
||||||
.excludePathPatterns("/admin/system/index/login", "/admin/system/index/generateValidateCode", "/admin/product/category/exportData");
|
.excludePathPatterns(interceptorsProperties.getNoAuthUrls());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,12 +24,7 @@ public class CategoryHelper {
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 将List<SysMenu>对象转换成List<SysMenuVo>对象
|
|
||||||
*
|
|
||||||
* @param categoryList 全部菜单列表
|
|
||||||
* @return 系统菜单响应结果实体类列表
|
|
||||||
*/
|
|
||||||
public static Category getChildren(Category category, List<Category> categoryList) {
|
public static Category getChildren(Category category, List<Category> categoryList) {
|
||||||
// 遍历所有菜单数据,判断id和parentID对应关系
|
// 遍历所有菜单数据,判断id和parentID对应关系
|
||||||
category.setChildren(new ArrayList<>());
|
category.setChildren(new ArrayList<>());
|
||||||
|
|
|
@ -24,7 +24,11 @@
|
||||||
<artifactId>spzx-model</artifactId>
|
<artifactId>spzx-model</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Spring-Web -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
<!-- fastjson依赖 -->
|
<!-- fastjson依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.atguigu.properties;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "bunny")
|
||||||
|
@Data
|
||||||
|
public class InterceptorsProperties {
|
||||||
|
private List<String> noAuthUrls;
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.atguigu.spzx.manger.properties;
|
package com.atguigu.properties;
|
||||||
|
|
||||||
import io.minio.MinioClient;
|
import io.minio.MinioClient;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
|
@ -2,7 +2,7 @@ package com.atguigu.spzx.manger.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.atguigu.exception.BunnyException;
|
import com.atguigu.exception.BunnyException;
|
||||||
import com.atguigu.spzx.manger.properties.MinioProperties;
|
import com.atguigu.properties.MinioProperties;
|
||||||
import com.atguigu.spzx.manger.service.FileUploadService;
|
import com.atguigu.spzx.manger.service.FileUploadService;
|
||||||
import io.minio.BucketExistsArgs;
|
import io.minio.BucketExistsArgs;
|
||||||
import io.minio.MakeBucketArgs;
|
import io.minio.MakeBucketArgs;
|
||||||
|
|
|
@ -16,3 +16,9 @@ bunny:
|
||||||
bucket-name: spzx-bucket
|
bucket-name: spzx-bucket
|
||||||
accessKey: "bunny"
|
accessKey: "bunny"
|
||||||
secretKey: "02120212"
|
secretKey: "02120212"
|
||||||
|
|
||||||
|
noAuthUrls:
|
||||||
|
- /admin/system/index/login
|
||||||
|
- /admin/system/index/generateValidateCode
|
||||||
|
- /admin/product/category/exportData
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
|
||||||
|
<contextName>logback</contextName>
|
||||||
|
|
||||||
|
<!-- 日志的输出目录 -->
|
||||||
|
<property name="log.path" value="logs//spzx-manager//logs"/>
|
||||||
|
|
||||||
|
<!--控制台日志格式:彩色日志-->
|
||||||
|
<!-- magenta:洋红 -->
|
||||||
|
<!-- boldMagenta:粗红-->
|
||||||
|
<!-- cyan:青色 -->
|
||||||
|
<!-- white:白色 -->
|
||||||
|
<!-- magenta:洋红 -->
|
||||||
|
<property name="CONSOLE_LOG_PATTERN"
|
||||||
|
value="%yellow(%date{yyyy-MM-dd HH:mm:ss}) %highlight([%-5level]) %green(%logger) %msg%n"/>
|
||||||
|
|
||||||
|
<!--文件日志格式-->
|
||||||
|
<property name="FILE_LOG_PATTERN" value="%date{yyyy-MM-dd HH:mm:ss} [%-5level] %thread %file:%line %logger %msg%n"/>
|
||||||
|
|
||||||
|
<!--编码-->
|
||||||
|
<property name="ENCODING" value="UTF-8"/>
|
||||||
|
|
||||||
|
<!-- 控制台日志 -->
|
||||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<!-- 临界值过滤器 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>INFO</level>
|
||||||
|
</filter>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||||
|
<charset>${ENCODING}</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 文件日志 -->
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||||
|
<file>${log.path}//log.log</file>
|
||||||
|
<append>true</append>
|
||||||
|
<encoder>
|
||||||
|
<pattern>%date{yyyy-MM-dd HH:mm:ss} %msg%n</pattern>
|
||||||
|
<charset>${ENCODING}</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 开发环境 -->
|
||||||
|
<springProfile name="dev">
|
||||||
|
<!-- com.atguigu日志记录器:业务程序INFO级别 -->
|
||||||
|
<logger name="com.atguigu" level="INFO"/>
|
||||||
|
<!-- 根日志记录器:INFO级别 -->
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
</configuration>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE configuration PUBLIC
|
||||||
|
"-//mybatis.org//DTD Config 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||||
|
<configuration>
|
||||||
|
<settings>
|
||||||
|
<!-- 设置驼峰标识 -->
|
||||||
|
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
||||||
|
<!-- 打印SQL语句 -->
|
||||||
|
<setting name="logImpl" value="STDOUT_LOGGING"/>
|
||||||
|
</settings>
|
||||||
|
<plugins>
|
||||||
|
<!-- 分页插件 -->
|
||||||
|
<plugin interceptor="com.github.pagehelper.PageInterceptor"/>
|
||||||
|
</plugins>
|
||||||
|
</configuration>
|
|
@ -18,39 +18,6 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>com.atguigu</groupId>
|
|
||||||
<artifactId>common-util</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- gateway -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- loadbalancer依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-loadbalancer</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 服务注册 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- config -->
|
|
||||||
<!-- <dependency> -->
|
|
||||||
<!-- <groupId>com.alibaba.cloud</groupId> -->
|
|
||||||
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> -->
|
|
||||||
<!-- </dependency> -->
|
|
||||||
|
|
||||||
<!-- 服务保护组件 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.atguigu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hello world!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class App
|
||||||
|
{
|
||||||
|
public static void main( String[] args )
|
||||||
|
{
|
||||||
|
System.out.println( "Hello World!" );
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +0,0 @@
|
||||||
package com.atguigu.gateway;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
@ComponentScan("com.atguigu")
|
|
||||||
public class GatewayApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(GatewayApplication.class, args);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
bunny:
|
|
||||||
nacos:
|
|
||||||
server-addr: z-bunny.cn:8848
|
|
||||||
discovery:
|
|
||||||
namespace: spzx
|
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
server:
|
|
||||||
port: 8500
|
|
||||||
spring:
|
|
||||||
profiles:
|
|
||||||
active: dev
|
|
||||||
application:
|
|
||||||
name: server-gateway
|
|
||||||
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
namespace: ${bunny.nacos.discovery.namespace}
|
|
||||||
server-addr: ${bunny.nacos.server-addr}
|
|
||||||
log-name: logs/${spring.application.name}
|
|
||||||
gateway:
|
|
||||||
discovery:
|
|
||||||
locator:
|
|
||||||
enabled: true
|
|
||||||
# 解决跨域
|
|
||||||
# globalcors:
|
|
||||||
# cors-configurations:
|
|
||||||
# '[/**]':
|
|
||||||
# allowedOriginPatterns: "*"
|
|
||||||
# # 允许请求中携带的头信息
|
|
||||||
# allowedHeaders: "*"
|
|
||||||
# # 运行跨域的请求方式
|
|
||||||
# allowedMethods: "*"
|
|
||||||
# # 跨域检测的有效期,单位s
|
|
||||||
# maxAge: 36000
|
|
||||||
# 路由
|
|
||||||
routes:
|
|
||||||
- id: service-product
|
|
||||||
uri: lb://service-product
|
|
||||||
predicates:
|
|
||||||
- Path=/*/product/**
|
|
||||||
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
com.atguigu.product.mapper: debug
|
|
||||||
com.atguigu.product.controller: info
|
|
||||||
com.atguigu.product.service: info
|
|
||||||
pattern:
|
|
||||||
dateformat: HH:mm:ss:SSS
|
|
||||||
file:
|
|
||||||
path: logs/${spring.application.name}
|
|
|
@ -1,16 +0,0 @@
|
||||||
-----------------▄██-█▄---------
|
|
||||||
-----------------███▄██▄--------
|
|
||||||
-----------------███████--------
|
|
||||||
-----------------▀███████-------
|
|
||||||
-------------------██████▄▄-----
|
|
||||||
-------------------█████████▄---
|
|
||||||
-------------------██████▄████--
|
|
||||||
-------▄███████████████████████-
|
|
||||||
-----▄███████████████████████▀--
|
|
||||||
---▄██████████████████████------
|
|
||||||
---███████████████████████------
|
|
||||||
---███████████████████████------
|
|
||||||
-▄▄██████████████████████▀------
|
|
||||||
-█████████████████▀█████--------
|
|
||||||
-▀██████████████▀▀-▀█████▄------
|
|
||||||
-------▀▀▀▀▀▀▀▀▀------▀▀▀▀------
|
|
Binary file not shown.
Before Width: | Height: | Size: 13 KiB |
|
@ -22,6 +22,11 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.atguigu</groupId>
|
<groupId>com.atguigu</groupId>
|
||||||
<artifactId>common-service</artifactId>
|
<artifactId>common-service</artifactId>
|
||||||
|
|
|
@ -18,10 +18,6 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- redis的起步依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -2,12 +2,8 @@ package com.atguigu.product;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@ComponentScan("com.atguigu")
|
|
||||||
@EnableCaching// 开启缓存注解
|
|
||||||
public class ProductApplication {
|
public class ProductApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(ProductApplication.class, args);
|
SpringApplication.run(ProductApplication.class, args);
|
||||||
|
|
|
@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
@ -17,7 +18,7 @@ import java.util.List;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/product/category/")
|
@RequestMapping("/api/product/category/")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
// @CrossOrigin
|
@CrossOrigin
|
||||||
public class CategoryController {
|
public class CategoryController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryService categoryService;
|
private CategoryService categoryService;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
@ -20,7 +21,7 @@ import java.util.List;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/api/product/index")
|
@RequestMapping(value = "/api/product/index")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
// @CrossOrigin
|
@CrossOrigin
|
||||||
public class IndexController {
|
public class IndexController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryService categoryService;
|
private CategoryService categoryService;
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
package com.atguigu.product.service.impl;
|
package com.atguigu.product.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.atguigu.product.mapper.CategoryMapper;
|
import com.atguigu.product.mapper.CategoryMapper;
|
||||||
import com.atguigu.product.service.CategoryService;
|
import com.atguigu.product.service.CategoryService;
|
||||||
import com.atguigu.spzx.model.entity.product.Category;
|
import com.atguigu.spzx.model.entity.product.Category;
|
||||||
import com.atguigu.utils.CategoryHelper;
|
import com.atguigu.utils.CategoryHelper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CategoryServiceImpl implements CategoryService {
|
public class CategoryServiceImpl implements CategoryService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryMapper categoryMapper;
|
private CategoryMapper categoryMapper;
|
||||||
@Autowired
|
|
||||||
private RedisTemplate<String, Object> redisTemplate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询以及分类
|
* 查询以及分类
|
||||||
|
@ -27,19 +21,7 @@ public class CategoryServiceImpl implements CategoryService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Category> selectOneCategory() {
|
public List<Category> selectOneCategory() {
|
||||||
Object categoryOne = redisTemplate.opsForValue().get("category:one");
|
return categoryMapper.findOneCategory();
|
||||||
String categoryJsonString = JSON.toJSONString(categoryOne);
|
|
||||||
|
|
||||||
// 如果Redis包含以及分类,直接返回
|
|
||||||
if (categoryOne != null) {
|
|
||||||
return JSON.parseArray(categoryJsonString, Category.class);
|
|
||||||
}
|
|
||||||
List<Category> dbCategory = categoryMapper.findOneCategory();
|
|
||||||
|
|
||||||
// 查到的数据放到Redis中
|
|
||||||
redisTemplate.opsForValue().set("category:one", dbCategory, 7, TimeUnit.DAYS);
|
|
||||||
|
|
||||||
return dbCategory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +29,6 @@ public class CategoryServiceImpl implements CategoryService {
|
||||||
*
|
*
|
||||||
* @return 分类实体类列表
|
* @return 分类实体类列表
|
||||||
*/
|
*/
|
||||||
@Cacheable(value = "category", key = "'all'")
|
|
||||||
@Override
|
@Override
|
||||||
public List<Category> findCategoryTree() {
|
public List<Category> findCategoryTree() {
|
||||||
// 查询所以分类,返回list集合
|
// 查询所以分类,返回list集合
|
||||||
|
|
|
@ -13,6 +13,4 @@ bunny:
|
||||||
|
|
||||||
nacos:
|
nacos:
|
||||||
server-addr: z-bunny.cn:8848
|
server-addr: z-bunny.cn:8848
|
||||||
discovery:
|
|
||||||
namespace: spzx
|
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,7 @@ spring:
|
||||||
|
|
||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
server-addr: ${bunny.nacos.server-addr}
|
||||||
namespace: ${bunny.nacos.discovery.namespace}
|
|
||||||
server-addr: ${bunny.nacos.server-addr}
|
|
||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
type: com.zaxxer.hikari.HikariDataSource
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
|
@ -30,11 +28,10 @@ logging:
|
||||||
com.atguigu.product.mapper: debug
|
com.atguigu.product.mapper: debug
|
||||||
com.atguigu.product.controller: info
|
com.atguigu.product.controller: info
|
||||||
com.atguigu.product.service: info
|
com.atguigu.product.service: info
|
||||||
com.alibaba.nacos: info
|
|
||||||
pattern:
|
pattern:
|
||||||
dateformat: HH:mm:ss:SSS
|
dateformat: HH:mm:ss:SSS
|
||||||
file:
|
file:
|
||||||
path: logs/${spring.application.name}
|
path: "logs/${spring.application.name}"
|
||||||
|
|
||||||
mybatis:
|
mybatis:
|
||||||
type-aliases-package: com.atguigu.spzx.model
|
type-aliases-package: com.atguigu.spzx.model
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
|
||||||
|
<contextName>logback</contextName>
|
||||||
|
|
||||||
|
<!-- 日志的输出目录 -->
|
||||||
|
<property name="log.path" value="logs/service-product/logs"/>
|
||||||
|
|
||||||
|
<!--控制台日志格式:彩色日志-->
|
||||||
|
<!-- magenta:洋红 -->
|
||||||
|
<!-- boldMagenta:粗红-->
|
||||||
|
<!-- cyan:青色 -->
|
||||||
|
<!-- white:白色 -->
|
||||||
|
<!-- magenta:洋红 -->
|
||||||
|
<property name="CONSOLE_LOG_PATTERN"
|
||||||
|
value="%yellow(%date{yyyy-MM-dd HH:mm:ss}) %highlight([%-5level]) %green(%logger) %msg%n"/>
|
||||||
|
|
||||||
|
<!--文件日志格式-->
|
||||||
|
<property name="FILE_LOG_PATTERN" value="%date{yyyy-MM-dd HH:mm:ss} [%-5level] %thread %file:%line %logger %msg%n"/>
|
||||||
|
|
||||||
|
<!--编码-->
|
||||||
|
<property name="ENCODING" value="UTF-8"/>
|
||||||
|
|
||||||
|
<!-- 控制台日志 -->
|
||||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<!-- 临界值过滤器 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>INFO</level>
|
||||||
|
</filter>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||||
|
<charset>${ENCODING}</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 文件日志 -->
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||||
|
<file>${log.path}//log.log</file>
|
||||||
|
<append>true</append>
|
||||||
|
<encoder>
|
||||||
|
<pattern>%date{yyyy-MM-dd HH:mm:ss} %msg%n</pattern>
|
||||||
|
<charset>${ENCODING}</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 开发环境 -->
|
||||||
|
<springProfile name="dev">
|
||||||
|
<!-- com.atguigu日志记录器:业务程序INFO级别 -->
|
||||||
|
<logger name="com.atguigu" level="INFO"/>
|
||||||
|
<!-- 根日志记录器:INFO级别 -->
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
</configuration>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE configuration PUBLIC
|
||||||
|
"-//mybatis.org//DTD Config 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||||
|
<configuration>
|
||||||
|
<settings>
|
||||||
|
<!-- 设置驼峰标识 -->
|
||||||
|
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
||||||
|
<!-- 打印SQL语句 -->
|
||||||
|
<setting name="logImpl" value="STDOUT_LOGGING"/>
|
||||||
|
</settings>
|
||||||
|
<plugins>
|
||||||
|
<!-- 分页插件 -->
|
||||||
|
<plugin interceptor="com.github.pagehelper.PageInterceptor"/>
|
||||||
|
</plugins>
|
||||||
|
</configuration>
|
Loading…
Reference in New Issue