package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.entity.VipGroupDefaultClassesCycle;
import com.ym.mec.biz.service.VipGroupDefaultClassesCycleService;
import com.ym.mec.common.controller.BaseController;

import io.swagger.annotations.Api;
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;

import java.util.Date;

@Api(tags = "vip课默认排课周期")
@RequestMapping("vipGroupDefaultClassesCycle")
@RestController
public class VipGroupDefaultClassesCycleController extends BaseController {

	@Autowired
	private VipGroupDefaultClassesCycleService vipGroupDefaultClassesCycleService;

	@ApiOperation("单查询")
	@GetMapping(value = "/query")
    @PreAuthorize("@pcs.hasPermissions('vipGroupDefaultClassesCycle/query')")
	public Object query(int id) {
		return succeed(vipGroupDefaultClassesCycleService.get(id));
	}

	@ApiOperation("全查询")
	@GetMapping(value = "/queryAll")
    @PreAuthorize("@pcs.hasPermissions('vipGroupDefaultClassesCycle/queryAll')")
	public Object queryAll() {
		return succeed(vipGroupDefaultClassesCycleService.findAllCycle());
	}

	@ApiOperation("新增")
	@PostMapping(value = "/add")
    @PreAuthorize("@pcs.hasPermissions('vipGroupDefaultClassesCycle/add')")
	public Object add(VipGroupDefaultClassesCycle vipGroupDefaultClassesCycle) {
		vipGroupDefaultClassesCycleService.insert(vipGroupDefaultClassesCycle);
		return succeed();
	}

	@ApiOperation("修改")
	@PostMapping(value = "/update")
    @PreAuthorize("@pcs.hasPermissions('vipGroupDefaultClassesCycle/update')")
	public Object update(VipGroupDefaultClassesCycle vipGroupDefaultClassesCycle) {
		Date date = new Date();
		vipGroupDefaultClassesCycle.setUpdateTime(date);
		vipGroupDefaultClassesCycleService.update(vipGroupDefaultClassesCycle);
		return succeed();
	}

	@ApiOperation("删除")
	@PostMapping(value = "/delete")
    @PreAuthorize("@pcs.hasPermissions('vipGroupDefaultClassesCycle/delete')")
	public Object delete(int id) {
		vipGroupDefaultClassesCycleService.delete(id);
		return succeed();
	}

}
