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.MusicGroupPaymentEntities;
import com.ym.mec.biz.service.MusicGroupPaymentEntitiesService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.page.QueryInfo;

@RequestMapping("musicGroupPaymentEntities")
@Api(tags = "乐团付费主体服务")
@RestController
public class MusicGroupPaymentEntitiesController extends BaseController {

    @Autowired
    private MusicGroupPaymentEntitiesService musicGroupPaymentEntitiesService;

    @ApiOperation(value = "新增乐团付费主体")
    @PostMapping("/add")
    public Object add(MusicGroupPaymentEntities musicGroupPaymentEntities){
        musicGroupPaymentEntitiesService.insert(musicGroupPaymentEntities);
        return succeed();
    }

    @ApiOperation(value = "批量新增乐团付费主体")
    @PostMapping("/batchAdd")
    public Object batchAdd(@RequestBody List<MusicGroupPaymentEntities> musicGroupPaymentEntities){
        musicGroupPaymentEntitiesService.batchInsert(musicGroupPaymentEntities);
        return succeed();
    }

    @ApiOperation(value = "删除乐团付费主体")
    @PostMapping("/del/{id}")
    public Object del(@ApiParam(value = "乐团付费主体编号", required = true) @PathVariable("id") Integer id){
        musicGroupPaymentEntitiesService.delete(id);
        return succeed();
    }

    @ApiOperation(value = "修改乐团付费主体")
    @PostMapping("/update")
    public Object update(MusicGroupPaymentEntities musicGroupPaymentEntities){
        musicGroupPaymentEntities.setUpdateTime(new Date());
        musicGroupPaymentEntitiesService.update(musicGroupPaymentEntities);
        return succeed();
    }

    @ApiOperation(value = "分页查询乐团付费主体")
    @GetMapping("/queryPage")
    public Object queryPage(QueryInfo queryInfo){
        return succeed(musicGroupPaymentEntitiesService.queryPage(queryInfo));
    }
}
