코드 정렬자동으로 밀리는 로직 추가
This commit is contained in:
parent
305baa8c58
commit
e8e10c48c0
@ -11,4 +11,8 @@ public interface CodeDetailMapper {
|
|||||||
void insert(CodeDetailVO codeDetailVO);
|
void insert(CodeDetailVO codeDetailVO);
|
||||||
void update(CodeDetailVO codeDetailVO);
|
void update(CodeDetailVO codeDetailVO);
|
||||||
void delete(String codeGroupId, String codeId);
|
void delete(String codeGroupId, String codeId);
|
||||||
|
|
||||||
|
int countSortOrder(CodeDetailVO codeDetail);
|
||||||
|
|
||||||
|
void pushBackSortOrder(CodeDetailVO codeDetail);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,11 +71,22 @@ public class CodeDetailServiceImpl implements CodeDetailService {
|
|||||||
log.warn("Failed to retrieve current user ID.");
|
log.warn("Failed to retrieve current user ID.");
|
||||||
throw new IllegalStateException("Current user ID is not available");
|
throw new IllegalStateException("Current user ID is not available");
|
||||||
}
|
}
|
||||||
log.info("Updating by user: [{}]", userId);
|
// log.info("Updating by user: [{}]", userId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 우선순위가 있는지 확인
|
||||||
|
int exists = codeDetailMapper.countSortOrder(codeDetail);
|
||||||
|
if (exists > 0) {
|
||||||
|
// 1. 이미 있으면 밀어주고
|
||||||
|
codeDetailMapper.pushBackSortOrder(codeDetail);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 그냥 insert (있든 없든 여기서 실행)
|
||||||
codeDetail.setLastUpdusrId(userId);
|
codeDetail.setLastUpdusrId(userId);
|
||||||
codeDetailMapper.update(codeDetail);
|
codeDetailMapper.update(codeDetail);
|
||||||
return new RestResponse(HttpStatus.OK, "등록되었습니다", codeDetail.getCodeName());
|
return new RestResponse(HttpStatus.OK, "수정되었습니다", codeDetail.getCodeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
|
log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
|
||||||
|
log4jdbc.dump.sql.select=true
|
||||||
|
log4jdbc.log4j2.properties.resultsettable.level=info
|
||||||
log4jdbc.dump.sql.maxlinelength=0
|
log4jdbc.dump.sql.maxlinelength=0
|
||||||
log4jdbc.dump.sql.addsemicolon=true
|
log4jdbc.dump.sql.addsemicolon=true
|
||||||
@ -35,6 +35,21 @@
|
|||||||
and code_group_id = #{codeGroupId}
|
and code_group_id = #{codeGroupId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="countSortOrder" resultType="int">
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM common_code_detail
|
||||||
|
WHERE code_group_id = #{codeGroupId}
|
||||||
|
AND sort_order = #{sortOrder}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<update id="pushBackSortOrder">
|
||||||
|
UPDATE common_code_detail
|
||||||
|
SET sort_order = sort_order + 1
|
||||||
|
WHERE code_group_id = #{codeGroupId}
|
||||||
|
AND sort_order >= #{sortOrder}
|
||||||
|
</update>
|
||||||
|
|
||||||
<!-- 코드 상세를 삭제하는 쿼리 -->
|
<!-- 코드 상세를 삭제하는 쿼리 -->
|
||||||
<delete id="delete" parameterType="String">
|
<delete id="delete" parameterType="String">
|
||||||
DELETE FROM common_code_detail WHERE code_id = #{codeId} AND code_group_id = #{codeGroupId}
|
DELETE FROM common_code_detail WHERE code_id = #{codeId} AND code_group_id = #{codeGroupId}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user