首页 > 其他分享 >分类管理业务开发

分类管理业务开发

时间:2023-06-17 15:34:35浏览次数:45  
标签:分类管理 业务 private 开发 reggie import com id itheima

代码写在reggie_take_out3

分类管理业务开发_自动填充

1. 公共字段自动填充  3-2

1.1 问题分析  3-2

前面我们已经完成了后台系统的员工管理功能开发,在新增员工时需要设置创建时间、创建人、修改时间、修改人等字段,在编辑员工时需要设置修改时间和修改人等字段。这些字段属于公共字段,也就是很多表中都有这些字段,如下:

分类管理业务开发_spring_02

1.2 代码实现  3-3

Mybatis Plus公共字段自动填充,也就是在插入或者更新的时候为指定字段赋予指定的值,使用它的好处就是可以统一对这些字段进行处理,避免了重复代码。

1.2.1 实现步骤:  3-3

1、在Employee实体类的属性.上加入@TableField注解,指定自动填充的策略:

2、按照框架要求编写元数据对象处理器,在此类中统一为公共字段赋值,此类需要实现MetaObjectHandler接口

Employee实体类 3-3
package com.itheima.reggie.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;

//员工实体类  7
@Data
public class Employee implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;

    private String username;

    private String name;

    private String password;

    private String phone;

    private String sex;

    private String idNumber;//身份证号码

    private Integer status;

    //@TableField指定自动填充的策略  3-3
    @TableField(fill = FieldFill.INSERT) //插入时填充字段
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE) //插入和更新时填充字段
    private LocalDateTime updateTime;

    @TableField(fill = FieldFill.INSERT) //插入时填充字段
    private Long createUser;

    @TableField(fill = FieldFill.INSERT_UPDATE) //插入和更新时填充字段
    private Long updateUser;

}

自定义元数据对象处理器MyMetaObjecthandler  3-3
package com.itheima.reggie.common;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.sun.prism.impl.BaseContext;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;

/**
 * 自定义元数据对象处理器
 */
@Component
@Slf4j
public class MyMetaObjecthandler implements MetaObjectHandler {
    /**
     * 插入操作,自动填充   3-3
     * @param metaObject
     */
    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("公共字段自动填充[insert]...");
        log.info(metaObject.toString());
        metaObject.setValue("createTime", LocalDateTime.now());
        metaObject.setValue("updateTime",LocalDateTime.now());
        metaObject.setValue("createUser",new Long(1));
        metaObject.setValue("updateUser",new Long(1));
    }

    /**
     * 更新操作,自动填充
     * @param metaObject
     */
    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("公共字段自动填充[update]...");
        log.info(metaObject.toString());

        metaObject.setValue("updateTime", LocalDateTime.now());
        metaObject.setValue("updateUser", new Long(1));
    }
}

新增成功

分类管理业务开发_自动填充_03

修改成功

分类管理业务开发_字段_04

分类管理业务开发_线程_05

1.3 功能完善  3-4

注意:当前我们设置createUser和updateUser为固定值,后面我们需要进行改造,改为动态获得当前登录用户的id

1.3.1 问题解决思路  3-4

前面我们已经完成了公共字段自动填充功能的代码开发,但是还有一个问题没有解决,就是我们在自动填充createUser和updateUser时设置的用户id是固定值,现在我们需要改造成动态获取当前登录用户的id。有的同学可能想到,用户登录成功后我们将用户id存入了HttpSession中,现在我从HttpSession中获取不就行了?

注意,我们在MyMetaObjectHandler类 中是不能获得HttpSession对象的,所以我们需要通过其他方式来获取登录用户id。

可以使用ThreadLocal来解决此问题,它是JDK中提供的一个类。

在学习ThreadLocal之前,我们需要先确认一个事情,就是客户端发送的每次http请求,对应的在服务端都会分配一个新的线程来处理,在处理过程中涉及到下面类中的方法都属于相同的一个线程:

1、LoginCheckFilter的dofFilter方法

2、EmployeeController的update方法

3、MyMetaObjectHandler的updateFill方法

