解决超管从后台创建租户报错的bug

This commit is contained in:
jishenghua
2024-06-20 22:52:28 +08:00
parent f8ea188267
commit aa58b36145
2 changed files with 28 additions and 20 deletions

View File

@@ -44,11 +44,8 @@ public class TenantService {
@Resource
private LogService logService;
@Value("${tenant.userNumLimit}")
private Integer userNumLimit;
@Value("${tenant.tryDayLimit}")
private Integer tryDayLimit;
@Value("${manage.roleId}")
private Integer manageRoleId;
public Tenant getTenant(long id)throws Exception {
Tenant result=null;
@@ -103,18 +100,14 @@ public class TenantService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertTenant(JSONObject obj, HttpServletRequest request)throws Exception {
Tenant tenant = JSONObject.parseObject(obj.toJSONString(), Tenant.class);
int result=0;
UserEx ue = JSONObject.parseObject(obj.toJSONString(), UserEx.class);
int result = 0;
try{
tenant.setCreateTime(new Date());
if(tenant.getUserNumLimit()==null) {
tenant.setUserNumLimit(userNumLimit); //默认用户限制数量
}
if(tenant.getExpireTime()==null) {
tenant.setExpireTime(Tools.addDays(new Date(), tryDayLimit)); //租户允许试用的天数
}
result = tenantMapper.insertSelective(tenant);
}catch(Exception e){
ue.setUsername(ue.getLoginName());
userService.checkLoginName(ue); //检查登录名
userService.registerUser(ue,manageRoleId,request);
result = 1;
} catch(Exception e){
JshException.writeFail(logger, e);
}
return result;