From 539f289702965a689ef9cfda5b3a8eca8ee8127f Mon Sep 17 00:00:00 2001 From: xyiege Date: Wed, 21 Sep 2022 02:29:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=95=E5=AE=9A=E8=8A=82=E5=81=87=E6=97=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/chjyj/szwh/bean/Festivals.java | 36 +++++++++++++++++++ .../cn/chjyj/szwh/mapper/FestivalsMapper.java | 23 ++++++++++++ .../service/impl/FestivalsServiceImpl.java | 25 +++++++++++++ .../resources/mapper/szwh/FestivalsMapper.xml | 34 ++++++++++++++++++ .../szwh/mapper/FestivalsMapperTest.java | 30 ++++++++++++++++ 5 files changed, 148 insertions(+) create mode 100644 src/main/java/cn/chjyj/szwh/bean/Festivals.java create mode 100644 src/main/java/cn/chjyj/szwh/mapper/FestivalsMapper.java create mode 100644 src/main/java/cn/chjyj/szwh/service/impl/FestivalsServiceImpl.java create mode 100644 src/main/resources/mapper/szwh/FestivalsMapper.xml create mode 100644 src/test/java/cn/chjyj/szwh/mapper/FestivalsMapperTest.java diff --git a/src/main/java/cn/chjyj/szwh/bean/Festivals.java b/src/main/java/cn/chjyj/szwh/bean/Festivals.java new file mode 100644 index 0000000..d4a7384 --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/bean/Festivals.java @@ -0,0 +1,36 @@ +package cn.chjyj.szwh.bean; + +import java.util.Date; + +/** + * 法定节假日 + */ +public class Festivals { + private Integer id; + private Integer iyear; //年份,eg.2022 + private Date idate; //日期 + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getIyear() { + return iyear; + } + + public void setIyear(Integer iyear) { + this.iyear = iyear; + } + + public Date getIdate() { + return idate; + } + + public void setIdate(Date idate) { + this.idate = idate; + } +} diff --git a/src/main/java/cn/chjyj/szwh/mapper/FestivalsMapper.java b/src/main/java/cn/chjyj/szwh/mapper/FestivalsMapper.java new file mode 100644 index 0000000..58878b2 --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/mapper/FestivalsMapper.java @@ -0,0 +1,23 @@ +package cn.chjyj.szwh.mapper; + +import cn.chjyj.szwh.bean.Festivals; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public interface FestivalsMapper { + /** + * 查询年度内的所有节假日 + * @param iyear + * @return + */ + List getYearFestivals(int iyear); + + /** + * 增加法定节假日 + * @param festivals + * @return + */ + int addFestival(Festivals festivals); +} diff --git a/src/main/java/cn/chjyj/szwh/service/impl/FestivalsServiceImpl.java b/src/main/java/cn/chjyj/szwh/service/impl/FestivalsServiceImpl.java new file mode 100644 index 0000000..d0231d7 --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/service/impl/FestivalsServiceImpl.java @@ -0,0 +1,25 @@ +package cn.chjyj.szwh.service.impl; + +import cn.chjyj.szwh.bean.Festivals; +import cn.chjyj.szwh.mapper.FestivalsMapper; +import cn.chjyj.szwh.service.FestivalsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class FestivalsServiceImpl implements FestivalsService { + @Autowired + private FestivalsMapper festivalsMapper; + + @Override + public List getYearFestivals(int iyear) { + return festivalsMapper.getYearFestivals(iyear); + } + + @Override + public int addFestival(Festivals festivals) { + return festivalsMapper.addFestival(festivals); + } +} diff --git a/src/main/resources/mapper/szwh/FestivalsMapper.xml b/src/main/resources/mapper/szwh/FestivalsMapper.xml new file mode 100644 index 0000000..b5a0ffc --- /dev/null +++ b/src/main/resources/mapper/szwh/FestivalsMapper.xml @@ -0,0 +1,34 @@ + + + + + + id,`year` as iyear,`date` as idate + + festivals + + + + + + + insert into + + (`year`,`date`) + values ( + #{iyear}, + #{idate} + ) + + + + \ No newline at end of file diff --git a/src/test/java/cn/chjyj/szwh/mapper/FestivalsMapperTest.java b/src/test/java/cn/chjyj/szwh/mapper/FestivalsMapperTest.java new file mode 100644 index 0000000..6086744 --- /dev/null +++ b/src/test/java/cn/chjyj/szwh/mapper/FestivalsMapperTest.java @@ -0,0 +1,30 @@ +package cn.chjyj.szwh.mapper; + +import cn.chjyj.szwh.bean.Festivals; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +@SpringBootTest +@RunWith(SpringRunner.class) +public class FestivalsMapperTest { + @Autowired + private FestivalsMapper festivalsMapper; + + @Test + public void getYearFestivals() { + int iyear=2022; + List flist = festivalsMapper.getYearFestivals(iyear); + System.out.println(flist.size()); + } + + @Test + public void addFestival() { + } +} \ No newline at end of file