后台管理--商品分类模块

目录

1 商品分类列表展现

1.1表结构设计

 1.2.pojo

1.3.编辑ItemCatController

1.4.编辑ItemCatService

优化方案

2 商品分类状态修改

2.1 编辑ItemCatController

2.2 编辑ItemCatService

3 商品新增

3.1 编辑ItemCatController

3.2 编辑ItemCatService

4 商品分类修改

4.1 编辑ItemCatController

4.2 编辑ItemCatService

5 商品分类删除

5.1 编辑ItemCatController

5.2 编辑ItemCatService


1 商品分类列表展现

1.1表结构设计


create table
CREATE TABLE `item_cat` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `parent_id` int(11) DEFAULT NULL,
   `name` varchar(150) DEFAULT NULL,
   `status` int(11) DEFAULT NULL,
   `level` int(11) DEFAULT NULL,
   `created` datetime DEFAULT NULL,
   `updated` datetime DEFAULT NULL,
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=1183 DEFAULT CHARSET=utf8

 1.2.pojo

package com.jt.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

@TableName("item_cat")
@Data
@Accessors(chain = true)
public class ItemCat extends BasePojo{

    @TableId(type = IdType.AUTO)
    private Integer id;         //定义主键
    private Integer parentId;   //定义父级菜单
    private String name;        //分类名称
    private Boolean status;     //分类状态 0 停用 1 正常
    private Integer level;      //商品分类等级  1 2 3
    @TableField(exist = false)
    private List<ItemCat> children;
}

1.3.编辑ItemCatController

package com.jt.controller;

import com.jt.pojo.ItemCat;
import com.jt.service.ItemCatService;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/itemCat")
@CrossOrigin
public class ItemCatController {
    @Autowired
    private ItemCatService itemCatService;
    @GetMapping("findAll")
    public SysResult findAll(){
        List<ItemCat> list = itemCatService.findAll();
        return SysResult.success(list);
    }
    @GetMapping("/findItemCatList/{level}")
    public SysResult findItemCatList(@PathVariable Integer level){
        List<ItemCat> itemCatList = itemCatService.findItemCatList(level);
        return SysResult.success(itemCatList);
    }
}

1.4.编辑ItemCatService

package com.jt.servi
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值