package com.yonge.cooleshow.teacher.controller;

import com.yonge.cooleshow.biz.dal.dto.search.MemberPriceSettingsSearch;
import com.yonge.cooleshow.biz.dal.entity.SysConfig;
import com.yonge.cooleshow.biz.dal.service.MemberPriceSettingsService;
import com.yonge.cooleshow.biz.dal.service.SysConfigService;
import com.yonge.cooleshow.biz.dal.vo.MemberPriceSettingsVo;
import com.yonge.cooleshow.biz.dal.vo.MemberPriceVo;
import com.yonge.cooleshow.common.controller.BaseController;
import com.yonge.cooleshow.common.entity.HttpResponseResult;
import io.swagger.annotations.Api;
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.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 java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("${app-config.url.teacher:}/memberPriceSettings")
@Api(tags = "会员价格设置")
@RestController
public class MemberPriceSettingsController extends BaseController {
	@Autowired
	private MemberPriceSettingsService memberPriceSettingsService;
	@Autowired
	private SysConfigService sysConfigService;

	/**
	 * 查询单条
	 */
	@GetMapping("/detail/{id}")
	@ApiOperation(value = "详情", notes = "传入id")
	public HttpResponseResult<MemberPriceSettingsVo> detail(@PathVariable("id") Long id) {
		return succeed(memberPriceSettingsService.detail(id)); 
	}

	@PostMapping("/list")
	@ApiOperation(value = "查询列表")
	public HttpResponseResult<MemberPriceVo> list(@RequestBody MemberPriceSettingsSearch query) {
		MemberPriceVo memberPriceVo = memberPriceSettingsService.getVipShare(query);
		return succeed(memberPriceVo);
	}

	@PostMapping("/vipPermissions")
	@ApiOperation(value = "查询vip权限")
	public HttpResponseResult<List<SysConfig>> vipPermissions() {
		Map<String,Object> params = new HashMap<>();
		params.put("group", "VIP_PERMISSION");
		List<SysConfig> configs = sysConfigService.findAll(params);
		return succeed(configs);
	}


}
