first commit
这个提交包含在:
父节点
7fce902044
当前提交
3b4ae6e5e8
@ -1,4 +1,4 @@
|
||||
package com.xuqm.server.appmanager.http;
|
||||
package com.xuqm.server.appmanager;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -16,9 +16,9 @@ public class GlobalCorsConfig {
|
||||
//添加映射路径
|
||||
registry.addMapping("/**")
|
||||
//放行哪些原始域
|
||||
.allowedOrigins("*")
|
||||
.allowedOriginPatterns("*")
|
||||
//是否发送Cookie信息
|
||||
.allowCredentials(false)
|
||||
.allowCredentials(true)
|
||||
//放行哪些原始域(请求方式)
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE")
|
||||
//放行哪些原始域(头部信息)
|
||||
@ -3,9 +3,11 @@ package com.xuqm.server.appmanager.controller.sys.v1;
|
||||
import cn.org.bjca.trust.java.imserver.common.TimeHelper;
|
||||
import com.xuqm.server.appmanager.entitys.sys.v1.ApplicationEntity;
|
||||
import com.xuqm.server.appmanager.entitys.sys.v1.TenantEntity;
|
||||
import com.xuqm.server.appmanager.entitys.sys.v1.TenantUserEntity;
|
||||
import com.xuqm.server.appmanager.http.HttpResult;
|
||||
import com.xuqm.server.appmanager.repository.sys.v1.ApplicationRepository;
|
||||
import com.xuqm.server.appmanager.repository.sys.v1.TenantRepository;
|
||||
import com.xuqm.server.appmanager.repository.sys.v1.TenantUserRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@ -21,27 +23,31 @@ public class TenantV1Controller {
|
||||
@Autowired
|
||||
private TenantRepository tenantRepository;
|
||||
@Autowired
|
||||
private TenantUserRepository tenantUserRepository;
|
||||
@Autowired
|
||||
private ApplicationRepository applicationRepository;
|
||||
|
||||
@PostMapping("/tenant/create")
|
||||
public HttpResult<String> tenantCreate(@RequestBody TenantEntity tenant) throws Exception {
|
||||
if (null == tenant.getTenantName() ||
|
||||
null == tenant.getUserPhone() ||
|
||||
public HttpResult<String> tenantCreate(@RequestBody TenantUserEntity tenant) throws Exception {
|
||||
if (null == tenant.getUserPhone() ||
|
||||
null == tenant.getUserEmail() ||
|
||||
null == tenant.getUserName()) {
|
||||
return new HttpResult<>(201, "参数错误", "");
|
||||
null == tenant.getUserPwd()) {
|
||||
return new HttpResult<>(201, "参数错误", null);
|
||||
} else {
|
||||
TenantEntity t = tenantRepository.findFirstByUserEmailOrUserPhone(tenant.getUserEmail(), tenant.getUserPhone());
|
||||
if (null != t) return new HttpResult<>(201, "当前联系人已注册", "");
|
||||
t = new TenantEntity();
|
||||
t.setTenantName(tenant.getTenantName());
|
||||
t.setUserEmail(tenant.getUserEmail());
|
||||
t.setUserName(tenant.getUserName());
|
||||
t.setUserPhone(tenant.getUserPhone());
|
||||
t.setTenantNo(TimeHelper.getTimeString("yyyyMMddHHmm") + (new Random().nextInt(899999999) + 100000000));
|
||||
TenantUserEntity u = tenantUserRepository.findFirstByUserEmailOrUserPhone(tenant.getUserEmail(), tenant.getUserPhone());
|
||||
if (null != u) return new HttpResult<>(201, "邮箱或手机号重复", null);
|
||||
u = new TenantUserEntity();
|
||||
u.setUserEmail(tenant.getUserEmail());
|
||||
u.setUserPhone(tenant.getUserPhone());
|
||||
u.setUserPwd(tenant.getUserPwd());
|
||||
u.setUserId(TimeHelper.getTimeString("yyyyMMddHHmm") + (new Random().nextInt(899999999) + 100000000));
|
||||
u.setTenantNo(TimeHelper.getTimeString("yyyyMMddHHmm") + (new Random().nextInt(899999999) + 100000000));
|
||||
tenantUserRepository.save(u);
|
||||
TenantEntity t = new TenantEntity();
|
||||
t.setUserId(u.getUserId());
|
||||
t.setTenantNo(u.getTenantNo());
|
||||
tenantRepository.save(t);
|
||||
|
||||
// RabbitMQHelper.requestByGetAndParams("http://114.115.203.60:15672/api/vhosts/" + appid, "");
|
||||
return new HttpResult<>(200, "创建成功", "创建成功");
|
||||
}
|
||||
|
||||
@ -51,10 +57,10 @@ public class TenantV1Controller {
|
||||
public HttpResult<String> appCreate(@RequestBody ApplicationEntity application) throws Exception {
|
||||
if (null == application.getAppName() ||
|
||||
null == application.getTenantNo()) {
|
||||
return new HttpResult<>(201, "参数错误", "");
|
||||
return new HttpResult<>(201, "参数错误", null);
|
||||
} else {
|
||||
ApplicationEntity app = applicationRepository.findFirstByAppNameAndTenantNo(application.getAppName(), application.getTenantNo());
|
||||
if (null != app) return new HttpResult<>(201, "已创建相关类型的同名应用", "");
|
||||
if (null != app) return new HttpResult<>(201, "已创建相关类型的同名应用", null);
|
||||
app = new ApplicationEntity();
|
||||
app.setTenantNo(application.getTenantNo());
|
||||
app.setAppName(application.getAppName());
|
||||
|
||||
@ -12,7 +12,4 @@ public class TenantEntity extends AbstractBaseTimeEntity {
|
||||
private String tenantNo;
|
||||
private String tenantName;
|
||||
private String userId;
|
||||
private String userName;
|
||||
private String userPhone;
|
||||
private String userEmail;
|
||||
}
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
package com.xuqm.server.appmanager.entitys.sys.v1;
|
||||
|
||||
import com.xuqm.server.appmanager.entitys.converter.AbstractBaseTimeEntity;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Table(name = "user_tenant")
|
||||
@Data
|
||||
public class TenantUserEntity extends AbstractBaseTimeEntity {
|
||||
private String userId;
|
||||
private String userName;
|
||||
private String userPhone;
|
||||
private String userEmail;
|
||||
private String userPwd;
|
||||
private String tenantNo;
|
||||
}
|
||||
@ -1,5 +1,10 @@
|
||||
package com.xuqm.server.appmanager.http;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class HttpResult<T> {
|
||||
/**
|
||||
* "code": 200
|
||||
@ -16,28 +21,4 @@ public class HttpResult<T> {
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,6 @@ import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface TenantRepository extends JpaRepository<TenantEntity, Long> {
|
||||
TenantEntity findFirstByUserEmailOrUserPhone(String userEmail, String userPhone);
|
||||
// TenantEntity findFirstByUserEmailOrUserPhone(String userEmail, String userPhone);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
package com.xuqm.server.appmanager.repository.sys.v1;
|
||||
|
||||
import com.xuqm.server.appmanager.entitys.sys.v1.TenantEntity;
|
||||
import com.xuqm.server.appmanager.entitys.sys.v1.TenantUserEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface TenantUserRepository extends JpaRepository<TenantUserEntity, Long> {
|
||||
TenantUserEntity findFirstByUserEmailOrUserPhone(String userEmail, String userPhone);
|
||||
|
||||
}
|
||||
正在加载...
在新工单中引用
屏蔽一个用户