package com.bjtdba.userCenter.controller;

import com.bjtdba.userCenter.service.UserLogOnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.net.UnknownHostException;
import java.util.Map;


@RestController
@RequestMapping("userCenter_service/userLogOnService")
public class UserLogOnController {

    @Autowired
    private UserLogOnService userLogOnService;

    /**
     * 登录获取手机号验证码方法
     * @param request
     * @return
     */
    @PostMapping("/userPhoneLogOnCode")
    public Object userLogOnPhoneCode(@RequestBody Map<String,String> map, HttpServletRequest request){
        return userLogOnService.userLogOnPhoneCode(map.get("phone"),request);
    }

    /**
     * @param request
     * @return
     * @throws UnknownHostException
     */
    @PostMapping("/userPhoneLogOn")
    public Object userPhoneLogOnService(@RequestBody Map<String,String> map, HttpServletRequest request) throws UnknownHostException {
        System.out.println(map.get("phone"));
        return userLogOnService.userPhoneLogOnService(map.get("phone"),map.get("sms_code"),map.get("third_user_id"),Integer.parseInt(map.get("type")),map.get("spread_uid"),request);

    }

    @GetMapping("/payWx")
    public Object payWx(){
        return userLogOnService.payWx();
    }
}
