package com.sv.api.controller;

import com.sv.entity.VenueLessonTag;
import com.sv.service.api.VenueLessonTagService;
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 - 课程拥有的tag名称
 *
 * @author lihong
 * @since 2018-08-06
 */
@RestController
public class VenueLessonTagController extends BaseApiController {

	private final Logger logger = LoggerFactory.getLogger(VenueLessonTagController.class);
	
	@Resource
	private VenueLessonTagService venueLessonTagService;

	/**
	 * 分页查询课程拥有的tag名称
	 */
	@RequestMapping(value = "/venue/lesson/tags", method = RequestMethod.GET)
	public ResponseDTO findPage(Pagination pagination) {
		return ResponseDTO.ok()
				.setPagination(venueLessonTagService.findPage(pagination));
	}

	/**
	 * 查询课程拥有的tag名称信息
	 */
	@RequestMapping(value = "/venue/lesson/tag/{id}", method = RequestMethod.GET)
	public ResponseDTO findById(@PathVariable("id") Integer id) {
		return ResponseDTO.ok()
				.addAttribute("venueLessonTag", venueLessonTagService.findById(id));
	}

	/**
	 * 保存课程拥有的tag名称
	 */
	@RequestMapping(value = "/venue/lesson/tag", method = RequestMethod.POST)
	public ResponseDTO save(VenueLessonTag venueLessonTag) {
		venueLessonTagService.save(venueLessonTag);
		return ResponseDTO.ok("保存成功");
	}

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

}
