package com.sv.api.controller;

import com.sv.entity.VenuePrice;
import com.sv.service.api.VenuePriceService;
import com.ydd.framework.core.common.Pagination;
import com.ydd.framework.core.common.dto.ResponseDTO;
import com.ydd.framework.core.controller.BaseApiController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Controller - 场馆对应价格表
 *
 * @author lihong
 * @since 2018-08-23
 */
@RestController
public class VenuePriceController extends BaseApiController {

	private final Logger logger = LoggerFactory.getLogger(VenuePriceController.class);
	
	@Resource
	private VenuePriceService venuePriceService;

	/**
	 * 分页查询场馆对应价格表
	 */
	@RequestMapping(value = "/venue/prices", method = RequestMethod.GET)
	public ResponseDTO findPage(Pagination pagination) {
		return ResponseDTO.ok()
				.setPagination(venuePriceService.findPage(pagination));
	}

	/**
	 * 查询场馆对应价格表信息
	 */
	@RequestMapping(value = "/venue/price/{id}", method = RequestMethod.GET)
	public ResponseDTO findById(@PathVariable("id") Integer id) {
		return ResponseDTO.ok()
				.addAttribute("venuePrice", venuePriceService.findById(id));
	}

	/**
	 * 保存场馆对应价格表
	 */
	@RequestMapping(value = "/venue/price", method = RequestMethod.POST)
	public ResponseDTO save(VenuePrice venuePrice) {
		venuePriceService.save(venuePrice);
		return ResponseDTO.ok("保存成功");
	}

	/**
	 * 删除场馆对应价格表
	 */
	@RequestMapping(value = "/venue/price/delete", method = RequestMethod.POST)
	public ResponseDTO delete(@RequestParam("id[]") Integer[] ids) {
		venuePriceService.deleteByIds(ids);
		return ResponseDTO.ok("删除成功");
	}

}
