This commit is contained in:
BLRTTX 2024-12-21 22:29:20 +08:00
parent b026492565
commit 719c3b3285
10 changed files with 134 additions and 12 deletions

View File

@ -38,7 +38,7 @@ public class DoctorInfo extends BaseEntity {
@Schema(description = "科室id") @Schema(description = "科室id")
@TableField(value = "department_id") @TableField(value = "department_id")
private String departmentId; private Long departmentId;
@Schema(description = "简介") @Schema(description = "简介")
@TableField(value = "briefly") @TableField(value = "briefly")

View File

@ -41,7 +41,7 @@ public class ArticleInfoController {
@Operation(summary = "删除医说") @Operation(summary = "删除医说")
@PostMapping("deleteArticle") @PostMapping("deleteArticle")
public Result deleteArticle(@RequestBody List<Long> ids) { public Result deleteArticle(@RequestBody List<Long> ids) {
service.removeBatchByIds(ids); service.deleteArticle(ids);
return Result.ok(); return Result.ok();
} }

View File

@ -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.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import java.util.List;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "医生信息管理") @Tag(name = "医生信息管理")
@RestController @RestController
@ -25,8 +24,21 @@ public class DoctorInfoController {
@PostMapping("getDoctorPageItem") @PostMapping("getDoctorPageItem")
public Result<IPage<DoctorInfoVo>> getDoctorPageItem(@RequestParam Integer current, @RequestParam Integer size, @RequestParam(required = false) String name) { public Result<IPage<DoctorInfoVo>> getDoctorPageItem(@RequestParam Integer current, @RequestParam Integer size, @RequestParam(required = false) String name) {
Page<DoctorInfoVo> page = new Page<>(current, size); Page<DoctorInfoVo> page = new Page<>(current, size);
IPage<DoctorInfoVo> result = service.getDoctorPageItem(page,name); IPage<DoctorInfoVo> result = service.getDoctorPageItem(page, name);
return Result.ok(result); 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<Long> ids) {
service.deleteDoctor(ids);
return Result.ok();
}
} }

View File

@ -7,8 +7,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
public interface ArticleInfoService extends IService<ArticleInfo> { public interface ArticleInfoService extends IService<ArticleInfo> {
IPage<ArticleListVo> getArticlePageItem(Page<ArticleListVo> page, String title); IPage<ArticleListVo> getArticlePageItem(Page<ArticleListVo> page, String title);
void saveOrUpdateArticle(ArticleInfoVo articleInfoVo); void saveOrUpdateArticle(ArticleInfoVo articleInfoVo);
void deleteArticle(List<Long> ids);
} }

View File

@ -6,6 +6,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
public interface DoctorInfoService extends IService<DoctorInfo> { public interface DoctorInfoService extends IService<DoctorInfo> {
IPage<DoctorInfoVo> getDoctorPageItem(Page<DoctorInfoVo> page,String name); IPage<DoctorInfoVo> getDoctorPageItem(Page<DoctorInfoVo> page,String name);
void saveOrUpdateDoctor(DoctorInfoVo doctorInfoVo);
void deleteDoctor(List<Long> ids);
} }

View File

@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.List;
@Service @Service
public class ArticleInfoServiceImpl extends ServiceImpl<ArticleInfoMapper, ArticleInfo> implements ArticleInfoService { public class ArticleInfoServiceImpl extends ServiceImpl<ArticleInfoMapper, ArticleInfo> implements ArticleInfoService {
@ -51,7 +52,7 @@ public class ArticleInfoServiceImpl extends ServiceImpl<ArticleInfoMapper, Artic
articleInfo.setTitleSmall(articleInfoVo.getTitleSmall()); articleInfo.setTitleSmall(articleInfoVo.getTitleSmall());
articleInfo.setContent(articleInfoVo.getContent()); articleInfo.setContent(articleInfoVo.getContent());
articleInfo.setDoctorId(articleInfoVo.getDoctorId()); articleInfo.setDoctorId(articleInfoVo.getDoctorId());
articleInfo.setNumber(0); articleInfo.setNumber(articleInfoVo.getNumber());
articleInfoMapper.insertOrUpdate(articleInfo); articleInfoMapper.insertOrUpdate(articleInfo);
@ -59,9 +60,18 @@ public class ArticleInfoServiceImpl extends ServiceImpl<ArticleInfoMapper, Artic
graphInfo.setIsDeleted((byte) 0); graphInfo.setIsDeleted((byte) 0);
graphInfo.setItemType(GraphItemType.ARTICLE); graphInfo.setItemType(GraphItemType.ARTICLE);
graphInfo.setUrl(articleInfoVo.getUrl()); graphInfo.setUrl(articleInfoVo.getUrl());
graphInfo.setItemId(articleInfoMapper.selectOne(new QueryWrapper<ArticleInfo>().select("max(id)")).getId()); graphInfo.setItemId(articleInfo.getId());
graphInfo.setName(articleInfoVo.getName()); graphInfo.setName(articleInfoVo.getName());
graphInfoMapper.insertOrUpdate(graphInfo); graphInfoMapper.insertOrUpdate(graphInfo);
} }
@Override
public void deleteArticle(List<Long> ids) {
for (Long id : ids) {
graphInfoMapper.delete(new LambdaQueryWrapper<GraphInfo>().eq(GraphInfo::getItemId, id).eq(GraphInfo::getItemType, GraphItemType.ARTICLE));
}
articleInfoMapper.deleteByIds(ids);
}
} }

