master
Cui YongXing 2024-07-26 09:47:03 +08:00
commit f73bba2d76
17 changed files with 304 additions and 0 deletions

38
.gitignore vendored 100644
View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

8
.idea/.gitignore vendored 100644
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

View File

@ -0,0 +1,5 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
</profile>
</component>

17
.idea/misc.xml 100644
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="arthas.idea.plugin">
<option name="redisAddress" value="" />
<option name="redisAuth" value="" />
<option name="redisCacheKey" value="" />
</component>
</project>

6
.idea/vcs.xml 100644
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

55
pom.xml 100644
View File

@ -0,0 +1,55 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bwie</groupId>
<artifactId>billManage</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>3.2.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>3.2.6</version>
</dependency>
<!-- bootstrap 启动器 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.29</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>3.2.6</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,11 @@
package com.bwie;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class,args);
}
}

View File

@ -0,0 +1,15 @@
package com.bwie.dao;
import com.bwie.pojo.Bill;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface BillDao {
int add(Bill bill);
List<Bill> selectAll();
}

View File

@ -0,0 +1,12 @@
package com.bwie.pojo;
import lombok.Data;
import java.util.Date;
@Data
public class Bill {
private Integer billid;
private Date billDate;
private Double billMonery;
}

View File

@ -0,0 +1,12 @@
package com.bwie.service;
import com.bwie.pojo.Bill;
import java.util.List;
public interface BillService{
int add(Bill bill);
List<Bill> selectAll();
}

View File

@ -0,0 +1,28 @@
package com.bwie.service.impl;
import com.bwie.dao.BillDao;
import com.bwie.pojo.Bill;
import com.bwie.service.BillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class BillServiceImpl implements BillService {
@Autowired
private BillDao billDao;
@Override
public int add(Bill bill) {
int add = billDao.add(bill);
return add;
}
@Override
public List<Bill> selectAll() {
return billDao.selectAll();
}
}

View File

@ -0,0 +1,46 @@
package com.bwie.test;
import com.bwie.pojo.Bill;
import com.bwie.service.BillService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class TestBill {
@Autowired
private BillService billService;
/**
*
*/
@Test
public void addBill(){
Bill bill = new Bill();
bill.setBillDate(new Date());
bill.setBillMonery(100.11);
int add = billService.add(bill);
if (add>0){
System.out.println("-----添加成功----");
}else {
System.out.println("-----添加失败----");
}
}
/**
*
*/
@Test
public void selectAll(){
billService.selectAll();
}
}

View File

@ -0,0 +1,22 @@
server:
port: 9009
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/day08?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: cyx12345
# mybatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: com.bwie.pojo
# 配置mapper的扫描找到所有的mapper.xml映射文件
mapperLocations: classpath:mapper/**/*.xml
configuration:
map-underscore-to-camel-case: true
# 将mapper接口所在包的日志级别改成debug可以在控制台打印sql
logging:
level:
com.bwie.**: debug

View File

@ -0,0 +1,14 @@
<?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.dao.BillDao">
<insert id="add">
insert into bill (billDate,billMonery) values (#{billDate},#{billMonery})
</insert>
<select id="selectAll" resultType="com.bwie.pojo.Bill">
select *
from bill;
</select>
</mapper>

BIN
理论/img.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB