package com.ruoyi.web.work.api;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.web.work.domain.Visit;
import com.ruoyi.web.work.service.IVisitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/app/sysDept")
@Api(tags = "小程序区分科主任和医生")
public class Api_SysDeptController {

    @Autowired
    private ISysDeptService deptService;

    @Autowired
    private IVisitService visitService;


    /**
     * 根据用户账号获取医生的部门信息
     * @param userName 用户账号
     * @return
     */
    @ApiOperation(value = "根据用户账号获取科主任的部门信息")
    @GetMapping("/getDeptByUserName")
    public AjaxResult getDeptList(String userName){
        List<SysDept> deptList = deptService.getDeptListByUserName(userName);
        return AjaxResult.success(deptList);
    }

    /**
     * 根据deptId获取所有部门的患者
     * @param deptId
     * @param userName 用户账号
     * @return
     */
    @ApiOperation(value = "根据deptId获取所有部门的患者")
    @GetMapping("/getPatientByDeptId")
    public AjaxResult getPatientByDeptId(Long deptId,String userName){
        List<Visit> visits = visitService.getPatientByDeptId(deptId,userName);
        return AjaxResult.success(visits);
    }
}
