129 lines
4.5 KiB
Java
129 lines
4.5 KiB
Java
package com.gxwebsoft.clinic.controller;
|
|
|
|
import com.gxwebsoft.common.core.web.BaseController;
|
|
import com.gxwebsoft.clinic.service.ClinicAppointmentService;
|
|
import com.gxwebsoft.clinic.entity.ClinicAppointment;
|
|
import com.gxwebsoft.clinic.param.ClinicAppointmentParam;
|
|
import com.gxwebsoft.common.core.web.ApiResult;
|
|
import com.gxwebsoft.common.core.web.PageResult;
|
|
import com.gxwebsoft.common.core.web.PageParam;
|
|
import com.gxwebsoft.common.core.web.BatchParam;
|
|
import com.gxwebsoft.common.core.annotation.OperationLog;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 挂号控制器
|
|
*
|
|
* @author 科技小王子
|
|
* @since 2025-10-19 09:27:04
|
|
*/
|
|
@Tag(name = "挂号管理")
|
|
@RestController
|
|
@RequestMapping("/api/clinic/clinic-appointment")
|
|
public class ClinicAppointmentController extends BaseController {
|
|
@Resource
|
|
private ClinicAppointmentService clinicAppointmentService;
|
|
|
|
@PreAuthorize("hasAuthority('clinic:clinicAppointment:list')")
|
|
@Operation(summary = "分页查询挂号")
|
|
@GetMapping("/page")
|
|
public ApiResult<PageResult<ClinicAppointment>> page(ClinicAppointmentParam param) {
|
|
// 使用关联查询
|
|
return success(clinicAppointmentService.pageRel(param));
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('clinic:clinicAppointment:list')")
|
|
@Operation(summary = "查询全部挂号")
|
|
@GetMapping()
|
|
public ApiResult<List<ClinicAppointment>> list(ClinicAppointmentParam param) {
|
|
// 使用关联查询
|
|
return success(clinicAppointmentService.listRel(param));
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('clinic:clinicAppointment:list')")
|
|
@Operation(summary = "根据id查询挂号")
|
|
@GetMapping("/{id}")
|
|
public ApiResult<ClinicAppointment> get(@PathVariable("id") Integer id) {
|
|
// 使用关联查询
|
|
return success(clinicAppointmentService.getByIdRel(id));
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('clinic:clinicAppointment:save')")
|
|
@OperationLog
|
|
@Operation(summary = "添加挂号")
|
|
@PostMapping()
|
|
public ApiResult<?> save(@RequestBody ClinicAppointment clinicAppointment) {
|
|
// 记录当前登录用户id
|
|
// User loginUser = getLoginUser();
|
|
// if (loginUser != null) {
|
|
// clinicAppointment.setUserId(loginUser.getUserId());
|
|
// }
|
|
if (clinicAppointmentService.save(clinicAppointment)) {
|
|
return success("添加成功");
|
|
}
|
|
return fail("添加失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('clinic:clinicAppointment:update')")
|
|
@OperationLog
|
|
@Operation(summary = "修改挂号")
|
|
@PutMapping()
|
|
public ApiResult<?> update(@RequestBody ClinicAppointment clinicAppointment) {
|
|
if (clinicAppointmentService.updateById(clinicAppointment)) {
|
|
return success("修改成功");
|
|
}
|
|
return fail("修改失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('clinic:clinicAppointment:remove')")
|
|
@OperationLog
|
|
@Operation(summary = "删除挂号")
|
|
@DeleteMapping("/{id}")
|
|
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
|
if (clinicAppointmentService.removeById(id)) {
|
|
return success("删除成功");
|
|
}
|
|
return fail("删除失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('clinic:clinicAppointment:save')")
|
|
@OperationLog
|
|
@Operation(summary = "批量添加挂号")
|
|
@PostMapping("/batch")
|
|
public ApiResult<?> saveBatch(@RequestBody List<ClinicAppointment> list) {
|
|
if (clinicAppointmentService.saveBatch(list)) {
|
|
return success("添加成功");
|
|
}
|
|
return fail("添加失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('clinic:clinicAppointment:update')")
|
|
@OperationLog
|
|
@Operation(summary = "批量修改挂号")
|
|
@PutMapping("/batch")
|
|
public ApiResult<?> removeBatch(@RequestBody BatchParam<ClinicAppointment> batchParam) {
|
|
if (batchParam.update(clinicAppointmentService, "id")) {
|
|
return success("修改成功");
|
|
}
|
|
return fail("修改失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('clinic:clinicAppointment:remove')")
|
|
@OperationLog
|
|
@Operation(summary = "批量删除挂号")
|
|
@DeleteMapping("/batch")
|
|
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
|
if (clinicAppointmentService.removeByIds(ids)) {
|
|
return success("删除成功");
|
|
}
|
|
return fail("删除失败");
|
|
}
|
|
|
|
}
|