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

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

import javax.annotation.Resource;

/**
 * Controller - 课程tag
 *
 * @author zhaoziyu
 * @since 2018-08-07
 */
@RestController
public class VenueLessonTagConfigController extends OmsController {

	private final Logger logger = LoggerFactory.getLogger(VenueLessonTagConfigController.class);
	
	@Resource
	private VenueLessonTagConfigService venueLessonTagConfigService;

	/**
	 * 分页查询课程tag
	 */
	@RequestMapping(value = "/venue/lesson/tag/configs", method = RequestMethod.GET)
	public ResponseDTO findPage(Pagination pagination) {
		return ResponseDTO.ok()
				.setPagination(venueLessonTagConfigService.findPage(pagination));
	}

	/**
	 * 分页查询课程tag
	 */
	@RequestMapping(value = "/venue/lesson/tag/all", method = RequestMethod.GET)
	public ResponseDTO findPage() {
		return ResponseDTO.ok()
				.addAttribute("tags",venueLessonTagConfigService.findAll());
	}

	/**
	 * 查询课程tag信息
	 */
	@RequestMapping(value = "/venue/lesson/tag/config/{id}", method = RequestMethod.GET)
	public ResponseDTO findById(@PathVariable("id") Integer id) {
		return ResponseDTO.ok()
				.addAttribute("venueLessonTagConfig", venueLessonTagConfigService.findById(id));
	}

	/**
	 * 保存课程tag
	 */
	@RequestMapping(value = "/venue/lesson/tag/config", method = RequestMethod.POST)
	public ResponseDTO save(VenueLessonTagConfig venueLessonTagConfig) {
		venueLessonTagConfigService.save(venueLessonTagConfig);
		return ResponseDTO.ok("保存成功");
	}

	/**
	 * 保存课程tag
	 */
	@RequestMapping(value = "/venue/lesson/tag/config/auto/add", method = RequestMethod.POST)
	public ResponseDTO autoSave(VenueLessonTagConfig venueLessonTagConfig) {
		venueLessonTagConfigService.save(venueLessonTagConfig);
		return ResponseDTO.ok("");
	}

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

}
