使用GenericGenerator,Elide不支持IdGeneratorType
This commit is contained in:
12
.idea/dataSources.xml
generated
12
.idea/dataSources.xml
generated
@@ -26,5 +26,17 @@
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
<data-source source="LOCAL" name="database" uuid="894c61bb-b6fb-4153-94dc-97175dd7fd95">
|
||||
<driver-ref>h2.unified</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.h2.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:h2:$PROJECT_DIR$/database</jdbc-url>
|
||||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
||||
@@ -14,8 +14,7 @@ export function amisRender(target, amisJson) {
|
||||
information,
|
||||
{
|
||||
theme: 'antd',
|
||||
enableAMISDebug:
|
||||
information.debug,
|
||||
enableAMISDebug: information.debug,
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -28,16 +28,11 @@ onMounted(() => {
|
||||
type: 'form',
|
||||
api: {
|
||||
method: 'post',
|
||||
url: `${information.baseUrl}/jsonapi/organization`,
|
||||
dataType: 'application/vnd.api+json',
|
||||
headers: {
|
||||
'Content-Type': 'application/vnd.api+json',
|
||||
},
|
||||
url: `${information.baseUrl}/graphql`,
|
||||
dataType: 'application/json',
|
||||
data: {
|
||||
type: 'user',
|
||||
attributes: {
|
||||
organizationName: '${organizationName}',
|
||||
},
|
||||
// language=GraphQL
|
||||
query: 'mutation {\n organization(op: UPSERT, data: {\n organizationName: "苹果"\n }) {\n edges {\n node {\n organizationId\n organizationName\n }\n }\n }\n}',
|
||||
},
|
||||
},
|
||||
body: [
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.lanyuanxiaoyao.server;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -31,4 +32,10 @@ public class ServerApplication {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ApplicationRunner initialRunner() {
|
||||
return args -> {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
@@ -16,6 +17,7 @@ import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
/**
|
||||
* 组织
|
||||
@@ -31,7 +33,8 @@ import lombok.ToString;
|
||||
@Include
|
||||
public class Department {
|
||||
@Id
|
||||
@SnowflakeId.Generator
|
||||
@GeneratedValue(generator = "snowflakeId")
|
||||
@GenericGenerator(name = "snowflakeId", type = SnowflakeId.IdGenerator.class)
|
||||
private Long departmentId;
|
||||
private String departmentName;
|
||||
|
||||
@@ -44,6 +47,7 @@ public class Department {
|
||||
private Set<User> users;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private Department parent;
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "parent")
|
||||
@ToString.Exclude
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.lanyuanxiaoyao.server.configuration.database.SnowflakeId;
|
||||
import com.yahoo.elide.annotation.Include;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
@@ -12,6 +13,7 @@ import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
/**
|
||||
* 组织
|
||||
@@ -27,7 +29,8 @@ import lombok.ToString;
|
||||
@Include
|
||||
public class Organization {
|
||||
@Id
|
||||
@SnowflakeId.Generator
|
||||
@GeneratedValue(generator = "snowflakeId")
|
||||
@GenericGenerator(name = "snowflakeId", type = SnowflakeId.IdGenerator.class)
|
||||
private Long organizationId;
|
||||
private String organizationName;
|
||||
|
||||
|
||||
@@ -6,14 +6,15 @@ import com.yahoo.elide.annotation.Include;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.persistence.UniqueConstraint;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
@@ -29,7 +30,8 @@ import lombok.ToString;
|
||||
@Include
|
||||
public class User {
|
||||
@Id
|
||||
@SnowflakeId.Generator
|
||||
@GeneratedValue(generator = "snowflakeId")
|
||||
@GenericGenerator(name = "snowflakeId", type = SnowflakeId.IdGenerator.class)
|
||||
private Long userId;
|
||||
private String userCode;
|
||||
private String userNickname;
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
### Create
|
||||
POST http://localhost:8080/jsonapi/organization
|
||||
Content-Type: application/json
|
||||
Content-Type: application/vnd.api+json
|
||||
|
||||
{
|
||||
"data": {
|
||||
"type": "organization",
|
||||
"attributes": {
|
||||
"organizationName": "苹果公司"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
### Create
|
||||
POST http://localhost:8080/graphql
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"query": "mutation {organization(op: UPSERT, data: {organizationName: \"苹果\"}) {edges {node {organizationId organizationName}}}}"
|
||||
}
|
||||
Reference in New Issue
Block a user