package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.entity.TeacherFreeTime;
import com.ym.mec.biz.service.TeacherFreeTimeService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.page.QueryInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("teacherFreeTime")
@Api(tags = "老师空余时间设置服务")
@RestController
public class TeacherFreeTimeController extends BaseController {

	@Autowired
	private TeacherFreeTimeService teacherFreeTimeService;

	@ApiOperation("分页查询")
	@GetMapping(value = "/list")
	public Object getList(QueryInfo queryInfo) {
		return succeed(teacherFreeTimeService.queryPage(queryInfo));
	}

	@ApiOperation("单查询")
	@ApiImplicitParam(name = "id", value = "ID编号", required = true, dataType = "Integer", paramType = "path")
	@GetMapping(value = "/query")
	@PreAuthorize("@pcs.hasPermissions('teacherFreeTime/query')")
	public Object query(Integer id) {
		return succeed(teacherFreeTimeService.findTeacherFreeTime(id));
	}

	@ApiOperation("新增")
	@PostMapping(value = "/updateSet")
	@PreAuthorize("@pcs.hasPermissions('teacherFreeTime/updateSet')")
	public Object add(TeacherFreeTime teacherFreeTime) {
		teacherFreeTimeService.updateSet(teacherFreeTime);
		return succeed();
	}
}
