package com.yonge.cooleshow.website.controller.open;

import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
import com.yonge.cooleshow.auth.api.entity.SysUser;
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 io.swagger.annotations.ApiParam;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/open/openWebsite")
@Api(value = "官网", tags = "官网")
public class OpenWebSiteController extends BaseController {
    @Autowired
    private SysUserFeignService sysUserFeignService;

    @ApiOperation(value = "判断注册状态 true 已注册 false 未注册")
    @GetMapping("/checkRegister")
    public HttpResponseResult<Boolean> checkRegister(
            @ApiParam(value = "userType", required = true) @RequestParam("userType") String userType,
            @ApiParam(value = "phone", required = true) @RequestParam("phone") String phone) {
        SysUser sysUser = sysUserFeignService.queryUserByMobile(phone);
        if (null == sysUser || !sysUser.getUserType().contains(userType)) {
            return HttpResponseResult.succeed(false);
        }
        return HttpResponseResult.succeed(true);
    }
}