可以在上面的三个方法中分别加入下面代码(获取当前线程id) :

long id = Thread. current Thread(). getId();

log. info("线程id: {}", id);

执行编辑员工功能进行验证,通过观察控制台输出可以发现,一次请求对应的线程id是相同的:

分类管理业务开发_字段_06

分类管理业务开发_线程_07

1.3.2 什么是ThreadLocal?  3-4

ThreadLocal并不是一个Thread,而是Thread的局部变量。当使用ThreadLocal维护变量时,ThreadLocal为每 个使用该变量的线程提供独立的变量副本,所以每-一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。ThreadLocal为每个线程提供单独一份存储空间,具有线程隔离的效果,只有在线程内才能获取到对应的值,线程外则不能访问。

1.3.3 ThreadLocal常用方法:  3-4

public void set(T value) 设置 当前线程的线程局部变量的值

public T get() 返回当前线程所对应的线程局部变量的值

我们可以在LoginCheckFilter的doFilter方法中获取当前登录用户id,并调用ThreadLocal的set方法来设置当前线程的线程局部变量的值(用户id) ,然后在MyMetaObjectHandler的updateFill方 法中调用ThreadLocal的get方法来获得当前线程所对应的线程局部变量的值(用户id)

1.3.4 实现步骤:  3-4

1、编写BaseContext工具类,基于ThreadLocal封装的工具类

2、在LoginCheckFilter的doFilter方法中调用BaseContext来设置当前登录用户的id

3、在MyMetaObjectHandler的方 法中调用BaseContext获取登录用户的id

保存用户id的线程工具类BaseContext  3-4
package com.itheima.reggie.common;

/**
 * 工具类
 * 基于ThreadLocal封装工具类,用户保存和获取当前登录用户id  3-4
 */
public class BaseContext {
    //泛型用Long是因为我们要往线程中存入用户id 而id是Long型
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    /**
     * 设置用户id值
     * @param id
     */
    public static void setCurrentId(Long id){
        threadLocal.set(id);
    }

    /**
     * 获取用户id值
     * @return
     */
    public static Long getCurrentId(){
        return threadLocal.get();
    }
}
过滤器LoginCheckFilter  3-4
 //4、判断登录状态,如果已登录,则直接放行
        if(request.getSession().getAttribute("employee") != null){//因为我们登录成功后将emp的id存入了session
            log.info("用户已登录,用户id为:{}",request.getSession().getAttribute("employee"));

            //将用户id存入当先线程  3-4
            Long empId = (Long) request.getSession().getAttribute("employee");
            BaseContext.setCurrentId(empId);

            
            filterChain.doFilter(request,response);
            return;
        }

自定义元数据对象处理器MyMetaObjecthandler  3-4
package com.itheima.reggie.common;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;

/**
 * 自定义元数据对象处理器
 */
@Component
@Slf4j
public class MyMetaObjecthandler implements MetaObjectHandler {
    /**
     * 插入操作,自动填充   3-3
     * @param metaObject
     */
    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("公共字段自动填充[insert]...");
        log.info(metaObject.toString());
        metaObject.setValue("createTime", LocalDateTime.now());
        metaObject.setValue("updateTime",LocalDateTime.now());
        metaObject.setValue("createUser",BaseContext.getCurrentId());
        metaObject.setValue("updateUser",BaseContext.getCurrentId());
    }

    /**
     * 更新操作,自动填充
     * @param metaObject
     */
    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("公共字段自动填充[update]...");
        log.info(metaObject.toString());

        //输出当前线程的id  3-4
        long id = Thread.currentThread().getId();
        log.info("线程id为:{}",id);

        metaObject.setValue("updateTime", LocalDateTime.now());
        metaObject.setValue("updateUser", BaseContext.getCurrentId());
    }
}

添加成功

分类管理业务开发_spring_08

2. 新增分类  3-5

2.1 大体框架  3-5

在开发业务功能前,先将需要用到的类和接口基本结构创建好:

●实体类Category (直接从课程资料中导入即可)

●Mapper接 口CategoryMapper

●业务层接口CategoryService

