跟着峰哥学java 第四天 商品分类 前后端显示

1.后端

1.1mybatis-plus分页查询配置

在商品热卖数据中,只让其显示八条数据 将要使用分页

也就是service.page方法 此时需要配置 mp拦截器

java 复制代码
@Configuration
public class MybatisPlusConfig {
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }
}

1.2递归查询

1.2.1更新实体类

这些都有外键关联 比如商品小类 有一个商品大类id

很多商品有一个商品小类id(红米k60 红米k70 都属于红米k系列小类)

1.2.2递归查询

这次我把控制层和业务层分开了 各尽其职 hhh

BigTypeController层

java 复制代码
 @ApiOperation("查询所有大类 里面蕴含小类及产品")
    @GetMapping("/findCategories")
    public Result findCategories(){
        return bigTypeService.findCategories();
    }

BigTypeServiceImpl层

java 复制代码
@Resource
    private BigTypeMapper bigTypeMapper;
    @Resource
    private SmallTypeMapper smallTypeMapper;
    @Resource
    private ProductMapper productMapper;
    @Override
    public Result findCategories() {
        QueryWrapper<BigType> bigTypeQueryWrapper = new QueryWrapper<>();
        List<BigType> bigTypeList = bigTypeMapper.selectList(bigTypeQueryWrapper);
        for (BigType bigType : bigTypeList) {
            Integer bigTypeId = bigType.getId();
            QueryWrapper<SmallType> smallTypeQueryWrapper = new QueryWrapper<SmallType>().eq("bigTypeId", bigTypeId);
            List<SmallType> smallTypeList = smallTypeMapper.selectList(smallTypeQueryWrapper);
            bigType.setSmallTypeList(smallTypeList);
            for (SmallType smallType : smallTypeList) {
                Integer smallTypeId = smallType.getId();
                QueryWrapper<Product> productQueryWrapper = new QueryWrapper<Product>().eq("typeId", smallTypeId);
                List<Product> productList = productMapper.selectList(productQueryWrapper);
                smallType.setProductList(productList);
            }
        }
        return new Result(200,"查询分类数据成功",bigTypeList);
    }

这是一个简单的递归 但仍有需要注意的地方,

根据不同的属性 设置到不同的嵌套循环中 比如说smallTypeList

mp真实一个处理单表操作的好工具

2.前端

2.1数据解耦处理

根据生命周期来讲 这些影响不大

2.2mode = widthfix

Widthfix 宽度不变,高度自动变化,保持原图宽高比不变

2.3配置文字超长省略

3.数据处理

3.1关于this的坑

3.2 map 与 箭头函数

4.自定义快速生成

4.1view{$}*x

5.前端视图层的规整

5.1上方有view时 模块高度调整

5.2 scroll-view 滑动视图

5.3左菜单栏调整

相关推荐
异常君8 分钟前
Redis 中的概率过滤器:布隆过滤器与布谷鸟过滤器实战对比
java·redis·后端
胡子发芽9 分钟前
请解释Java中的逃逸分析(Escape Analysis)及其对性能的影响,并说明如何通过JVM参数来控制逃逸分析的行为
java
Stimd10 分钟前
【重写SpringFramework】声明式事务上:构建事务切面(chapter 4-5)
java·后端·spring
码熔burning11 分钟前
【MQ篇】RabbitMQ之消息持久化!
java·分布式·rabbitmq·mq
南客先生13 分钟前
深入解析:RocketMQ、RabbitMQ和Kafka的区别与使用场景
java·kafka·消息队列·rabbitmq·rocketmq
caihuayuan416 分钟前
【docker&redis】用docker容器运行单机redis
java·大数据·sql·spring·课程设计
我是苏苏18 分钟前
消息中间件RabbitMQ02:账号的注册、点对点推送信息
开发语言·后端·ruby
写bug写bug36 分钟前
Java并发编程:优雅的关闭钩子(Shutdown Hook)
java·后端
工藤新一¹36 分钟前
C++/SDL 进阶游戏开发 —— 双人塔防(代号:村庄保卫战 14)
开发语言·c++·游戏引擎·游戏开发·sdl·实践项目
钢铁男儿44 分钟前
C#核心技术解析:静态类型、dynamic与可空类型
开发语言·c#