package cn.besteam.modules.system.controller;
|
|
import cn.besteam.common.api.vo.Result;
|
import cn.besteam.modules.system.dto.SysDepartmentInformationDTO;
|
import cn.besteam.modules.system.service.ISysDepartmentInformationService;
|
import cn.besteam.modules.system.vo.SysDepartmentInformationVO;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.mybatis.spring.MyBatisSystemException;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.dao.DuplicateKeyException;
|
import org.springframework.web.bind.annotation.*;
|
|
/**
|
* 医疗机构信息
|
*/
|
@RestController
|
@RequestMapping("/system/sysDepartmentInformation")
|
@Slf4j
|
@Api(description = "医疗机构信息")
|
public class SysDepartmentInformationController {
|
@Autowired
|
ISysDepartmentInformationService sysDepartmentInformationService;
|
|
/**
|
* 根据医院id获取医院信息
|
*
|
* @param departmentId
|
* @return
|
*/
|
@RequestMapping(value = "/queryOne", method = RequestMethod.GET)
|
@ApiOperation(value = "医疗机构信息-根据医院id获取医院信息", notes = "医疗机构信息-根据医院id获取医院信息")
|
public Result<?> queryOne(@RequestParam(name = "departmentId") Integer departmentId) {
|
SysDepartmentInformationVO sysDepartmentInformationVO=sysDepartmentInformationService.queryOne(departmentId);
|
return Result.ok(sysDepartmentInformationVO);
|
}
|
|
|
|
/**
|
* 编辑
|
*
|
* @param departmentInformationDTO
|
* @return
|
*/
|
@RequestMapping(value = "/update", method = RequestMethod.PUT)
|
@ApiOperation(value = "医疗机构信息-保存信息", notes = "医疗机构信息-保存信息")
|
public Result<?> update(@RequestBody SysDepartmentInformationDTO departmentInformationDTO) {
|
SysDepartmentInformationVO sysDepartmentInformationVO= null;
|
try {
|
sysDepartmentInformationVO = sysDepartmentInformationService.update(departmentInformationDTO);
|
} catch (DuplicateKeyException e) {
|
SysDepartmentInformationVO res = new SysDepartmentInformationVO();
|
BeanUtils.copyProperties(departmentInformationDTO, res);
|
return Result.ok(res);
|
}
|
return Result.ok(sysDepartmentInformationVO);
|
}
|
|
/**
|
* 通过id删除
|
*
|
* @param id
|
* @return
|
*/
|
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
@ApiOperation(value = "医疗机构信息-删除信息", notes = "医疗机构信息-删除信息")
|
public Result<?> delete(@RequestParam(name = "id") Integer id) {
|
sysDepartmentInformationService.delete(id);
|
return Result.ok("删除成功");
|
}
|
|
}
|