package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.page.RewardsRulesQueryInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;

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 com.ym.mec.biz.dal.entity.CourseScheduleRewardsRules;
import com.ym.mec.biz.service.CourseScheduleRewardsRulesService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.page.QueryInfo;

@RequestMapping("courseScheduleRewards")
@Api(tags = "课程奖励规则")
@RestController
public class CourseScheduleRewardsRulesController extends BaseController {

	@Autowired
	private CourseScheduleRewardsRulesService courseScheduleRewardsRulesService;

	@ApiOperation(value = "查询规则列表")
	@GetMapping("/queryPage")
	@PreAuthorize("@pcs.hasPermissions('courseScheduleRewards/queryPage')")
	public Object queryPage(RewardsRulesQueryInfo queryInfo) {
		return succeed(courseScheduleRewardsRulesService.queryDetailPage(queryInfo));
	}

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

	@ApiOperation(value = "查询已设置的分部列表")
	@GetMapping("/queryOrganIdList")
	@PreAuthorize("@pcs.hasPermissions('courseScheduleRewards/queryOrganIdList')")
	public Object queryOrganIdList() {
		return succeed(courseScheduleRewardsRulesService.queryOrganIdList());
	}

	@ApiOperation(value = "新增")
	@PostMapping("/add")
	@PreAuthorize("@pcs.hasPermissions('courseScheduleRewards/add')")
	public Object add(CourseScheduleRewardsRules courseScheduleRewardsRules) {
		return succeed(courseScheduleRewardsRulesService.add(courseScheduleRewardsRules));
	}

	@ApiOperation(value = "修改")
	@PostMapping("/update")
	@PreAuthorize("@pcs.hasPermissions('courseScheduleRewards/update')")
	public Object update(CourseScheduleRewardsRules courseScheduleRewardsRules) {
		return succeed(courseScheduleRewardsRulesService.updateDetail(courseScheduleRewardsRules));
	}

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