package com.example.controller;

import com.example.bean.DailyReport;
import com.example.bean.RespBean;
import com.example.bean.User;
import com.example.bean.Doctor;
import com.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController
{
    @Autowired
    private UserService userService;

    @PostMapping("/updateUser")
    public RespBean updateUser(@RequestBody User user)
    {
        int result = userService.updateUser(user);
        if(result == 1)
            return new RespBean("success","更新成功");
        else
            return new RespBean("error","更新失败");
    }
    @GetMapping ("/deleteDoctor")
    public RespBean deleteDoctor(String userid)
    {
        int result = userService.deleteDoctor(userid);
        if(result == 1)
            return new RespBean("success","删除成功");
        else
            return new RespBean("error","删除失败");
    }
    @GetMapping("/selectDoctor")
    public RespBean selectDoctor(@RequestParam(name = "userid") String userid,@RequestParam(name = "doctorid") String doctorid)
    {
        int result = userService.selectDoctor(userid,doctorid);
        if(result == 1)
            return new RespBean("success","更改成功");
        else
            return new RespBean("error","更新失败");
    }
}
