commit f73bba2d760d03de4574cc10f948ddea1e842ca9 Author: Cui YongXing <2835316714@qq.com> Date: Fri Jul 26 09:47:03 2024 +0800 day08 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -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 diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..8d66637 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..544713a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/setting.xml b/.idea/setting.xml new file mode 100644 index 0000000..ed05fd8 --- /dev/null +++ b/.idea/setting.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..cd15fc8 --- /dev/null +++ b/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + com.bwie + billManage + 1.0-SNAPSHOT + + + 17 + 17 + UTF-8 + + + + org.springframework.boot + spring-boot-starter + 3.2.6 + + + org.springframework.boot + spring-boot-starter-web + 3.2.6 + + + + org.springframework.cloud + spring-cloud-starter-bootstrap + 3.1.0 + + + mysql + mysql-connector-java + 8.0.29 + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 3.0.2 + + + org.projectlombok + lombok + 1.18.32 + + + org.springframework.boot + spring-boot-starter-test + 3.2.6 + + + + diff --git a/src/main/java/com/bwie/Application.java b/src/main/java/com/bwie/Application.java new file mode 100644 index 0000000..fafef69 --- /dev/null +++ b/src/main/java/com/bwie/Application.java @@ -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); + } +} diff --git a/src/main/java/com/bwie/dao/BillDao.java b/src/main/java/com/bwie/dao/BillDao.java new file mode 100644 index 0000000..8119684 --- /dev/null +++ b/src/main/java/com/bwie/dao/BillDao.java @@ -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 selectAll(); +} diff --git a/src/main/java/com/bwie/pojo/Bill.java b/src/main/java/com/bwie/pojo/Bill.java new file mode 100644 index 0000000..8d92759 --- /dev/null +++ b/src/main/java/com/bwie/pojo/Bill.java @@ -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; +} diff --git a/src/main/java/com/bwie/service/BillService.java b/src/main/java/com/bwie/service/BillService.java new file mode 100644 index 0000000..18b8941 --- /dev/null +++ b/src/main/java/com/bwie/service/BillService.java @@ -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 selectAll(); + +} diff --git a/src/main/java/com/bwie/service/impl/BillServiceImpl.java b/src/main/java/com/bwie/service/impl/BillServiceImpl.java new file mode 100644 index 0000000..48bae2b --- /dev/null +++ b/src/main/java/com/bwie/service/impl/BillServiceImpl.java @@ -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 selectAll() { + return billDao.selectAll(); + } +} diff --git a/src/main/java/com/bwie/test/TestBill.java b/src/main/java/com/bwie/test/TestBill.java new file mode 100644 index 0000000..0d42cdd --- /dev/null +++ b/src/main/java/com/bwie/test/TestBill.java @@ -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(); + } + + + + + +} diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..4e206d6 --- /dev/null +++ b/src/main/resources/bootstrap.yml @@ -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 diff --git a/src/main/resources/mapper/BillDao.xml b/src/main/resources/mapper/BillDao.xml new file mode 100644 index 0000000..de525dd --- /dev/null +++ b/src/main/resources/mapper/BillDao.xml @@ -0,0 +1,14 @@ + + + + + + insert into bill (billDate,billMonery) values (#{billDate},#{billMonery}) + + + diff --git a/理论/img.png b/理论/img.png new file mode 100644 index 0000000..c9d855e Binary files /dev/null and b/理论/img.png differ