解决超管从后台创建租户报错的bug
This commit is contained in:
@@ -44,11 +44,8 @@ public class TenantService {
|
|||||||
@Resource
|
@Resource
|
||||||
private LogService logService;
|
private LogService logService;
|
||||||
|
|
||||||
@Value("${tenant.userNumLimit}")
|
@Value("${manage.roleId}")
|
||||||
private Integer userNumLimit;
|
private Integer manageRoleId;
|
||||||
|
|
||||||
@Value("${tenant.tryDayLimit}")
|
|
||||||
private Integer tryDayLimit;
|
|
||||||
|
|
||||||
public Tenant getTenant(long id)throws Exception {
|
public Tenant getTenant(long id)throws Exception {
|
||||||
Tenant result=null;
|
Tenant result=null;
|
||||||
@@ -103,18 +100,14 @@ public class TenantService {
|
|||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int insertTenant(JSONObject obj, HttpServletRequest request)throws Exception {
|
public int insertTenant(JSONObject obj, HttpServletRequest request)throws Exception {
|
||||||
Tenant tenant = JSONObject.parseObject(obj.toJSONString(), Tenant.class);
|
UserEx ue = JSONObject.parseObject(obj.toJSONString(), UserEx.class);
|
||||||
int result=0;
|
int result = 0;
|
||||||
try{
|
try{
|
||||||
tenant.setCreateTime(new Date());
|
ue.setUsername(ue.getLoginName());
|
||||||
if(tenant.getUserNumLimit()==null) {
|
userService.checkLoginName(ue); //检查登录名
|
||||||
tenant.setUserNumLimit(userNumLimit); //默认用户限制数量
|
userService.registerUser(ue,manageRoleId,request);
|
||||||
}
|
result = 1;
|
||||||
if(tenant.getExpireTime()==null) {
|
} catch(Exception e){
|
||||||
tenant.setExpireTime(Tools.addDays(new Date(), tryDayLimit)); //租户允许试用的天数
|
|
||||||
}
|
|
||||||
result = tenantMapper.insertSelective(tenant);
|
|
||||||
}catch(Exception e){
|
|
||||||
JshException.writeFail(logger, e);
|
JshException.writeFail(logger, e);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.jsh.erp.service.user;
|
package com.jsh.erp.service.user;
|
||||||
|
|
||||||
import com.jsh.erp.datasource.entities.*;
|
import com.jsh.erp.datasource.entities.*;
|
||||||
|
import com.jsh.erp.datasource.mappers.TenantMapper;
|
||||||
import com.jsh.erp.exception.BusinessParamCheckingException;
|
import com.jsh.erp.exception.BusinessParamCheckingException;
|
||||||
import com.jsh.erp.service.functions.FunctionService;
|
import com.jsh.erp.service.functions.FunctionService;
|
||||||
import com.jsh.erp.service.platformConfig.PlatformConfigService;
|
import com.jsh.erp.service.platformConfig.PlatformConfigService;
|
||||||
@@ -43,7 +44,8 @@ public class UserService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserMapper userMapper;
|
private UserMapper userMapper;
|
||||||
|
@Resource
|
||||||
|
private TenantMapper tenantMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private UserMapperEx userMapperEx;
|
private UserMapperEx userMapperEx;
|
||||||
@Resource
|
@Resource
|
||||||
@@ -65,6 +67,12 @@ public class UserService {
|
|||||||
@Resource
|
@Resource
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@Value("${tenant.userNumLimit}")
|
||||||
|
private Integer userNumLimit;
|
||||||
|
|
||||||
|
@Value("${tenant.tryDayLimit}")
|
||||||
|
private Integer tryDayLimit;
|
||||||
|
|
||||||
public User getUser(long id)throws Exception {
|
public User getUser(long id)throws Exception {
|
||||||
User result=null;
|
User result=null;
|
||||||
try{
|
try{
|
||||||
@@ -585,9 +593,8 @@ public class UserService {
|
|||||||
ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER);
|
ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER);
|
||||||
}
|
}
|
||||||
ue.setStatus(BusinessConstants.USER_STATUS_NORMAL);
|
ue.setStatus(BusinessConstants.USER_STATUS_NORMAL);
|
||||||
int result=0;
|
|
||||||
try{
|
try{
|
||||||
result= userMapper.insertSelective(ue);
|
userMapper.insertSelective(ue);
|
||||||
Long userId = getIdByLoginName(ue.getLoginName());
|
Long userId = getIdByLoginName(ue.getLoginName());
|
||||||
ue.setId(userId);
|
ue.setId(userId);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
@@ -614,7 +621,15 @@ public class UserService {
|
|||||||
tenantObj.put("userNumLimit", ue.getUserNumLimit());
|
tenantObj.put("userNumLimit", ue.getUserNumLimit());
|
||||||
tenantObj.put("expireTime", ue.getExpireTime());
|
tenantObj.put("expireTime", ue.getExpireTime());
|
||||||
tenantObj.put("remark", ue.getRemark());
|
tenantObj.put("remark", ue.getRemark());
|
||||||
tenantService.insertTenant(tenantObj, request);
|
Tenant tenant = JSONObject.parseObject(tenantObj.toJSONString(), Tenant.class);
|
||||||
|
tenant.setCreateTime(new Date());
|
||||||
|
if(tenant.getUserNumLimit()==null) {
|
||||||
|
tenant.setUserNumLimit(userNumLimit); //默认用户限制数量
|
||||||
|
}
|
||||||
|
if(tenant.getExpireTime()==null) {
|
||||||
|
tenant.setExpireTime(Tools.addDays(new Date(), tryDayLimit)); //租户允许试用的天数
|
||||||
|
}
|
||||||
|
tenantMapper.insertSelective(tenant);
|
||||||
logger.info("===============创建租户信息完成===============");
|
logger.info("===============创建租户信息完成===============");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user