package cn.com.ty.lift.system.user.controller;

import cn.com.ty.lift.system.user.dao.entity.model.ChangeMobileRequest;
import cn.com.ty.lift.system.user.dao.entity.model.UserRequest;
import cn.com.ty.lift.system.user.service.IUserService;
import cn.com.xwy.boot.web.dto.RestResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * @author huangyuan
 * @date 2019-11-29
 * @description 用户管理
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private IUserService userService;

    /**
     * @param userRequest 用户请求类
     * @return
     * @description
     * @date 2019/11/27 10:03 AM
     */
    @RequestMapping("/list")
    public RestResponse list(@RequestBody UserRequest userRequest) {
        return userService.list(userRequest);
    }

    /**
     * @param
     * @return
     * @description app获取用户信息
     * @date 2019-12-28 15:41
     */
    @RequestMapping("/info")
    public RestResponse info(@RequestBody UserRequest userRequest) {
        return userService.getUserInfo(userRequest);
    }

    /**
     * @param userRequest 用户请求参数
     * @return
     * @description 添加用户
     * @date 2019/11/27 10:03 AM
     */
    @PostMapping("/add")
    public RestResponse addUser(@RequestBody UserRequest userRequest) {
        return userService.addUser(userRequest);
    }

    /**
     * @param userRequest 用户请求参数
     * @return
     * @description 更新用户信息
     * @date 2019/11/27 10:03 AM
     */
    @PostMapping("/update")
    public RestResponse updateUser(@RequestBody UserRequest userRequest) {
        return userService.updateUser(userRequest);
    }

    /**
     * @param userRequest 用户请求参数
     * @return
     * @description 删除用户信息
     * @date 2019/11/27 10:03 AM
     */
    @PostMapping("/delete")
    public RestResponse deleteUser(@RequestBody UserRequest userRequest) {
        return userService.deleteUser(userRequest);
    }

    /**
     * @param
     * @return
     * @description 更换手机号
     * @date 2020-01-04 16:30
     */
    @PostMapping("/changeMobile")
    public RestResponse changeMobile(@RequestBody ChangeMobileRequest changeMobileRequest, HttpSession session) {
        return userService.changeMobile(changeMobileRequest, session);
    }

    /**
     * @param userRequest 请求数据
     * @return
     * @description
     * @date 2020/4/16 10:33 上午
     */
    @RequestMapping("/personalCenter")
    public RestResponse personCenter(@RequestBody UserRequest userRequest) {
        return userService.personalCenter(userRequest);
    }

    /**
     * @param userRequest 用户帐号
     * @return 是否成功
     * @description 修改帐号
     * @date 2020/4/16 2:40 下午
     */
    @PostMapping("/modifyAccount")
    public RestResponse modifyAccount(@RequestBody UserRequest userRequest) {
        return userService.modifyAccount(userRequest);
    }

    /**
     * @param userRequest 用户描述
     * @return 是否成功
     * @description 修改用户描述
     * @date 2020/4/16 2:54 下午
     */
    @PostMapping("/modifyRemarks")
    public RestResponse modifyRemarks(@RequestBody UserRequest userRequest) {
        return userService.modifyRemarks(userRequest);
    }

    /**
     * @param userRequest 用户id 用户头像路径
     * @return 修改是否成功
     * @description 修改用户头像
     * @date 2020/4/29 9:02 上午
     */
    @PostMapping("/modifyAvatar")
    public RestResponse modifyAvatar(@RequestBody UserRequest userRequest) {
        return userService.modifyAvatar(userRequest);
    }

    /**
     * @param userRequest 用户id 用户名称
     * @return 修改是否成功过
     * @description 修改用户昵称
     * @date 2020/4/29 9:02 上午
     */
    @PostMapping("/modifyName")
    public RestResponse modifyName(@RequestBody UserRequest userRequest) {
        return userService.modifyName(userRequest);
    }

}
