package com.quinn.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quinn.pojo.Blog;
import com.quinn.pojo.Comment;
import com.quinn.pojo.UserInfo;
import com.quinn.service.BlogService;
import com.quinn.service.CommentService;
import com.quinn.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author limqsh
 * @since 2020-06-29
 */
@Controller
public class UserInfoController extends BaseModelController {

    @Autowired
    UserInfoService userInfoService;
    @Autowired
    BlogService blogService;
    @Autowired
    CommentService commentService;

    // 更新用户资料
    @GetMapping("/userinfo/setting")
    public String userSetting(HttpServletRequest request, Model model){
        String uid = getLoginUserId(request);
        UserInfo userInfo = userInfoService.getById(uid);
        model.addAttribute("userInfo",userInfo);
        return "user/settings";
    }
    @PostMapping("/userinfo/update")
    public String userInfo(UserInfo userInfo){
        // 获取用户信息;
        userInfoService.updateById(userInfo);
        return "redirect:/user";
    }

}

