package com.sv.oms.controller;

import com.sv.entity.VenueImage;
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 zuojie.Liang
 * @since 2018-08-02
 */
@RestController
public class VenueImageController extends OmsController {

	private final Logger logger = LoggerFactory.getLogger(VenueImageController.class);
	
	@Resource
	private com.sv.service.oms.VenueImageService venueImageService;

	/**
	 * 分页查询场馆图片
	 */
	@RequestMapping(value = "/venue/images", method = RequestMethod.GET)
	public ResponseDTO findPage(Pagination pagination) {
		return ResponseDTO.ok()
				.setPagination(venueImageService.findPage(pagination));
	}

	/**
	 * 查询场馆图片信息
	 */
	@RequestMapping(value = "/venue/image/{id}", method = RequestMethod.GET)
	public ResponseDTO findById(@PathVariable("id") Integer id) {
		return ResponseDTO.ok()
				.addAttribute("venueImage", venueImageService.findById(id));
	}

	/**
	 * 保存场馆图片
	 */
	@RequestMapping(value = "/venue/image", method = RequestMethod.POST)
	public ResponseDTO save(VenueImage venueImage) {
		venueImageService.save(venueImage);
		return ResponseDTO.ok("保存成功");
	}

	/**
	 * 删除场馆图片
	 */
	@RequestMapping(value = "/venue/image/delete", method = RequestMethod.POST)
	public ResponseDTO delete(@RequestParam("id[]") Integer[] ids) {
		venueImageService.deleteByIds(ids);
		return ResponseDTO.ok("删除成功");
	}

}
