package com.diagbot.web;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.diagbot.annotation.SysLogger;
import com.diagbot.dto.DeptShortDTO;
import com.diagbot.dto.DeptVitalDTO;
import com.diagbot.dto.RespDTO;
import com.diagbot.facade.DeptVitalFacade;
import com.diagbot.vo.DeptVitalPageVO;
import com.diagbot.vo.DeptVitalVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 科室查体对应表 前端控制器
 * </p>
 *
 * @author zhaops
 * @since 2018-11-22
 */
@RestController
@RequestMapping("/deptVital")
@SuppressWarnings("unchecked")
@Api(value = "查体模板相关API", tags = { "查体模板相关API" })
public class DeptVitalController {

    @Autowired
    private DeptVitalFacade deptVitalFacade;

    @ApiOperation(value = "保存查体模板[by:zhaops]",
            notes = "deptId:科室ID，必填<br>" +
                    "vitalIds:查体标签ids，必填<br>")
    @PostMapping("/saveDeptVitals")
    @SysLogger("saveDeptVitals")
    @Transactional
    public RespDTO<Boolean> saveDeptVitals(@RequestBody DeptVitalVO deptVitalVO) {
        Boolean data = deptVitalFacade.saveDeptVitals(deptVitalVO);
        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "删除模板标签-部分删除[by:zhaops]",
            notes = "deptId:科室ID，必填<br>" +
                    "vitalIds:查体标签ids，必填<br>")
    @PostMapping("/delDeptVitalList")
    @SysLogger("delDeptVitalList")
    @Transactional
    public RespDTO<Boolean> delDeptVitalList(@RequestBody DeptVitalVO deptVitalVO) {
        Boolean data = deptVitalFacade.delDeptVitalList(deptVitalVO);
        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "删除模板标签-全删除[by:zhaops]",
            notes = "deptId:科室ID，必填<br>")
    @PostMapping("/delAllDeptVitalList")
    @SysLogger("delAllDeptVitalList")
    @Transactional
    public RespDTO<Boolean> delAllDeptVitalList(@RequestParam("deptId") Long deptId) {
        Boolean data = deptVitalFacade.delAllDeptVitalList(deptId);
        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "根据科室ID获取查体模板[by:zhaops]",
            notes = "deptId:科室ID，必填<br>")
    @PostMapping("/getModuleByDeptId")
    @SysLogger("getModuleByDeptId")
    public RespDTO<DeptVitalDTO> getModuleByDeptId(@RequestParam("deptId") Long deptId) {
        DeptVitalDTO data = deptVitalFacade.getModuleByDeptId(deptId);
        return RespDTO.onSuc(data);
    }

    /**
     * 分页查询查体模板，可带等于条件
     *
     * @param deptVitalPageVO
     * @return
     */
    @ApiOperation(value = "分页查询查体模板，可带等于条件[by:zhaops]",
            notes = "current:页码，必填<br>" +
                    "size:每页显示条数，必填<br>" +
                    "deptName:科室名称<br>")
    @PostMapping("/getDeptVitalPage")
    @SysLogger("getDeptVitalPage")
    public RespDTO getDeptVitalPage(@RequestBody DeptVitalPageVO deptVitalPageVO) {
        IPage<DeptVitalDTO> infoIPage = deptVitalFacade.getDeptVitalPageByMap(deptVitalPageVO);
        return RespDTO.onSuc(infoIPage);
    }

    @ApiOperation(value = "查询科室下拉列表-新增[by:zhaops]")
    @PostMapping("/getDeptShortList_create")
    @SysLogger("getDeptShortList_create")
    public RespDTO<DeptShortDTO> getDeptShortListCreate() {
        List<DeptShortDTO> data = deptVitalFacade.getDeptShortLisCreate();
        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "查询科室下拉列表-修改[by:zhaops]",
            notes = "deptId:科室ID，必填<br>")
    @PostMapping("/getDeptShortList_modify")
    @SysLogger("getDeptShortList_modify")
    public RespDTO<DeptShortDTO> getDeptShortListModify(@RequestParam("deptId") Long deptId) {
        List<DeptShortDTO> data = deptVitalFacade.getDeptShortLisModify(deptId);
        return RespDTO.onSuc(data);
    }
}
