黑马程序员-瑞吉外卖-day6

目录

做下面两个功能:

1.写实体类 

2. Mapper

3.Service

4.controller 

5.将分类管理表的进行分页查询返回给前端 

 6.套餐分类

7.修改套餐分类


后台系统中可以管理分类信息,分类包括两种类型,分别是 **菜品分类** 和 **套餐分类** 。当我们在后台系统中添加菜品时需要选择一个菜品分类,当我们在后台系统中添加一个套餐时需要选择一个套餐分类,在移动端也会按照菜品分类和套餐分类来展示对应的菜品和套餐。

做下面两个功能:

 

 

1.写实体类 

package com.itheima.reggie.entity;import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;/*** 分类*/
@Data
@EqualsAndHashCode(callSuper = false)
public class Category implements Serializable {private static final long serialVersionUID = 1L;private Long id;/*** 类型 1 菜品分类 2 套餐分类*/@ApiModelProperty("类型")private Integer type;/*** 分类名称*/@ApiModelProperty("分类名称")private String name;/*** 顺序*/@ApiModelProperty("顺序")private Integer sort;/*** 创建时间*/@ApiModelProperty("创建时间")@TableField(fill = FieldFill.INSERT)private LocalDateTime createTime;/*** 更新时间*/@ApiModelProperty("更新时间")@TableField(fill = FieldFill.INSERT_UPDATE)private LocalDateTime updateTime;/*** 创建人*/@ApiModelProperty("创建人")@TableField(fill = FieldFill.INSERT)private Long createUser;/*** 修改人*/@ApiModelProperty("修改人")@TableField(fill = FieldFill.INSERT_UPDATE)private Long updateUser;}

2. Mapper


package com.itheima.reggie.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.reggie.entity.Category;
import org.apache.ibatis.annotations.Mapper;@Mapper
public interface CategoryMapper extends BaseMapper<Category> {
}

3.Service


package com.itheima.reggie.service;import com.baomidou.mybatisplus.extension.service.IService;
import com.itheima.reggie.entity.Category;public interface CategoryService extends IService<Category> {}

4.ServiceImpl 

package com.itheima.reggie.service.impl;import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.reggie.entity.Category;
import com.itheima.reggie.mapper.CategoryMapper;
import com.itheima.reggie.service.CategoryService;
import org.springframework.stereotype.Service;@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper,Category> implements CategoryService{}

4.controller 

package com.itheima.reggie.controller;import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.Category;
import com.itheima.reggie.service.CategoryService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;import java.util.List;/*** 分类管理*/@RestController
@Api(tags = "分类管理")
@RequestMapping("/category")
@RequiredArgsConstructor
@Slf4j
public class CategoryController {}

5.将分类管理表的进行分页查询返回给前端 

package com.itheima.reggie.controller;import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.Category;
import com.itheima.reggie.service.CategoryService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;import java.util.List;/*** 分类管理*/@RestController
@Api(tags = "分类管理")
@RequestMapping("/category")
@RequiredArgsConstructor
@Slf4j
public class CategoryController {private final CategoryService categoryService;/*** 分页查询* 路径:** @param page* @param pageSize* @return*/@GetMapping("/page")@ApiOperation("分页查询")public R<Page> page(int page, int pageSize) {//分页构造器Page<Category> pageInfo = new Page<>(page, pageSize);Page<Category> result = categoryService.page(pageInfo, Wrappers.lambdaQuery(Category.class)//添加排序条件,根据sort进行排序 大到小//  .orderByDesc(Category::getSort)//小到大.orderByAsc(Category::getSort));return R.success(result);}}

 6.套餐分类

写在controller里面

/*** 新增分类** @param category* @return*/@PostMapping@ApiOperation("新增菜品分类/套餐分类")public R<String> save(@RequestBody Category category) {categoryService.save(category);return R.success("新增分类成功");}

7.修改套餐分类

在分类管理列表页面点击修改按钮,弹出修改窗口,在修改窗口回显分类信息并进行修改,最后点击确定按钮完成修改操作。

