New file |
| | |
| | | package com.kidgrow.usercenter.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.model.SysOrganization; |
| | | import com.kidgrow.common.service.impl.SuperServiceImpl; |
| | | import com.kidgrow.usercenter.mapper.SysDepartmentMapper; |
| | | import com.kidgrow.usercenter.model.SysDepartment; |
| | | import com.kidgrow.usercenter.model.SysHospital; |
| | | import com.kidgrow.usercenter.service.ISysDepartmentService; |
| | | import com.kidgrow.usercenter.service.ISysHospitalService; |
| | | import com.kidgrow.usercenter.service.ISysOrganizationService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * @Description: 科室表<br> |
| | | * @Project: 用户中心<br> |
| | | * @CreateDate: Created in 2020-04-02 14:02:50 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | * @version 1.0 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class SysDepartmentServiceImpl extends SuperServiceImpl<SysDepartmentMapper, SysDepartment> implements ISysDepartmentService { |
| | | |
| | | @Autowired |
| | | private ISysOrganizationService iSysOrganizationService; |
| | | @Autowired |
| | | private ISysHospitalService iSysHospitalService; |
| | | /** |
| | | * 列表 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<SysDepartment> findList(Map<String, Object> params){ |
| | | Page<SysDepartment> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | List<SysDepartment> list = baseMapper.findList(page, params); |
| | | return PageResult.<SysDepartment>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | | * 根据SysDepartment对象当做查询条件进行查询 |
| | | * @param sysDepartment |
| | | * @return SysDepartment |
| | | */ |
| | | @Override |
| | | public SysDepartment findByObject(SysDepartment sysDepartment){ |
| | | return baseMapper.findByObject(sysDepartment); |
| | | } |
| | | |
| | | @Override |
| | | public ResultBody findAll(Map<String, Object> params) { |
| | | return ResultBody.ok().data(baseMapper.selectByMap(params)); |
| | | } |
| | | |
| | | @Override |
| | | public ResultBody findListByHospitalId(Map<String, Object> params) { |
| | | //查询组织 |
| | | Long id = MapUtils.getLong(params, "id"); |
| | | List<SysDepartment> sysDepartments=new ArrayList<>(); |
| | | SysHospital byId = iSysHospitalService.getById(id); |
| | | if(byId!=null){ |
| | | params=new HashMap<>(); |
| | | params.put("org_parent_id",byId.getOrgId()); |
| | | List<SysOrganization> sysOrganizations = iSysOrganizationService.listByMap(params); |
| | | if (sysOrganizations.size()>0) { |
| | | List<Long> collect = sysOrganizations.stream().map(e -> e.getId()).collect(Collectors.toList()); |
| | | QueryWrapper<SysDepartment> queryWrapper=new QueryWrapper(); |
| | | queryWrapper.in("org_id",collect ); |
| | | sysDepartments= baseMapper.selectList(queryWrapper); |
| | | } |
| | | } |
| | | return ResultBody.ok().data(sysDepartments); |
| | | } |
| | | |
| | | @Override |
| | | public String checkDepartmentName(Long hosId, String departmentName) { |
| | | String departName=baseMapper.checkDepartmentName(hosId,departmentName); |
| | | return departName; |
| | | } |
| | | } |