●业务 层实现类CategoryServicelmpl

●控制层CategoryController

菜品分类实体类Category

package com.itheima.reggie.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 菜品分类实体类   3-5
 */
@Data
public class Category implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;


    //类型 1 菜品分类 2 套餐分类
    private Integer type;


    //分类名称
    private String name;


    //顺序
    private Integer sort;


    //创建时间
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;


    //更新时间
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;


    //创建人
    @TableField(fill = FieldFill.INSERT)
    private Long createUser;


    //修改人
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updateUser;


    //是否删除
    private Integer isDeleted;

}

菜品分类 持久层接口CategoryMapper

package com.itheima.reggie.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.reggie.entity.Category;
import org.apache.ibatis.annotations.Mapper;

//菜品分类 持久层接口  3-5
@Mapper
public interface CategoryMapper extends BaseMapper<Category> {
}

菜品分类 业务层接口CategoryService

package com.itheima.reggie.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.itheima.reggie.entity.Category;

//菜品分类 业务层接口  3-5
public interface CategoryService extends IService<Category> {
}

菜品分类 业务层接口实现类CategoryServiceImpl

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;

//菜品分类 业务层接口实现类  3-5
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper,Category> implements CategoryService{
}

菜品分类 控制层 CategoryController

package com.itheima.reggie.controller;

import com.itheima.reggie.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//菜品分类 控制层  3-5
@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

}

分类管理业务开发_线程_09

2.2 需求分析  3-5

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

分类管理业务开发_自动填充_10

分类管理业务开发_字段_11

新增分类对应的表是category

分类管理业务开发_自动填充_12

2.3 代码开发  3-5

在开发代码之前,需要梳理一下整个程序的执行过程:

1、页面(backend/page/category/list.html)发 送ajax请求,将新增分类窗口输入的数据以json形式提交到服务端

2、服务端Controller接收页面提交的数据并调用Service将数据进行保存

3、Service调用Mapper操作数据库,保存数据

可以看到新增菜品分类和新增套餐分类请求的服务端地址和提交的json数据结构相同,所以服务端只需要提供一个方法统一处理即可

分类管理业务开发_字段_13

菜品分类 CategoryController   3-5

package com.itheima.reggie.controller;

import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.Category;
import com.itheima.reggie.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//菜品分类 控制层  3-5
@RestController
@RequestMapping("/category")
@Slf4j
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    //新增分类  3-5
    @PostMapping
    public R<String> save(@RequestBody Category category){
        log.info("category:{}",category);

        categoryService.save(category);
        return R.success("新增菜品分类成功");
    }

}

如果数据库中已经存在该分类,就会提示,因为我们之前做了一个全局异常处理类

GlobalExceptionHandler

分类管理业务开发_字段_14

我们添加川菜,成功

分类管理业务开发_线程_15

分类管理业务开发_线程_16

分类管理业务开发_spring_17

3. 分类信息的分页查询  3-6

3.1 需求分析

系统中的分类很多的时候,如果在-个页面中全部展示出来会显得比较乱,不便于查看,所以一般的系统中都会以分页的方式来展示列表数据。

分类管理业务开发_spring_18

3.2 代码开发  3-6

在开发代码之前,需要梳理一下整个程序的执行过程:

1、页面发送ajax请求,将分页查询参数(page、pageSize)提交到服务端

2、服务端Controller接收页面提交的数据并调用Service查询数据

3、Service调用Mapper操作数据库,查询分页数据

4、Controller将 查询到的分页数据响应给页面

5、页面接收到分页数据并通过ElementUl的Table组件展示到页面上

分类管理业务开发_线程_19

CateGoryController  3-6

