增加多租户的功能

This commit is contained in:
季圣华
2019-06-27 18:01:08 +08:00
parent a6223e57db
commit 97111a9c82
16 changed files with 1632 additions and 45 deletions

View File

@@ -1655,4 +1655,26 @@ where Type = 'RoleFunctions' and KeyId = '10';
-- ---------------------------- -- ----------------------------
drop table jsh_asset; drop table jsh_asset;
drop table jsh_assetcategory; drop table jsh_assetcategory;
drop table jsh_assetname; drop table jsh_assetname;
-- ----------------------------
-- 时间2019年6月27日
-- 增加租户表
-- ----------------------------
DROP TABLE IF EXISTS `jsh_tenant`;
CREATE TABLE `jsh_tenant` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`tenant_id` bigint(20) DEFAULT NULL COMMENT '用户id',
`login_name` varchar(255) DEFAULT NULL COMMENT '登录名',
`user_num_limit` int(11) DEFAULT NULL COMMENT '用户数量限制',
`bills_num_limit` int(11) DEFAULT NULL COMMENT '单据数量限制',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=81 DEFAULT CHARSET=utf8 COMMENT='租户';
-- ----------------------------
-- 时间2019年6月27日
-- 给租户表增加数据
-- ----------------------------
INSERT INTO `jsh_tenant` VALUES ('13', '63', 'jsh', '20', '2000', null);

View File

