[CORE] daily.record core package 로 이동.
This commit is contained in:
126
core/src/main/resources/mappers/daily/DailyRecordMapper.xml
Normal file
126
core/src/main/resources/mappers/daily/DailyRecordMapper.xml
Normal file
@@ -0,0 +1,126 @@
|
||||
<?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="app.module.core.usecase.daily.record.adapters.persistence.DailyRecordMapper">
|
||||
|
||||
<select id="getDailyRecord"
|
||||
resultType="app.module.core.usecase.daily.record.adapters.persistence.model.DailyRecordDto">
|
||||
select ddg.group_no, ddg.start_day, ddg.end_day
|
||||
, dr.id, dr.record_month, dr.day_group_no, dr.start_date, dr.end_date
|
||||
, dr.all_status, dr.income_status, dr.work_status, dr.expense_status, dr.power_status, dr.forestry_status, dr.farming_status
|
||||
from daily_day_group ddg
|
||||
left join
|
||||
daily_record dr on dr.day_group_no = ddg.group_no and dr.is_deleted = false
|
||||
and dr.record_month = #{searchMonth}
|
||||
and dr.household_seq = #{householdSeq}
|
||||
where ddg.is_deleted = false
|
||||
and ddg.group_no = #{groupNo}
|
||||
</select>
|
||||
|
||||
<select id="getDailyRecordStatus"
|
||||
resultType="app.module.core.usecase.daily.record.adapters.persistence.model.DailyRecordStatusDto">
|
||||
select dr.id as daily_id
|
||||
, dr.day_group_no, dr.start_date, dr.end_date
|
||||
, dr.all_status
|
||||
, dr.income_status
|
||||
, dr.work_status
|
||||
, dr.expense_status
|
||||
, dr.power_status
|
||||
, dr.forestry_status
|
||||
, dr.farming_status
|
||||
, (select count(*) from daily_income di where di.daily_record_seq = dr.id and di.is_deleted = false) as income_count
|
||||
, (select count(*) from daily_work dw where dw.daily_record_seq = dr.id and dw.is_deleted = false) as work_count
|
||||
, (select count(*) from daily_expense de where de.daily_record_seq = dr.id and de.is_deleted = false) as expense_count
|
||||
, (select count(*) from daily_power dp where dp.daily_record_seq = dr.id and dp.is_deleted = false) as power_count
|
||||
, (select count(*) from daily_forestry df1 where df1.daily_record_seq = dr.id and df1.is_deleted = false) as forestry_count
|
||||
, (select count(*) from daily_farming df2 where df2.daily_record_seq = dr.id and df2.is_deleted = false) as farming_count
|
||||
from daily_record dr
|
||||
where dr.is_deleted = false
|
||||
and dr.household_seq = #{householdSeq}
|
||||
and dr.record_month = #{searchMonth}
|
||||
<if test="groupNo != null">
|
||||
and dr.day_group_no = #{groupNo}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getDailyRecordExistCount" resultType="int">
|
||||
select count(1) as exist
|
||||
from daily_record dr
|
||||
where dr.is_deleted = false
|
||||
and dr.household_seq = #{householdSeq}
|
||||
and dr.record_month = #{searchMonth}
|
||||
and dr.day_group_no = #{groupNo}
|
||||
</select>
|
||||
|
||||
<insert id="createDailyRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into daily_record (
|
||||
household_seq, record_month, day_group_no, start_date, end_date
|
||||
, all_status, income_status, work_status, expense_status, power_status, forestry_status, farming_status
|
||||
, is_deleted
|
||||
, <include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
) values (
|
||||
#{householdSeq}
|
||||
, #{recordMonth}, #{dayGroupNo}, #{startDate}, #{endDate}
|
||||
, #{allStatus}, #{incomeStatus}, #{workStatus}, #{expenseStatus}, #{powerStatus}, #{forestryStatus}, #{farmingStatus}
|
||||
, false
|
||||
, <include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateDailyRecord">
|
||||
update daily_record set <include refid="common.fields.UpdateBaseSet"/>
|
||||
, all_status = #{allStatus}
|
||||
, income_status = #{incomeStatus}
|
||||
, work_status = #{workStatus}
|
||||
, expense_status = #{expenseStatus}
|
||||
, power_status = #{powerStatus}
|
||||
, forestry_status = #{forestryStatus}
|
||||
, farming_status = #{farmingStatus}
|
||||
where is_deleted = false
|
||||
and record_month = #{recordMonth}
|
||||
and day_group_no = #{dayGroupNo}
|
||||
and household_seq = #{householdSeq}
|
||||
</update>
|
||||
|
||||
<update id="updateDailyRecordStatus">
|
||||
update daily_record set <include refid="common.fields.UpdateBaseSet"/>
|
||||
<if test="allStatus != null and allStatus != ''">
|
||||
, all_status = #{allStatus}
|
||||
</if>
|
||||
<if test="targetType != null and targetType != ''">
|
||||
/* TODO 개별 상태값 변경 */
|
||||
<choose>
|
||||
<when test="targetType eq 'INCOME'">
|
||||
, income_status = #{targetStatus}
|
||||
</when>
|
||||
<when test="targetType eq 'WORK'">
|
||||
, work_status = #{targetStatus}
|
||||
</when>
|
||||
<when test="targetType eq 'EXPENSE'">
|
||||
, expense_status = #{targetStatus}
|
||||
</when>
|
||||
<when test="targetType eq 'POWER'">
|
||||
, power_status = #{targetStatus}
|
||||
</when>
|
||||
<when test="targetType eq 'FORESTRY'">
|
||||
, forestry_status = #{targetStatus}
|
||||
</when>
|
||||
<when test="targetType eq 'FARMING'">
|
||||
, farming_status = #{targetStatus}
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
where is_deleted = false
|
||||
and household_seq = #{householdSeq}
|
||||
and record_month = #{recordMonth}
|
||||
and day_group_no = #{dayGroupNo}
|
||||
</update>
|
||||
|
||||
<sql id="InnerJoinByDailyRecord">
|
||||
inner join daily_record dr on
|
||||
dr.id = ds.daily_record_seq
|
||||
and dr.is_deleted = false
|
||||
and dr.record_month = #{searchMonth} and dr.day_group_no = #{groupNo}
|
||||
and dr.household_seq = #{householdSeq}
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user