package com.fs.app.controller;

import com.fs.common.core.domain.R;
import com.fs.his.domain.FsUserInformationCollection;
import com.fs.his.param.UserInformationDoctorType2Param;
import com.fs.his.service.IFsUserInformationCollectionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user/collection")
public class FsUserInformationCollectionController extends  AppBaseController {
    @Autowired
    private IFsUserInformationCollectionService fsUserInformationCollectionService;
    @GetMapping("/getUserInformation")
    public R getUserInformation(@RequestParam("id") Long id) {

        return R.ok().put("data", fsUserInformationCollectionService.selectFsUserInformationCollectionVoById(id));
    }
    //医生确认
    @PostMapping("/doctorConfirm")
    public R doctorConfirm(@RequestBody FsUserInformationCollection collection){
        return fsUserInformationCollectionService.doctorConfirm(collection);
    }

    @GetMapping("/getCollectionList")
    private R getCollectionList(UserInformationDoctorType2Param userInformationDoctorType2Param) {

        PageHelper.startPage(userInformationDoctorType2Param.getPageNum(), userInformationDoctorType2Param.getPageSize());
        if (userInformationDoctorType2Param.getDoctorType()==2){
            userInformationDoctorType2Param.setDoctorType2Id(Long.parseLong(getDoctorId()));
            List<FsUserInformationCollection> fsUserInformationCollections = fsUserInformationCollectionService.selectFsUserInformationCollectionByDoctorType2(userInformationDoctorType2Param);
            PageInfo<FsUserInformationCollection> listPageInfo=new PageInfo<>(fsUserInformationCollections);
            return R.ok().put("data",listPageInfo);
        }else if (userInformationDoctorType2Param.getDoctorType()==1){
            userInformationDoctorType2Param.setDoctorId(Long.parseLong(getDoctorId()));
            List<FsUserInformationCollection> fsUserInformationCollections = fsUserInformationCollectionService.selectFsUserInformationCollectionByDoctorType1(userInformationDoctorType2Param);
            PageInfo<FsUserInformationCollection> listPageInfo=new PageInfo<>(fsUserInformationCollections);
            return R.ok().put("data",listPageInfo);
        }
        return R.ok().put("data",null);

    }


    //药师确认
    @PostMapping("/doctorType2Confirm")
    public R doctorType2Confirm(@RequestBody FsUserInformationCollection collection){
        return fsUserInformationCollectionService.doctorType2Confirm(collection);
    }
}