/**
     * 菜品分页查询  3-6
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/page")
    public R<Page> page(int page, int pageSize){
        //分页构造器
        Page<Category> pageInfo = new Page<>(page,pageSize);
        //条件构造器
        LambdaQueryWrapper<Category> queryWrapper = new LambdaQueryWrapper<>();
        //添加排序条件,根据sort进行排序
        queryWrapper.orderByAsc(Category::getSort);

        //分页查询
        categoryService.page(pageInfo,queryWrapper);
        return R.success(pageInfo);
    }

分类管理业务开发_字段_20

4.  删除分类  3-7

4.1 需求分析 3-7

分类管理业务开发_spring_21

4.2 代码开发  3-7

在开发代码之前,需要梳理一下 整个程序的执行过程:

1、页面发送ajax请求,将参数(id)提交到服务端

2、服务端Controller接收页面提交的数据并调用Service删除数据

3、Service调用Mapper操作数据库

分类管理业务开发_spring_22

CateGoryController  3-7


    //删除分类  3-7
    @DeleteMapping
    public R<String> delete(Long ids){
        log.info("删除分类,id为:{}",ids);

        categoryService.removeById(ids);
        //categoryService.remove(id);

        return R.success("分类信息删除成功");
    }

分类管理业务开发_spring_23

4.3 功能完善  3-8

前面我们已经实现了根据id删除分类的功能,但是并没有检查删除的分类是否关联了菜品或者套餐,所以我们需要进行功能完善。

要完善分类删除功能,需要先准备基础的类和接口:

1、实体类Dish和Setmeal (从课程资料中复制即可)

2、Mapper接口DishMapper和SetmealMapper

3、Service接 口DishService和SetmealService

4、Service实现类DishServicelmpl和SetmealServicelmpl

分类管理业务开发_线程_24

菜品管理Dish

package com.itheima.reggie.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 菜品管理  3-8
 */
@Data
public class Dish implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;


    //菜品名称
    private String name;


    //菜品分类id
    private Long categoryId;


    //菜品价格
    private BigDecimal price;


    //商品码
    private String code;


    //图片
    private String image;


    //描述信息
    private String description;


    //0 停售 1 起售
    private Integer status;


    //顺序
    private Integer sort;


    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;


    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;


    @TableField(fill = FieldFill.INSERT)
    private Long createUser;


    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updateUser;


    //是否删除
    private Integer isDeleted;

}

套餐管理Setmeal

package com.itheima.reggie.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 套餐管理  3-8
 */
@Data
public class Setmeal implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;


    //分类id
    private Long categoryId;


    //套餐名称
    private String name;


    //套餐价格
    private BigDecimal price;


    //状态 0:停用 1:启用
    private Integer status;


    //编码
    private String code;


    //描述信息
    private String description;


    //图片
    private String image;


    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;


    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;


    @TableField(fill = FieldFill.INSERT)
    private Long createUser;


    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updateUser;


    //是否删除
    private Integer isDeleted;
}

菜品管理 持久层接口DishMapper

package com.itheima.reggie.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.reggie.entity.Dish;
import org.apache.ibatis.annotations.Mapper;

//菜品管理 持久层接口  3-8
@Mapper
public interface DishMapper extends BaseMapper<Dish> {
}

套餐管理持久层接口SetmealMapper

package com.itheima.reggie.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.reggie.entity.Setmeal;
import org.apache.ibatis.annotations.Mapper;

//套餐管理持久层接口   3-8
@Mapper
public interface SetmealMapper extends BaseMapper<Setmeal> {
}

菜品管理业务层接口DishService

package com.itheima.reggie.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.itheima.reggie.entity.Dish;

//菜品管理业务层接口  3-8
public interface DishService extends IService<Dish> {
}

套餐管理业务层接口SetmealService

package com.itheima.reggie.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.itheima.reggie.entity.Setmeal;

//套餐管理业务层接口  3-8
public interface SetmealService extends IService<Setmeal> {
}

菜品管理业务层接口实现类DishServiceImpl

package com.itheima.reggie.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.reggie.entity.Dish;
import com.itheima.reggie.mapper.DishMapper;
import com.itheima.reggie.service.DishService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

//菜品管理业务层接口实现类  3-8
@Service
@Slf4j
public class DishServiceImpl extends ServiceImpl<DishMapper,Dish> implements DishService {
}

套餐管理业务层接口实现类SetmealServiceImpl

package com.itheima.reggie.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.reggie.entity.Setmeal;
import com.itheima.reggie.mapper.SetmealMapper;
import com.itheima.reggie.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

