package com.ym.controller;

import com.ym.common.ApiException;
import com.ym.common.BaseResponse;
import com.ym.mec.common.controller.BaseController;
import com.ym.pojo.ReqUserData;
import com.ym.service.UserService;
import io.rong.models.user.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by weiqinxiao on 2019/2/25.
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

//    @RequestMapping(value = "/refresh-token", method = RequestMethod.POST)
//    public Object refreshToken(@RequestBody ReqUserData reqUserData)
//            throws ApiException, Exception {
//        String token = userService.refreshToken(reqUserData.getUserId(), reqUserData.getUserId());
//        BaseResponse<String> response = new BaseResponse<>();
//        response.setData(token);
//        return response;
//    }

    @RequestMapping(value = "/register", method = RequestMethod.POST)
    public Object register(@RequestBody UserModel userModel) throws Exception {
        return userService.register(userModel);
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Object update(@RequestBody UserModel userModel) throws Exception {
        return userService.update(userModel);
    }
}
