/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ifish.controller;

import com.ifish.bean.Tbl_User;
import com.ifish.helper.UserHelperI;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;

/**
 *
 * @author Administrator
 */
@RestController
public class Login {

    @Autowired
    private UserHelperI userHelperI;

    /**
     * 用户登陆
     *
     * @param user
     * @return
     */
    @RequestMapping(value = "/userLogin.do", method = RequestMethod.POST)
    public Object userLogin(Tbl_User user) {
        return userHelperI.login(user);
    }

    /**
     * 手机注册
     *
     * @param user
     * @return
     */
    @RequestMapping(value = "/registerByMobile", method = RequestMethod.POST)
    public Object registerByMobile(Tbl_User user) {
        return userHelperI.registerUserMobile(user);
    }

    /**
     * 注册账号发送邮件验证
     *
     * @param user 注册的账号邮箱和账号密码
     * @return
     */
    @RequestMapping(value = "/registerByEmail", method = RequestMethod.POST)
    public Object registerByEmail(Tbl_User user) {
        return userHelperI.registerByEmail(user);
    }

    /**
     * 添加邮箱用户
     *
     * @param md5
     * @return
     */
    @RequestMapping(value = "/registerEmail", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public Object registerEmailUser(String md5) {
        return userHelperI.registerEmail(md5);
    }

    /**
     * 游客注册
     *
     * @return
     */
    @RequestMapping(value = "/touristLogin.do", method = RequestMethod.POST)
    public Object touristLogin(String loginType) {
        return userHelperI.touristRegister(loginType);
    }

    /**
     * 修改用户信息发送邮件验证
     *
     * @param user
     * @return
     */
    @RequestMapping(value = "/forgetPasswordByEmail", method = RequestMethod.POST)
    public Object updateUserEmail(String userEmail, String userPassword) {
        return userHelperI.forgetPasswordByEmail(userEmail, userPassword);
    }

    /**
     * 邮箱修改密码激活地址
     *
     * @param md5
     * @return
     */
    @RequestMapping(value = "/updatePasswordEmail", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public Object updatePasswordEmail(String md5) {
        return userHelperI.updatePasswordEmail(md5);
    }

    /**
     * 修改用户属性
     *
     * @param user
     * @return
     */
    @RequestMapping(value = "/updateInfo.do", method = RequestMethod.POST)
    public Object updateUser(Tbl_User user) {
        return userHelperI.updateUser(user);
    }

    /**
     * 修改用户头像
     *
     * @param userId
     * @param file
     * @return
     */
    @RequestMapping(value = "/updateUserImg", method = RequestMethod.POST)
    public Object updateUserImg(Integer userId, MultipartFile file, String path) {
        return userHelperI.updateUserImg(file, userId, path);
    }

    /**
     * 修改用户手机和密码
     *
     * @param userId
     * @param password
     * @param phoneNumber
     * @return
     */
    @RequestMapping(value = "/updateUserPassword", method = RequestMethod.POST)
    public Object updateUserPassword(Integer userId, String password, String phoneNumber, String token) {
        return userHelperI.updateUserPassword(userId, password, phoneNumber, token);
    }

    /**
     * 忘记密码，根据手机号修改密码
     *
     * @param phoneNumber
     * @param password
     * @return
     */
    @RequestMapping(value = "/forgetPassword", method = RequestMethod.POST)
    public Object forgetPasswordByMobile(String phoneNumber, String password) {
        return userHelperI.forgetPassword(phoneNumber, password);
    }

    @RequestMapping(value = "/IsRegisterJPush", method = RequestMethod.POST)
    public Object IsRegisterJPush(String userId) {
        return userHelperI.IsRegisterJPush(userId);
    }
}
