|
@@ -4,12 +4,17 @@ import com.diagbot.client.AuthServiceClient;
|
|
|
import com.diagbot.dto.LoginDTO;
|
|
|
import com.diagbot.dto.RespDTO;
|
|
|
import com.diagbot.entity.JWT;
|
|
|
+import com.diagbot.entity.Organization;
|
|
|
import com.diagbot.entity.User;
|
|
|
+import com.diagbot.entity.UserOrganization;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.exception.ServiceErrorCode;
|
|
|
+import com.diagbot.mapper.OrganizationMapper;
|
|
|
+import com.diagbot.mapper.UserOrganizationMapper;
|
|
|
import com.diagbot.service.impl.UserServiceImpl;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.util.UserUtils;
|
|
|
import com.diagbot.vo.ImgVerVerVO;
|
|
@@ -24,6 +29,9 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @Description: 用户业务层
|
|
@@ -39,6 +47,10 @@ public class UserFacade extends UserServiceImpl {
|
|
|
AuthServiceClient authServiceClient;
|
|
|
@Autowired
|
|
|
VerFacade verFacade;
|
|
|
+ @Autowired
|
|
|
+ OrganizationMapper organizationMapper;
|
|
|
+ @Autowired
|
|
|
+ UserOrganizationMapper userOrganizationMapper;
|
|
|
|
|
|
public User createUser(UserSaveVO userSaveVO){
|
|
|
User user = new User();
|
|
@@ -56,7 +68,25 @@ public class UserFacade extends UserServiceImpl {
|
|
|
String entryPassword= passwordEncoder.encode(user.getPassword());
|
|
|
user.setPassword(entryPassword);
|
|
|
this.save(user);
|
|
|
- //TODO 添加机构信息
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
+ String name = userSaveVO.getOrganization();
|
|
|
+ paramMap.put("name", name);
|
|
|
+ Long orgId = 0L;
|
|
|
+ List<Organization> list = organizationMapper.selectByMap(paramMap);
|
|
|
+ if(ListUtil.isEmpty(list)) {
|
|
|
+ Organization org = new Organization();
|
|
|
+ org.setName(name);
|
|
|
+ org.setGmtCreate(new Date());
|
|
|
+ organizationMapper.insert(org);
|
|
|
+ orgId = org.getId();
|
|
|
+ } else {
|
|
|
+ orgId = list.get(0).getId();
|
|
|
+ }
|
|
|
+ UserOrganization userOrganization = new UserOrganization();
|
|
|
+ userOrganization.setUserId(user.getId());
|
|
|
+ userOrganization.setOrganizationId(orgId);
|
|
|
+ userOrganization.setGmtCreate(new Date());
|
|
|
+ userOrganizationMapper.insert(userOrganization);
|
|
|
return user;
|
|
|
}
|
|
|
|
|
@@ -82,6 +112,8 @@ public class UserFacade extends UserServiceImpl {
|
|
|
LoginDTO loginDTO=new LoginDTO();
|
|
|
loginDTO.setUser(user);
|
|
|
loginDTO.setToken(jwt.getAccess_token());
|
|
|
+ Organization org = organizationMapper.getByUserId(user.getId());
|
|
|
+ loginDTO.setOrganization(org);
|
|
|
return RespDTO.onSuc(loginDTO);
|
|
|
}
|
|
|
|