 /*** 根据id修改分类信息** @param category* @return*/@PutMapping@ApiOperation("根据id修改分类信息")public R<String> update(@RequestBody Category category) {log.info("修改分类信息:{}", category);categoryService.updateById(category);return R.success("修改分类信息成功");}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/437729.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Nginx负载均衡下的webshell连接

一、上传AntSword-Labs-master搭建负载均衡实验环境 搭建好docker环境&#xff0c;并且配置好docker-compose 我的Redhat的docker版本&#xff1a; 查看当前环境下的文件是否正确&#xff1a; 接着执行docker compose up -d 拉取环境 访问成功页面&#xff1a; 进入docker容器…

图形绘制-仪表盘(2)

本章节我们介绍如何如何绘制刻度对应的数字及指针。效果如下&#xff1a; 关于通过继承重写QWidget的绘制事件paintEvent()&#xff0c;来绘制仪表盘的基础操作&#xff0c;请看上一章节《图形绘制-仪表盘&#xff08;1&#xff09;-CSDN博客》介绍。 在paintEvent()中继续写以…

【JAVE SE】---运算符和程序逻辑控制语句

1.运算符 算数运算符 - * / % 注意&#xff1a;1.Java的%符号左右两边可以是小数&#xff0c;也可以是负数 //运算符float a1.0f;float b2.0f;float c-1.5f;System.out.println(a%b); //1.0System.out.println(a%c); //1.0 2.Java中除数不可以为0&#xff0c…

一些著名的软件都用什么语言编写?

1、操作系统 Microsoft Windows &#xff1a;汇编 -> C -> C 备注&#xff1a;曾经在智能手机的操作系统&#xff08;Windows Mobile&#xff09;考虑掺点C#写的程序&#xff0c;比如软键盘&#xff0c;结果因为写出来的程序太慢&#xff0c;实在无法和别的模块合并&…

前端实现弹小球功能

这篇文章将会做弹小球游戏&#xff0c;弹小球游戏大家小时候都玩过&#xff0c;玩家需要在小球到达游戏区域底部时候控制砖块去承接小球&#xff0c;并不断的将小球弹出去。 首先看一下实现的效果。 效果演示 玩家需要通过控制鼠标来实现砖块的移动&#xff0c;保证在小球下落…

burp靶场--CSRF

burp靶场–CSRF https://portswigger.net/web-security/csrf#what-is-csrf ### 什么是 CSRF&#xff1f; 跨站请求伪造&#xff08;也称为 CSRF&#xff09;是一种 Web 安全漏洞&#xff0c;允许攻击者诱导用户执行他们不打算执行的操作。它允许攻击者部分规避同源策略&#…

xcode安装visionOS Simulator模拟器报错解决方法手动安装方法

手动安装方法&#xff1a; 手动下载visionOS Simulator模拟器地址&#xff1a; https://developer.apple.com/download/all/ 选择 Xcode 版本 sudo xcode-select -s /Applications/Xcode.app # 用 Xcode-beta 的话是&#xff1a; # xcode-select -s /Applications/Xcode-beta…

【ArcGIS微课1000例】0098:查询河流流经过的格网

本实验讲述,ArcGIS中查询河流流经过的格网,如黄河流经过的格网、县城、乡镇、省份等。 文章目录 一、加载数据二、空间查询三、结果导出四、注意事项一、加载数据 加载实验配套数据0098.rar中的河流(黄河)和格网数据,如下图所示: 接下来,将查询河流流经过的格网有哪些并…

3338 蓝桥杯 wyz的数组IV 简单

3338 蓝桥杯 wyz的数组IV 简单 //C风格解法1&#xff0c;通过率50% #include<bits/stdc.h>int main(){std::ios::sync_with_stdio(false);std::cin.tie(nullptr);std::cout.tie(nullptr);int n; std::cin >> n;int ans 0;std::vector<int>a(n);for(auto &am…

Java语言名字由来

文章目录 一、1990年代初Java雏形初诞生&#xff0c;第一个名称是Greentalk二、创始人办公室前有棵橡树&#xff0c;后来改名叫“oak&#xff08;橡树&#xff09;”三、在家电行业失败进入互联网行业&#xff0c;发现商标被抢注被迫换名四、创始团队成员在喝咖啡时灵机一动&am…

Mysql-ReadView + MVCC-RR 与 RC

实验准备 创建脚本 CREATE TABLE user (id int(11) NOT NULL AUTO_INCREMENT,name varchar(16) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,age int(11) NULL DEFAULT NULL,addr varchar(256) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,PRIMARY …

双非本科准备秋招(9.3)—— JVM2

学这个JVM还是挺抽象的&#xff0c;不理解的东西我尽量记忆了&#xff0c;毕竟刚接触两天&#xff0c;也没遇到过实际应用场景&#xff0c;所以学起来还是挺费劲的&#xff0c;明天再补完垃圾回收这块的知识点。U•ェ•*U 先补一下JVM运行时的栈帧结构。 线程调用一个方法的执…