集团模式修改为通俗名称:多租户、租户代码、租户名称;代码生成config.xml支持自定义,放同目录下config-custom.xml文件即可覆盖。
This commit is contained in:
@@ -41,19 +41,10 @@ import com.jeesite.modules.sys.utils.EmpUtils;
|
||||
}, extWhereKeys="dsf", orderBy="a.tree_sort, a.office_code"
|
||||
)
|
||||
public class Office extends TreeEntity<Office> {
|
||||
|
||||
/** 机构类型(0:集团) */
|
||||
public static final String TYPE_GROUP = "0";
|
||||
/** 机构类型(1:公司) */
|
||||
public static final String TYPE_COMPANY = "1";
|
||||
/** 机构类型(2:部门) */
|
||||
public static final String TYPE_DEPT = "2";
|
||||
/** 机构类型(3:小组) */
|
||||
public static final String TYPE_TEAM = "3";
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String officeCode; // 机构编码
|
||||
private String viewCode; // 机构代码(作为显示用,集团内唯一)
|
||||
private String viewCode; // 机构代码(作为显示用,多租户内唯一)
|
||||
private String officeName; // 机构名称
|
||||
private String fullName; // 机构全称
|
||||
private String officeType; // 机构类型(1:公司;2:部门;3:小组)
|
||||
@@ -195,7 +186,10 @@ public class Office extends TreeEntity<Office> {
|
||||
|
||||
/**
|
||||
* 根据类型查找上级部门
|
||||
* @param type 机构类型 0:集团TYPE_GROUP 1:公司TYPE_COMPANY 2:部门TYPE_DEPT 3:小组TYPE_TEAM
|
||||
* 1、例如当前机构类型为部门,你想获取部门所在的省公司名称
|
||||
* 2、例如当前机构类型为部门的子部门,你想获取部门所在省公司名称
|
||||
* 3、例如当前机构类型为小组,你想获取所在公司名称
|
||||
* @param type 机构类型
|
||||
* @return
|
||||
*/
|
||||
@JsonIgnore
|
||||
|
||||
@@ -25,7 +25,7 @@ public class EmpUtils {
|
||||
// public static final String CACHE_OFFICE_LIST = "officeList";
|
||||
// public static final String CACHE_COMPANY_LIST = "companyList";
|
||||
|
||||
// 集团缓存常量
|
||||
// 部门和公司缓存常量
|
||||
public static final String CACHE_OFFICE_ALL_LIST = "officeAllList";
|
||||
public static final String CACHE_COMPANY_ALL_LIST = "companyAllList";
|
||||
|
||||
|
||||
@@ -169,15 +169,7 @@ public class LoginController extends BaseController{
|
||||
|
||||
// 非授权异常,登录失败,验证码加1。
|
||||
if (!UnauthorizedException.class.getName().equals(exception)){
|
||||
// // 如果使用了集团用户模式,则获取集团Code
|
||||
// String corpCode = null;
|
||||
// if (Global.isUseCorpModel()){
|
||||
// corpCode = (String)paramMap.get("corpCode");
|
||||
// if (StringUtils.isBlank(corpCode)){
|
||||
// throw new AuthenticationException("msg:请选择您要登录的集团公司.");
|
||||
// }
|
||||
// }
|
||||
model.addAttribute("isValidCodeLogin", BaseAuthorizingRealm.isValidCodeLogin(username, /*corpCode, */(String)paramMap.get("deviceType"), "failed"));
|
||||
model.addAttribute("isValidCodeLogin", BaseAuthorizingRealm.isValidCodeLogin(username, (String)paramMap.get("deviceType"), "failed"));
|
||||
}
|
||||
|
||||
//获取当前会话对象
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.jeesite.modules.sys.service.UserService;
|
||||
import com.jeesite.modules.sys.utils.UserUtils;
|
||||
|
||||
/**
|
||||
* 集团公司管理员Controller
|
||||
* 系统管理员Controller
|
||||
* @author ThinkGem
|
||||
* @version 2017-03-26
|
||||
*/
|
||||
@@ -58,8 +58,8 @@ public class CorpAdminController extends BaseController {
|
||||
@ResponseBody
|
||||
public Page<User> listData(User user, HttpServletRequest request, HttpServletResponse response) {
|
||||
user.setUserType(User.USER_TYPE_NONE); // 仅登录用户
|
||||
user.setMgrType(User.MGR_TYPE_CORP_ADMIN); // 集团管理员
|
||||
// 禁用自动添加集团代码条件,添加自定义集团查询条件
|
||||
user.setMgrType(User.MGR_TYPE_CORP_ADMIN); // 租户管理员
|
||||
// 禁用自动添加租户代码条件,添加自定义租户查询条件
|
||||
user.getSqlMap().getWhere().disableAutoAddCorpCodeWhere()
|
||||
.and("corp_code", QueryType.EQ, user.getCorpCode_())
|
||||
.and("corp_name", QueryType.LIKE, user.getCorpName_());
|
||||
@@ -71,13 +71,13 @@ public class CorpAdminController extends BaseController {
|
||||
@RequestMapping(value = "form")
|
||||
public String form(User user, String op, Model model) {
|
||||
if (user.getIsNewRecord()){
|
||||
// 新增集团,如果已存在集团,则不能保存
|
||||
// 新增租户管理员,如果已存在,则不能保存
|
||||
if ("addCorp".equals(op)){
|
||||
user.setCorpCode_(StringUtils.EMPTY); // 归属集团Code
|
||||
user.setCorpName_(StringUtils.EMPTY); // 归属集团Name
|
||||
user.setCorpCode_(StringUtils.EMPTY); // 租户代码
|
||||
user.setCorpName_(StringUtils.EMPTY); // 租户名称
|
||||
}
|
||||
}
|
||||
// 操作类型:addCorp: 添加集团; addAdmin: 添加管理员; edit: 编辑
|
||||
// 操作类型:addCorp: 添加租户; addAdmin: 添加管理员; edit: 编辑
|
||||
model.addAttribute("op", op);
|
||||
model.addAttribute("user", user);
|
||||
return "modules/sys/user/corpAdminForm";
|
||||
@@ -97,24 +97,24 @@ public class CorpAdminController extends BaseController {
|
||||
return renderResult(Global.FALSE, "非法操作,不能够操作此用户!");
|
||||
}
|
||||
if (StringUtils.isBlank(user.getCorpCode_())){
|
||||
return renderResult(Global.FALSE, "集团编码不能为空!");
|
||||
return renderResult(Global.FALSE, "租户代码不能为空!");
|
||||
}
|
||||
if (!Global.TRUE.equals(userService.checkLoginCode(oldLoginCode, user.getLoginCode()/*, user.getCorpCode_()*/))) {
|
||||
return renderResult(Global.FALSE, "保存用户'" + user.getLoginCode() + "'失败,登录账号已存在");
|
||||
}
|
||||
user.setUserType(User.USER_TYPE_NONE); // 仅登录用户
|
||||
user.setMgrType(User.MGR_TYPE_CORP_ADMIN); // 集团管理员
|
||||
// 如果新增,则验证集团代码合法性
|
||||
user.setMgrType(User.MGR_TYPE_CORP_ADMIN); // 租户管理员
|
||||
// 如果新增,则验证租户代码合法性
|
||||
if (user.getIsNewRecord()){
|
||||
User where = new User();
|
||||
where.setCorpCode_(user.getCorpCode_());
|
||||
List<User> list = userService.findCorpList(user);
|
||||
if (list.size() > 0){
|
||||
// 新增集团,如果已存在集团,则不能保存
|
||||
// 新增租户,如果已存在,则不能保存
|
||||
if ("addCorp".equals(op)){
|
||||
return renderResult(Global.FALSE, "保存用户失败,集团编码已存在");
|
||||
return renderResult(Global.FALSE, "保存用户失败,租户代码已存在");
|
||||
}
|
||||
// 新增管理员,则使用已有的集团代码和名称
|
||||
// 新增管理员,则使用已有的租户代码和名称
|
||||
else if ("addAdmin".equals(op)){
|
||||
user.setCorpCode_(list.get(0).getCorpCode_());
|
||||
user.setCorpName_(list.get(0).getCorpName_());
|
||||
|
||||
@@ -195,7 +195,7 @@ user:
|
||||
remarks: ""
|
||||
}]
|
||||
|
||||
# 集团模式(多公司、多租户、SAAS模式)
|
||||
# 多租户模式(SAAS模式)
|
||||
useCorpModel: false
|
||||
|
||||
# 任务调度
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="box box-main">
|
||||
<div class="box-header with-border">
|
||||
<div class="box-title">
|
||||
<i class="fa fa-list-alt"></i> ${user.isNewRecord ? op == 'addCorp' ? '新增集团' : '新增管理员' : '编辑管理员'}
|
||||
<i class="fa fa-list-alt"></i> ${user.isNewRecord ? op == 'addCorp' ? '新增租户' : '新增' : '编辑'}管理员
|
||||
</div>
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
|
||||
@@ -19,9 +19,9 @@
|
||||
<div class="col-xs-6">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label" title="">
|
||||
<span class="required">*</span> 集团代码:<i class="fa icon-question hide"></i></label>
|
||||
<span class="required">*</span> 租户代码:<i class="fa icon-question hide"></i></label>
|
||||
<div class="col-sm-8">
|
||||
<#form:input path="corpCode_" placeholder="请输入集团代码" maxlength="20"
|
||||
<#form:input path="corpCode_" placeholder="请输入租户代码" maxlength="20"
|
||||
readonly="${!user.isNewRecord || op=='addAdmin'}" class="form-control abc required"/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -29,9 +29,9 @@
|
||||
<div class="col-xs-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-4" title="">
|
||||
<span class="required">*</span> 集团名称:<i class="fa icon-question hide"></i></label>
|
||||
<span class="required">*</span> 租户名称:<i class="fa icon-question hide"></i></label>
|
||||
<div class="col-sm-8">
|
||||
<#form:input path="corpName_" placeholder="请输入集团名称" maxlength="32"
|
||||
<#form:input path="corpName_" placeholder="请输入租户名称" maxlength="32"
|
||||
readonly="${!user.isNewRecord || op=='addAdmin'}" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<a href="#" class="btn btn-default" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
|
||||
<% if(hasPermi('sys:corpAdmin:edit')){ %>
|
||||
<% if(@ObjectUtils.toBoolean(@Global.getConfig('user.useCorpModel'))){ %>
|
||||
<a href="${ctx}/sys/corpAdmin/form?op=addCorp" class="btn btn-default btnTool" title="新增集团"><i class="fa fa-plus"></i> 新增集团</a>
|
||||
<a href="${ctx}/sys/corpAdmin/form?op=addCorp" class="btn btn-default btnTool" title="新增租户管理员"><i class="fa fa-plus"></i> 新增租户管理员</a>
|
||||
<% }else{ %>
|
||||
<a href="${ctx}/sys/corpAdmin/form?corpCode_=${user.currentUser.corpCode_}&corpName_=${user.currentUser.corpName_}&op=addAdmin" class="btn btn-default btnTool" title="新增管理员"><i class="fa fa-plus"></i> 新增管理员</a>
|
||||
<% } %>
|
||||
@@ -32,13 +32,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group ${@ObjectUtils.toBoolean(@Global.getConfig('user.useCorpModel'))?'':'hide'}">
|
||||
<label class="control-label">集团代码:</label>
|
||||
<label class="control-label">租户代码:</label>
|
||||
<div class="control-inline">
|
||||
<#form:input path="corpCode_" maxlength="100" class="form-control width-90"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group ${@ObjectUtils.toBoolean(@Global.getConfig('user.useCorpModel'))?'':'hide'}">
|
||||
<label class="control-label">集团名称:</label>
|
||||
<label class="control-label">租户名称:</label>
|
||||
<div class="control-inline">
|
||||
<#form:input path="corpName_" maxlength="100" class="form-control width-90"/>
|
||||
</div>
|
||||
@@ -70,10 +70,10 @@ $('#dataGrid').dataGrid({
|
||||
}},
|
||||
{header:'用户昵称', name:'userName', index:'a.user_name', width:200, align:"center"},
|
||||
<% if(@ObjectUtils.toBoolean(@Global.getConfig('user.useCorpModel'))){ %>
|
||||
{header:'集团代码', name:'corpCode_', index:'a.corp_code', width:200, align:"center", formatter: function(val, obj, row, act){
|
||||
{header:'租户代码', name:'corpCode_', index:'a.corp_code', width:200, align:"center", formatter: function(val, obj, row, act){
|
||||
return '<a href="javascript:" onclick="$(\'#corpCode_\').val(\''+val+'\');$(\'#searchForm\').submit()">'+val+'</a>';
|
||||
}},
|
||||
{header:'集团名称', name:'corpName_', index:'a.corp_name', width:200, align:"center"},
|
||||
{header:'租户名称', name:'corpName_', index:'a.corp_name', width:200, align:"center"},
|
||||
<% } %>
|
||||
{header:'电子邮箱', name:'email', index:'a.email', width:200, align:"center"},
|
||||
{header:'手机号码', name:'mobile', index:'a.mobile', width:200, align:"center"},
|
||||
|
||||
Reference in New Issue
Block a user