View File

@ -1,21 +1,45 @@
package com.atjy.web.admin.service.impl; package com.atjy.web.admin.service.impl;
import com.atjy.model.entity.DoctorInfo; import com.atjy.common.exception.HassleFreeException;
import com.atjy.web.admin.mapper.DoctorInfoMapper; 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.service.DoctorInfoService;
import com.atjy.web.admin.vo.doctor.DoctorInfoVo; 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.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
@Service @Service
public class DoctorInfoServiceImpl extends ServiceImpl<DoctorInfoMapper, DoctorInfo> implements DoctorInfoService { public class DoctorInfoServiceImpl extends ServiceImpl<DoctorInfoMapper, DoctorInfo> implements DoctorInfoService {
@Autowired @Autowired
private DoctorInfoMapper doctorInfoMapper; 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 @Override
public IPage<DoctorInfoVo> getDoctorPageItem(Page<DoctorInfoVo> page, String name) { public IPage<DoctorInfoVo> getDoctorPageItem(Page<DoctorInfoVo> page, String name) {
IPage<DoctorInfoVo> result; IPage<DoctorInfoVo> result;
@ -26,4 +50,50 @@ public class DoctorInfoServiceImpl extends ServiceImpl<DoctorInfoMapper, DoctorI
} }
return result; return result;
} }
@Override
public void saveOrUpdateDoctor(DoctorInfoVo doctorInfoVo) {
DoctorInfo doctorInfo = new DoctorInfo();
doctorInfo.setDepartmentId(departmentInfoMapper.selectOne(new LambdaQueryWrapper<DepartmentInfo>().eq(DepartmentInfo::getName, doctorInfoVo.getDepartmentName())).getId());
doctorInfo.setHospitalId(hospitalInfoMapper.selectOne(new LambdaQueryWrapper<HospitalInfo>().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<Long> ids) {
for (Long id : ids) {
if (doctorAppointmentMapper.selectOne(new LambdaQueryWrapper<DoctorAppointment>().eq(DoctorAppointment::getDoctorId, id)) != null) {
throw new HassleFreeException(ResultCodeEnum.DELETE_ERROR);
}
if (articleInfoMapper.selectOne(new LambdaQueryWrapper<ArticleInfo>().eq(ArticleInfo::getDoctorId, id)) != null) {
throw new HassleFreeException(ResultCodeEnum.DELETE_ERROR);
}
if (userAppointmentMapper.selectOne(new LambdaQueryWrapper<UserAppointment>().eq(UserAppointment::getDoctorId, id)) != null) {
throw new HassleFreeException(ResultCodeEnum.DELETE_ERROR);
}
}
for (Long id : ids) {
graphInfoMapper.delete(new LambdaQueryWrapper<GraphInfo>().eq(GraphInfo::getItemId, id).eq(GraphInfo::getItemType, GraphItemType.DOCTOR));
}
doctorInfoMapper.deleteByIds(ids);
}
} }

View File

@ -11,6 +11,9 @@ import java.util.Date;
@Schema(description = "医说列表实体") @Schema(description = "医说列表实体")
public class ArticleListVo { public class ArticleListVo {
@Schema(description = "阅读量")
private Integer number;
@Schema(description = "大标题") @Schema(description = "大标题")
private String titleBig; private String titleBig;

View File

@ -17,6 +17,7 @@
ai.title_big, ai.title_big,
ai.title_small, ai.title_small,
ai.publish_time, ai.publish_time,
ai.number,
ai.content, ai.content,
di.id doctor_id, di.id doctor_id,
di.doctor_name, di.doctor_name,
@ -38,6 +39,7 @@
ai.title_big, ai.title_big,
ai.title_small, ai.title_small,
ai.publish_time, ai.publish_time,
ai.number,
ai.content, ai.content,
di.id doctor_id, di.id doctor_id,
di.doctor_name, di.doctor_name,

View File

@ -24,6 +24,21 @@
<select id="getDoctorPageItemByName" resultType="com.atjy.web.admin.vo.doctor.DoctorInfoVo"> <select id="getDoctorPageItemByName" resultType="com.atjy.web.admin.vo.doctor.DoctorInfoVo">
select distinct di.id,
di.doctor_name,
di.level,
di.source,
di.appointment_number,
di.expertise,
di.briefly,
hi.hospital_name,
d.name department_name,
gi.url
from doctor_info di
join hospital_info hi on di.hospital_id = hi.id and hi.is_deleted = 0
join department_info d on di.department_id = d.id and d.is_deleted = 0
join graph_info gi on gi.item_type = 3 and gi.item_id = di.id and gi.is_deleted = 0
where di.is_deleted = 0
and di.doctor_name like '${name}'
</select> </select>
</mapper> </mapper>