|
@@ -6,16 +6,17 @@ import com.diagbot.dto.RespDTO;
|
|
|
import com.diagbot.entity.JWT;
|
|
|
import com.diagbot.entity.Organization;
|
|
|
import com.diagbot.entity.User;
|
|
|
+import com.diagbot.entity.UserAuthentication;
|
|
|
import com.diagbot.entity.UserOrganization;
|
|
|
import com.diagbot.entity.UserRole;
|
|
|
import com.diagbot.entity.wrapper.MenuWrapper;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.exception.ServiceErrorCode;
|
|
|
-import com.diagbot.mapper.MenuMapper;
|
|
|
-import com.diagbot.mapper.OrganizationMapper;
|
|
|
-import com.diagbot.mapper.UserOrganizationMapper;
|
|
|
-import com.diagbot.mapper.UserRoleMapper;
|
|
|
+import com.diagbot.service.MenuService;
|
|
|
+import com.diagbot.service.OrganizationService;
|
|
|
+import com.diagbot.service.UserOrganizationService;
|
|
|
+import com.diagbot.service.UserRoleService;
|
|
|
import com.diagbot.service.impl.UserServiceImpl;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
@@ -52,13 +53,13 @@ public class UserFacade extends UserServiceImpl {
|
|
|
@Autowired
|
|
|
VerFacade verFacade;
|
|
|
@Autowired
|
|
|
- OrganizationMapper organizationMapper;
|
|
|
+ OrganizationService organizationService;
|
|
|
@Autowired
|
|
|
- UserOrganizationMapper userOrganizationMapper;
|
|
|
+ UserOrganizationService userOrganizationService;
|
|
|
@Autowired
|
|
|
- UserRoleMapper userRoleMapper;
|
|
|
+ UserRoleService userRoleService;
|
|
|
@Autowired
|
|
|
- MenuMapper menuMapper;
|
|
|
+ MenuService menuService;
|
|
|
|
|
|
public User createUser(UserSaveVO userSaveVO){
|
|
|
User user = new User();
|
|
@@ -76,23 +77,34 @@ public class UserFacade extends UserServiceImpl {
|
|
|
PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
|
|
|
String entryPassword= passwordEncoder.encode(user.getPassword());
|
|
|
user.setPassword(entryPassword);
|
|
|
-// this.save(user);
|
|
|
+ this.save(user);
|
|
|
|
|
|
// 机构相关业务
|
|
|
doOrganization(userSaveVO, user);
|
|
|
|
|
|
//权限相关业务
|
|
|
doPermisson(userSaveVO, user);
|
|
|
+
|
|
|
+ //用户认证业务
|
|
|
+ doUserAuthentication(userSaveVO, user);
|
|
|
return user;
|
|
|
}
|
|
|
|
|
|
+ //添加一条默认用户认证信息
|
|
|
+ public void doUserAuthentication(UserSaveVO userSaveVO, User user) {
|
|
|
+ UserAuthentication ua = new UserAuthentication();
|
|
|
+ ua.setGmtCreate(new Date());
|
|
|
+ ua.setUserId(user.getId());
|
|
|
+// userAuthenticationService.save(ua);
|
|
|
+ }
|
|
|
+
|
|
|
//如果机构已存在,只要添加用户与机构的映射即可;如果机构不存在,先添加机构信息
|
|
|
public void doPermisson(UserSaveVO userSaveVO, User user) {
|
|
|
UserRole userRole = new UserRole();
|
|
|
userRole.setUserId(user.getId());
|
|
|
userRole.setRoleId(1L);
|
|
|
userRole.setGmtCreate(new Date());
|
|
|
- userRoleMapper.insert(userRole);
|
|
|
+ userRoleService.save(userRole);
|
|
|
}
|
|
|
|
|
|
//如果机构已存在,只要添加用户与机构的映射即可;如果机构不存在,先添加机构信息
|
|
@@ -101,12 +113,12 @@ public class UserFacade extends UserServiceImpl {
|
|
|
String name = userSaveVO.getOrganization();
|
|
|
paramMap.put("name", name);
|
|
|
Long orgId = 0L;
|
|
|
- List<Organization> list = organizationMapper.selectByMap(paramMap);
|
|
|
+ List<Organization> list = organizationService.selectByMap(paramMap);
|
|
|
if(ListUtil.isEmpty(list)) {
|
|
|
Organization org = new Organization();
|
|
|
org.setName(name);
|
|
|
org.setGmtCreate(new Date());
|
|
|
- organizationMapper.insert(org);
|
|
|
+ organizationService.save(org);
|
|
|
orgId = org.getId();
|
|
|
} else {
|
|
|
orgId = list.get(0).getId();
|
|
@@ -114,7 +126,7 @@ public class UserFacade extends UserServiceImpl {
|
|
|
Map paramMap1 = new HashMap();
|
|
|
paramMap1.put("organization_id", orgId);
|
|
|
paramMap1.put("is_deleted", "N");
|
|
|
- List<UserOrganization> res1 = userOrganizationMapper.selectByMap(paramMap1);
|
|
|
+ List<UserOrganization> res1 = userOrganizationService.selectByMap(paramMap1);
|
|
|
if(ListUtil.isNotEmpty(res1)) {
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该机构下已存在用户,不能再添加别的用户!");
|
|
|
}
|
|
@@ -124,7 +136,7 @@ public class UserFacade extends UserServiceImpl {
|
|
|
userOrganization.setUserId(user.getId());
|
|
|
userOrganization.setOrganizationId(orgId);
|
|
|
userOrganization.setGmtCreate(new Date());
|
|
|
- userOrganizationMapper.insert(userOrganization);
|
|
|
+ userOrganizationService.save(userOrganization);
|
|
|
}
|
|
|
|
|
|
//@Cacheable(value = "UserName", key = "'username:'+#p0")
|
|
@@ -152,10 +164,10 @@ public class UserFacade extends UserServiceImpl {
|
|
|
//添加token
|
|
|
loginDTO.setToken(jwt.getAccess_token());
|
|
|
//添加机构信息
|
|
|
- Organization org = organizationMapper.getByUserId(user.getId());
|
|
|
+ Organization org = organizationService.getById(user.getId());
|
|
|
loginDTO.setOrganization(org);
|
|
|
//添加菜单信息
|
|
|
- List<MenuWrapper> menuList = menuMapper.getByRole(user.getId());
|
|
|
+ List<MenuWrapper> menuList = menuService.getByRole(user.getId());
|
|
|
getMenuStruct(menuList);
|
|
|
loginDTO.setMenuWrappers(menuList);
|
|
|
return RespDTO.onSuc(loginDTO);
|
|
@@ -173,7 +185,7 @@ public class UserFacade extends UserServiceImpl {
|
|
|
}
|
|
|
|
|
|
public List<MenuWrapper> recursion(MenuWrapper m) {
|
|
|
- List<MenuWrapper> subMenu = menuMapper.getSubMenuById(m.getId());
|
|
|
+ List<MenuWrapper> subMenu = menuService.getSubMenuById(m.getId());
|
|
|
for (MenuWrapper sub : subMenu) {
|
|
|
sub.setSubMenuList(recursion(sub));
|
|
|
}
|