package com.ym.mec.web.controller;

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

import org.springframework.beans.factory.annotation.Autowired;
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.auth.api.client.SysUserFeignService;
import com.ym.mec.biz.dal.entity.ApprovalStatus;
import com.ym.mec.biz.service.MusicGroupQuitService;
import com.ym.mec.biz.service.MusicGroupService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.entity.HttpResponseResult;
import com.ym.mec.common.page.QueryInfo;

@RequestMapping("musicGroupQuit")
@Api(tags = "退团服务")
@RestController
public class MusicGroupQuitController extends BaseController {

	@Autowired
	private MusicGroupService musicGroupService;
	
	@Autowired
	private MusicGroupQuitService musicGroupQuitService;
	
	@Autowired
	private SysUserFeignService sysUserFeignService;

	@ApiOperation(value = "分页查询")
	@GetMapping("/queryPage")
	public HttpResponseResult queryPage(QueryInfo queryInfo) throws Exception {
		return succeed(musicGroupQuitService.queryPage(queryInfo));
	}
	
	@ApiOperation(value = "单查询")
	@GetMapping("/query")
	public HttpResponseResult query(Long id) throws Exception {
		return succeed(musicGroupQuitService.get(id));
	}

	@ApiOperation(value = "退团")
	@PostMapping("/quitMusicGroup")
	@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "退团申请id", required = true, dataType = "Long"),
			@ApiImplicitParam(name = "status", value = "审批状态（APPROVED, DENIED, PROCESSING）", required = true, dataType = "String"),
			@ApiImplicitParam(name = "reason", value = "原因", required = true, dataType = "String") })
	public HttpResponseResult quitMusicGroup(Long id, ApprovalStatus status, String reason) throws Exception {
		return succeed(musicGroupService.approveQuitMusicGroup(id, status, reason));
	}
}