//套餐管理业务层接口实现类  3-8
@Service
@Slf4j
public class SetmealServiceImpl extends ServiceImpl<SetmealMapper,Setmeal> implements SetmealService {
}

删除分类功能完善  3-8

 自定义业务异常类CustomException
package com.itheima.reggie.common;

/**
 * 自定义业务异常类 (这个我们在本项目用于完善删除菜品分类和套餐分类使用)  3-8
 */
public class CustomException extends RuntimeException {
    public CustomException(String message){
        super(message);
    }
}

全局异常处理器 GlobalExceptionHandler
//删除菜品或者套餐分类时的异常处理器  3-8
    @ExceptionHandler(CustomException.class)
    public R<String> exceptionHandler(CustomException ex){
        log.error(ex.getMessage());
        return R.error(ex.getMessage());
    }
菜品分类 业务层接口实现类CategoryServiceImpl
package com.itheima.reggie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.reggie.common.CustomException;
import com.itheima.reggie.entity.Category;
import com.itheima.reggie.entity.Dish;
import com.itheima.reggie.entity.Setmeal;
import com.itheima.reggie.mapper.CategoryMapper;
import com.itheima.reggie.service.CategoryService;
import com.itheima.reggie.service.DishService;
import com.itheima.reggie.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

//菜品分类 业务层接口实现类  3-5
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper,Category> implements CategoryService{

    @Autowired
    private DishService dishService;

    @Autowired
    private SetmealService setmealService;


    //根据id删除分类 在删除之前需要判断该分类是不是关联了菜品和套餐  3-8
    @Override
    public void remove(Long id) {

        LambdaQueryWrapper<Dish> dishLambdaQueryWrapper = new LambdaQueryWrapper<>();
        //添加查询条件,根据分类id进行查询
        dishLambdaQueryWrapper.eq(Dish::getCategoryId,id);
        //查询当前分类是否关联了菜品,如果已经关联,抛出一个业务异常
        int count = dishService.count(dishLambdaQueryWrapper);
        if(count>10){
            //已经关联,抛出一个业务异常
            throw new CustomException("当前分类下关联了菜品,不能删除");
        }

        //查询当前分类是否关联了套餐,如果已经关联,抛出一个业务异常
        LambdaQueryWrapper<Setmeal> setmealLambdaQueryWrapper = new LambdaQueryWrapper<>();
        //添加查询条件,根据分类id进行查询
        setmealLambdaQueryWrapper.eq(Setmeal::getCategoryId,id);
        int count2 = setmealService.count();
        if(count2 > 0){
            //已经关联套餐,抛出一个业务异常
            throw new CustomException("当前分类下关联了套餐,不能删除");
        }


        //正常删除分类
        super.removeById(id);
    }
}

CateGoryController  3-8
//删除分类  3-7
    @DeleteMapping
    public R<String> delete(Long ids){
        log.info("删除分类,id为:{}",ids);

        //categoryService.removeById(ids);
        categoryService.remove(ids);  //3-8

        return R.success("分类信息删除成功");
    }

测试,比如我们删除湘菜,删除不成功,应为此份额里关联了菜品

分类管理业务开发_自动填充_25

我们删除test 成功

分类管理业务开发_spring_26

5. 修改分类  3-9

5.1 需求分析  3-9

分类管理业务开发_线程_27

5.2 代码实现  3-9

/**
     * 根据id修改分类信息  3-9
     * @param category
     * @return
     */
    @PutMapping
    public R<String> update(@RequestBody Category category){
        log.info("修改分类信息:{}",category);

        categoryService.updateById(category);

        return R.success("修改分类信息成功");
    }

分类管理业务开发_spring_28

分类管理业务开发_spring_29

标签:分类管理,业务,private,开发,reggie,import,com,id,itheima
From: https://blog.51cto.com/u_15784725/6505043

