Authored by unknown

update

package com.yoho.activity.controller;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yoho.activity.common.ApiResponse;
import com.yoho.activity.service.IUserdayPrizeLogService;
import com.yoho.service.model.activity.userday.response.UserdayPrizeLogResponseBO;
/**
* 会员日,中奖纪录
*/
@Controller
@RequestMapping("/UserdayPrizeLogController")
public class UserdayPrizeLogController {
private static final Logger log = LoggerFactory.getLogger(UserdayPrizeLogController.class);
@Autowired
IUserdayPrizeLogService userdayPrizeLogService;
@Value("${userday.open.day}")
String userdayOpenDay;
/**
* 用户抽奖
* @param uid
* @param prize_type
* @return
* @throws Exception
*/
@RequestMapping("/addPrizeLog")
@ResponseBody
public ApiResponse addPrizeLog(int uid, int prize_type) throws Exception {
log.info("enter addPrizeLog. param uid={}, prize_type={}", uid, prize_type);
int result = userdayPrizeLogService.addPrizeLog(uid, prize_type);
return new ApiResponse(result);
}
@RequestMapping("/isOpenDay")
@ResponseBody
public ApiResponse isOpenDay(){
return new ApiResponse(userdayOpenDay);
}
/**
* 查询是否抽过奖
* @param uid
* @param prize_type
* @return
* @throws Exception
*/
@RequestMapping("/existsPrizeLog")
@ResponseBody
public ApiResponse existsPrizeLog(int uid, int prize_type) throws Exception {
log.info("enter existsPrizeLog. param uid={}, prize_type={}", uid, prize_type);
boolean result = userdayPrizeLogService.existsPrizeLog(uid, prize_type);
return new ApiResponse(result);
}
/**
* 查询中奖纪录
* @param uid
* @param prize_type
* @return
* @throws Exception
*/
@RequestMapping("/queryPrizeLog")
@ResponseBody
public ApiResponse queryPrizeLog(int uid, int prize_type) throws Exception {
log.info("enter queryPrizeLog. param uid={}, prize_type={}", uid, prize_type);
List<UserdayPrizeLogResponseBO> list = userdayPrizeLogService.queryPrizeLog(uid, prize_type);
if (CollectionUtils.isEmpty(list)) {
log.warn("queryPrizeLog error. result is empty");
}
return new ApiResponse(list);
}
/**
* 查询参与抽奖人数
* @param prize_type
* @return
* @throws Exception
*/
@RequestMapping("/queryPrizeLogNum")
@ResponseBody
public ApiResponse queryPrizeLogNum(int prize_type) throws Exception {
log.info("enter queryPrizeLogNum. param prize_type={}", prize_type);
int num = userdayPrizeLogService.queryPrizeLogNum(prize_type);
return new ApiResponse(num);
}
}