package com.sv.oms.controller;
import com.sv.entity.MemberEnterVenueLog;
import com.sv.service.oms.MemberEnterVenueLogService;
import com.ydd.framework.core.common.Pagination;
import com.ydd.framework.core.common.dto.ResponseDTO;
import com.ydd.oms.controller.OmsController;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Controller - 篮球进场订单
 *
 * @author yechanglin
 * @since 2018-08-03
 */
@RestController
public class MemberEnterVeneuLogController extends OmsController {

	private final Logger logger = LoggerFactory.getLogger(MemberEnterVeneuLogController.class);
	
	@Resource
	private MemberEnterVenueLogService memberEnterVeneuLogService;

	/**
	 * 分页查询篮球进场订单
	 */
	@RequestMapping(value = "/member/enter/veneu/logs", method = RequestMethod.GET)
	public ResponseDTO findPage(Pagination pagination,
								@RequestParam(value = "payStatus",required = false) Integer payStatus,
								@RequestParam(value = "memberId",required = false) Integer memberId,
								@RequestParam(value = "starTime",required = false) String starTime,
								@RequestParam(value = "endTime",required = false) String endTime,
								@RequestParam(value = "orderSn",required = false) String orderSn,
								@RequestParam(value = "payType",required = false) Integer payType,
								@RequestParam(value = "venueId",required = false)Integer venueId) {
		return ResponseDTO.ok()
				.setPagination(memberEnterVeneuLogService.findPage(pagination, payStatus, memberId, starTime, endTime, orderSn, payType,venueId));
	}

	/**
	 * 查询篮球进场订单信息
	 */
	@RequestMapping(value = "/member/enter/veneu/log/{id}", method = RequestMethod.GET)
	public ResponseDTO findById(@PathVariable("id") Integer id) {
		return ResponseDTO.ok()
				.addAttribute("memberEnterVeneuLog", memberEnterVeneuLogService.findById(id));
	}

	/**
	 * 保存篮球进场订单
	 */
	@RequestMapping(value = "/member/enter/veneu/log", method = RequestMethod.POST)
	public ResponseDTO save(MemberEnterVenueLog memberEnterVenueLog) {
		memberEnterVeneuLogService.save(memberEnterVenueLog);
		return ResponseDTO.ok("保存成功");
	}

	/**
	 * 删除篮球进场订单
	 */
	@RequestMapping(value = "/member/enter/veneu/log/delete", method = RequestMethod.POST)
	public ResponseDTO delete(@RequestParam("id[]") Integer[] ids) {
		memberEnterVeneuLogService.deleteByIds(ids);
		return ResponseDTO.ok("删除成功");
	}

}