相关文章

  • PostgreSQL 已领先于 MySQL 成为开发人员的首选
    一项针对90,000名开发人员的调查显示,PostgreSQL领先于MySQL作为数据库引擎的选择,与去年的同一项调查相比有显着变化。2023年5月的调查由开发人员问答网站StackOverflow进行,有45.55%的受访者使用PostgreSQL,而MySQL和SQLite分别为41.09%和30.9%。三年前,同一......
  • Android-JNI开发概论
    什么是JNI开发JNI的全称是JavaNativeInterface,顾名思义,这是一种解决Java和C/C++相互调用的编程方式。它其实只解决两个方面的问题,怎么找到和怎么访问。弄清楚这两个话题,我们就学会了JNI开发。需要注意的是,JNI开发只涉及到一小部分C/C++开发知识,遇到问题的时候我们首先要判断是......
  • 专业app定制开发服务App开发的三个阶段
    App开发的三个阶段1需求阶段。客户要和项目经理对产品类型、用户定位进行清晰的规划,然后对于APP需要哪些功能、哪些平台、具体的功能设置、界面设计风格、预期交付时间、开发预算等内容双方进行反复的沟通讨论,形成初步的项目开发方案。2开发阶段。确定人员安排、项目开发周期、测试......
  • 软件开发人员必须阅读的20本书
    本文翻译自国外论坛medium,原文地址:https://irina-seng.medium.com/top-20-books-a-software-developer-must-read-updated-b24bcc9ee3d持续学习的心态是软件开发人员想要保持专业相关性并增长自身价值的关键品质。在这篇博文中,我将推荐20本最受欢迎的软件工程书籍清单,以帮......
  • ​任务编排工具在之家业务系统中应用探究
     本文主要介绍在之家广告业务系统中运用任务编排治理工具的场景及其可以解决的问题,讲解任务编排框架的核心要点,以及向大家演示一个任务编排框架的基本结构,让大家对任务编排工具增强业务开发效率,提高研发质量有更深刻的理解。 1.背景我们开始以下面的实际业......
  • 《安富莱嵌入式周报》第315期:开源USB高速分析仪,8GHz示波器开发, 600行C编写RISC-V内
    周报汇总地址:http://www.armbbs.cn/forum.php?mod=forumdisplay&fid=12&filter=typeid&typeid=104 视频版:https://www.bilibili.com/video/BV1gV4y117UD/1、开源USB2.0高速分析仪https://github.com/ataradov/usb-snifferusb-sniffer-main.zip(2.05MB)分析仪上位机......
  • 【GStreamer rtsp】gstreamer-rtsp-server开发环境搭建
    1.安装gstreamer基础库sudoapt-getinstalllibgl1-mesa-devsudoapt-getinstallgstreamer1.0-libavsudoapt-getinstallgstreamer1.0-plugins-badsudoapt-getinstallgstreamer1.0-plugins-basesudoapt-getinstallgstreamer1.0-plugins-uglysudoapt-getinstall......
  • k8sphp业务
    1.K8S部署初始化准备1.1系统安装地址规划,根据实际情况进行修改主机名IP操作系统master10.0.0.10ubuntu22.04worker0110.0.0.11ubuntu22.04worker0210.0.0.12ubuntu22.04下载地址:https://mirrors.aliyun.com/ubuntu-releases/bionic/ubuntu-18.04......
  • 【web开发】使用Trait解决PHP面向对象中类只支持单继承的限制
    前言众所周知,PHP的面向对象和Java一样,类只支持单继承,即是一个类只能继承自一个父类,不能存在多个父类,这也很好理解,就像现实的人类社会一样,儿子继承自你的父亲,父亲继承自祖父。。。,但是在实际开发中很多时候我们想像c++一样使用多重继承。奈何PHP只能使用单继承,在Trait出现之前,在PHP......
  • 【Java技术专题】「Guava开发指南」手把手教你如何进行使用Guava工具箱进行开发系统实
    异常传播有时候,您可能需要重新抛出捕获到的异常。这种情况通常发生在捕获到Error或RuntimeException时,因为您可能没有预料到这些异常,但在声明捕获Throwable和Exception时,它们也被包含在内了。为了解决这个问题,Guava提供了多种方法来判断异常类型并重新抛出异常。例如:try{......