package com.ym.mec.web.controller.education;

import com.ym.mec.auth.api.client.SysUserFeignService;
import com.ym.mec.auth.api.entity.SysUser;
import com.ym.mec.biz.service.ContractService;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * @Author Joburgess
 * @Date 2020.09.24
 */
@RequestMapping("eduContracts")
@Api(tags = "协议服务")
@RestController
public class EduContractsController extends BaseController {
    @Autowired
    private SysUserFeignService sysUserFeignService;

    @Autowired
    private ContractService contractService;

    @ApiOperation("查询产品协议")
    @GetMapping(value = "queryProduceContract")
    public Object queryProduceContract(Integer userId, String musicGroupId) {
        if(Objects.isNull(userId)){
            SysUser sysUser = sysUserFeignService.queryUserInfo();
            if (sysUser == null) {
                return failed("获取用户信息失败");
            }
            userId = sysUser.getId();
        }
        return succeed(contractService.queryProductContract(userId,musicGroupId));
    }
}
