fix:添加购物车

上级 c146533d
-- kwan.chatbot definition
CREATE TABLE `vue_chat`
(
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`goods_name` varchar(64) DEFAULT NULL COMMENT '商品名称',
`goods_img` varchar(64) DEFAULT NULL COMMENT '商品图片',
`goods_price` DECIMAL(8, 2) DEFAULT NULL COMMENT '商品价格',
`goods_state` varchar(10) DEFAULT NULL COMMENT '商品购买状态',
`goods_count` DECIMAL(8, 2) DEFAULT NULL COMMENT '商品价格',
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci
ROW_FORMAT = DYNAMIC COMMENT ='vue购物车项目';
TRUNCATE TABLE vue_chat;
INSERT INTO kwan.vue_chat (goods_name, goods_img, goods_price, goods_state, goods_count)
VALUES ( '荣耀X40 120Hz OLED硬核曲屏 5100mAh 快充大电池 7.9mm轻薄设计 5G手机 8GB+128GB 彩云追月'
, 'https://img10.360buyimg.com/n7/jfs/t1/7169/20/17985/33829/63241b3aE7dcfd261/efb35507276509cd.jpg', 1599
, 'true', 1)
, ( 'OPPO K9x 8GB+128GB 银紫超梦 天玑810 5000mAh长续航 33W快充 90Hz电竞屏 6400万三摄 拍照5G手机oppok9x'
, 'https://img13.360buyimg.com/n7/jfs/t1/131034/11/34154/75516/64a9649aF9a6632c5/af70a934923c8425.jpg', 1199
, 'true', 2)
, ( 'OPPO K10x 极光 8GB+128GB 67W超级闪充 5000mAh长续航 120Hz高帧屏 6400万三摄 高通骁龙695 拍照 5G手机'
, 'https://img12.360buyimg.com/n7/jfs/t1/125512/22/36170/52200/64a7c2b2F2ad555ff/21e5369b895d70c8.jpg', 1299
, 'true', 1)
, ( '荣耀90 2亿像素写真相机 零风险调光护眼屏 5000mAh轻薄长续航 12GB+256GB 冰羽蓝 5G'
, 'https://img13.360buyimg.com/n7/jfs/t1/132760/11/35047/63820/64744f04F8e389e09/796303a2b991a621.jpg', 2499
, 'true', 1)
;
package com.kwan.springbootkwan.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kwan.springbootkwan.entity.Result;
import com.kwan.springbootkwan.entity.VueChat;
import com.kwan.springbootkwan.service.VueChatService;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;
/**
* vue购物车项目(VueChat)表控制层
*
* @author makejava
* @since 2023-07-09 15:12:55
*/
@RestController
@RequestMapping("vueChat")
public class VueChatController {
/**
* 服务对象
*/
@Resource
private VueChatService vueChatService;
/**
* 获取所有数据
*
* @return
*/
@GetMapping
public Result selectAll() {
return Result.ok(this.vueChatService.list());
}
/**
* 分页查询所有数据
*
* @param page 分页对象
* @param vueChat 查询实体
* @return 所有数据
*/
@GetMapping("/page")
public Result selectPage(Page<VueChat> page, VueChat vueChat) {
return Result.ok(this.vueChatService.page(page, new QueryWrapper<>(vueChat)));
}
/**
* 通过主键查询单条数据
*
* @param id 主键
* @return 单条数据
*/
@GetMapping("{id}")
public Result selectOne(@PathVariable Serializable id) {
return Result.ok(this.vueChatService.getById(id));
}
/**
* 新增数据
*
* @param vueChat 实体对象
* @return 新增结果
*/
@PostMapping
public Result insert(@RequestBody VueChat vueChat) {
return Result.ok(this.vueChatService.save(vueChat));
}
/**
* 修改数据
*
* @param vueChat 实体对象
* @return 修改结果
*/
@PutMapping
public Result update(@RequestBody VueChat vueChat) {
return Result.ok(this.vueChatService.updateById(vueChat));
}
/**
* 删除数据
*
* @param idList 主键结合
* @return 删除结果
*/
@DeleteMapping
public Result delete(@RequestParam("idList") List<Long> idList) {
return Result.ok(this.vueChatService.removeByIds(idList));
}
}
package com.kwan.springbootkwan.entity;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import java.util.Date;
/**
* vue购物车项目(VueChat)表实体类
*
* @author makejava
* @since 2023-07-09 15:12:56
*/
@SuppressWarnings("serial")
@Data
public class VueChat extends Model<VueChat> {
private Integer id;
//商品名称
private String goodsName;
//商品图片
private String goodsImg;
//商品价格
private Double goodsPrice;
//商品购买状态
private String goodsState;
//商品价格
private Double goodsCount;
private Date createTime;
}
\ No newline at end of file
package com.kwan.springbootkwan.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kwan.springbootkwan.entity.VueChat;
/**
* vue购物车项目(VueChat)表数据库访问层
*
* @author makejava
* @since 2023-07-09 15:12:55
*/
public interface VueChatDao extends BaseMapper<VueChat> {
}
package com.kwan.springbootkwan.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.kwan.springbootkwan.entity.VueChat;
/**
* vue购物车项目(VueChat)表服务接口
*
* @author makejava
* @since 2023-07-09 15:12:56
*/
public interface VueChatService extends IService<VueChat> {
}
package com.kwan.springbootkwan.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kwan.springbootkwan.mapper.VueChatDao;
import com.kwan.springbootkwan.entity.VueChat;
import com.kwan.springbootkwan.service.VueChatService;
import org.springframework.stereotype.Service;
/**
* vue购物车项目(VueChat)表服务实现类
*
* @author makejava
* @since 2023-07-09 15:12:56
*/
@Service
public class VueChatServiceImpl extends ServiceImpl<VueChatDao, VueChat> implements VueChatService {
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册