diff --git a/src/main/java/com/gxwebsoft/clinic/controller/ClinicAppointmentController.java b/src/main/java/com/gxwebsoft/clinic/controller/ClinicAppointmentController.java new file mode 100644 index 0000000..4612446 --- /dev/null +++ b/src/main/java/com/gxwebsoft/clinic/controller/ClinicAppointmentController.java @@ -0,0 +1,128 @@ +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-16 20:26:59 + */ +@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> page(ClinicAppointmentParam param) { + // 使用关联查询 + return success(clinicAppointmentService.pageRel(param)); + } + + @PreAuthorize("hasAuthority('clinic:clinicAppointment:list')") + @Operation(summary = "查询全部挂号") + @GetMapping() + public ApiResult> list(ClinicAppointmentParam param) { + // 使用关联查询 + return success(clinicAppointmentService.listRel(param)); + } + + @PreAuthorize("hasAuthority('clinic:clinicAppointment:list')") + @Operation(summary = "根据id查询挂号") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Long 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 list) { + if (clinicAppointmentService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @PreAuthorize("hasAuthority('clinic:clinicAppointment:update')") + @OperationLog + @Operation(summary = "批量修改挂号") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam 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 ids) { + if (clinicAppointmentService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/clinic/entity/ClinicAppointment.java b/src/main/java/com/gxwebsoft/clinic/entity/ClinicAppointment.java new file mode 100644 index 0000000..0588200 --- /dev/null +++ b/src/main/java/com/gxwebsoft/clinic/entity/ClinicAppointment.java @@ -0,0 +1,60 @@ +package com.gxwebsoft.clinic.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import java.io.Serializable; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 挂号 + * + * @author 科技小王子 + * @since 2025-10-16 20:26:59 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "ClinicAppointment对象", description = "挂号") +public class ClinicAppointment implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "主键ID") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @Schema(description = "类型") + private Integer type; + + @Schema(description = "就诊原因") + private String reason; + + @Schema(description = "挂号时间") + private LocalDateTime evaluateTime; + + @Schema(description = "医生") + private Integer doctorId; + + @Schema(description = "患者") + private Integer userId; + + @Schema(description = "备注") + private String comments; + + @Schema(description = "排序号") + private Integer sortNumber; + + @Schema(description = "是否删除") + private Integer isDelete; + + @Schema(description = "租户id") + private Integer tenantId; + + @Schema(description = "创建时间") + private LocalDateTime createTime; + + @Schema(description = "修改时间") + private LocalDateTime updateTime; + +} diff --git a/src/main/java/com/gxwebsoft/clinic/mapper/ClinicAppointmentMapper.java b/src/main/java/com/gxwebsoft/clinic/mapper/ClinicAppointmentMapper.java new file mode 100644 index 0000000..34eea12 --- /dev/null +++ b/src/main/java/com/gxwebsoft/clinic/mapper/ClinicAppointmentMapper.java @@ -0,0 +1,37 @@ +package com.gxwebsoft.clinic.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.gxwebsoft.clinic.entity.ClinicAppointment; +import com.gxwebsoft.clinic.param.ClinicAppointmentParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 挂号Mapper + * + * @author 科技小王子 + * @since 2025-10-16 20:26:59 + */ +public interface ClinicAppointmentMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") ClinicAppointmentParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") ClinicAppointmentParam param); + +} diff --git a/src/main/java/com/gxwebsoft/clinic/mapper/xml/ClinicAppointmentMapper.xml b/src/main/java/com/gxwebsoft/clinic/mapper/xml/ClinicAppointmentMapper.xml new file mode 100644 index 0000000..3825e91 --- /dev/null +++ b/src/main/java/com/gxwebsoft/clinic/mapper/xml/ClinicAppointmentMapper.xml @@ -0,0 +1,60 @@ + + + + + + + SELECT a.* + FROM clinic_appointment a + + + AND a.id = #{param.id} + + + AND a.type = #{param.type} + + + AND a.reason LIKE CONCAT('%', #{param.reason}, '%') + + + AND a.evaluate_time LIKE CONCAT('%', #{param.evaluateTime}, '%') + + + AND a.doctor_id = #{param.doctorId} + + + AND a.user_id = #{param.userId} + + + AND a.comments LIKE CONCAT('%', #{param.comments}, '%') + + + AND a.sort_number = #{param.sortNumber} + + + AND a.is_delete = #{param.isDelete} + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') + ) + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/clinic/param/ClinicAppointmentParam.java b/src/main/java/com/gxwebsoft/clinic/param/ClinicAppointmentParam.java new file mode 100644 index 0000000..8caebe1 --- /dev/null +++ b/src/main/java/com/gxwebsoft/clinic/param/ClinicAppointmentParam.java @@ -0,0 +1,58 @@ +package com.gxwebsoft.clinic.param; + +import java.math.BigDecimal; +import com.gxwebsoft.common.core.annotation.QueryField; +import com.gxwebsoft.common.core.annotation.QueryType; +import com.gxwebsoft.common.core.web.BaseParam; +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 挂号查询参数 + * + * @author 科技小王子 + * @since 2025-10-16 20:26:59 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@Schema(name = "ClinicAppointmentParam对象", description = "挂号查询参数") +public class ClinicAppointmentParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @Schema(description = "主键ID") + @QueryField(type = QueryType.EQ) + private Long id; + + @Schema(description = "类型") + @QueryField(type = QueryType.EQ) + private Integer type; + + @Schema(description = "就诊原因") + private String reason; + + @Schema(description = "挂号时间") + private String evaluateTime; + + @Schema(description = "医生") + @QueryField(type = QueryType.EQ) + private Integer doctorId; + + @Schema(description = "患者") + @QueryField(type = QueryType.EQ) + private Integer userId; + + @Schema(description = "备注") + private String comments; + + @Schema(description = "排序号") + @QueryField(type = QueryType.EQ) + private Integer sortNumber; + + @Schema(description = "是否删除") + @QueryField(type = QueryType.EQ) + private Integer isDelete; + +} diff --git a/src/main/java/com/gxwebsoft/clinic/service/ClinicAppointmentService.java b/src/main/java/com/gxwebsoft/clinic/service/ClinicAppointmentService.java new file mode 100644 index 0000000..83156dc --- /dev/null +++ b/src/main/java/com/gxwebsoft/clinic/service/ClinicAppointmentService.java @@ -0,0 +1,42 @@ +package com.gxwebsoft.clinic.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.clinic.entity.ClinicAppointment; +import com.gxwebsoft.clinic.param.ClinicAppointmentParam; + +import java.util.List; + +/** + * 挂号Service + * + * @author 科技小王子 + * @since 2025-10-16 20:26:59 + */ +public interface ClinicAppointmentService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(ClinicAppointmentParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(ClinicAppointmentParam param); + + /** + * 根据id查询 + * + * @param id 主键ID + * @return ClinicAppointment + */ + ClinicAppointment getByIdRel(Long id); + +} diff --git a/src/main/java/com/gxwebsoft/clinic/service/impl/ClinicAppointmentServiceImpl.java b/src/main/java/com/gxwebsoft/clinic/service/impl/ClinicAppointmentServiceImpl.java new file mode 100644 index 0000000..fb79e40 --- /dev/null +++ b/src/main/java/com/gxwebsoft/clinic/service/impl/ClinicAppointmentServiceImpl.java @@ -0,0 +1,47 @@ +package com.gxwebsoft.clinic.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.clinic.mapper.ClinicAppointmentMapper; +import com.gxwebsoft.clinic.service.ClinicAppointmentService; +import com.gxwebsoft.clinic.entity.ClinicAppointment; +import com.gxwebsoft.clinic.param.ClinicAppointmentParam; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.PageResult; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 挂号Service实现 + * + * @author 科技小王子 + * @since 2025-10-16 20:26:59 + */ +@Service +public class ClinicAppointmentServiceImpl extends ServiceImpl implements ClinicAppointmentService { + + @Override + public PageResult pageRel(ClinicAppointmentParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("sort_number asc, create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(ClinicAppointmentParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } + + @Override + public ClinicAppointment getByIdRel(Long id) { + ClinicAppointmentParam param = new ClinicAppointmentParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } + +}