|
|
@@ -1,10 +1,13 @@
|
|
|
package cn.tr.module.smart.common.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.tr.core.annotation.TenantIgnore;
|
|
|
import cn.tr.core.exception.TRExcCode;
|
|
|
import cn.tr.core.strategy.LoginUserStrategy;
|
|
|
+import cn.tr.module.smart.common.po.BizHospitalPO;
|
|
|
import cn.tr.module.smart.common.po.BizWxUserHospitalPO;
|
|
|
+import cn.tr.module.smart.common.repository.BizHospitalRepository;
|
|
|
import cn.tr.module.smart.common.repository.BizWxUserHospitalRepository;
|
|
|
import cn.tr.module.smart.wx.controller.vo.BizWxUserBindHospitalVO;
|
|
|
import cn.tr.module.sys.user.service.ISysUserService;
|
|
|
@@ -26,6 +29,9 @@ import cn.tr.module.smart.common.dto.BizWxUserQueryDTO;
|
|
|
import java.util.*;
|
|
|
import cn.tr.module.smart.common.service.IBizWxUserService;
|
|
|
import cn.tr.module.smart.common.mapper.BizWxUserMapper;
|
|
|
+
|
|
|
+import javax.annotation.Resources;
|
|
|
+
|
|
|
/**
|
|
|
* 微信用户Service接口实现类
|
|
|
*
|
|
|
@@ -43,6 +49,9 @@ public class BizWxUserServiceImpl implements IBizWxUserService {
|
|
|
@Autowired
|
|
|
private ISysUserService sysUserService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BizHospitalRepository hospitalRepository;
|
|
|
+
|
|
|
/**
|
|
|
* 根据条件查询微信用户
|
|
|
* @param query 查询参数
|
|
|
@@ -163,4 +172,25 @@ public class BizWxUserServiceImpl implements IBizWxUserService {
|
|
|
baseRepository.updateById(wxUserPO);
|
|
|
sysUserService.delUserIdAndNickNameCache();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void bindHospital(String currentUserId, String hospitalId) {
|
|
|
+ //判断医院是否存在
|
|
|
+ BizHospitalPO hospital = hospitalRepository.selectById(hospitalId);
|
|
|
+ if(ObjectUtil.isEmpty(hospital)){
|
|
|
+ throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"医院不存在");
|
|
|
+ }
|
|
|
+ BizWxUserHospitalPO bizWxUserHospital = wxUserHospitalRepository.selectOne(new LambdaQueryWrapper<BizWxUserHospitalPO>()
|
|
|
+ .eq(BizWxUserHospitalPO::getWxUserId, currentUserId)
|
|
|
+ .eq(BizWxUserHospitalPO::getTenantId, hospital)
|
|
|
+ .last("limit 1"));
|
|
|
+ if(ObjectUtil.isNotEmpty(bizWxUserHospital)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BizWxUserHospitalPO insertSource = new BizWxUserHospitalPO();
|
|
|
+ insertSource.setWxUserId(currentUserId);
|
|
|
+ insertSource.setTenantId(hospitalId);
|
|
|
+ wxUserHospitalRepository.insert(insertSource);
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|