package cn.lihu.jh.module.ecg.controller.admin.checktype;
|
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import java.util.*;
|
import java.io.IOException;
|
|
import cn.lihu.jh.framework.common.pojo.PageParam;
|
import cn.lihu.jh.framework.common.pojo.PageResult;
|
import cn.lihu.jh.framework.common.pojo.CommonResult;
|
import cn.lihu.jh.framework.common.util.object.BeanUtils;
|
import static cn.lihu.jh.framework.common.pojo.CommonResult.success;
|
|
import cn.lihu.jh.framework.excel.core.util.ExcelUtils;
|
|
import cn.lihu.jh.framework.apilog.core.annotation.ApiAccessLog;
|
import static cn.lihu.jh.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
import cn.lihu.jh.module.ecg.controller.admin.checktype.vo.*;
|
import cn.lihu.jh.module.ecg.dal.dataobject.checktype.CheckTypeDO;
|
import cn.lihu.jh.module.ecg.service.checktype.CheckTypeService;
|
|
import javax.annotation.Resource;
|
import javax.annotation.security.PermitAll;
|
import javax.servlet.http.HttpServletResponse;
|
import javax.validation.Valid;
|
|
@Tag(name = "管理后台 - 检查类型")
|
@RestController
|
@RequestMapping("/ecg/check-type")
|
@Validated
|
public class CheckTypeController {
|
|
@Resource
|
private CheckTypeService checkTypeService;
|
|
@PostMapping("/create")
|
@Operation(summary = "创建检查类型")
|
@PreAuthorize("@ss.hasPermission('ecg:check-type:create')")
|
public CommonResult<Integer> createCheckType(@Valid @RequestBody CheckTypeSaveReqVO createReqVO) {
|
return success(checkTypeService.createCheckType(createReqVO));
|
}
|
|
@PutMapping("/update")
|
@Operation(summary = "更新检查类型")
|
@PreAuthorize("@ss.hasPermission('ecg:check-type:update')")
|
public CommonResult<Boolean> updateCheckType(@Valid @RequestBody CheckTypeSaveReqVO updateReqVO) {
|
checkTypeService.updateCheckType(updateReqVO);
|
return success(true);
|
}
|
|
@DeleteMapping("/delete")
|
@Operation(summary = "删除检查类型")
|
@Parameter(name = "id", description = "编号", required = true)
|
@PreAuthorize("@ss.hasPermission('ecg:check-type:delete')")
|
public CommonResult<Boolean> deleteCheckType(@RequestParam("id") Integer id) {
|
checkTypeService.deleteCheckType(id);
|
return success(true);
|
}
|
|
@GetMapping("/get")
|
@Operation(summary = "获得检查类型")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@PreAuthorize("@ss.hasPermission('ecg:check-type:query')")
|
public CommonResult<CheckTypeRespVO> getCheckType(@RequestParam("id") Integer id) {
|
CheckTypeDO checkType = checkTypeService.getCheckType(id);
|
return success(BeanUtils.toBean(checkType, CheckTypeRespVO.class));
|
}
|
|
@GetMapping("/page")
|
@Operation(summary = "获得检查类型分页")
|
@PreAuthorize("@ss.hasPermission('ecg:check-type:query')")
|
public CommonResult<PageResult<CheckTypeRespVO>> getCheckTypePage(@Valid CheckTypePageReqVO pageReqVO) {
|
PageResult<CheckTypeDO> pageResult = checkTypeService.getCheckTypePage(pageReqVO);
|
return success(BeanUtils.toBean(pageResult, CheckTypeRespVO.class));
|
}
|
|
@GetMapping("/export-excel")
|
@Operation(summary = "导出检查类型 Excel")
|
@PreAuthorize("@ss.hasPermission('ecg:check-type:export')")
|
@ApiAccessLog(operateType = EXPORT)
|
public void exportCheckTypeExcel(@Valid CheckTypePageReqVO pageReqVO,
|
HttpServletResponse response) throws IOException {
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
List<CheckTypeDO> list = checkTypeService.getCheckTypePage(pageReqVO).getList();
|
// 导出 Excel
|
ExcelUtils.write(response, "检查类型.xls", "数据", CheckTypeRespVO.class,
|
BeanUtils.toBean(list, CheckTypeRespVO.class));
|
}
|
|
@GetMapping("/list-simple-check-type")
|
@Operation(summary = "获得简单检查类型列表")
|
@PermitAll
|
public CommonResult<List<SimpleCheckTypeRespVO>> getSimpleCheckTypeList() {
|
List<CheckTypeDO> list = checkTypeService.getSimpleCheckTypeList();
|
return success(BeanUtils.toBean(list, SimpleCheckTypeRespVO.class));
|
}
|
}
|