From 719c3b328584689bf656e5cd182b6254b9fb9425 Mon Sep 17 00:00:00 2001 From: BLRTTX <2232721325@qq.com> Date: Sat, 21 Dec 2024 22:29:20 +0800 Subject: [PATCH] 12.21 --- .../com/atjy/model/entity/DoctorInfo.java | 2 +- .../article/ArticleInfoController.java | 2 +- .../doctor/DoctorInfoController.java | 22 ++++-- .../web/admin/service/ArticleInfoService.java | 4 + .../web/admin/service/DoctorInfoService.java | 6 ++ .../service/impl/ArticleInfoServiceImpl.java | 14 +++- .../service/impl/DoctorInfoServiceImpl.java | 74 ++++++++++++++++++- .../web/admin/vo/article/ArticleListVo.java | 3 + .../resources/mapper/ArticleInfoMapper.xml | 2 + .../resources/mapper/DoctorInfoMapper.xml | 17 ++++- 10 files changed, 134 insertions(+), 12 deletions(-) diff --git a/model/src/main/java/com/atjy/model/entity/DoctorInfo.java b/model/src/main/java/com/atjy/model/entity/DoctorInfo.java index fb506ba..2d2a15d 100644 --- a/model/src/main/java/com/atjy/model/entity/DoctorInfo.java +++ b/model/src/main/java/com/atjy/model/entity/DoctorInfo.java @@ -38,7 +38,7 @@ public class DoctorInfo extends BaseEntity { @Schema(description = "科室id") @TableField(value = "department_id") - private String departmentId; + private Long departmentId; @Schema(description = "简介") @TableField(value = "briefly") diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/controller/article/ArticleInfoController.java b/web/web-admin/src/main/java/com/atjy/web/admin/controller/article/ArticleInfoController.java index 2b7d30f..883b200 100644 --- a/web/web-admin/src/main/java/com/atjy/web/admin/controller/article/ArticleInfoController.java +++ b/web/web-admin/src/main/java/com/atjy/web/admin/controller/article/ArticleInfoController.java @@ -41,7 +41,7 @@ public class ArticleInfoController { @Operation(summary = "删除医说") @PostMapping("deleteArticle") public Result deleteArticle(@RequestBody List ids) { - service.removeBatchByIds(ids); + service.deleteArticle(ids); return Result.ok(); } diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/controller/doctor/DoctorInfoController.java b/web/web-admin/src/main/java/com/atjy/web/admin/controller/doctor/DoctorInfoController.java index 26ada9b..cddb85a 100644 --- a/web/web-admin/src/main/java/com/atjy/web/admin/controller/doctor/DoctorInfoController.java +++ b/web/web-admin/src/main/java/com/atjy/web/admin/controller/doctor/DoctorInfoController.java @@ -8,10 +8,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.util.List; @Tag(name = "医生信息管理") @RestController @@ -25,8 +24,21 @@ public class DoctorInfoController { @PostMapping("getDoctorPageItem") public Result> getDoctorPageItem(@RequestParam Integer current, @RequestParam Integer size, @RequestParam(required = false) String name) { Page page = new Page<>(current, size); - IPage result = service.getDoctorPageItem(page,name); + IPage result = service.getDoctorPageItem(page, name); return Result.ok(result); } + @Operation(summary = "增加/更新医生") + @PostMapping("saveOrUpdateDoctor") + public Result saveOrUpdateDoctor(@RequestBody DoctorInfoVo doctorInfoVo) { + service.saveOrUpdateDoctor(doctorInfoVo); + return Result.ok(); + } + + @Operation(summary = "删除医生") + @PostMapping("deleteDoctor") + public Result deleteDoctor(@RequestParam List ids) { + service.deleteDoctor(ids); + return Result.ok(); + } } diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/service/ArticleInfoService.java b/web/web-admin/src/main/java/com/atjy/web/admin/service/ArticleInfoService.java index 14e9025..51f0cfb 100644 --- a/web/web-admin/src/main/java/com/atjy/web/admin/service/ArticleInfoService.java +++ b/web/web-admin/src/main/java/com/atjy/web/admin/service/ArticleInfoService.java @@ -7,8 +7,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + public interface ArticleInfoService extends IService { IPage getArticlePageItem(Page page, String title); void saveOrUpdateArticle(ArticleInfoVo articleInfoVo); + + void deleteArticle(List ids); } diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/service/DoctorInfoService.java b/web/web-admin/src/main/java/com/atjy/web/admin/service/DoctorInfoService.java index 1cdb4d7..2f7c3f4 100644 --- a/web/web-admin/src/main/java/com/atjy/web/admin/service/DoctorInfoService.java +++ b/web/web-admin/src/main/java/com/atjy/web/admin/service/DoctorInfoService.java @@ -6,6 +6,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + public interface DoctorInfoService extends IService { IPage getDoctorPageItem(Page page,String name); + + void saveOrUpdateDoctor(DoctorInfoVo doctorInfoVo); + + void deleteDoctor(List ids); } diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/ArticleInfoServiceImpl.java b/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/ArticleInfoServiceImpl.java index 4b77e71..16837bc 100644 --- a/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/ArticleInfoServiceImpl.java +++ b/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/ArticleInfoServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; +import java.util.List; @Service public class ArticleInfoServiceImpl extends ServiceImpl implements ArticleInfoService { @@ -51,7 +52,7 @@ public class ArticleInfoServiceImpl extends ServiceImpl().select("max(id)")).getId()); + graphInfo.setItemId(articleInfo.getId()); graphInfo.setName(articleInfoVo.getName()); graphInfoMapper.insertOrUpdate(graphInfo); } + + @Override + public void deleteArticle(List ids) { + for (Long id : ids) { + graphInfoMapper.delete(new LambdaQueryWrapper().eq(GraphInfo::getItemId, id).eq(GraphInfo::getItemType, GraphItemType.ARTICLE)); + } + + articleInfoMapper.deleteByIds(ids); + } } diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/DoctorInfoServiceImpl.java b/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/DoctorInfoServiceImpl.java index 4ca44e6..aeb6cdf 100644 --- a/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/DoctorInfoServiceImpl.java +++ b/web/web-admin/src/main/java/com/atjy/web/admin/service/impl/DoctorInfoServiceImpl.java @@ -1,21 +1,45 @@ package com.atjy.web.admin.service.impl; -import com.atjy.model.entity.DoctorInfo; -import com.atjy.web.admin.mapper.DoctorInfoMapper; +import com.atjy.common.exception.HassleFreeException; +import com.atjy.common.result.ResultCodeEnum; +import com.atjy.model.entity.*; +import com.atjy.model.enums.GraphItemType; +import com.atjy.web.admin.mapper.*; import com.atjy.web.admin.service.DoctorInfoService; import com.atjy.web.admin.vo.doctor.DoctorInfoVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + @Service public class DoctorInfoServiceImpl extends ServiceImpl implements DoctorInfoService { @Autowired private DoctorInfoMapper doctorInfoMapper; + @Autowired + private DepartmentInfoMapper departmentInfoMapper; + + @Autowired + private HospitalInfoMapper hospitalInfoMapper; + + @Autowired + private GraphInfoMapper graphInfoMapper; + + @Autowired + private DoctorAppointmentMapper doctorAppointmentMapper; + + @Autowired + private ArticleInfoMapper articleInfoMapper; + + @Autowired + private UserAppointmentMapper userAppointmentMapper; + @Override public IPage getDoctorPageItem(Page page, String name) { IPage result; @@ -26,4 +50,50 @@ public class DoctorInfoServiceImpl extends ServiceImpl().eq(DepartmentInfo::getName, doctorInfoVo.getDepartmentName())).getId()); + doctorInfo.setHospitalId(hospitalInfoMapper.selectOne(new LambdaQueryWrapper().eq(HospitalInfo::getHospitalName, doctorInfoVo.getHospitalName())).getId()); + doctorInfo.setIsDeleted((byte) 0); + doctorInfo.setDoctorName(doctorInfo.getDoctorName()); + doctorInfo.setBriefly(doctorInfoVo.getBriefly()); + doctorInfo.setSource(doctorInfoVo.getSource()); + doctorInfo.setLevel(doctorInfoVo.getLevel()); + doctorInfo.setExpertise(doctorInfoVo.getExpertise()); + doctorInfo.setAppointmentNumber(doctorInfoVo.getAppointmentNumber()); + + doctorInfoMapper.insertOrUpdate(doctorInfo); + + GraphInfo graphInfo = new GraphInfo(); + graphInfo.setIsDeleted((byte) 0); + graphInfo.setItemType(GraphItemType.DOCTOR); + graphInfo.setUrl(doctorInfoVo.getUrl()); + graphInfo.setItemId(doctorInfo.getId()); + graphInfo.setName(doctorInfoVo.getGraphName()); + + graphInfoMapper.insertOrUpdate(graphInfo); + } + + @Override + public void deleteDoctor(List ids) { + for (Long id : ids) { + if (doctorAppointmentMapper.selectOne(new LambdaQueryWrapper().eq(DoctorAppointment::getDoctorId, id)) != null) { + throw new HassleFreeException(ResultCodeEnum.DELETE_ERROR); + } + if (articleInfoMapper.selectOne(new LambdaQueryWrapper().eq(ArticleInfo::getDoctorId, id)) != null) { + throw new HassleFreeException(ResultCodeEnum.DELETE_ERROR); + } + if (userAppointmentMapper.selectOne(new LambdaQueryWrapper().eq(UserAppointment::getDoctorId, id)) != null) { + throw new HassleFreeException(ResultCodeEnum.DELETE_ERROR); + } + } + + for (Long id : ids) { + graphInfoMapper.delete(new LambdaQueryWrapper().eq(GraphInfo::getItemId, id).eq(GraphInfo::getItemType, GraphItemType.DOCTOR)); + } + + doctorInfoMapper.deleteByIds(ids); + } } diff --git a/web/web-admin/src/main/java/com/atjy/web/admin/vo/article/ArticleListVo.java b/web/web-admin/src/main/java/com/atjy/web/admin/vo/article/ArticleListVo.java index 8a08775..ebc77bf 100644 --- a/web/web-admin/src/main/java/com/atjy/web/admin/vo/article/ArticleListVo.java +++ b/web/web-admin/src/main/java/com/atjy/web/admin/vo/article/ArticleListVo.java @@ -11,6 +11,9 @@ import java.util.Date; @Schema(description = "医说列表实体") public class ArticleListVo { + @Schema(description = "阅读量") + private Integer number; + @Schema(description = "大标题") private String titleBig; diff --git a/web/web-admin/src/main/resources/mapper/ArticleInfoMapper.xml b/web/web-admin/src/main/resources/mapper/ArticleInfoMapper.xml index 71c605c..c2876d9 100644 --- a/web/web-admin/src/main/resources/mapper/ArticleInfoMapper.xml +++ b/web/web-admin/src/main/resources/mapper/ArticleInfoMapper.xml @@ -17,6 +17,7 @@ ai.title_big, ai.title_small, ai.publish_time, + ai.number, ai.content, di.id doctor_id, di.doctor_name, @@ -38,6 +39,7 @@ ai.title_big, ai.title_small, ai.publish_time, + ai.number, ai.content, di.id doctor_id, di.doctor_name, diff --git a/web/web-admin/src/main/resources/mapper/DoctorInfoMapper.xml b/web/web-admin/src/main/resources/mapper/DoctorInfoMapper.xml index 34c07a2..8e92dcb 100644 --- a/web/web-admin/src/main/resources/mapper/DoctorInfoMapper.xml +++ b/web/web-admin/src/main/resources/mapper/DoctorInfoMapper.xml @@ -24,6 +24,21 @@ \ No newline at end of file