/*
 * 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.enums.ResultEnum;
import com.ifish.helper.UserHelperI;
import com.ifish.util.IfishUtil;
import org.apache.commons.lang3.StringUtils;
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.GET)
    public Object registerByMobile(Tbl_User user) {
        return userHelperI.registerUserMobile(user);
    }

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

    /**
     * 发送邮件验证
     *
     * @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)
    public Object registerEmailUser(String md5) {
        return userHelperI.registerEmail(md5);
    }

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

    /**
     * 修改用户属性
     *
     * @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);
    }

}
