day8
commit
75b991fdff
|
@ -0,0 +1,33 @@
|
|||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
|
@ -0,0 +1,156 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>Zg6-day8</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Zg6-day8</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<spring-boot.version>2.3.12.RELEASE</spring-boot.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--分页插件mybatis-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus</artifactId>
|
||||
<version>3.5.7</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 添加servlet依赖模块 -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- 添加jstl标签库依赖模块 -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>jstl</artifactId>
|
||||
</dependency>
|
||||
<!--添加tomcat依赖模块.-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- 使用jsp引擎,springboot内置tomcat没有此依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-jasper</artifactId>
|
||||
</dependency>
|
||||
<!-- sqring框架依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.1.4</version>
|
||||
</dependency>
|
||||
<!-- 热部署依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- mysql数据库依赖 -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.32</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- lombok小辣椒依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- 测试类依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
<version>4.4.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<mainClass>com.bwie.Zg6Day8Application</mainClass>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
Navicat Premium Data Transfer
|
||||
|
||||
Source Server : zhangteng
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 80038
|
||||
Source Host : localhost:3306
|
||||
Source Schema : zg6_day8
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 80038
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 26/07/2024 09:12:34
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for bill
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `bill`;
|
||||
CREATE TABLE `bill` (
|
||||
`bill_id` int NOT NULL AUTO_INCREMENT,
|
||||
`bil_date` datetime NULL DEFAULT NULL,
|
||||
`bill_money` decimal(10, 2) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`bill_id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of bill
|
||||
-- ----------------------------
|
||||
INSERT INTO `bill` VALUES (1, '2013-04-06 15:20:58', 287.31);
|
||||
INSERT INTO `bill` VALUES (2, '2000-01-08 12:07:30', 178.91);
|
||||
INSERT INTO `bill` VALUES (3, '2009-01-06 21:05:04', 722.54);
|
||||
INSERT INTO `bill` VALUES (4, '2022-10-17 16:51:15', 784.05);
|
||||
INSERT INTO `bill` VALUES (5, '2023-12-09 13:03:46', 711.71);
|
||||
INSERT INTO `bill` VALUES (6, '2020-03-28 04:43:42', 389.84);
|
||||
INSERT INTO `bill` VALUES (7, '2023-03-13 12:20:38', 781.42);
|
||||
INSERT INTO `bill` VALUES (8, '2003-02-24 08:48:16', 818.61);
|
||||
INSERT INTO `bill` VALUES (9, '2014-08-31 23:41:19', 310.08);
|
||||
INSERT INTO `bill` VALUES (10, '2008-02-10 10:30:26', 791.41);
|
||||
INSERT INTO `bill` VALUES (11, '2019-06-09 02:11:30', 186.66);
|
||||
INSERT INTO `bill` VALUES (12, '2008-07-21 17:58:46', 672.25);
|
||||
INSERT INTO `bill` VALUES (13, '2016-10-17 01:22:02', 623.89);
|
||||
INSERT INTO `bill` VALUES (14, '2005-06-28 14:03:36', 122.66);
|
||||
INSERT INTO `bill` VALUES (15, '2021-09-10 03:08:26', 831.16);
|
||||
INSERT INTO `bill` VALUES (16, '2011-06-16 11:24:37', 734.75);
|
||||
INSERT INTO `bill` VALUES (17, '2013-07-20 21:24:05', 867.63);
|
||||
INSERT INTO `bill` VALUES (18, '2020-06-20 14:11:43', 733.18);
|
||||
INSERT INTO `bill` VALUES (19, '2018-04-24 18:01:01', 193.07);
|
||||
INSERT INTO `bill` VALUES (20, '2007-11-15 14:21:43', 899.95);
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
|
@ -0,0 +1,15 @@
|
|||
package com.bwie;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.bwie.mapper")
|
||||
public class Zg6Day8Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Zg6Day8Application.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.bwie.controller;
|
||||
|
||||
import com.bwie.mapper.BillMapper;
|
||||
import com.bwie.pojo.BillDao;
|
||||
import com.bwie.service.BillService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:张腾
|
||||
* @Package:com.bwie.controller
|
||||
* @Project:Zg6-day8
|
||||
* @name:BillController
|
||||
* @Date:2024/7/26 8:49
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/bill")
|
||||
public class BillController {
|
||||
|
||||
@Autowired
|
||||
private BillService billService;
|
||||
|
||||
/***
|
||||
* 查询所有
|
||||
* @return 返回BillDao集合
|
||||
*
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public List<BillDao> selectAll(){
|
||||
return billService.selectAll();
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param billDao 账单
|
||||
* @return 1 成功 0 失败 error 失败
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Integer add(@RequestBody BillDao billDao){
|
||||
return billService.add(billDao);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.bwie.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bwie.pojo.BillDao;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Author:张腾
|
||||
* @Package:com.bwie.mapper
|
||||
* @Project:Zg6-day8
|
||||
* @name:BillMapper
|
||||
* @Date:2024/7/26 8:45
|
||||
*/
|
||||
public interface BillMapper extends BaseMapper<BillDao> {
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.bwie.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author:张腾
|
||||
* @Package:com.bwie.pojo
|
||||
* @Project:Zg6-day8
|
||||
* @name:BillDao
|
||||
* @Date:2024/7/26 8:45
|
||||
*/
|
||||
@Data
|
||||
@TableName("bill")
|
||||
public class BillDao {
|
||||
private Integer billId;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date billDate;
|
||||
private BigDecimal billMoney;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.bwie.service;
|
||||
|
||||
import com.bwie.pojo.BillDao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:张腾
|
||||
* @Package:com.bwie.service
|
||||
* @Project:Zg6-day8
|
||||
* @name:BillService
|
||||
* @Date:2024/7/26 8:48
|
||||
*/
|
||||
public interface BillService {
|
||||
|
||||
Integer add(BillDao billDao);
|
||||
|
||||
List<BillDao> selectAll();
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.bwie.service.impl;
|
||||
|
||||
import com.bwie.mapper.BillMapper;
|
||||
import com.bwie.pojo.BillDao;
|
||||
import com.bwie.service.BillService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:张腾
|
||||
* @Package:com.bwie.service.impl
|
||||
* @Project:Zg6-day8
|
||||
* @name:BillServiceImpl
|
||||
* @Date:2024/7/26 8:48
|
||||
*/
|
||||
@Service
|
||||
public class BillServiceImpl implements BillService {
|
||||
|
||||
@Autowired
|
||||
private BillMapper billMapper;
|
||||
|
||||
@Override
|
||||
public Integer add(BillDao billDao) {
|
||||
return billMapper.insert(billDao);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BillDao> selectAll() {
|
||||
List<BillDao> billDaos = billMapper.selectList(null);
|
||||
for (BillDao billDao : billDaos) {
|
||||
System.out.println(billDao);
|
||||
}
|
||||
return billDaos;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
# 应用服务 WEB 访问端口号
|
||||
server.port=8080
|
||||
# 日志输出
|
||||
logging.level.com.bawei=debug
|
||||
# 数据库驱动:
|
||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||
# 数据源名称
|
||||
#spring.datasource.name=defaultDataSource
|
||||
# 数据库连接地址
|
||||
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/zg6_day8?characterEncoding=utf-8&useUnicode=true
|
||||
# 数据库用户名&密码:
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=root
|
||||
# 视图解析器
|
||||
spring.mvc.view.prefix=/WEB-INF/view/
|
||||
spring.mvc.view.suffix=.jsp
|
||||
|
||||
# pageHelper插件
|
||||
# 分页合理化
|
||||
pagehelper.reasonable=true
|
||||
# 分页自动转换方言。。。不同的数据库 分页的语句是不同的 mysql--limit oracle--rownum
|
||||
pagehelper.auto-dialect=true
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bwie.mapper.BillMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,13 @@
|
|||
package com.bwie;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class Zg6Day8ApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue