package com.ym.mec.teacher.controller;

import com.ym.mec.auth.api.client.SysUserFeignService;
import com.ym.mec.auth.api.entity.SysUser;
import com.ym.mec.biz.dal.dto.VipGroupApplyDto;
import com.ym.mec.biz.dal.dto.VipGroupCostCountParamsDto;
import com.ym.mec.biz.service.VipGroupService;
import com.ym.mec.common.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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.Objects;

/**
 * @Author Joburgess
 * @Date 2019/9/21
 */
@Api(tags = "vip课-教师端")
@RequestMapping("teacherVipGroup")
@RestController
public class TeacherVipGroupController extends BaseController {

    @Autowired
    private VipGroupService vipGroupService;

    @Autowired
    private SysUserFeignService sysUserFeignService;

    @ApiOperation("vip课申请")
    @PostMapping("/vipGroupApply")
    public Object vipGroupApply(@RequestBody VipGroupApplyDto vipGroupApplyDto){
        SysUser user = sysUserFeignService.queryUserInfo();
        if(Objects.isNull(user)){
            return failed("请登录");
        }
        vipGroupApplyDto.getVipGroupApplyBaseInfo().setTeacherId(Long.valueOf(user.getId()));
        vipGroupApplyDto.getVipGroupApplyBaseInfo().setOrganIdList(user.getOrganId().toString());
        vipGroupService.createVipGroup(vipGroupApplyDto);
        return succeed();
    }

    @ApiOperation("获取vip课课程和课酬总费用")
    @PostMapping("/getVipGroupCostCount")
    public Object getVipGroupCostCount(VipGroupCostCountParamsDto vipGroupCostCountParamsDto){
//        return succeed(vipGroupService.vipGroupCostCount(vipGroupCostCountParamsDto));
        return succeed();
    }

}
