|
@ -1,10 +1,19 @@
|
|
|
package com.yihu.jw.base.service.user;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
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.util.ConstantUtils;
|
|
|
import com.yihu.jw.base.util.JavaBeanUtils;
|
|
|
import com.yihu.jw.entity.base.org.BaseOrgUserDO;
|
|
|
import com.yihu.jw.entity.base.role.RoleDO;
|
|
|
import com.yihu.jw.entity.base.saas.SaasDO;
|
|
|
import com.yihu.jw.entity.base.user.UserDO;
|
|
@ -12,13 +21,16 @@ import com.yihu.mysql.query.BaseJpaService;
|
|
|
import com.yihu.utils.security.MD5;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Service - 后台管理员
|
|
@ -145,82 +157,84 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> findUserBaseInfo(String id) {
|
|
|
public Map<String, Object> findUserBaseInfo(String id) throws Exception {
|
|
|
|
|
|
Map<String, Object> userinfo = new HashedMap();
|
|
|
|
|
|
UserDO user = userDao.findOne(id);
|
|
|
RoleDO role = roleDao.findByCode(user.getRoleCode());
|
|
|
|
|
|
userinfo.put("id", user.getId());
|
|
|
userinfo.put("name", user.getName());
|
|
|
userinfo.put("role", role.getName());
|
|
|
userinfo.put("roleCode", role.getCode());
|
|
|
userinfo.put("system", role.getSystem());
|
|
|
if(user!=null){
|
|
|
userinfo.put("id",user.getId());
|
|
|
userinfo.put("name",user.getName());
|
|
|
if (user != null) {
|
|
|
userinfo.put("id", user.getId());
|
|
|
userinfo.put("name", user.getName());
|
|
|
}
|
|
|
|
|
|
//获取角色
|
|
|
RoleDO role = roleDao.findOne(user.getRoleCode());
|
|
|
if(role!=null){
|
|
|
userinfo.put("role",role.getId());
|
|
|
userinfo.put("roleCode",role.getCode());
|
|
|
userinfo.put("system",role.getSystem());
|
|
|
|
|
|
if ("admin".equals(role.getCode())) {
|
|
|
if("admin".equals(role.getCode())){
|
|
|
|
|
|
} else if ("saasAdmin".equals(role.getCode())) {
|
|
|
}else if("saasAdmin".equals(role.getCode())){
|
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(user.getId())) {
|
|
|
SaasDO saas = saasDao.findOne(user.getSaasId());
|
|
|
Map<String, Object> ss = new HashedMap();
|
|
|
ss.put("id", saas.getId());
|
|
|
ss.put("name", saas.getName());
|
|
|
userinfo.put("saas", ss);
|
|
|
}
|
|
|
if(org.apache.commons.lang3.StringUtils.isNotBlank(user.getId())){
|
|
|
SaasDO saas = saasDao.findOne(user.getSaasId());
|
|
|
Map<String,Object> ss = new HashedMap();
|
|
|
ss.put("id",saas.getId());
|
|
|
ss.put("name",saas.getName());
|
|
|
userinfo.put("saas",ss);
|
|
|
}
|
|
|
if (role != null) {
|
|
|
userinfo.put("role", role.getId());
|
|
|
userinfo.put("roleCode", role.getCode());
|
|
|
userinfo.put("system", role.getSystem());
|
|
|
|
|
|
if ("admin".equals(role.getCode())) {
|
|
|
if ("admin".equals(role.getCode())) {
|
|
|
|
|
|
} else if ("saasAdmin".equals(role.getCode())) {
|
|
|
} else if ("saasAdmin".equals(role.getCode())) {
|
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(user.getId())) {
|
|
|
SaasDO saas = saasDao.findOne(user.getSaasId());
|
|
|
Map<String, Object> ss = new HashedMap();
|
|
|
ss.put("id", saas.getId());
|
|
|
ss.put("name", saas.getName());
|
|
|
userinfo.put("saas", ss);
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(user.getId())) {
|
|
|
SaasDO saas = saasDao.findOne(user.getSaasId());
|
|
|
Map<String, Object> ss = new HashedMap();
|
|
|
ss.put("id", saas.getId());
|
|
|
ss.put("name", saas.getName());
|
|
|
userinfo.put("saas", ss);
|
|
|
}
|
|
|
|
|
|
|
|
|
}else if("hosAdmin".equals(role.getCode())){
|
|
|
String sql = "SELECT " +
|
|
|
" g.code AS orgCode, " +
|
|
|
" g.province_code AS provinceCode, " +
|
|
|
" g.province_name AS privinceName, " +
|
|
|
" g.city_code AS cityCode, " +
|
|
|
" g.city_name AS cityName, " +
|
|
|
" g.town_code AS townCode, " +
|
|
|
" g.town_name AS townName, " +
|
|
|
" g.street_code AS streetCode, " +
|
|
|
" g.street_name AS streetName, " +
|
|
|
" g.name, " +
|
|
|
" address " +
|
|
|
" FROM " +
|
|
|
" base_org g " +
|
|
|
" JOIN base_org_user u ON g.`code` = u.org_code " +
|
|
|
" WHERE " +
|
|
|
" u.user_id = '"+id+"'";
|
|
|
List<Map<String,Object>> org = jdbcTemplate.queryForList(sql);
|
|
|
if(org!=null&&org.size()>0){
|
|
|
userinfo.put("org",org.get(0));
|
|
|
}else{
|
|
|
userinfo.put("org",null);
|
|
|
}
|
|
|
} else if ("hosAdmin".equals(role.getCode())) {
|
|
|
String sql = "SELECT " +
|
|
|
" g.code AS orgCode, " +
|
|
|
" g.province_code AS provinceCode, " +
|
|
|
" g.province_name AS privinceName, " +
|
|
|
" g.city_code AS cityCode, " +
|
|
|
" g.city_name AS cityName, " +
|
|
|
" g.town_code AS townCode, " +
|
|
|
" g.town_name AS townName, " +
|
|
|
" g.street_code AS streetCode, " +
|
|
|
" g.street_name AS streetName, " +
|
|
|
" g.name, " +
|
|
|
" address " +
|
|
|
" FROM " +
|
|
|
" base_org g " +
|
|
|
" JOIN base_org_user u ON g.`code` = u.org_code " +
|
|
|
" WHERE " +
|
|
|
" u.user_id = '" + id + "'";
|
|
|
List<Map<String, Object>> org = jdbcTemplate.queryForList(sql);
|
|
|
if (org != null && org.size() > 0) {
|
|
|
userinfo.put("org", org.get(0));
|
|
|
} else {
|
|
|
userinfo.put("org", null);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return userinfo;
|
|
|
return userinfo;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 创建用户
|
|
|
*
|