完成医生模块
Some checks are pending
Java CI with Maven / build (11) (push) Waiting to run
Java CI with Maven / build (17) (push) Waiting to run
Java CI with Maven / build (8) (push) Waiting to run
yudao-ui-admin CI / build (14.x) (push) Waiting to run
yudao-ui-admin CI / build (16.x) (push) Waiting to run

This commit is contained in:
lxd 2024-07-23 14:55:53 +08:00
parent 1a4625c97c
commit 4cdf0e9e4d
10 changed files with 553 additions and 0 deletions

View File

@ -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<String> create(@Valid @RequestBody DoctorSaveReqVO createReqVO) {
return success(Service.create(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新医生管理")
@PreAuthorize("@ss.hasPermission('doctor::update')")
public CommonResult<Boolean> 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<Boolean> 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<DoctorRespVO> 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<PageResult<DoctorRespVO>> getPage(@Valid DoctorPageReqVO pageReqVO) {
PageResult<DoctorDO> 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<DoctorDO> 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<Boolean> handleFileUpload(@Valid @RequestBody uoloadVO uoloadVO) {
String id=uoloadVO.getDoctorID();
return success(true);
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 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;
}

View File

@ -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<DoctorDO> {
default PageResult<DoctorDO> selectPage(DoctorPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<DoctorDO>()
.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));
}
}

View File

@ -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<DoctorDO> getPage(DoctorPageReqVO pageReqVO);
}

View File

@ -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<DoctorDO> getPage(DoctorPageReqVO pageReqVO) {
return Mapper.selectPage(pageReqVO);
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.doctor.DoctorMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>