package com.ym.mec.web.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.Date;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ym.mec.biz.dal.entity.TeacherDefaultVipGroupSalary;
import com.ym.mec.biz.service.TeacherDefaultVipGroupSalaryService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.page.QueryInfo;

/**
 * @Author Joburgess
 * @Date 2019/10/9
 */
@Api(tags = "老师默认VIP课薪酬")
@RequestMapping("teacherDefaultVipGroupSalary")
@RestController
public class TeacherDefaultVipGroupSalaryController extends BaseController {

    @Autowired
    private TeacherDefaultVipGroupSalaryService teacherDefaultVipGroupSalaryService;

    @ApiOperation(value = "根据老师编号及课程类型编号获取默认课酬")
    @GetMapping("/findByTeacherAndCategory")
    @PreAuthorize("@pcs.hasPermissions('teacherDefaultVipGroupSalary/findByTeacherAndCategory')")
    public Object findByTeacherAndCategory(Integer userId, Integer categoryId){
        return succeed(teacherDefaultVipGroupSalaryService.findByTeacherAndCategory(userId,categoryId));
    }

    @ApiOperation(value = "获取教师的vip课酬列表")
    @GetMapping("/queryPageByTeacherId")
    @PreAuthorize("@pcs.hasPermissions('teacherDefaultVipGroupSalary/queryPageByTeacherId')")
    public Object queryPageByTeacherId(QueryInfo queryInfo){
        return succeed(teacherDefaultVipGroupSalaryService.queryPage(queryInfo));
    }

    @ApiOperation(value = "批量新增、修改教师vip课酬")
    @PostMapping("/upSet")
    @PreAuthorize("@pcs.hasPermissions('teacherDefaultVipGroupSalary/upSet')")
    public Object setVipGroupSalary(@RequestBody TeacherDefaultVipGroupSalaryTemp teacherDefaultVipGroupSalaryTemp){
        teacherDefaultVipGroupSalaryService.upSet(teacherDefaultVipGroupSalaryTemp.teacherDefaultVipGroupSalaries, teacherDefaultVipGroupSalaryTemp.startDate);
        return succeed();
    }

    static class TeacherDefaultVipGroupSalaryTemp{
    	
    	private List<TeacherDefaultVipGroupSalary> teacherDefaultVipGroupSalaries;
    	
    	private Date startDate;

		public List<TeacherDefaultVipGroupSalary> getTeacherDefaultVipGroupSalaries() {
			return teacherDefaultVipGroupSalaries;
		}

		public void setTeacherDefaultVipGroupSalaries(List<TeacherDefaultVipGroupSalary> teacherDefaultVipGroupSalaries) {
			this.teacherDefaultVipGroupSalaries = teacherDefaultVipGroupSalaries;
		}

		public Date getStartDate() {
			return startDate;
		}

		public void setStartDate(Date startDate) {
			this.startDate = startDate;
		}
    }
}
