5 changed files with 148 additions and 0 deletions
@ -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; |
|||
} |
|||
} |
|||
@ -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<Festivals> getYearFestivals(int iyear); |
|||
|
|||
/** |
|||
* 增加法定节假日 |
|||
* @param festivals |
|||
* @return |
|||
*/ |
|||
int addFestival(Festivals festivals); |
|||
} |
|||
@ -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<Festivals> getYearFestivals(int iyear) { |
|||
return festivalsMapper.getYearFestivals(iyear); |
|||
} |
|||
|
|||
@Override |
|||
public int addFestival(Festivals festivals) { |
|||
return festivalsMapper.addFestival(festivals); |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
<?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="cn.chjyj.szwh.mapper.FestivalsMapper"> |
|||
|
|||
<sql id="column"> |
|||
id,`year` as iyear,`date` as idate |
|||
</sql> |
|||
<sql id="tbName">festivals</sql> |
|||
|
|||
<!--查询年度内的所有法定节假日--> |
|||
<select id="getYearFestivals" parameterType="java.lang.Integer" resultType="cn.chjyj.szwh.bean.Festivals"> |
|||
select |
|||
<include refid="column"/> |
|||
from |
|||
<include refid="tbName"/> |
|||
where `year`=#{iyear} |
|||
ORDER BY id DESC; |
|||
</select> |
|||
|
|||
<!--新增用户--> |
|||
<insert id="addFestival" parameterType="cn.chjyj.szwh.bean.Festivals" useGeneratedKeys="true" keyColumn="id" keyProperty="id"> |
|||
insert into |
|||
<include refid="tbName"/> |
|||
(`year`,`date`) |
|||
values ( |
|||
#{iyear}, |
|||
#{idate} |
|||
) |
|||
</insert> |
|||
|
|||
|
|||
</mapper> |
|||
@ -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<Festivals> flist = festivalsMapper.getYearFestivals(iyear); |
|||
System.out.println(flist.size()); |
|||
} |
|||
|
|||
@Test |
|||
public void addFestival() { |
|||
} |
|||
} |
|||
Loading…
Reference in new issue