Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 병합정렬
- java
- 매일프로그래밍
- 생년
- 자바스크립트
- 초(second)
- Flyweight Pattern
- 디자인패턴
- degien pattern
- 자바
- 분(minute)
- ThreeWayPartition
- JavaScript
- map
- list
- boot
- SpringBoot
- 곱 최대값
- 시(hour)
- 스트레티지패턴
- SSL설정
- 조인
- jQuery
- 시간더하기
- oracle
- json
- 파사드패턴
- spring
- 알고리즘
- 널체크
Archives
- Today
- Total
만들어가는 세상
[JAVA] full calendar 서버 및 UI 로직 입니다. 본문
[JAVA] full calendar 서버 및 UI 로직 입니다..
build.gradle 에서 dependencies 합니다.
stap1
build.gradle
compile group: 'org.json', name: 'json', version: '20180813'
stap2
query.xml
<sql id="selectEvent">
SELECT
E.EVENT_SEQ
, E.SUBJECT
, TO_CHAR(TO_DATE(E.START_DT, 'YYYYMMDD'), 'YYYY-MM-DD') S_DT
, TO_CHAR(TO_DATE(E.END_DT, 'YYYYMMDD'), 'YYYY-MM-DD') E_DT
FROM EVENT_INFO E
WHERE E.DEL_YN = 'N'
</sql>
<select id="getEventList" parameterType="com.stoneitgt.sekm.user.domain.EventParameter"
resultType="com.test.domain.LowerKeyMap">
<include refid="selectEvent"></include>
ORDER BY EVENT_SEQ
</select>
stap3
LowerKeyMap.java
public class LowerKeyMap extends HashMap<Object, Object> {
private static final long serialVersionUID = 2244013042329551131L;
public Object put(Object key, Object value) {
return super.put(String.valueOf(key).toLowerCase(), value);
}
}
stap4
Mapper.java
@Mapper
public interface Mapper {
List<Map<String, Object>> getEventList(EventParameter params);
}
stap5
@Service
public class EventService extends BaseService {
@Autowired
private EventMapper eventMapper;
public List<Map<String, Object>> getEventList(EventParameter params) {
return eventMapper.getEventList(params);
}
}
stap6
@Controller
@RequestMapping("/event")
public class EventController extends BaseController {
@Autowired
private EventService eventService;
@GetMapping("/schedule")
public String schedule(Model model, EventParameter eventParameter) {
List<Map<String, Object>> list = eventService.getEventList(eventParameter);
JSONObject obj = new JSONObject();
JSONArray jArray = new JSONArray();
if(list.size() > 0) {
for (int i = 0; i < list.size(); i++){
JSONObject sObject = new JSONObject();
sObject.put("title", list.get(i).get("subject"));
sObject.put("start", list.get(i).get("s_dt"));
sObject.put("end", list.get(i).get("e_dt"));
sObject.put("groupId", list.get(i).get("event_seq"));
sObject.put("url", "/test/schedule?field="+list.get(i).get("event_seq"));
jArray.put(sObject);
}
obj.put("item", jArray);
}
model.addAttribute("list", obj);
return "test/schedule";
}
}
stap7
schedule.html
<div id="calendar"></div>
<th:block layout:fragment="custom_css">
<link type="text/css" rel="stylesheet" th:href="@{/css/calendar/core/main.css}">
<link type="text/css" rel="stylesheet" th:href="@{/css/calendar/daygrid/main.css}">
<link type="text/css" rel="stylesheet" th:href="@{/css/calendar/list/main.css}">
<link type="text/css" rel="stylesheet" th:href="@{/css/calendar/timegrid/main.css}">
</th:block>
<th:block layout:fragment="custom_js">
<script type="text/javascript" th:src="@{/js/calendar/core/main.js}"></script>
<script type="text/javascript" th:src="@{/js/calendar/daygrid/main.js}"></script>
<script type="text/javascript" th:src="@{/js/calendar/interaction/main.js}"></script>
<script type="text/javascript" th:src="@{/js/calendar/list/main.js}"></script>
<script type="text/javascript" th:src="@{/js/calendar/timegrid/main.js}"></script>
<script type="text/javascript" >
var jsonList = '[[${list}]]'
var initday = '[[${info.s_dt}]]'
</script>
<script type="text/javascript" th:src="@{/js/event/schedule.js}"></script>
</th:block>
stap8
schedule.js
(function () {
var jsonData = jsonList.replace(/"/g,'"');
var jsonConvertList = JSON.parse(jsonData);
var defaultDate = String.prototype.yyyy_mm_dd();
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [ 'bootstrap', 'interaction', 'dayGrid', 'timeGrid', 'list' ],
header: {
left: 'prev,next today',
//right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
right: 'title'
},
defaultDate: defaultDate,
weekNumbers: true,
weekNumbersWithinDays: true,
weekNumberCalculation: 0,
locale: 'ko',
allDayDefault: false,
editable: true,
weekNumbers: false,
eventLimit: true, // allow "more" link when too many events
events: eval(JSON.stringify(jsonConvertList.item))
});
calendar.render();
});
})();
stap9
common.js
String.prototype.yyyy_mm_dd = function() {
var date = new Date();
var d = date.getDate();
var m = (date.getMonth()+1>9)?(date.getMonth()+1):'0'+(date.getMonth()+1);
var y = date.getFullYear();
var defaultDate = y+'-'+m+'-'+d;
return defaultDate;
};
stap10
daygrid/main.css
.fc-sun { color:#c83636; }
.fc-sat { color:#2a81b8; }
stap11
daygrid/main.js
html += core.buildGotoAnchorHtml(view, date, { 'class': 'fc-day-number' },
dateEnv.format(date, DAY_NUM_FORMAT).replace("일","") // inner HTML
'IT > JAVA' 카테고리의 다른 글
[JAVA] 파일에서 확장자만 가져오기 (1) | 2020.03.10 |
---|---|
[JAVA]LIST MAP 객체 JSON 변환 (0) | 2019.11.26 |
[JAVA] 이미지 썸네일(image Thumbnail) 만들기 (0) | 2019.10.24 |
[JAVA] 다형성(polymorphism) 개념 및 이해하기 (0) | 2018.06.25 |
[JAVA] JSON으로 여러 객체에 데이터 처리하기 (0) | 2018.06.25 |
Comments