From 3bcfe18babcdb44a4c3e030859d79cd7ad1863cf Mon Sep 17 00:00:00 2001 From: anxin Date: Mon, 24 Feb 2025 17:03:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=BA=E6=9E=84organization=E6=96=B0?= =?UTF-8?q?=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/OrganizationController.java | 117 ++++++++++++++++++ .../service/IOrganizationService.java | 7 +- .../service/impl/OrganizationServiceImpl.java | 40 +++++- 3 files changed, 158 insertions(+), 6 deletions(-) create mode 100644 openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/OrganizationController.java diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/OrganizationController.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/OrganizationController.java new file mode 100644 index 00000000..5b9a8c25 --- /dev/null +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/OrganizationController.java @@ -0,0 +1,117 @@ +/* + * Copyright ©2023 CJB-CNIT Team. All rights reserved + */ +package com.openhis.web.basedatamanage.controller; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.core.common.core.domain.R; +import com.core.common.enums.AssignSeqEnum; +import com.core.common.utils.AssignSeqUtil; +import com.core.common.utils.MessageUtils; +import com.openhis.administration.domain.Organization; +import com.openhis.administration.service.IOrganizationService; +import com.openhis.common.constant.PromptMsgConstant; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +/** + * 机构管理(科室)controller + * + * @author + * @date 2025-02-21 + */ +@RestController +@RequestMapping("/basedatamanage/organization") +@Slf4j +@AllArgsConstructor +public class OrganizationController { + + private final IOrganizationService organizationService; + + @Autowired(required = false) + private AssignSeqUtil assignSeqUtil; + + /** + * 添加科室信息 + * + * @param organization 科室信息 + */ + @PostMapping("/organization") + public R addOrganization(@Validated @RequestBody Organization organization) { + + // 新增organization信息 + // Organization organization = new Organization(); + // BeanUtils.copyProperties(organizationdto, organization); + + // 基础采番 + String code = assignSeqUtil.getSeq(AssignSeqEnum.TEST.getPrefix()); + organization.setBus_no(code); + + boolean saveOrganizationSuccess = organizationService.save(organization); + + return saveOrganizationSuccess + ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00001, new Object[] {"科室信息"})) + : R.fail(PromptMsgConstant.Common.M00007, null); + } + + /** + * 编辑科室信息 + * + * @param organization 科室信息 + */ + @PutMapping("/organization") + public R editOrganization(@Validated @RequestBody Organization organization) { + // 更新organization信息 + // Organization organization = new Organization(); + // BeanUtils.copyProperties(organizationdto, organization); + + boolean updateSuccess = organizationService.updateById(organization); + return updateSuccess + ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[] {"科室信息"})) + : R.fail(PromptMsgConstant.Common.M00007, null); + } + + /** + * 删除科室信息 + * + * @param orgId 主表id + */ + @DeleteMapping("/organization") + public R deleteSupplyRequest(@RequestParam Long orgId) { + + boolean deleteSuccess = organizationService.removeById(orgId); + + return deleteSuccess + ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00005, new Object[] {"科室信息"})) + : R.fail(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00006, new Object[] {"科室信息删除失败"})); + } + + /** + * 科室分页列表 + * + * @param classEnum 机构分类枚举 + * @param activeFlag 活动标识 + * @param pageNo 当前页码 + * @param pageSize 查询条数 + * @param request 请求数据 + * @return 科室分页列表 + */ + @GetMapping(value = "/organization") + public R getOrganizationPage(Integer classEnum, Integer activeFlag, + @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) { + + // 查询【科室】分页列表 + Page organizationPage = + organizationService.getOrganizationPage(classEnum, activeFlag, pageNo, pageSize); + return R.ok(organizationPage); + } + +} diff --git a/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/IOrganizationService.java b/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/IOrganizationService.java index a64cc4ed..c9853467 100644 --- a/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/IOrganizationService.java +++ b/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/IOrganizationService.java @@ -1,14 +1,15 @@ package com.openhis.administration.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.openhis.administration.domain.Organization; /** - * 机构管理Service接口 + * 机构管理(科室)Service接口 * * @author system - * @date 2025-02-20 + * @date 2025-02-21 */ public interface IOrganizationService extends IService { - + Page getOrganizationPage(Integer classEnum,Integer activeFlag, Integer pageNo, Integer pageSize); } \ No newline at end of file diff --git a/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/impl/OrganizationServiceImpl.java b/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/impl/OrganizationServiceImpl.java index e97a117c..4586afbc 100644 --- a/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/impl/OrganizationServiceImpl.java +++ b/openhis-server/openhis-domain/src/main/java/com/openhis/administration/service/impl/OrganizationServiceImpl.java @@ -1,19 +1,53 @@ package com.openhis.administration.service.impl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.openhis.administration.domain.Organization; import com.openhis.administration.mapper.OrganizationMapper; import com.openhis.administration.service.IOrganizationService; +import com.openhis.common.enums.DelFlag; /** - * 机构管理Service业务层处理 + * 机构管理(科室)Service业务层处理 * * @author system - * @date 2025-02-20 + * @date 2025-02-21 */ @Service -public class OrganizationServiceImpl extends ServiceImpl implements IOrganizationService { +public class OrganizationServiceImpl extends ServiceImpl + implements IOrganizationService { + + @Autowired + private OrganizationMapper organizationMapper; + + /** + * 查询科室列表 + * + * @param classEnum 机构分类枚举 + * @param activeFlag 活动标识 + * @return 科室列表 + */ + @Override + public Page getOrganizationPage(Integer classEnum,Integer activeFlag, Integer pageNo, Integer pageSize) { + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + + if (classEnum != null) { + queryWrapper.eq(Organization::getTypeEnum, classEnum); + } + + if (activeFlag != null) { + queryWrapper.eq(Organization::getTypeEnum, activeFlag); + } + + Page organizationPage = organizationMapper.selectPage(new Page<>(pageNo, pageSize), queryWrapper); + + // 返回科室信息列表 + return organizationPage; + } } \ No newline at end of file