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 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.dto.SubFeeSettingDto;
import com.ym.mec.biz.dal.entity.MusicGroup;
import com.ym.mec.biz.dal.page.MusicGroupQueryInfo;
import com.ym.mec.biz.service.MusicGroupService;
import com.ym.mec.common.controller.BaseController;

@RequestMapping("musicGroup")
@Api(tags = "乐团服务")
@RestController
public class MusicGroupController extends BaseController {

    @Autowired
    private MusicGroupService musicGroupService;

    @ApiOperation(value = "删除乐团")
    @PostMapping("/del/{id}")
    public Object del(@ApiParam(value = "乐团编号", required = true) @PathVariable("id") String id){
        musicGroupService.delete(id);
        return succeed();
    }

    @ApiOperation(value = "修改乐团")
    @PostMapping("/update")
    public Object update(MusicGroup musicGroup){
        musicGroup.setUpdateTime(new Date());
        musicGroupService.update(musicGroup);
        return succeed();
    }

    @ApiOperation(value = "根据乐团编号查询乐团")
    @GetMapping("/get/{id}")
    public Object get(@ApiParam(value = "乐团编号", required = true) @PathVariable("id") String id){
        return succeed(musicGroupService.get(id));
    }

    @ApiOperation(value = "分页查询乐团列表")
    @GetMapping("/queryPage")
    public Object queryPage(MusicGroupQueryInfo queryInfo){
        return succeed(musicGroupService.queryPage(queryInfo));
    }

    @ApiOperation(value = "新增乐团  建团申请数据提交")
    @PostMapping("/createGroup")
    public Object createGroup(@RequestBody SubFeeSettingDto subFeeSettingDto){
        musicGroupService.createGroup(subFeeSettingDto);
        return succeed();
    }
}