@@ -1882,6 +1882,29 @@ CREATE TABLE `tbl_sequence` (
-- ---------------------------- -- ----------------------------
INSERT INTO `tbl_sequence` VALUES ('depot_number_seq', '1', '999999999999999999', '304', '1', '单据编号sequence'); INSERT INTO `tbl_sequence` VALUES ('depot_number_seq', '1', '999999999999999999', '304', '1', '单据编号sequence');
-- ----------------------------
-- Table structure for jsh_tenant
-- ----------------------------
DROP TABLE IF EXISTS `jsh_tenant`;
CREATE TABLE `jsh_tenant` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`tenant_id` bigint(20) DEFAULT NULL COMMENT '用户id',
`login_name` varchar(255) DEFAULT NULL COMMENT '登录名',
`user_num_limit` int(11) DEFAULT NULL COMMENT '用户数量限制',
`bills_num_limit` int(11) DEFAULT NULL COMMENT '单据数量限制',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=81 DEFAULT CHARSET=utf8 COMMENT='租户';
-- ----------------------------
-- Records of jsh_tenant
-- ----------------------------
INSERT INTO `jsh_tenant` VALUES ('13', '63', 'jsh', '20', '2000', null);
INSERT INTO `jsh_tenant` VALUES ('14', '92', 'abc123', '2', '200', null);
INSERT INTO `jsh_tenant` VALUES ('15', '94', 'jzh', '2', '200', null);
INSERT INTO `jsh_tenant` VALUES ('16', '95', 'qiankun', '2', '200', null);
INSERT INTO `jsh_tenant` VALUES ('17', '96', 'czq', '2', '200', null);
-- ---------------------------- -- ----------------------------
-- Function structure for `_nextval` -- Function structure for `_nextval`
-- ---------------------------- -- ----------------------------

View File

@@ -59,7 +59,8 @@ public class TenantConfig {
// 这里可以判断是否过滤表 // 这里可以判断是否过滤表
if ("databasechangelog".equals(tableName) || "databasechangeloglock".equals(tableName) if ("databasechangelog".equals(tableName) || "databasechangeloglock".equals(tableName)
|| "jsh_materialproperty".equals(tableName) || "tbl_sequence".equals(tableName) || "dual".equals(tableName) || "jsh_materialproperty".equals(tableName) || "tbl_sequence".equals(tableName) || "dual".equals(tableName)
|| "jsh_userbusiness".equals(tableName) || "jsh_app".equals(tableName) || "jsh_functions".equals(tableName)) { || "jsh_userbusiness".equals(tableName) || "jsh_app".equals(tableName) || "jsh_functions".equals(tableName)
|| "jsh_tenant".equals(tableName)) {
return true; return true;
} else { } else {
return false; return false;

View File

@@ -7,10 +7,12 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.Tenant;
import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserEx; import com.jsh.erp.datasource.entities.UserEx;
import com.jsh.erp.datasource.vo.TreeNodeEx; import com.jsh.erp.datasource.vo.TreeNodeEx;
import com.jsh.erp.exception.BusinessParamCheckingException; import com.jsh.erp.exception.BusinessParamCheckingException;
import com.jsh.erp.service.tenant.TenantService;
import com.jsh.erp.service.user.UserService; import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.*; import com.jsh.erp.utils.*;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -52,6 +54,9 @@ public class UserController {
@Resource @Resource
private UserService userService; private UserService userService;
@Resource
private TenantService tenantService;
private static String message = "成功"; private static String message = "成功";
private static final String HTTP = "http://"; private static final String HTTP = "http://";
private static final String CODE_OK = "200"; private static final String CODE_OK = "200";
@@ -107,19 +112,15 @@ public class UserController {
msgTip = "user can login"; msgTip = "user can login";
request.getSession().setAttribute("user",user); request.getSession().setAttribute("user",user);
if(("open").equals(mybatisPlusStatus)) { if(("open").equals(mybatisPlusStatus)) {
String url = HTTP + manageIp + ":" + managePort + "/tenant/getTenant?tenantId=" + user.getTenantId(); Tenant tenant = tenantService.getTenantByTenantId(user.getTenantId());
JSONObject obj = HttpClient.httpGet(url); if(tenant!=null) {
if(obj!=null && obj.getString("code").equals(CODE_OK)) { Long tenantId = tenant.getTenantId();
JSONObject dataObj = obj.getJSONObject("data"); Integer userNumLimit = tenant.getUserNumLimit();
if(dataObj!=null) { Integer billsNumLimit = tenant.getBillsNumLimit();
String tenantId = dataObj.getString("tenantId"); if(tenantId!=null) {
String userNumLimit = dataObj.getString("userNumLimit"); request.getSession().setAttribute("tenantId",tenantId); //租户tenantId
String billsNumLimit = dataObj.getString("billsNumLimit"); request.getSession().setAttribute("userNumLimit",userNumLimit); //用户限制数
if(tenantId!=null) { request.getSession().setAttribute("billsNumLimit",billsNumLimit); //单据限制数
request.getSession().setAttribute("tenantId",tenantId); //租户tenantId
request.getSession().setAttribute("userNumLimit",userNumLimit); //用户限制数
request.getSession().setAttribute("billsNumLimit",billsNumLimit); //单据限制数
}
} }
} }
} }
@@ -351,33 +352,7 @@ public class UserController {
ue.setLoginame(loginame); ue.setLoginame(loginame);
ue.setPassword(password); ue.setPassword(password);
userService.checkUserNameAndLoginName(ue); //检查用户名和登录名 userService.checkUserNameAndLoginName(ue); //检查用户名和登录名
ue = userService.registerUser(ue,manageRoleId); ue = userService.registerUser(ue,manageRoleId,request);
/**
* create by: qiankunpingtai
* create time: 2019/4/9 17:17
* websitehttps://qiankunpingtai.cn
* description:
* 这里涉及到多个项目,需要用分布式事务去处理
* 为了不使问题复杂化,暂时另外开启一个线程去处理其它项目的数据操作
*/
final UserEx ueFinal=ue;
final ExecutorService executorService = Executors.newFixedThreadPool(1);
executorService.execute(() -> {
try{
//调第三方接口创建租户管理信息
String url = HTTP + manageIp + ":" + managePort + "/tenant/add";
JSONObject tenantObj = new JSONObject();
tenantObj.put("tenantId", ueFinal.getId());
tenantObj.put("loginName",ueFinal.getLoginame());
String param = URLEncoder.encode(tenantObj.toString());
HttpClient.httpPost(url + "?info=" + param, param);
logger.info("===============创建租户信息完成===============");
}catch(Exception e){
//记录一下第三方接口创建租户管理信息创建失败
logger.debug("调用第三方接口创建租户管理信息失败tenantId[{}],loginName:[{}]",ueFinal.getId(),ueFinal.getLoginame());
}
});
return result; return result;
} }
/** /**

View File

@@ -0,0 +1,197 @@
package com.jsh.erp.datasource.entities;
import java.util.Date;
public class Tenant {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column jsh_tenant.id
*
* @mbggenerated
*/
private Long id;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column jsh_tenant.tenant_id
*
* @mbggenerated
*/
private Long tenantId;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column jsh_tenant.login_name
*
* @mbggenerated
*/
private String loginName;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column jsh_tenant.user_num_limit
*
* @mbggenerated
*/
private Integer userNumLimit;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column jsh_tenant.bills_num_limit
*
* @mbggenerated
*/
private Integer billsNumLimit;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column jsh_tenant.create_time
*
* @mbggenerated
*/
private Date createTime;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column jsh_tenant.id
*
* @return the value of jsh_tenant.id
*
* @mbggenerated
*/
public Long getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column jsh_tenant.id
*
* @param id the value for jsh_tenant.id
*
* @mbggenerated
*/
public void setId(Long id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column jsh_tenant.tenant_id
*
* @return the value of jsh_tenant.tenant_id
*
* @mbggenerated
*/
public Long getTenantId() {
return tenantId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column jsh_tenant.tenant_id
*
* @param tenantId the value for jsh_tenant.tenant_id
*
* @mbggenerated
*/
public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column jsh_tenant.login_name
*
* @return the value of jsh_tenant.login_name
*
* @mbggenerated
*/
public String getLoginName() {
return loginName;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column jsh_tenant.login_name
*
* @param loginName the value for jsh_tenant.login_name
*
* @mbggenerated
*/
public void setLoginName(String loginName) {
this.loginName = loginName == null ? null : loginName.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column jsh_tenant.user_num_limit
*
* @return the value of jsh_tenant.user_num_limit
*
* @mbggenerated
*/
public Integer getUserNumLimit() {
return userNumLimit;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column jsh_tenant.user_num_limit
*
* @param userNumLimit the value for jsh_tenant.user_num_limit
*
* @mbggenerated
*/
public void setUserNumLimit(Integer userNumLimit) {
this.userNumLimit = userNumLimit;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column jsh_tenant.bills_num_limit
*
* @return the value of jsh_tenant.bills_num_limit
*
* @mbggenerated
*/
public Integer getBillsNumLimit() {
return billsNumLimit;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column jsh_tenant.bills_num_limit
*
* @param billsNumLimit the value for jsh_tenant.bills_num_limit
*
* @mbggenerated
*/
public void setBillsNumLimit(Integer billsNumLimit) {
this.billsNumLimit = billsNumLimit;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column jsh_tenant.create_time
*
* @return the value of jsh_tenant.create_time
*
* @mbggenerated
*/
public Date getCreateTime() {
return createTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column jsh_tenant.create_time
*
* @param createTime the value for jsh_tenant.create_time
*
* @mbggenerated
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}

View File

@@ -0,0 +1,673 @@
package com.jsh.erp.datasource.entities;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class TenantExample {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
protected String orderByClause;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
protected boolean distinct;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
protected List<Criteria> oredCriteria;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
public TenantExample() {
oredCriteria = new ArrayList<Criteria>();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
public String getOrderByClause() {
return orderByClause;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
public boolean isDistinct() {
return distinct;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andTenantIdIsNull() {
addCriterion("tenant_id is null");
return (Criteria) this;
}
public Criteria andTenantIdIsNotNull() {
addCriterion("tenant_id is not null");
return (Criteria) this;
}
public Criteria andTenantIdEqualTo(Long value) {
addCriterion("tenant_id =", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdNotEqualTo(Long value) {
addCriterion("tenant_id <>", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdGreaterThan(Long value) {
addCriterion("tenant_id >", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdGreaterThanOrEqualTo(Long value) {
addCriterion("tenant_id >=", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdLessThan(Long value) {
addCriterion("tenant_id <", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdLessThanOrEqualTo(Long value) {
addCriterion("tenant_id <=", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdIn(List<Long> values) {
addCriterion("tenant_id in", values, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdNotIn(List<Long> values) {
addCriterion("tenant_id not in", values, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdBetween(Long value1, Long value2) {
addCriterion("tenant_id between", value1, value2, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdNotBetween(Long value1, Long value2) {
addCriterion("tenant_id not between", value1, value2, "tenantId");
return (Criteria) this;
}
public Criteria andLoginNameIsNull() {
addCriterion("login_name is null");
return (Criteria) this;
}
public Criteria andLoginNameIsNotNull() {
addCriterion("login_name is not null");
return (Criteria) this;
}
public Criteria andLoginNameEqualTo(String value) {
addCriterion("login_name =", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginNameNotEqualTo(String value) {
addCriterion("login_name <>", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginNameGreaterThan(String value) {
addCriterion("login_name >", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginNameGreaterThanOrEqualTo(String value) {
addCriterion("login_name >=", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginNameLessThan(String value) {
addCriterion("login_name <", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginNameLessThanOrEqualTo(String value) {
addCriterion("login_name <=", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginNameLike(String value) {
addCriterion("login_name like", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginNameNotLike(String value) {
addCriterion("login_name not like", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginNameIn(List<String> values) {
addCriterion("login_name in", values, "loginName");
return (Criteria) this;
}
public Criteria andLoginNameNotIn(List<String> values) {
addCriterion("login_name not in", values, "loginName");
return (Criteria) this;
}
public Criteria andLoginNameBetween(String value1, String value2) {
addCriterion("login_name between", value1, value2, "loginName");
return (Criteria) this;
}
public Criteria andLoginNameNotBetween(String value1, String value2) {
addCriterion("login_name not between", value1, value2, "loginName");
return (Criteria) this;
}
public Criteria andUserNumLimitIsNull() {
addCriterion("user_num_limit is null");
return (Criteria) this;
}
public Criteria andUserNumLimitIsNotNull() {
addCriterion("user_num_limit is not null");
return (Criteria) this;
}
public Criteria andUserNumLimitEqualTo(Integer value) {
addCriterion("user_num_limit =", value, "userNumLimit");
return (Criteria) this;
}
public Criteria andUserNumLimitNotEqualTo(Integer value) {
addCriterion("user_num_limit <>", value, "userNumLimit");
return (Criteria) this;
}
public Criteria andUserNumLimitGreaterThan(Integer value) {
addCriterion("user_num_limit >", value, "userNumLimit");
return (Criteria) this;
}
public Criteria andUserNumLimitGreaterThanOrEqualTo(Integer value) {
addCriterion("user_num_limit >=", value, "userNumLimit");
return (Criteria) this;
}
public Criteria andUserNumLimitLessThan(Integer value) {
addCriterion("user_num_limit <", value, "userNumLimit");
return (Criteria) this;
}
public Criteria andUserNumLimitLessThanOrEqualTo(Integer value) {
addCriterion("user_num_limit <=", value, "userNumLimit");
return (Criteria) this;
}
public Criteria andUserNumLimitIn(List<Integer> values) {
addCriterion("user_num_limit in", values, "userNumLimit");
return (Criteria) this;
}
public Criteria andUserNumLimitNotIn(List<Integer> values) {
addCriterion("user_num_limit not in", values, "userNumLimit");
return (Criteria) this;
}
public Criteria andUserNumLimitBetween(Integer value1, Integer value2) {
addCriterion("user_num_limit between", value1, value2, "userNumLimit");
return (Criteria) this;
}
public Criteria andUserNumLimitNotBetween(Integer value1, Integer value2) {
addCriterion("user_num_limit not between", value1, value2, "userNumLimit");
return (Criteria) this;
}
public Criteria andBillsNumLimitIsNull() {
addCriterion("bills_num_limit is null");
return (Criteria) this;
}
public Criteria andBillsNumLimitIsNotNull() {
addCriterion("bills_num_limit is not null");
return (Criteria) this;
}
public Criteria andBillsNumLimitEqualTo(Integer value) {
addCriterion("bills_num_limit =", value, "billsNumLimit");
return (Criteria) this;
}
public Criteria andBillsNumLimitNotEqualTo(Integer value) {
addCriterion("bills_num_limit <>", value, "billsNumLimit");
return (Criteria) this;
}
public Criteria andBillsNumLimitGreaterThan(Integer value) {
addCriterion("bills_num_limit >", value, "billsNumLimit");
return (Criteria) this;
}
public Criteria andBillsNumLimitGreaterThanOrEqualTo(Integer value) {
addCriterion("bills_num_limit >=", value, "billsNumLimit");
return (Criteria) this;
}
public Criteria andBillsNumLimitLessThan(Integer value) {
addCriterion("bills_num_limit <", value, "billsNumLimit");
return (Criteria) this;
}
public Criteria andBillsNumLimitLessThanOrEqualTo(Integer value) {
addCriterion("bills_num_limit <=", value, "billsNumLimit");
return (Criteria) this;
}
public Criteria andBillsNumLimitIn(List<Integer> values) {
addCriterion("bills_num_limit in", values, "billsNumLimit");
return (Criteria) this;
}
public Criteria andBillsNumLimitNotIn(List<Integer> values) {
addCriterion("bills_num_limit not in", values, "billsNumLimit");
return (Criteria) this;
}
public Criteria andBillsNumLimitBetween(Integer value1, Integer value2) {
addCriterion("bills_num_limit between", value1, value2, "billsNumLimit");
return (Criteria) this;
}
public Criteria andBillsNumLimitNotBetween(Integer value1, Integer value2) {
addCriterion("bills_num_limit not between", value1, value2, "billsNumLimit");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table jsh_tenant
*
* @mbggenerated do_not_delete_during_merge
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@@ -0,0 +1,96 @@
package com.jsh.erp.datasource.mappers;
import com.jsh.erp.datasource.entities.Tenant;
import com.jsh.erp.datasource.entities.TenantExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TenantMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
int countByExample(TenantExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
int deleteByExample(TenantExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
int deleteByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
int insert(Tenant record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
int insertSelective(Tenant record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
List<Tenant> selectByExample(TenantExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
Tenant selectByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
int updateByExampleSelective(@Param("record") Tenant record, @Param("example") TenantExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
int updateByExample(@Param("record") Tenant record, @Param("example") TenantExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
int updateByPrimaryKeySelective(Tenant record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_tenant
*
* @mbggenerated
*/
int updateByPrimaryKey(Tenant record);
}

View File

@@ -0,0 +1,17 @@
package com.jsh.erp.datasource.mappers;
import com.jsh.erp.datasource.entities.Tenant;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TenantMapperEx {
List<Tenant> selectByConditionTenant(
@Param("loginName") String loginName,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
Long countsByTenant(
@Param("loginName") String loginName);
}

View File

@@ -24,6 +24,10 @@ import java.lang.annotation.*;
* depotItem-90 * depotItem-90
* accountHead-95 * accountHead-95
* accountItem-100 * accountItem-100
* serialNumber-105
* organization-110
* orgaUserRel-115
* tenant-120
*/ */
@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE}) @Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)

View File

@@ -0,0 +1,71 @@
package com.jsh.erp.service.tenant;
import com.jsh.erp.service.ICommonQuery;
import com.jsh.erp.service.user.UserResource;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.Constants;
import com.jsh.erp.utils.QueryUtils;
import com.jsh.erp.utils.StringUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@Service(value = "tenant_component")
@UserResource
public class TenantComponent implements ICommonQuery {
@Resource
private TenantService tenantService;
@Override
public Object selectOne(Long id) throws Exception {
return tenantService.getTenant(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getTenantList(map);
}
private List<?> getTenantList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String loginName = StringUtil.getInfo(search, "loginName");
return tenantService.select(loginName, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String loginName = StringUtil.getInfo(search, "loginName");
return tenantService.countTenant(loginName);
}
@Override
public int insert(String beanJson, HttpServletRequest request)throws Exception {
return tenantService.insertTenant(beanJson, request);
}
@Override
public int update(String beanJson, Long id)throws Exception {
return tenantService.updateTenant(beanJson, id);
}
@Override
public int delete(Long id)throws Exception {
return tenantService.deleteTenant(id);
}
@Override
public int batchDelete(String ids)throws Exception {
return tenantService.batchDeleteTenant(ids);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return tenantService.checkIsNameExist(id, name);
}
}

View File

@@ -0,0 +1,15 @@
package com.jsh.erp.service.tenant;
import com.jsh.erp.service.ResourceInfo;
import java.lang.annotation.*;
/**
* @author jishenghua qq752718920 2019-6-27 22:56:56
*/
@ResourceInfo(value = "tenant", type = 120)
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface TenantResource {
}

View File

@@ -0,0 +1,171 @@
package com.jsh.erp.service.tenant;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.TenantMapper;
import com.jsh.erp.datasource.mappers.TenantMapperEx;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
@Service
public class TenantService {
private Logger logger = LoggerFactory.getLogger(TenantService.class);
@Resource
private TenantMapper tenantMapper;
@Resource
private TenantMapperEx tenantMapperEx;
public Tenant getTenant(long id)throws Exception {
Tenant result=null;
try{
result=tenantMapper.selectByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
}
public List<Tenant> getTenant()throws Exception {
TenantExample example = new TenantExample();
List<Tenant> list=null;
try{
list=tenantMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
}
public List<Tenant> select(String loginName, int offset, int rows)throws Exception {
List<Tenant> list=null;
try{
list=tenantMapperEx.selectByConditionTenant(loginName, offset, rows);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
}
public Long countTenant(String loginName)throws Exception {
Long result=null;
try{
result=tenantMapperEx.countsByTenant(loginName);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertTenant(String beanJson, HttpServletRequest request)throws Exception {
Tenant tenant = JSONObject.parseObject(beanJson, Tenant.class);
int result=0;
try{
tenant.setUserNumLimit(2); //默认用户限制数量
tenant.setBillsNumLimit(200); //默认单据限制数量
tenant.setCreateTime(new Date());
result=tenantMapper.insertSelective(tenant);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateTenant(String beanJson, Long id)throws Exception {
Tenant tenant = JSONObject.parseObject(beanJson, Tenant.class);
int result=0;
try{
tenant.setId(id);
result=tenantMapper.updateByPrimaryKeySelective(tenant);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteTenant(Long id)throws Exception {
int result=0;
try{
result= tenantMapper.deleteByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteTenant(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
TenantExample example = new TenantExample();
example.createCriteria().andIdIn(idList);
int result=0;
try{
result= tenantMapper.deleteByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
}
public int checkIsNameExist(Long id, String name)throws Exception {
TenantExample example = new TenantExample();
example.createCriteria().andIdEqualTo(id);
List<Tenant> list=null;
try{
list= tenantMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list==null?0:list.size();
}
public Tenant getTenantByTenantId(long tenantId) {
Tenant tenant = new Tenant();
TenantExample example = new TenantExample();
example.createCriteria().andTenantIdEqualTo(tenantId);
List<Tenant> list = tenantMapper.selectByExample(example);
if(list.size()>0) {
tenant = list.get(0);
}
return tenant;
}
}

View File

@@ -15,6 +15,7 @@ import com.jsh.erp.datasource.vo.TreeNodeEx;
import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.orgaUserRel.OrgaUserRelService; import com.jsh.erp.service.orgaUserRel.OrgaUserRelService;
import com.jsh.erp.service.tenant.TenantService;
import com.jsh.erp.service.userBusiness.UserBusinessService; import com.jsh.erp.service.userBusiness.UserBusinessService;
import com.jsh.erp.utils.ExceptionCodeConstants; import com.jsh.erp.utils.ExceptionCodeConstants;
import com.jsh.erp.utils.JshException; import com.jsh.erp.utils.JshException;
@@ -49,7 +50,8 @@ public class UserService {
private LogService logService; private LogService logService;
@Resource @Resource
private UserService userService; private UserService userService;
@Resource
private TenantService tenantService;
@Resource @Resource
private UserBusinessService userBusinessService; private UserBusinessService userBusinessService;
@@ -416,7 +418,7 @@ public class UserService {
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public UserEx registerUser(UserEx ue, Integer manageRoleId) throws Exception{ public UserEx registerUser(UserEx ue, Integer manageRoleId, HttpServletRequest request) throws Exception{
/** /**
* create by: qiankunpingtai * create by: qiankunpingtai
* create time: 2019/4/9 18:00 * create time: 2019/4/9 18:00
@@ -456,6 +458,13 @@ public class UserService {
ubArr.add(manageRoleId); ubArr.add(manageRoleId);
ubObj.put("value", ubArr.toString()); ubObj.put("value", ubArr.toString());
userBusinessService.insertUserBusiness(ubObj.toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); userBusinessService.insertUserBusiness(ubObj.toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
//创建租户信息
JSONObject tenantObj = new JSONObject();
tenantObj.put("tenantId", ue.getId());
tenantObj.put("loginName",ue.getLoginame());
String param = tenantObj.toJSONString();
tenantService.insertTenant(param, request);
logger.info("===============创建租户信息完成===============");
if (result > 0) { if (result > 0) {
return ue; return ue;
} }

View File

@@ -0,0 +1,288 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.jsh.erp.datasource.mappers.TenantMapper" >
<resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.Tenant" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" property="id" jdbcType="BIGINT" />
<result column="tenant_id" property="tenantId" jdbcType="BIGINT" />
<result column="login_name" property="loginName" jdbcType="VARCHAR" />
<result column="user_num_limit" property="userNumLimit" jdbcType="INTEGER" />
<result column="bills_num_limit" property="billsNumLimit" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Example_Where_Clause" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where >
<foreach collection="oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where >
<foreach collection="example.oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, tenant_id, login_name, user_num_limit, bills_num_limit, create_time
</sql>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.jsh.erp.datasource.entities.TenantExample" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from jsh_tenant
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from jsh_tenant
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from jsh_tenant
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="com.jsh.erp.datasource.entities.TenantExample" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from jsh_tenant
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.jsh.erp.datasource.entities.Tenant" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into jsh_tenant (id, tenant_id, login_name,
user_num_limit, bills_num_limit, create_time
)
values (#{id,jdbcType=BIGINT}, #{tenantId,jdbcType=BIGINT}, #{loginName,jdbcType=VARCHAR},
#{userNumLimit,jdbcType=INTEGER}, #{billsNumLimit,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.Tenant" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into jsh_tenant
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="tenantId != null" >
tenant_id,
</if>
<if test="loginName != null" >
login_name,
</if>
<if test="userNumLimit != null" >
user_num_limit,
</if>
<if test="billsNumLimit != null" >
bills_num_limit,
</if>
<if test="createTime != null" >
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="tenantId != null" >
#{tenantId,jdbcType=BIGINT},
</if>
<if test="loginName != null" >
#{loginName,jdbcType=VARCHAR},
</if>
<if test="userNumLimit != null" >
#{userNumLimit,jdbcType=INTEGER},
</if>
<if test="billsNumLimit != null" >
#{billsNumLimit,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.jsh.erp.datasource.entities.TenantExample" resultType="java.lang.Integer" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from jsh_tenant
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update jsh_tenant
<set >
<if test="record.id != null" >
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.tenantId != null" >
tenant_id = #{record.tenantId,jdbcType=BIGINT},
</if>
<if test="record.loginName != null" >
login_name = #{record.loginName,jdbcType=VARCHAR},
</if>
<if test="record.userNumLimit != null" >
user_num_limit = #{record.userNumLimit,jdbcType=INTEGER},
</if>
<if test="record.billsNumLimit != null" >
bills_num_limit = #{record.billsNumLimit,jdbcType=INTEGER},
</if>
<if test="record.createTime != null" >
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update jsh_tenant
set id = #{record.id,jdbcType=BIGINT},
tenant_id = #{record.tenantId,jdbcType=BIGINT},
login_name = #{record.loginName,jdbcType=VARCHAR},
user_num_limit = #{record.userNumLimit,jdbcType=INTEGER},
bills_num_limit = #{record.billsNumLimit,jdbcType=INTEGER},
create_time = #{record.createTime,jdbcType=TIMESTAMP}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.jsh.erp.datasource.entities.Tenant" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update jsh_tenant
<set >
<if test="tenantId != null" >
tenant_id = #{tenantId,jdbcType=BIGINT},
</if>
<if test="loginName != null" >
login_name = #{loginName,jdbcType=VARCHAR},
</if>
<if test="userNumLimit != null" >
user_num_limit = #{userNumLimit,jdbcType=INTEGER},
</if>
<if test="billsNumLimit != null" >
bills_num_limit = #{billsNumLimit,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.jsh.erp.datasource.entities.Tenant" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update jsh_tenant
set tenant_id = #{tenantId,jdbcType=BIGINT},
login_name = #{loginName,jdbcType=VARCHAR},
user_num_limit = #{userNumLimit,jdbcType=INTEGER},
bills_num_limit = #{billsNumLimit,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jsh.erp.datasource.mappers.TenantMapperEx">
<select id="selectByConditionTenant" parameterType="com.jsh.erp.datasource.entities.TenantExample" resultMap="com.jsh.erp.datasource.mappers.TenantMapper.BaseResultMap">
select *
FROM jsh_tenant
where 1=1
<if test="loginName != null">
and loginame like '%${loginName}%'
</if>
<if test="offset != null and rows != null">
limit #{offset},#{rows}
</if>
</select>
<select id="countsByTenant" resultType="java.lang.Long">
SELECT
COUNT(id)
FROM jsh_tenant
WHERE 1=1
<if test="loginName != null">
and loginame like '%${loginName}%'
</if>
</select>
</mapper>

View File

@@ -63,6 +63,7 @@
<table tableName="jsh_userbusiness" domainObjectName="UserBusiness"></table> <table tableName="jsh_userbusiness" domainObjectName="UserBusiness"></table>
<table tableName="jsh_serial_number" domainObjectName="SerialNumber"></table> <table tableName="jsh_serial_number" domainObjectName="SerialNumber"></table>
<table tableName="jsh_organization" domainObjectName="Organization"></table> <table tableName="jsh_organization" domainObjectName="Organization"></table>
<table tableName="jsh_orga_user_rel" domainObjectName="OrgaUserRel"></table> --> <table tableName="jsh_orga_user_rel" domainObjectName="OrgaUserRel"></table>
<table tableName="jsh_tenant" domainObjectName="Tenant"></table> -->
</context> </context>
</generatorConfiguration> </generatorConfiguration>