package com.sv.api.controller;

import com.sv.entity.VenueLessonImage;
import com.sv.service.api.VenueLessonImageService;
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-06
 */
@RestController
public class VenueLessonImageController extends BaseApiController {

	private final Logger logger = LoggerFactory.getLogger(VenueLessonImageController.class);
	
	@Resource
	private VenueLessonImageService venueLessonImageService;

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

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

	/**
	 * 保存场馆课程图片
	 */
	@RequestMapping(value = "/venue/lesson/image", method = RequestMethod.POST)
	public ResponseDTO save(VenueLessonImage venueLessonImage) {
		venueLessonImageService.save(venueLessonImage);
		return ResponseDTO.ok("保存成功");
	}

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

}
