|
|
package com.yoho.activity.queue.restapi;
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import com.yoho.activity.queue.ApiResponse;
|
|
|
import com.yoho.activity.queue.service.ITimeTaskService;
|
|
|
import com.yoho.queue.dal.IDrawlineActivityDAO;
|
|
|
import com.yoho.queue.dal.model.DrawlineActivity;
|
|
|
|
|
|
@Controller
|
|
|
@RequestMapping("/LuckyDrawHandlerRest")
|
|
|
public class LuckyDrawHandlerRest {
|
|
|
private static Logger logger = LoggerFactory.getLogger(LuckyDrawHandlerRest.class);
|
|
|
|
|
|
@Autowired
|
|
|
private ITimeTaskService timeTaskService;
|
|
|
@Autowired
|
|
|
private IDrawlineActivityDAO drawlineActivityDAO;
|
|
|
|
|
|
@RequestMapping("/luckyDraw")
|
|
|
@ResponseBody
|
|
|
public ApiResponse luckyDraw(@RequestParam("activityId") int activityId) {
|
|
|
logger.info("Enter luckyDraw. param activityId is {}", activityId);
|
|
|
|
|
|
DrawlineActivity drawlineActivity = drawlineActivityDAO.selectByPrimaryKey(activityId);
|
|
|
if (null == drawlineActivity) {
|
|
|
logger.warn("luckyDraw: drawlineActivity is not exists.");
|
|
|
return new ApiResponse(200, "luckyDraw: drawlineActivity is not exists.", new Object());
|
|
|
}
|
|
|
if (null == drawlineActivity.getEndTime()) {
|
|
|
logger.warn("luckyDraw: drawlineActivity endTime is not setting.");
|
|
|
return new ApiResponse(200, "luckyDraw: drawlineActivity endTime is not setting.", new Object());
|
|
|
}
|
|
|
|
|
|
long endTime = drawlineActivity.getEndTime().longValue() * 1000;
|
|
|
long currTime = System.currentTimeMillis();
|
|
|
if (endTime > currTime) {
|
|
|
logger.warn("luckyDraw: drawlineActivity is not end.");
|
|
|
return new ApiResponse(200, "luckyDraw: drawlineActivity is not end.", new Object());
|
|
|
}
|
|
|
|
|
|
ApiResponse apiResponse = new ApiResponse();
|
|
|
apiResponse.setData(timeTaskService.luckyDraw(activityId, endTime));
|
|
|
return apiResponse;
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/shutdownLuckyDraw")
|
|
|
@ResponseBody
|
|
|
public ApiResponse shutdownLuckyDraw() {
|
|
|
logger.info("Enter shutdownLuckyDraw.");
|
|
|
|
|
|
timeTaskService.shutdownLuckyDraw();
|
|
|
|
|
|
return new ApiResponse();
|
|
|
}
|
|
|
} |
...
|
...
|
|