|
|
@@ -20,7 +20,6 @@ import com.nb.common.crud.BaseService;
|
|
|
import com.nb.common.websocket.event.DisConnectedEvent;
|
|
|
import com.nb.core.enums.StatusEnum;
|
|
|
import com.nb.core.exception.CustomException;
|
|
|
-import com.nb.core.sms.SmsHelper;
|
|
|
import com.nb.im.entity.ImMsgEntity;
|
|
|
import com.nb.im.entity.ImRoomEntity;
|
|
|
import com.nb.im.enums.ImMsgType;
|
|
|
@@ -31,9 +30,11 @@ import com.nb.im.room.ImRoomOperatorManager;
|
|
|
import com.nb.im.service.LocalImRoomService;
|
|
|
import com.nb.im.utils.ImUtils;
|
|
|
import com.nb.im.ws.PubMsgInfo;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.context.event.EventListener;
|
|
|
+import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.tio.core.ChannelContext;
|
|
|
@@ -43,6 +44,7 @@ import org.tio.websocket.starter.TioWebSocketServerBootstrap;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.stream.Collectors;
|
|
|
import static com.nb.core.Constants.LOGIN_USER_KEY;
|
|
|
/**
|
|
|
@@ -53,6 +55,7 @@ import static com.nb.core.Constants.LOGIN_USER_KEY;
|
|
|
* @createTime 2022年08月09日 21:24:00
|
|
|
*/
|
|
|
@Component
|
|
|
+@Slf4j
|
|
|
public class LocalAppDoctorUserService extends BaseService<AppDoctorUserMapper, AppDoctorUserEntity,String> implements IAppDoctorUserClient {
|
|
|
|
|
|
@Autowired
|
|
|
@@ -74,6 +77,24 @@ public class LocalAppDoctorUserService extends BaseService<AppDoctorUserMapper,
|
|
|
@Autowired
|
|
|
TioWebSocketServerBootstrap serverBootstrap;
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean saveBatch(Collection<AppDoctorUserEntity> entityList, int batchSize) {
|
|
|
+ try {
|
|
|
+ return super.saveBatch(entityList, batchSize);
|
|
|
+ }catch (DuplicateKeyException e){
|
|
|
+ throw new CustomException(String.format("新增账户用户名不可重复,{%s}",e.getMessage()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean save(AppDoctorUserEntity entity) {
|
|
|
+ try {
|
|
|
+ return super.save(entity);
|
|
|
+ }catch (DuplicateKeyException e){
|
|
|
+ throw new CustomException(String.format("用户名{%s}已存在,不可重复添加",entity.getUsername()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void validateBeforeSave(AppDoctorUserEntity entity) {
|
|
|
if(StrUtil.isEmpty(entity.getUsername())){
|
|
|
@@ -86,15 +107,23 @@ public class LocalAppDoctorUserService extends BaseService<AppDoctorUserMapper,
|
|
|
entity.setPassword(SecurityUtil.encryptPassword(entity.getPassword()));
|
|
|
}
|
|
|
String username = entity.getUsername();
|
|
|
- AppDoctorUserEntity doctor = this.getOne(new QueryWrapper<AppDoctorUserEntity>()
|
|
|
- .lambda().eq(AppDoctorUserEntity::getUsername, username)
|
|
|
- .last("limit 1"));
|
|
|
- if(entity.getStatus()==null){
|
|
|
- entity.setStatus(StatusEnum.YES);
|
|
|
- }
|
|
|
- if(doctor!=null){
|
|
|
- throw new CustomException(String.format("用户名{%s}已存在,不可重复添加",username));
|
|
|
+ try {
|
|
|
+ AppDoctorUserEntity doctor = CompletableFuture.supplyAsync(()->
|
|
|
+ this.getOne(new QueryWrapper<AppDoctorUserEntity>()
|
|
|
+ .lambda().eq(AppDoctorUserEntity::getUsername, username)
|
|
|
+ .last("limit 1"))
|
|
|
+ ).get();
|
|
|
+ if(entity.getStatus()==null){
|
|
|
+ entity.setStatus(StatusEnum.YES);
|
|
|
+ }
|
|
|
+ if(doctor!=null){
|
|
|
+ throw new CustomException(String.format("用户名{%s}已存在,不可重复添加",username));
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("新增医院账号时发生故障,",e.getMessage());
|
|
|
+ throw new CustomException("系统繁忙,请稍后再试");
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|