일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- MySQL
- git
- 리액트
- 자바
- 도커
- 리팩토링
- Winform
- 스프링
- AWS
- Python
- 스프링부트
- docker
- Kotlin
- Spring Boot
- react
- 코틀린
- Spring
- github
- mybatis
- 쿠버네티스
- springboot
- machine-learning
- c#
- 파이썬
- kubernetes
- DataGridView
- VOA
- design pattern
- 마이바티스
- Java
Archives
- Today
- Total
보뇨 다이어리
마이바티스 리팩토링하기 2 본문
반응형
시리즈물이기 때문에 글은 생략
Before
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | <select id="getCommuteRecordSelectList" resultType="com.tistory.vessel.api.vo.CommuteRecordVO"> SELECT r.id , UNIX_TIMESTAMP(r.come) as come , UNIX_TIMESTAMP(r.leave) as `leave` , r.employee_id , r.division_id , r.manager_id , r.come_match , r.leave_match , r.pad , valid , e.wage , come_beacon , leave_beacon FROM commute_record as r inner join employee as e on r.employee_id = e.id left outer join grade as g on e.grade_id = g.id WHERE 1=1 <if test="employee_id != null and employee_id != -1"> AND e.id = #{employee_id} </if> <if test="company_id != -1"> AND d.company_id = #{company_id} </if> <if test="valid != null"> AND r.valid = #{valid} </if> <if test="manager_id != null and manager_id != -1"> AND (e.manager_id = #{manager_id} OR e.id = #{manager_id}) </if> <if test="hourly_wage != null"> AND e.hourly_wage = #{hourly_wage} </if> <if test="division_id != null and division_id != -1"> AND r.division_id = #{division_id} </if> <if test="start != null and start != -1 and end != null and end != -1"> <if test="is_come == null"> <![CDATA[ AND r.come >= from_unixtime(#{start}) AND r.come <= from_unixtime(#{end}) AND (r.leave is null OR r.leave <= from_unixtime(#{end})) ]]> </if> <if test="is_come != null"> <if test="is_come == true"> <![CDATA[ AND r.come >= from_unixtime(#{start}) AND r.come <= from_unixtime(#{end}) AND r.come is not null ]]> </if> <if test="is_come == false"> <![CDATA[ AND r.leave >= from_unixtime(#{start}) AND r.leave <= from_unixtime(#{end}) AND r.leave is not null ]]> </if> </if> </if> <if test="come_match > 0"> <if test="is_upper == false"> <![CDATA[ AND (r.come_match < #{come_match} or r.come_match is null) ]]> </if> <if test="is_upper == null or is_upper != false"> <![CDATA[ AND r.come_match >= #{come_match} ]]> </if> </if> ORDER BY g.priority DESC, e.name, r.come DESC </select> | cs |
after
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <select id="getCommuteRecordSelectList" resultType="com.tistory.vessel.api.vo.CommuteRecordVO"> SELECT r.id , UNIX_TIMESTAMP(r.come) as come , UNIX_TIMESTAMP(r.leave) as `leave` , r.employee_id , r.division_id , r.manager_id , r.come_match , r.leave_match , r.pad , valid , e.wage , come_beacon , leave_beacon FROM commute_record as r inner join employee as e on r.employee_id = e.id left outer join grade as g on e.grade_id = g.id <trim prefix="WHERE" prefixOverrides="AND|OR"> <if test="employee_id != null">AND e.id = #{employee_id}</if> <if test="company_id != null">AND d.company_id = #{company_id}</if> <if test="valid != null">AND r.valid = #{valid}</if> <if test="manager_id != null">AND (e.manager_id = #{manager_id} OR e.id = #{manager_id})</if> <if test="hourly_wage != null">AND e.hourly_wage = #{hourly_wage}</if> <if test="division_id != null">AND r.division_id = #{division_id}</if> <if test="come_gt != null"><![CDATA[AND r.come >= from_unixtime(#{come_gt})]]></if> <if test="come_lt != null"><![CDATA[AND r.come <= from_unixtime(#{come_lt})]]></if> <if test="leave_gt != null"><![CDATA[AND r.leave >= from_unixtime(#{leave_gt})]]></if> <if test="leave_lt != null"><![CDATA[AND r.leave <= from_unixtime(#{leave_lt})]]></if> </trim> ORDER BY r.come DESC <if test="limit != null">limit #{limit}</if> </select> | cs |
반응형
'컴퓨터 관련 > DB 정보' 카테고리의 다른 글
mybatis date 조건 비교처리 (0) | 2018.08.14 |
---|---|
쿼리 리팩토링하기 1 (0) | 2018.08.14 |
마이바티스 리팩토링하기 1 (0) | 2018.07.31 |
mybatis 사용시 디비에 데이터를 가져오지 못하는 에러 (0) | 2018.07.31 |
FROM_UNIXTIME, TIME 사용 (0) | 2018.07.17 |