使用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>
|
</jdbc-additional-properties>
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
</data-source>
|
</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>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -14,8 +14,7 @@ export function amisRender(target, amisJson) {
|
|||||||
information,
|
information,
|
||||||
{
|
{
|
||||||
theme: 'antd',
|
theme: 'antd',
|
||||||
enableAMISDebug:
|
enableAMISDebug: information.debug,
|
||||||
information.debug,
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -28,16 +28,11 @@ onMounted(() => {
|
|||||||
type: 'form',
|
type: 'form',
|
||||||
api: {
|
api: {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url: `${information.baseUrl}/jsonapi/organization`,
|
url: `${information.baseUrl}/graphql`,
|
||||||
dataType: 'application/vnd.api+json',
|
dataType: 'application/json',
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/vnd.api+json',
|
|
||||||
},
|
|
||||||
data: {
|
data: {
|
||||||
type: 'user',
|
// language=GraphQL
|
||||||
attributes: {
|
query: 'mutation {\n organization(op: UPSERT, data: {\n organizationName: "苹果"\n }) {\n edges {\n node {\n organizationId\n organizationName\n }\n }\n }\n}',
|
||||||
organizationName: '${organizationName}',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
body: [
|
body: [
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.lanyuanxiaoyao.server;
|
package com.lanyuanxiaoyao.server;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.Bean;
|
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.Entity;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.ForeignKey;
|
import jakarta.persistence.ForeignKey;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.JoinColumn;
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
@@ -16,6 +17,7 @@ import java.util.Set;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组织
|
* 组织
|
||||||
@@ -31,7 +33,8 @@ import lombok.ToString;
|
|||||||
@Include
|
@Include
|
||||||
public class Department {
|
public class Department {
|
||||||
@Id
|
@Id
|
||||||
@SnowflakeId.Generator
|
@GeneratedValue(generator = "snowflakeId")
|
||||||
|
@GenericGenerator(name = "snowflakeId", type = SnowflakeId.IdGenerator.class)
|
||||||
private Long departmentId;
|
private Long departmentId;
|
||||||
private String departmentName;
|
private String departmentName;
|
||||||
|
|
||||||
@@ -44,6 +47,7 @@ public class Department {
|
|||||||
private Set<User> users;
|
private Set<User> users;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
|
@JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||||
private Department parent;
|
private Department parent;
|
||||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "parent")
|
@OneToMany(fetch = FetchType.LAZY, mappedBy = "parent")
|
||||||
@ToString.Exclude
|
@ToString.Exclude
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.lanyuanxiaoyao.server.configuration.database.SnowflakeId;
|
|||||||
import com.yahoo.elide.annotation.Include;
|
import com.yahoo.elide.annotation.Include;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.OneToMany;
|
import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
@@ -12,6 +13,7 @@ import java.util.Set;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组织
|
* 组织
|
||||||
@@ -27,7 +29,8 @@ import lombok.ToString;
|
|||||||
@Include
|
@Include
|
||||||
public class Organization {
|
public class Organization {
|
||||||
@Id
|
@Id
|
||||||
@SnowflakeId.Generator
|
@GeneratedValue(generator = "snowflakeId")
|
||||||
|
@GenericGenerator(name = "snowflakeId", type = SnowflakeId.IdGenerator.class)
|
||||||
private Long organizationId;
|
private Long organizationId;
|
||||||
private String organizationName;
|
private String organizationName;
|
||||||
|
|
||||||
|
|||||||
@@ -6,14 +6,15 @@ import com.yahoo.elide.annotation.Include;
|
|||||||
import jakarta.persistence.ConstraintMode;
|
import jakarta.persistence.ConstraintMode;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.ForeignKey;
|
import jakarta.persistence.ForeignKey;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.JoinColumn;
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import jakarta.persistence.UniqueConstraint;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户
|
* 用户
|
||||||
@@ -29,7 +30,8 @@ import lombok.ToString;
|
|||||||
@Include
|
@Include
|
||||||
public class User {
|
public class User {
|
||||||
@Id
|
@Id
|
||||||
@SnowflakeId.Generator
|
@GeneratedValue(generator = "snowflakeId")
|
||||||
|
@GenericGenerator(name = "snowflakeId", type = SnowflakeId.IdGenerator.class)
|
||||||
private Long userId;
|
private Long userId;
|
||||||
private String userCode;
|
private String userCode;
|
||||||
private String userNickname;
|
private String userNickname;
|
||||||
|
|||||||
@@ -1,10 +1,20 @@
|
|||||||
### Create
|
### Create
|
||||||
POST http://localhost:8080/jsonapi/organization
|
POST http://localhost:8080/jsonapi/organization
|
||||||
Content-Type: application/json
|
Content-Type: application/vnd.api+json
|
||||||
|
|
||||||
{
|
{
|
||||||
|
"data": {
|
||||||
"type": "organization",
|
"type": "organization",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"organizationName": "苹果公司"
|
"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