diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/DoctorController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/DoctorController.java new file mode 100644 index 000000000..1acfe1ff7 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/DoctorController.java @@ -0,0 +1,119 @@ +package cn.iocoder.yudao.module.system.controller.admin.doctor; + +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.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.system.controller.admin.doctor.vo.*; +import cn.iocoder.yudao.module.system.dal.dataobject.doctor.DoctorDO; +import cn.iocoder.yudao.module.system.service.doctor.DoctorService; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; + +@Tag(name = "管理后台 - 医生管理") +@RestController +@RequestMapping("/doctor/") +@Validated +public class DoctorController { + + @Resource + private DoctorService Service; + + @PostMapping("/create") + @Operation(summary = "创建医生管理") + @PreAuthorize("@ss.hasPermission('doctor::create')") + public CommonResult create(@Valid @RequestBody DoctorSaveReqVO createReqVO) { + return success(Service.create(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新医生管理") + @PreAuthorize("@ss.hasPermission('doctor::update')") + public CommonResult update(@Valid @RequestBody DoctorSaveReqVO updateReqVO) { + Service.update(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除医生管理") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('doctor::delete')") + public CommonResult delete(@RequestParam("id") String id, @RequestParam("username") String username) { + //不是真删除 修改状态 + //Service.delete(id); + //当前时间 + LocalDateTime dateTime= LocalDateTime.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + DoctorSaveReqVO up=new DoctorSaveReqVO(); + up.setDoctorID(id); + up.setDeletePerson(username); + up.setDeleteDate(dateTime); + up.setIsdelete("1"); + Service.update(up); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得医生管理") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('doctor::query')") + public CommonResult get(@RequestParam("id") String id) { + DoctorDO doctorDO= Service.get(id); + return success(BeanUtils.toBean(doctorDO, DoctorRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得医生管理分页") + @PreAuthorize("@ss.hasPermission('doctor::query')") + public CommonResult> getPage(@Valid DoctorPageReqVO pageReqVO) { + PageResult pageResult = Service.getPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, DoctorRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出医生管理 Excel") + @PreAuthorize("@ss.hasPermission('doctor::export')") + @ApiAccessLog(operateType = EXPORT) + public void exportExcel(@Valid DoctorPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = Service.getPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "医生管理.xls", "数据", DoctorRespVO.class, + BeanUtils.toBean(list, DoctorRespVO.class)); + } + + @PostMapping("/upload") + @Operation(summary = "上传图片") + @PreAuthorize("@ss.hasPermission('doctor::create')") + public CommonResult handleFileUpload(@Valid @RequestBody uoloadVO uoloadVO) { + + String id=uoloadVO.getDoctorID(); + return success(true); + } + + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/vo/DoctorPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/vo/DoctorPageReqVO.java new file mode 100644 index 000000000..34dd57331 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/vo/DoctorPageReqVO.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.system.controller.admin.doctor.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 医生管理分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class DoctorPageReqVO extends PageParam { + + @Schema(description = "医生姓名", example = "赵六") + private String doctorName; + + @Schema(description = "科室名称", example = "王五") + private String departmentName; + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/vo/DoctorRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/vo/DoctorRespVO.java new file mode 100644 index 000000000..709289521 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/vo/DoctorRespVO.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.system.controller.admin.doctor.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 医生管理 Response VO") +@Data +@ExcelIgnoreUnannotated +public class DoctorRespVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "10747") + private String doctorID; + + @Schema(description = "医生姓名", example = "赵六") + @ExcelProperty("医生姓名") + private String doctorName; + + @Schema(description = "性别") + @ExcelProperty("性别") + private String gender; + + @Schema(description = "出生日期") + @ExcelProperty("出生日期") + private LocalDateTime birthday; + + @Schema(description = "科室名称", example = "王五") + @ExcelProperty("所属科室") + private String departmentName; + + @Schema(description = "医生联系电话") + @ExcelProperty("医生联系电话") + private String doctorTel; + + @Schema(description = "备注", example = "你猜") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "医生电子签名URL", example = "https://www.iocoder.cn") + private String eSignatureUrl; + + @Schema(description = "医生级别") + @ExcelProperty("医生级别") + private String doctorLevel; + + @Schema(description = "机构ID", example = "30805") + private String orgId; + + @Schema(description = "科室代码", requiredMode = Schema.RequiredMode.REQUIRED) + private String departmentCode; + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/vo/DoctorSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/vo/DoctorSaveReqVO.java new file mode 100644 index 000000000..f1e3e2cdd --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/vo/DoctorSaveReqVO.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.system.controller.admin.doctor.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 医生管理新增/修改 Request VO") +@Data +public class DoctorSaveReqVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "10747") + private String doctorID; + + @Schema(description = "医生姓名", example = "赵六") + private String doctorName; + + @Schema(description = "性别") + private String gender; + + @Schema(description = "出生日期") + private LocalDateTime birthday; + + @Schema(description = "科室名称", example = "王五") + private String departmentName; + + @Schema(description = "医生联系电话") + private String doctorTel; + + @Schema(description = "备注", example = "你猜") + private String remark; + + @Schema(description = "医生电子签名URL", example = "https://www.iocoder.cn") + private String eSignatureUrl; + + @Schema(description = "医生级别:执业医师,主治医师,副主任医师,主任医师") + private String doctorLevel; + + @Schema(description = "机构ID", example = "30805") + private String orgId; + + @Schema(description = "科室代码", requiredMode = Schema.RequiredMode.REQUIRED) + private String departmentCode; + + @Schema(description = "删除人") + private String deletePerson; + + @Schema(description = "删除时间") + private LocalDateTime deleteDate; + + @Schema(description = "是否删除") + private String isdelete; +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/vo/uoloadVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/vo/uoloadVO.java new file mode 100644 index 000000000..49478400a --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/doctor/vo/uoloadVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.system.controller.admin.doctor.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class uoloadVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "10747") + private String doctorID; + + @Schema(description = "base64", example = "") + private String base; + + @Schema(description = "文件名称", example = "") + private String imagefilename; + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/doctor/DoctorDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/doctor/DoctorDO.java new file mode 100644 index 000000000..236bb608b --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/doctor/DoctorDO.java @@ -0,0 +1,107 @@ +package cn.iocoder.yudao.module.system.dal.dataobject.doctor; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 医生管理 DO + * + * @author 李晓东 + */ +@TableName("tb_doctor") +@KeySequence("tb_doctor_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DoctorDO { + + /** + * 主键 + */ + + @TableId(value ="doctorID", type = IdType.INPUT) + private String doctorID; + /** + * 医生姓名 + */ + @TableField("doctorName") + private String doctorName; + /** + * 性别 + */ + @TableField("gender") + private String gender; + /** + * 出生日期 + */ + @TableField("birthday") + private LocalDateTime birthday; + /** + * 科室名称 + */ + @TableField("departmentName") + private String departmentName; + /** + * 医生联系电话 + */ + @TableField("doctorTel") + private String doctorTel; + /** + * 创建人 + */ + @TableField("createPerson") + private String createPerson; + /** + * 创建日期:年月日时分秒 + */ + @TableField("createDate") + private LocalDateTime createDate; + /** + * 删除标记:1 为删除 + */ + @TableField("isdelete") + private String isdelete; + /** + * 删除人 + */ + @TableField("deletePerson") + private String deletePerson; + /** + * 删除日期 + */ + @TableField("deleteDate") + private LocalDateTime deleteDate; + /** + * 备注 + */ + @TableField("remark") + private String remark; + /** + * 医生电子签名URL + */ + @TableField("eSignatureUrl") + private String eSignatureUrl; + /** + * 医生级别:执业医师,主治医师,副主任医师,主任医师 + */ + @TableField("doctorLevel") + private String doctorLevel; + /** + * 机构ID + */ + @TableField("orgId") + private String orgId; + /** + * 科室代码 + */ + @TableField("departmentCode") + private String departmentCode; + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/doctor/DoctorMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/doctor/DoctorMapper.java new file mode 100644 index 000000000..80ed93029 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/doctor/DoctorMapper.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.system.dal.mysql.doctor; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.system.dal.dataobject.doctor.DoctorDO; +import com.baomidou.mybatisplus.annotation.InterceptorIgnore; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.system.controller.admin.doctor.vo.*; + +/** + * 医生管理 Mapper + * + * @author 李晓东 + */ +@InterceptorIgnore(tenantLine = "true") +@Mapper +public interface DoctorMapper extends BaseMapperX { + + default PageResult selectPage(DoctorPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(DoctorDO::getDoctorName, reqVO.getDoctorName()) + .likeIfPresent(DoctorDO::getDepartmentName, reqVO.getDepartmentName()) + .or(wrapper -> wrapper.eq(DoctorDO::getIsdelete, 0)) + .or(wrapper -> wrapper.isNull(DoctorDO::getIsdelete)) + .orderByDesc(DoctorDO::getDoctorID)); + } + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/doctor/DoctorService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/doctor/DoctorService.java new file mode 100644 index 000000000..e9d9ec620 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/doctor/DoctorService.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.system.service.doctor; + +import java.util.*; +import cn.iocoder.yudao.module.system.controller.admin.doctor.vo.*; +import cn.iocoder.yudao.module.system.dal.dataobject.doctor.DoctorDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +import javax.validation.Valid; + +/** + * 医生管理 Service 接口 + * + * @author 李晓东 + */ +public interface DoctorService { + + /** + * 创建医生管理 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + String create(@Valid DoctorSaveReqVO createReqVO); + + /** + * 更新医生管理 + * + * @param updateReqVO 更新信息 + */ + void update(@Valid DoctorSaveReqVO updateReqVO); + + /** + * 删除医生管理 + * + * @param id 编号 + */ + void delete(String id); + + /** + * 获得医生管理 + * + * @param id 编号 + * @return 医生管理 + */ + DoctorDO get(String id); + + /** + * 获得医生管理分页 + * + * @param pageReqVO 分页查询 + * @return 医生管理分页 + */ + PageResult getPage(DoctorPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/doctor/DoctorServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/doctor/DoctorServiceImpl.java new file mode 100644 index 000000000..f28220ee6 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/doctor/DoctorServiceImpl.java @@ -0,0 +1,76 @@ +package cn.iocoder.yudao.module.system.service.doctor; + +import cn.iocoder.yudao.framework.common.exception.ErrorCode; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.system.controller.admin.doctor.vo.*; +import cn.iocoder.yudao.module.system.dal.dataobject.doctor.DoctorDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.system.dal.mysql.doctor.DoctorMapper; + +import javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; + +/** + * 医生管理 Service 实现类 + * + * @author 李晓东 + */ +@Service +@Validated +public class DoctorServiceImpl implements DoctorService { + + @Resource + private DoctorMapper Mapper; + + @Override + public String create(DoctorSaveReqVO createReqVO) { + // 插入 + DoctorDO doctorDO = BeanUtils.toBean(createReqVO, DoctorDO.class); + Mapper.insert(doctorDO); + // 返回 + return doctorDO.getDoctorID(); + } + + @Override + public void update(DoctorSaveReqVO updateReqVO) { + // 校验存在 + validateExists(updateReqVO.getDoctorID()); + // 更新 + DoctorDO updateObj = BeanUtils.toBean(updateReqVO, DoctorDO.class); + Mapper.updateById(updateObj); + } + + @Override + public void delete(String id) { + // 校验存在 + validateExists(id); + // 删除 + Mapper.deleteById(id); + } + + private void validateExists(String id) { + if (Mapper.selectById(id) == null) { + throw exception(new ErrorCode(1,"用户ID为空")); + } + } + + @Override + public DoctorDO get(String id) { + return Mapper.selectById(id); + } + + @Override + public PageResult getPage(DoctorPageReqVO pageReqVO) { + return Mapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/doctor/DoctorMapper.xml b/yudao-module-system/yudao-module-system-biz/src/main/resources/doctor/DoctorMapper.xml new file mode 100644 index 000000000..7c1b30c97 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/doctor/DoctorMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file