1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- package com.lemon.lifecenter.scheduler.common;
- import java.io.IOException;
- import java.util.HashMap;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.scheduling.annotation.Scheduled;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import com.lemon.lifecenter.scheduler.controller.PushController;
- import com.lemon.lifecenter.scheduler.test.TestService;
- @RestController
- public class HomeController {
-
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- @Autowired
- private PushUtils pushUtils;
-
- @Autowired
- private TestService service;
-
- @Autowired
- private PushController pushController;
-
- @RequestMapping(value = "/test", method = RequestMethod.GET)
- public String index() {
- // String title = "푸시 발송 테스트 제목";
- // String content = "푸시 발송 테스트 내용!@#$!@#$!@#";
- // String redirectUrl = "nonface";
- // String token = "dLi2buimCUq-tjyLRfN6Fn:APA91bGi2LDEgN689j1hAxb8p7NXdC0n7aLgPLfJmBAxSlMpVvCdv5_yWx7w-72er5le6d_Ky97B4c2chPFiZpbHQN6Dr6QqLdJve9hlwbqNLOoFPSHj4MT7varK27d4AmfhY2BoZMKC";
- //
- // HashMap<String, String> response = new HashMap<>();
- //
- // response = pushUtils.sendFcm(token,
- // title, content, redirectUrl);
- //
- // logger.error("response -- > " + response);
- //
- // return response;
- return "helloWorld";
- }
-
- @RequestMapping(value = "/sendTest", method = RequestMethod.POST)
- public String sendTest(
- @RequestParam(value="redirectUrl", required=false, defaultValue="") String redirectUrl,
- @RequestParam(value="token", required=false, defaultValue="") String token,
- @RequestParam(value="title", required=false, defaultValue="") String title,
- @RequestParam(value="content", required=false, defaultValue="") String content) {
-
- HashMap<String, String> response = new HashMap<>();
-
- response = pushUtils.sendFcm(token,
- title, content, redirectUrl);
-
- logger.error("response -- > " + response);
- return "result : " + response;
- // return "helloWorld";
- }
-
- /**
- * 하루에 한번 결과 테이블이 있는지 확인 후 없으면 생성한다
- * *(초) *(분) *(시) *(일) *(월) *(요일)
- */
- @Scheduled(cron = "* * 02 * * *", zone = "Asia/Seoul")
- public void createTable() {
- pushController.createResultTable();
- }
-
- /**
- * 매분 마다
- */
- @Scheduled(cron = "*/5 * * * * *", zone = "Asia/Seoul")
- public void sendTask() {
- pushController.selectSendPushList();
- pushController.everyDayPushSend();
- }
-
- }
|