Compare commits
2 Commits
e648c9b1ee
...
fee9dab785
Author | SHA1 | Date |
---|---|---|
|
fee9dab785 | |
|
52004cf2ba |
|
@ -21,4 +21,11 @@ public class Knife4jConfig {
|
||||||
return new OpenAPI().info(new Info().title("尚品甑选API接口文档")
|
return new OpenAPI().info(new Info().title("尚品甑选API接口文档")
|
||||||
.version("1.0").description("尚品甑选API接口文档").contact(new Contact().name("bunny")));
|
.version("1.0").description("尚品甑选API接口文档").contact(new Contact().name("bunny")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public GroupedOpenApi webApi() { // 创建了一个api接口的分组
|
||||||
|
return GroupedOpenApi.builder()
|
||||||
|
.group("web-api") // 分组名称
|
||||||
|
.pathsToMatch("/api/**").build(); // 接口请求路径规则
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.atguigu.utils;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.entity.product.Category;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class CategoryHelper {
|
||||||
|
/**
|
||||||
|
* 构建树型结构
|
||||||
|
*
|
||||||
|
* @param categoryList 分类列表
|
||||||
|
* @return 结构列表
|
||||||
|
*/
|
||||||
|
public static List<Category> buildTree(List<Category> categoryList) {
|
||||||
|
ArrayList<Category> tree = new ArrayList<>();
|
||||||
|
// 将菜单进行遍历
|
||||||
|
categoryList.forEach(category -> {
|
||||||
|
if (category.getParentId() == 0) {
|
||||||
|
tree.add(getChildren(category, categoryList));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return tree;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Category getChildren(Category category, List<Category> categoryList) {
|
||||||
|
// 遍历所有菜单数据,判断id和parentID对应关系
|
||||||
|
category.setChildren(new ArrayList<>());
|
||||||
|
|
||||||
|
categoryList.forEach(menu -> {
|
||||||
|
if (menu.getChildren() == null) menu.setChildren(new ArrayList<>());
|
||||||
|
if (category.getId().equals(menu.getParentId())) {
|
||||||
|
category.getChildren().add(getChildren(menu, categoryList));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,9 +23,9 @@ spring:
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.atguigu.mapper: debug
|
com.atguigu.spzx.manger.mapper: debug
|
||||||
com.atguigu.controller: info
|
com.atguigu.spzx.manger.controller: info
|
||||||
com.atguigu.service: info
|
com.atguigu.spzx.manger.service: info
|
||||||
pattern:
|
pattern:
|
||||||
dateformat: HH:mm:ss:SSS
|
dateformat: HH:mm:ss:SSS
|
||||||
file:
|
file:
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.atguigu.product.controller;
|
||||||
|
|
||||||
|
import com.atguigu.product.service.CategoryService;
|
||||||
|
import com.atguigu.spzx.model.entity.product.Category;
|
||||||
|
import com.atguigu.spzx.model.vo.result.Result;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
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.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Tag(name = "分类接口管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/product/category/")
|
||||||
|
@Slf4j
|
||||||
|
@CrossOrigin
|
||||||
|
public class CategoryController {
|
||||||
|
@Autowired
|
||||||
|
private CategoryService categoryService;
|
||||||
|
|
||||||
|
@Operation(summary = "获取分类树形数据", description = "获取分类树形数据")
|
||||||
|
@GetMapping("findCategoryTree")
|
||||||
|
public Result<List<Category>> findCategoryTree() {
|
||||||
|
log.info("===>获取分类树形数据");
|
||||||
|
List<Category> list = categoryService.findCategoryTree();
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,9 @@ import com.atguigu.spzx.model.vo.h5.IndexVo;
|
||||||
import com.atguigu.spzx.model.vo.result.Result;
|
import com.atguigu.spzx.model.vo.result.Result;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
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 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;
|
||||||
|
@ -18,6 +20,8 @@ import java.util.List;
|
||||||
@Tag(name = "首页接口管理")
|
@Tag(name = "首页接口管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/api/product/index")
|
@RequestMapping(value = "/api/product/index")
|
||||||
|
@Slf4j
|
||||||
|
@CrossOrigin
|
||||||
public class IndexController {
|
public class IndexController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryService categoryService;
|
private CategoryService categoryService;
|
||||||
|
@ -27,6 +31,7 @@ public class IndexController {
|
||||||
@Operation(summary = "获取首页数据", description = "获取首页数据")
|
@Operation(summary = "获取首页数据", description = "获取首页数据")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public Result<IndexVo> findData() {
|
public Result<IndexVo> findData() {
|
||||||
|
log.info("===>获取首页数据");
|
||||||
// 查询以及分类
|
// 查询以及分类
|
||||||
List<Category> categoryList = categoryService.selectOneCategory();
|
List<Category> categoryList = categoryService.selectOneCategory();
|
||||||
// 根据销量排序,获取前十条数据
|
// 根据销量排序,获取前十条数据
|
||||||
|
|
|
@ -13,4 +13,11 @@ public interface CategoryMapper {
|
||||||
* @return 分类列表
|
* @return 分类列表
|
||||||
*/
|
*/
|
||||||
List<Category> findOneCategory();
|
List<Category> findOneCategory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所以分类
|
||||||
|
*
|
||||||
|
* @return 分类列表
|
||||||
|
*/
|
||||||
|
List<Category> findAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,11 @@ public interface CategoryService {
|
||||||
* @return 分类实体类列表
|
* @return 分类实体类列表
|
||||||
*/
|
*/
|
||||||
List<Category> selectOneCategory();
|
List<Category> selectOneCategory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询属性结构
|
||||||
|
*
|
||||||
|
* @return 分类实体类列表
|
||||||
|
*/
|
||||||
|
List<Category> findCategoryTree();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.atguigu.product.service.impl;
|
||||||
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 org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -22,4 +23,16 @@ public class CategoryServiceImpl implements CategoryService {
|
||||||
public List<Category> selectOneCategory() {
|
public List<Category> selectOneCategory() {
|
||||||
return categoryMapper.findOneCategory();
|
return categoryMapper.findOneCategory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询属性结构
|
||||||
|
*
|
||||||
|
* @return 分类实体类列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Category> findCategoryTree() {
|
||||||
|
// 查询所以分类,返回list集合
|
||||||
|
List<Category> categoryList = categoryMapper.findAll();
|
||||||
|
return CategoryHelper.buildTree(categoryList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,5 +6,11 @@ bunny:
|
||||||
username: root
|
username: root
|
||||||
password: "02120212"
|
password: "02120212"
|
||||||
|
|
||||||
|
redis:
|
||||||
|
host: 106.15.251.123
|
||||||
|
port: 6379
|
||||||
|
database: 2
|
||||||
|
|
||||||
nacos:
|
nacos:
|
||||||
server-addr: z-bunny.cn:8848
|
server-addr: z-bunny.cn:8848
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,26 @@ spring:
|
||||||
username: ${bunny.datasource.username}
|
username: ${bunny.datasource.username}
|
||||||
password: "${bunny.datasource.password}"
|
password: "${bunny.datasource.password}"
|
||||||
|
|
||||||
|
data:
|
||||||
|
redis:
|
||||||
|
host: ${bunny.redis.host}
|
||||||
|
port: ${bunny.redis.port}
|
||||||
|
database: ${bunny.redis.database}
|
||||||
|
|
||||||
|
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}"
|
||||||
|
|
||||||
mybatis:
|
mybatis:
|
||||||
config-location: classpath:mybatis-config.xml
|
type-aliases-package: com.atguigu.spzx.model
|
||||||
mapper-locations: classpath:/mapper/*/*.xml
|
mapper-locations: classpath:/mapper/*/*.xml
|
||||||
|
configuration:
|
||||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
map-underscore-to-camel-case: true
|
||||||
|
auto-mapping-behavior: full
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
-----------------▄██-█▄---------
|
||||||
|
-----------------███▄██▄--------
|
||||||
|
-----------------███████--------
|
||||||
|
-----------------▀███████-------
|
||||||
|
-------------------██████▄▄-----
|
||||||
|
-------------------█████████▄---
|
||||||
|
-------------------██████▄████--
|
||||||
|
-------▄███████████████████████-
|
||||||
|
-----▄███████████████████████▀--
|
||||||
|
---▄██████████████████████------
|
||||||
|
---███████████████████████------
|
||||||
|
---███████████████████████------
|
||||||
|
-▄▄██████████████████████▀------
|
||||||
|
-█████████████████▀█████--------
|
||||||
|
-▀██████████████▀▀-▀█████▄------
|
||||||
|
-------▀▀▀▀▀▀▀▀▀------▀▀▀▀------
|
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
|
@ -4,7 +4,7 @@
|
||||||
<contextName>logback</contextName>
|
<contextName>logback</contextName>
|
||||||
|
|
||||||
<!-- 日志的输出目录 -->
|
<!-- 日志的输出目录 -->
|
||||||
<property name="log.path" value="logs//spzx-manager//logs"/>
|
<property name="log.path" value="logs/service-product/logs"/>
|
||||||
|
|
||||||
<!--控制台日志格式:彩色日志-->
|
<!--控制台日志格式:彩色日志-->
|
||||||
<!-- magenta:洋红 -->
|
<!-- magenta:洋红 -->
|
||||||
|
|
|
@ -11,7 +11,20 @@
|
||||||
select
|
select
|
||||||
<include refid="columns"/>
|
<include refid="columns"/>
|
||||||
from category
|
from category
|
||||||
where is_deleted = 0
|
where parent_id = 0
|
||||||
and parent_id = #{parentId} order by id
|
and status = 1
|
||||||
|
and is_deleted = 0
|
||||||
|
order by order_num
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 查询所以分类 -->
|
||||||
|
<select id="findAll" resultType="com.atguigu.spzx.model.entity.product.Category">
|
||||||
|
select
|
||||||
|
<include refid="columns"/>
|
||||||
|
from category
|
||||||
|
where
|
||||||
|
status = 1
|
||||||
|
and is_deleted = 0
|
||||||
|
order by order_num
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -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