package Ġan iss ia . services Ċ Ċ import Ġan iss ia . dto . An ime Schedule Dto Ċ import Ġan iss ia . rdb . repository . An ime Repository Ċ import Ġme . sar o . kit . Cache Store Ċ import Ġorg . springframework . stereotype . Service Ċ import Ġjava . time . LocalDateTime Ċ import Ġjava . time . format . DateTime Formatter Ċ Ċ @ Service Ċ class ĠAn ime Schedule Service ( ĊĠĠĠ Ġprivate Ġval Ġan ime Repository : ĠAn ime Repository , ĊĠĠĠ Ġprivate Ġval Ġgoogle Analytics Proxy Service : ĠGoogle Analytics Proxy Service Ċ ) Ġ{ ĊĠĠĠ Ġprivate Ġval Ġschedule Cache Store Ġ= ĠCache Store < String , ĠList < An ime Schedule Dto >> (( 5 Ġ* Ġ 6 0 0 0 0 ). to Long ()) ĊĊĠĠĠ Ġprivate Ġval Ġsvg DateFormat Ġ= ĠDateTime Formatter . of Pattern (" yyyy ëħĦ ĠMM ìĽĶ Ġdd ìĿ¼ ") ĊĊĠĠĠ Ġfun Ġget Schedule ( week : ĠString ): ĠList < An ime Schedule Dto > Ġ= ĊĠĠĠĠĠĠĠ Ġschedule Cache Store ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. find ( week ) Ġ{ Ġget Schedule Not Cache ( week ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. also Ġ{ Ġgoogle Analytics Proxy Service . send ("/ api / anime / schedule /$ week ") Ġ} ĊĊĠĠĠ Ġ// Ġusing Ġfor Ġadmin ĊĠĠĠ Ġfun Ġget Schedule Not Cache ( week : ĠString ): ĠList < An ime Schedule Dto > Ġ= ĊĠĠĠĠĠĠĠ Ġan ime Repository ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. findAll Schedule ( week ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĠAn ime Schedule Dto ( it ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġwhen ( week ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" 7 " Ġ-> Ġsorted By Descending Ġ{ Ġif Ġ( it . time Ġ!= Ġ"") Ġit . time Ġelse Ġ" 9 9 9 9 " Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" 8 " Ġ-> Ġsorted By Ġ{ Ġif Ġ( it . time Ġ!= Ġ"") Ġit . time Ġelse Ġ" 9 9 9 9 " Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġsorted By Ġ{ Ġit . time Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Schedule Svg ( width : ĠString , Ġcolor : ĠString ): ĠString Ġ= ĊĠĠĠĠĠĠĠ ĠLocalDateTime . now (). let Ġ{ Ġdt Ġ-> Ġget Schedule (( dt . day OfWeek . value Ġ% Ġ 7 ). toString ()). run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtitle Bg Ġ= Ġcolor . substring ( 0 , Ġ 6 ); Ġval Ġtitle Ġ= Ġcolor . substring ( 6 , Ġ 1 2 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġy md Bg Ġ= Ġcolor . substring ( 1 2 , Ġ 1 8 ); Ġval Ġy md Ġ= Ġcolor . substring ( 1 8 , Ġ 2 4 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġlist Bg Ġ= Ġcolor . substring ( 2 4 , Ġ 3 0 ); Ġval Ġlist Ġ= Ġcolor . substring ( 3 0 , Ġ 3 6 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġheight Ġ= Ġ( this . size Ġ* Ġ 2 0 Ġ+ Ġ 5 0 ). toString () Ċ """ <? xml Ġversion =" 1 . 0 " Ġencoding =" utf - 8 "?> Ċ <! DOCTYPE Ġsvg ĠPUBLIC Ġ"-// W 3 C // DTD ĠSVG Ġ 1 . 1 // EN " Ġ" http :// www . w 3 . org / Graphics / SVG / 1 . 1 / DTD / svg 1 1 . dtd "> Ċ < svg Ġversion =" 1 . 1 " Ġid =" Layer _ 1 " Ġxmlns =" http :// www . w 3 . org / 2 0 0 0 / svg " Ġx =" 0 px " Ġy =" 0 px " ĊĠĠĠĠ Ġwidth ="${ width } px " Ġheight ="${ height } px " ĠviewBox =" 0 Ġ 0 Ġ$ width Ġ$ height " Ġenable - background =" new Ġ 0 Ġ 0 Ġ$ width Ġ$ height " Ġxml : space =" preserve "> Ċ < rect Ġfill ="# ${ list Bg }" Ġwidth =" 1 0 0 %" Ġheight =" 1 0 0 % "/> Ċ < rect Ġfill ="# ${ title Bg }" Ġwidth =" 1 0 0 %" Ġheight =" 3 0 " Ġ/> Ċ < rect Ġfill ="# ${ y md Bg }" Ġwidth =" 1 0 0 %" Ġheight =" 2 0 " Ġy =" 3 0 " Ġ/> Ċ < text Ġx =" 0 " Ġy =" 0 " Ġfill ="# ${ list }" Ġfont - family ="' Mal gun ĠGo th ic '" Ġfont - size =" 1 3 "> Ċ < t span Ġx =" 5 0 %" Ġdy =" 2 0 " Ġfill ="# ${ title }" Ġtext - anchor =" middle " Ġfont - size =" 1 3 " Ġfont - weight =" bold "> ìķ ł ëĭĪ íİ ¸ ìĦ± íĳľ </ t span > Ċ < t span Ġx =" 5 0 %" Ġdy =" 2 5 " Ġfill ="# ${ y md }" Ġtext - anchor =" middle " Ġfont - size =" 1 2 ">${ dt . format ( svg DateFormat )}</ t span > Ċ ${ join ToString ("\ n ") Ġ{ Ġ""" < t span Ġx =" 2 " Ġdy =" 2 0 ">< ![ CDATA [ ${ it . time } Ġ${ it . subject } ]] ></ t span > """ Ġ}} Ċ </ text > Ċ </ svg > """ Ġ}} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. also Ġ{ Ġgoogle Analytics Proxy Service . send ("/ api / anime / schedule / svg ") Ġ} Ċ } Ċ