package com.ym.mec.web.controller;

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

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.MusicGroupPaymentCalender;
import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.page.QueryInfo;

@RequestMapping("musicGroupPaymentCalender")
@Api(tags = "乐团缴费日历服务")
@RestController
public class MusicGroupPaymentCalenderController extends BaseController {

    @Autowired
    private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;

    @ApiOperation(value = "新增乐团缴费日历")
    @PostMapping("/add")
    public Object add(MusicGroupPaymentCalender musicGroupPaymentCalender) {
        musicGroupPaymentCalenderService.insert(musicGroupPaymentCalender);
        return succeed();
    }

    @ApiOperation(value = "批量新增、修改乐团缴费周期")
    @PostMapping("/batchAdd")
    public Object batchAdd(@RequestBody List<MusicGroupPaymentCalender> musicGroupPaymentCalenders) {
        musicGroupPaymentCalenderService.batchInsert(musicGroupPaymentCalenders);
        return succeed();
    }

    @ApiOperation(value = "删除乐团缴费日历")
    @PostMapping("/del/{id}")
    public Object del(@ApiParam(value = "乐团缴费日历编号", required = true) @PathVariable("id") Long id) {
        musicGroupPaymentCalenderService.delete(id);
        return succeed();
    }

    @ApiOperation(value = "修改乐团缴费日历")
    @PostMapping("/update")
    public Object update(MusicGroupPaymentCalender musicGroupPaymentCalender) {
        musicGroupPaymentCalender.setUpdateTime(new Date());
        musicGroupPaymentCalenderService.update(musicGroupPaymentCalender);
        return succeed();
    }

    @ApiOperation(value = "分页查询乐团缴费日历列表")
    @GetMapping("/queryPage")
    public Object queryPage(QueryInfo queryInfo) {
        return succeed(musicGroupPaymentCalenderService.queryPage(queryInfo));
    }

}
