feat:新增企业入驻接口

dev.event
袁子龙 2024-09-30 12:23:56 +08:00
parent d6ff8ad340
commit 78747b7d03
3 changed files with 50 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package com.muyu.auth.controller; package com.muyu.auth.controller;
import com.muyu.auth.form.EnterpriseSettlement;
import com.muyu.auth.form.Firm; import com.muyu.auth.form.Firm;
import com.muyu.auth.form.LoginBody; import com.muyu.auth.form.LoginBody;
import com.muyu.auth.form.RegisterBody; import com.muyu.auth.form.RegisterBody;
@ -79,4 +80,10 @@ public class TokenController {
sysLoginService.register(registerBody.getUsername(), registerBody.getPassword()); sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
return Result.success(); return Result.success();
} }
@PostMapping("enterprise")
public Result<?> enterprise(@RequestBody EnterpriseSettlement enterpriseSettlement){
sysLoginService.enterprise(enterpriseSettlement.getDatabaseName(),enterpriseSettlement.getFirmName());
return Result.success();
}
} }

View File

@ -1,10 +1,23 @@
package com.muyu.auth.form; package com.muyu.auth.form;
import lombok.Data;
/** /**
*
* @author * @author
* @package com.muyu.auth.form * @package com.muyu.auth.form
* @name EnterpriseSettlement * @name EnterpriseSettlement
* @date 2024/9/30 11:25 * @date 2024/9/30 11:25
*/ */
@Data
public class EnterpriseSettlement { public class EnterpriseSettlement {
/**
*
*/
private String firmName;
/**
*
*/
private String databaseName;
} }

View File

@ -1,5 +1,6 @@
package com.muyu.auth.service; package com.muyu.auth.service;
import com.muyu.auth.form.EnterpriseSettlement;
import com.muyu.common.core.constant.CacheConstants; import com.muyu.common.core.constant.CacheConstants;
import com.muyu.common.core.constant.Constants; import com.muyu.common.core.constant.Constants;
import com.muyu.common.core.constant.SecurityConstants; import com.muyu.common.core.constant.SecurityConstants;
@ -12,6 +13,7 @@ import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.core.utils.ip.IpUtils; import com.muyu.common.core.utils.ip.IpUtils;
import com.muyu.common.redis.service.RedisService; import com.muyu.common.redis.service.RedisService;
import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.Enterprise;
import com.muyu.common.system.remote.RemoteUserService; import com.muyu.common.system.remote.RemoteUserService;
import com.muyu.common.system.domain.SysUser; import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.domain.LoginUser; import com.muyu.common.system.domain.LoginUser;
@ -124,4 +126,32 @@ public class SysLoginService {
} }
recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功"); recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
} }
/**
*
* @param databaseName
* @param fileName
*/
public void enterprise (String databaseName,String fileName){
// 参数校验 数据库名或企业名称不能为空
if (StringUtils.isAnyBlank(databaseName,fileName)){
throw new ServiceException("数据库名或企业名称不能为空");
}
if (databaseName.length()<UserConstants.PASSWORD_MIN_LENGTH||databaseName.length()>UserConstants.PASSWORD_MAX_LENGTH){
throw new ServiceException("数据库名长度必须在5到20个字符之间");
}
if (fileName.length()<UserConstants.Firm_NAME_MIN_LENGTH||fileName.length()>UserConstants.Firm_NAME_MAX_LENGTH){
throw new ServiceException("企业名称长度必须在2到20个字符之间");
}
Enterprise settlement = new Enterprise();
settlement.setDatabaseName(databaseName);
settlement.setFirmName(fileName);
Result<?> registerResult = remoteUserService.settlementEnterpriseInfo(settlement, SecurityConstants.INNER);
if (Result.FAIL == registerResult.getCode()) {
throw new ServiceException(registerResult.getMsg());
}
recordLogService.recordLogininfor(fileName, Constants.REGISTER, "注册成功"); }
} }