//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.luozhihui.project.controller;

import com.luozhihui.project.common.ApiResponse;
import com.luozhihui.project.entity.User;
import com.luozhihui.project.mapper.UserInfoMapper;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/api"})
@CrossOrigin
public class UserInfoController {
    @Resource
    UserInfoMapper userInfoMapper;

    public UserInfoController() {
    }

    @PostMapping({"/upuserinfo"})
    public ApiResponse updateUser(User user) {
        User existingUserinfo = this.userInfoMapper.findById(Integer.valueOf(user.getUserId()));
        if (existingUserinfo != null) {
            existingUserinfo.setPhone(user.getPhone());
            existingUserinfo.setUserName(user.getUserName());
            existingUserinfo.setPassWord(user.getPassWord());
            existingUserinfo.setIdCard(user.getIdCard());
            existingUserinfo.setDriverLicense(user.getDriverLicense());
            this.userInfoMapper.update(existingUserinfo);
            return new ApiResponse((Object)null, 200, "用户信息更新成功");
        } else {
            return new ApiResponse((Object)null, 404, "用户不存在");
        }
    }

    @PostMapping({"/RealUser"})
    public ApiResponse RealUser(User user) {
        User existingUserinfo = this.userInfoMapper.findById(Integer.valueOf(user.getUserId()));
        if (existingUserinfo != null) {
            existingUserinfo.setPhone(user.getPhone());
            existingUserinfo.setUserName(user.getUserName());
            existingUserinfo.setIdCard(user.getIdCard());
            existingUserinfo.setDriverLicense(user.getDriverLicense());
            existingUserinfo.setAvatar(user.getAvatar());
            this.userInfoMapper.update(existingUserinfo);
            return new ApiResponse((Object)null, 200, "用户实名成功");
        } else {
            return new ApiResponse((Object)null, 404, "用户不存在");
        }
    }
}
