package shop.alien.gateway.controller;

import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import shop.alien.entity.result.R;
import shop.alien.entity.store.vo.LifeUserVo;
import shop.alien.gateway.service.LifeUserService;

/**
 * 用户
 */
@Api(tags = {"一期-用户"})
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class LifeUserController {

    private final LifeUserService service;

    @ApiOperation("用户登录")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams({@ApiImplicitParam(name = "phoneNum", value = "手机号", dataType = "String", paramType = "query", required = true)})
    @GetMapping("/userLogin")
    public R<LifeUserVo> userLogin(@RequestParam("phoneNum") String phoneNum) {
        log.info("LifeUserController.userLogin?phoneNum={}", phoneNum);
        LifeUserVo userVo = service.userLogin(phoneNum);
        if (null == userVo) {
            return R.fail("登录失败");
        }
        return R.data(userVo);
    }

}
