|
@ -8,10 +8,7 @@ import com.yihu.jw.base.dao.role.BaseRoleMenuDao;
|
|
|
import com.yihu.jw.base.dao.role.RoleDao;
|
|
|
import com.yihu.jw.base.dao.saas.SaasDao;
|
|
|
import com.yihu.jw.base.dao.user.UserDao;
|
|
|
import com.yihu.jw.base.service.org.BaseOrgSaasService;
|
|
|
import com.yihu.jw.base.service.org.BaseOrgUserService;
|
|
|
import com.yihu.jw.base.service.org.OrgTree;
|
|
|
import com.yihu.jw.base.service.org.OrgTreeService;
|
|
|
import com.yihu.jw.base.service.org.*;
|
|
|
import com.yihu.jw.base.util.ConstantUtils;
|
|
|
import com.yihu.jw.base.util.JavaBeanUtils;
|
|
|
import com.yihu.jw.entity.base.org.BaseOrgUserDO;
|
|
@ -486,6 +483,42 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 租户只能给用户归属到自己租户底下的机构
|
|
|
* 机构管理员只能属于一个租户,增加社区树
|
|
|
* @param saasid
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject orgChoiceInfo(String saasid,String userId,String roleId) throws IOException {
|
|
|
JSONObject result = new JSONObject();
|
|
|
List<OrgTree> orgList = new ArrayList<>();
|
|
|
// 有归属租户加载saas底下的所有机构树列表,角色为机构管理员时不需要选管理机构
|
|
|
if(!StringUtils.isEmpty(saasid) && !StringUtils.endsWithIgnoreCase(RoleDO.BaseRoleType.admin.toString(),roleId)){
|
|
|
StringBuilder sql = new StringBuilder("SELECT tree.* FROM org_tree tree, base_org org, base_org_saas saas WHERE org.code = saas.org_code and 'null'= '{saasid}';");
|
|
|
// StringBuilder sql = new StringBuilder("SELECT tree.* FROM base_org base , org_tree tree WHERE base.`code` = tree.code ");
|
|
|
orgList = jdbcTemplate.query(sql.toString().replace("{saasid}","null"),new BeanPropertyRowMapper(OrgTree.class));
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(userId)){// 用户不为空表示修改,需要筛选出用户已经选择过的机构,设置checked为true
|
|
|
Set<String> codeSet = baseOrgUserService.findorgCodeListByUserId(userId);
|
|
|
orgList.forEach( one -> {
|
|
|
if(codeSet.contains(one.getCode())){
|
|
|
one.setChecked(true);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if(!CollectionUtils.isEmpty(orgList)){
|
|
|
String tree = orgTreeService.makeTree(orgList,false,true);
|
|
|
result.put("msg",objectMapper.readValue(tree,JSONArray.class));
|
|
|
}else{
|
|
|
result.put("msg",orgList);
|
|
|
}
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 用户修改密码
|
|
|
* @param userId
|
|
@ -620,6 +653,32 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 生效或失效单个用户
|
|
|
* @param userId
|
|
|
* @param lock
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject enableOrDisable(String userId,boolean lock){
|
|
|
JSONObject result = new JSONObject();
|
|
|
if(StringUtils.isEmpty(userId) || StringUtils.isEmpty(lock)){
|
|
|
result.put("msg","parameter id or del is null");
|
|
|
result.put("response",ConstantUtils.FAIL);
|
|
|
return result;
|
|
|
}
|
|
|
UserDO user = userDao.findOne(userId);
|
|
|
if( null == user ){
|
|
|
result.put("msg","user not exist for id:" + userId);
|
|
|
result.put("response",ConstantUtils.FAIL);
|
|
|
return result;
|
|
|
}
|
|
|
user.setEnabled(lock);
|
|
|
this.save(user);
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 用户信息列表
|
|
|
* @param name
|