package com.diagbot.web;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.diagbot.annotation.SysLogger;
import com.diagbot.dto.GetDeptInfoDTO;
import com.diagbot.dto.RespDTO;
import com.diagbot.entity.DeptInfo;
import com.diagbot.facade.DeptInfoFacade;
import com.diagbot.vo.AddDeptInfoVO;
import com.diagbot.vo.DeleteDeptInfoVO;
import com.diagbot.vo.GetDeptInfoDetialsVO;
import com.diagbot.vo.GetDeptInfoVO;
import com.diagbot.vo.UpdateDeptInfoVO;
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.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 科室信息表 前端控制器
 * </p>
 *
 * @author zhaops
 * @since 2018-11-22
 */
@RestController
@RequestMapping("/deptInfo")
@SuppressWarnings("unchecked")
@Api(value = "科室维护相关API", tags = { "科室相关维护API" })
public class DeptInfoController {

    @Autowired
    private DeptInfoFacade deptInfoFacade;

    @ApiOperation(value = "科室维护——添加[by:wangyu]",
            notes = "name: 科室名称,必填<br>")
    @PostMapping("/addDeptInfo")
    @SysLogger("addDeptInfo")
    @Transactional
    public RespDTO<Boolean> addDeptInfo(@Valid @RequestBody AddDeptInfoVO addDeptInfoVO) {
        Boolean data = deptInfoFacade.addDeptInfo(addDeptInfoVO);
        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "科室维护——修改[by:wangyu]",
            notes = "name: 科室名称,必填<br>" +
                    "id: 科室id，必填")
    @PostMapping("/updateDeptInfo")
    @SysLogger("updateDeptInfo")
    @Transactional
    public RespDTO<Boolean> updateDeptInfo(@Valid @RequestBody UpdateDeptInfoVO updateDeptInfoVO) {
        Boolean data = deptInfoFacade.updateDeptInfo(updateDeptInfoVO);
        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "科室维护——删除[by:wangyu]",
            notes = "id: 科室id,必填<br>")
    @PostMapping("/deleteDeptInfo")
    @SysLogger("deleteDeptInfo")
    @Transactional
    public RespDTO<Boolean> deleteDeptInfo(@Valid @RequestBody DeleteDeptInfoVO deleteDeptInfoVO) {
        Boolean data = deptInfoFacade.deleteDeptInfo(deleteDeptInfoVO);
        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "科室维护——查询[by:wangyu]",
            notes = "name: 科室名称 <br>")
    @PostMapping("/getDeptInfo")
    @SysLogger("getDeptInfo")
    public RespDTO<IPage<GetDeptInfoDTO>> getDeptInfo(@Valid @RequestBody GetDeptInfoVO getDeptInfoVO) {
        IPage<GetDeptInfoDTO> data = deptInfoFacade.getDeptInfo(getDeptInfoVO);
        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "科室维护——详情[by:wangyu]",
            notes = "deptId: 科室id <br>")
    @PostMapping("/getDeptInfoDetials")
    @SysLogger("getDeptInfoDetials")
    public RespDTO<DeptInfo> getDeptInfoDetials(@Valid @RequestBody GetDeptInfoDetialsVO getDeptInfoDetialsVO) {
        DeptInfo data = deptInfoFacade.getDeptInfoDetials(getDeptInfoDetialsVO);
        return RespDTO.onSuc(data);
    }
}
