Initial commit
This commit is contained in:
parent
327517ca12
commit
39d1de99a0
@ -1,6 +1,9 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
<component name="InspectionProjectProfileManager">
|
||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ADDITIONAL_TAGS" value="date" />
|
||||||
|
</inspection_tool>
|
||||||
<inspection_tool class="MavenPackageUpdate" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
<inspection_tool class="MavenPackageUpdate" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
<option name="excludeList">
|
<option name="excludeList">
|
||||||
<list>
|
<list>
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
# SpringBoot_Study
|
# SpringBoot_Study
|
||||||
此项目用于学习SpringBoot
|
此项目用于学习SpringBoot
|
||||||
|
|
||||||
|
其中`springboot_08_ssmp`项目中的`Goods`前端`Vue`页面项目[在此](https://github.com/yovinchen/demo-cart)
|
||||||
|
@ -5,7 +5,7 @@ import lombok.Data;
|
|||||||
/**
|
/**
|
||||||
* @author YoVinchen
|
* @author YoVinchen
|
||||||
* @date 2023/3/15 下午 9:24
|
* @date 2023/3/15 下午 9:24
|
||||||
*
|
* <p>
|
||||||
* lombok
|
* lombok
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
18
springboot_08_ssmp/src/main/java/com/yv/admain/Goods.java
Normal file
18
springboot_08_ssmp/src/main/java/com/yv/admain/Goods.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package com.yv.admain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YoVinchen
|
||||||
|
* @date 2023/5/10 19:03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Goods {
|
||||||
|
private int id;
|
||||||
|
private String goods_name;
|
||||||
|
private String goods_img;
|
||||||
|
private String goods_price;
|
||||||
|
private int goods_count;
|
||||||
|
private String goods_state;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.yv.controller;
|
||||||
|
|
||||||
|
import com.yv.controller.utils.R;
|
||||||
|
import com.yv.service.GoodsService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YoVinchen
|
||||||
|
* @date 2023/5/10 19:45
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@CrossOrigin
|
||||||
|
@RequestMapping("/goods")
|
||||||
|
public class GoodsController {
|
||||||
|
@Autowired
|
||||||
|
private GoodsService goodsService;
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public R getAll() {
|
||||||
|
return new R(true,goodsService.list());
|
||||||
|
}
|
||||||
|
}
|
@ -32,4 +32,10 @@ public class R {
|
|||||||
this.flag = false;
|
this.flag = false;
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public R(Boolean flag, Object data, String msg) {
|
||||||
|
this.flag = flag;
|
||||||
|
this.data = data;
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
13
springboot_08_ssmp/src/main/java/com/yv/dao/GoodsDao.java
Normal file
13
springboot_08_ssmp/src/main/java/com/yv/dao/GoodsDao.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.yv.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.yv.admain.Goods;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YoVinchen
|
||||||
|
* @date 2023/5/10 19:08
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface GoodsDao extends BaseMapper<Goods> {
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.yv.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.yv.admain.Goods;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YoVinchen
|
||||||
|
* @date 2023/5/10 19:09
|
||||||
|
*/
|
||||||
|
public interface GoodsService extends IService<Goods> {
|
||||||
|
boolean saveGoods(Goods goods);
|
||||||
|
|
||||||
|
boolean modify(Goods goods);
|
||||||
|
|
||||||
|
boolean delete(Integer id);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.yv.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.yv.admain.Goods;
|
||||||
|
import com.yv.dao.GoodsDao;
|
||||||
|
import com.yv.service.GoodsService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YoVinchen
|
||||||
|
* @date 2023/5/10 19:15
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements GoodsService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GoodsDao goodsDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean saveGoods(Goods goods) {
|
||||||
|
return goodsDao.insert(goods) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean modify(Goods goods) {
|
||||||
|
return goodsDao.updateById(goods) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delete(Integer id) {
|
||||||
|
return goodsDao.deleteById(id) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -11,11 +11,12 @@ spring:
|
|||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
global-config:
|
global-config:
|
||||||
db-config:
|
db-config:
|
||||||
table-prefix: tbl_
|
# 这个是关于book在sql的设置
|
||||||
|
# table-prefix: tbl_
|
||||||
id-type: auto
|
id-type: auto
|
||||||
configuration:
|
configuration:
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
map-underscore-to-camel-case: false
|
||||||
#端口配置
|
#端口配置
|
||||||
server:
|
server:
|
||||||
port: 8080
|
port: 8080
|
||||||
|
43
springboot_08_ssmp/src/main/resources/sql/goods.sql
Normal file
43
springboot_08_ssmp/src/main/resources/sql/goods.sql
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
Navicat Premium Data Transfer
|
||||||
|
|
||||||
|
Source Server : mysql
|
||||||
|
Source Server Type : MySQL
|
||||||
|
Source Server Version : 80033 (8.0.33)
|
||||||
|
Source Host : localhost:3306
|
||||||
|
Source Schema : ssm_db
|
||||||
|
|
||||||
|
Target Server Type : MySQL
|
||||||
|
Target Server Version : 80033 (8.0.33)
|
||||||
|
File Encoding : 65001
|
||||||
|
|
||||||
|
Date: 10/05/2023 20:07:12
|
||||||
|
*/
|
||||||
|
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for goods
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `goods`;
|
||||||
|
CREATE TABLE `goods` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
`goods_name` varchar(255) DEFAULT NULL,
|
||||||
|
`goods_img` varchar(255) DEFAULT NULL,
|
||||||
|
`goods_price` int DEFAULT NULL,
|
||||||
|
`goods_count` int DEFAULT NULL,
|
||||||
|
`goods_state` varchar(255) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of goods
|
||||||
|
-- ----------------------------
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO `goods` (`id`, `goods_name`, `goods_img`, `goods_price`, `goods_count`, `goods_state`) VALUES (1, '班俏BANQIAO超火ins潮卫衣女士2020秋季新款韩版宽松慵懒风薄款外套带帽上衣', 'https://www.escook.cn/vuebase/pics/1.png', 108, 1, 'true');
|
||||||
|
INSERT INTO `goods` (`id`, `goods_name`, `goods_img`, `goods_price`, `goods_count`, `goods_state`) VALUES (2, '嘉叶希连帽卫衣女春秋薄款2020新款宽松bf韩版字母印花中长款外套ins潮', 'https://www.escook.cn/vuebase/pics/2.png', 129, 1, 'true');
|
||||||
|
INSERT INTO `goods` (`id`, `goods_name`, `goods_img`, `goods_price`, `goods_count`, `goods_state`) VALUES (3, '思蜜怡2020休闲运动套装女春秋季新款时尚大码宽松长袖卫衣两件套', 'https://www.escook.cn/vuebase/pics/3.png', 120, 1, 'false');
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.yv.service;
|
||||||
|
|
||||||
|
import com.yv.admain.Goods;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YoVinchen
|
||||||
|
* @date 2023/5/10 19:54
|
||||||
|
*/
|
||||||
|
@SpringBootTest
|
||||||
|
public class GoodsServiceTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GoodsService goodsService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testGetAll(){
|
||||||
|
List<Goods> list = goodsService.list();
|
||||||
|
System.out.println(list.toString());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user