package cn.lihu.jh.module.ecg.controller.admin.call; 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.call.vo.*; import cn.lihu.jh.module.ecg.dal.dataobject.call.CallDO; import cn.lihu.jh.module.ecg.service.call.CallService; import javax.annotation.Resource; import javax.annotation.security.PermitAll; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; @Tag(name = "管理后台 - 叫号") @RestController @RequestMapping("/ecg/call") @Validated public class CallController { @Resource private CallService callService; @PostMapping("/create") @Operation(summary = "创建叫号") @PreAuthorize("@ss.hasPermission('ecg:call:create')") public CommonResult createCall(@Valid @RequestBody CallSaveReqVO createReqVO) { return success(callService.createCall(createReqVO)); } @PutMapping("/update") @Operation(summary = "更新叫号") @PreAuthorize("@ss.hasPermission('ecg:call:update')") public CommonResult updateCall(@Valid @RequestBody CallSaveReqVO updateReqVO) { callService.updateCall(updateReqVO); return success(true); } @DeleteMapping("/delete") @Operation(summary = "删除叫号") @Parameter(name = "id", description = "编号", required = true) @PreAuthorize("@ss.hasPermission('ecg:call:delete')") public CommonResult deleteCall(@RequestParam("id") Integer id) { callService.deleteCall(id); return success(true); } @GetMapping("/get") @Operation(summary = "获得叫号") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('ecg:call:query')") public CommonResult getCall(@RequestParam("id") Integer id) { CallDO call = callService.getCall(id); return success(BeanUtils.toBean(call, CallRespVO.class)); } @GetMapping("/next") @Operation(summary = "获得下一个叫号") @PermitAll public CommonResult nextCall() { CallDO call = callService.getNextCall(); return success(BeanUtils.toBean(call, CallRespVO.class)); } }