后端查询所有商品大类接口实现

/*
SQLyog Ultimate v11.33 (64 bit)
MySQL - 5.7.18-log 
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;

create table `t_bigtype` (
	`id` int (11),
	`name` varchar (150),
	`remark` varchar (765),
	`image` varchar (765)
); 
insert into `t_bigtype` (`id`, `name`, `remark`, `image`) values('1','手机','手机描述','1.jpg');
insert into `t_bigtype` (`id`, `name`, `remark`, `image`) values('2','电脑平板','电脑平板描述','2.jpg');
insert into `t_bigtype` (`id`, `name`, `remark`, `image`) values('3','智能穿戴','智能穿戴描述','3.jpg');
insert into `t_bigtype` (`id`, `name`, `remark`, `image`) values('4','电视','电视描述','4.jpg');
insert into `t_bigtype` (`id`, `name`, `remark`, `image`) values('5','大家电','大家电描述','5.jpg');
insert into `t_bigtype` (`id`, `name`, `remark`, `image`) values('6','小家电','小家电描述','6.jpg');
insert into `t_bigtype` (`id`, `name`, `remark`, `image`) values('7','智能家居','智能家居描述','7.jpg');
insert into `t_bigtype` (`id`, `name`, `remark`, `image`) values('8','户外出行','户外出行描述','8.jpg');
insert into `t_bigtype` (`id`, `name`, `remark`, `image`) values('9','日用百货','日用百货描述','9.jpg');
insert into `t_bigtype` (`id`, `name`, `remark`, `image`) values('10','儿童用品','儿童用品描述','10.jpg');
insert into `t_bigtype` (`id`, `name`, `remark`, `image`) values('41','ds','ds','default.jpg');
insert into `t_bigtype` (`id`, `name`, `remark`, `image`) values('42','dsds','ds','default.jpg');
insert into `t_bigtype` (`id`, `name`, `remark`, `image`) values('43','22','22','20220226111030000000632.jpg');

package com.java1234.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

/**
 * 商品大类
 * @author java1234_小锋
 * @site www.java1234.com
 * @company 南通小锋网络科技有限公司
 * @create 2021-11-22 22:03
 */
@TableName("t_bigType")
@Data
public class BigType {

    private Integer id; // 编号

    private String name; // 名称

    private String remark; // 备注

    private String image="default.jpg"; // 封面图片

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }



}

Mapper

package com.java1234.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.java1234.entity.BigType;

/**
 * 商品大类Mapper接口
 */
public interface BigTypeMapper extends BaseMapper<BigType> {
}

Service

package com.java1234.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.java1234.entity.BigType;
import com.java1234.entity.Product;

/**
 * 商品大类Service接口
 */
public interface IBigTypeService extends IService<BigType> {
}

package com.java1234.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.java1234.entity.BigType;
import com.java1234.entity.Product;
import com.java1234.mapper.BigTypeMapper;
import com.java1234.mapper.ProductMapper;
import com.java1234.service.IBigTypeService;
import com.java1234.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 * 商品大类Service实现类
 */
@Service("bigTypeService")
public class IBigTypeServiceImpl extends ServiceImpl<BigTypeMapper, BigType> implements IBigTypeService {

    @Autowired
    private BigTypeMapper bigTypeMapper;
}

Controller

package com.java1234.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.java1234.entity.BigType;
import com.java1234.entity.Product;
import com.java1234.entity.R;
import com.java1234.service.IBigTypeService;
import com.java1234.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 商品大类Controller
 */
@RestController
@RequestMapping("/bigType")
public class BigTypeController {

    @Autowired
    private IBigTypeService bigTypeService;

    /**
     * 查询所有商品大类
     * @return
     */
    @GetMapping("/findAll")
    public R findAll(){
        List<BigType> bigTypeList = bigTypeService.list();
        Map<String,Object> map=new HashMap<>();
        map.put("message",bigTypeList);
        return R.ok(map);
    }
}

你可能感兴趣的:(分布式小程序电商2,java)