从简单到复杂完善组织架构

This commit is contained in:
2025-04-18 18:24:08 +08:00
parent e615aefaee
commit c73a7b48fa
14 changed files with 78 additions and 238 deletions

View File

@@ -11,6 +11,11 @@
<option name="name" value="jitpack.io" /> <option name="name" value="jitpack.io" />
<option name="url" value="https://jitpack.io" /> <option name="url" value="https://jitpack.io" />
</remote-repository> </remote-repository>
<remote-repository>
<option name="id" value="lanyuanxiaoyao-maven-central" />
<option name="name" value="lanyuanxiaoyao-maven-central" />
<option name="url" value="https://maven.lanyuanxiaoyao.com/central" />
</remote-repository>
<remote-repository> <remote-repository>
<option name="id" value="central" /> <option name="id" value="central" />
<option name="name" value="central" /> <option name="name" value="central" />
@@ -26,5 +31,10 @@
<option name="name" value="JBoss Community repository" /> <option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository> </remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://maven.lanyuanxiaoyao.com/central" />
</remote-repository>
</component> </component>
</project> </project>

View File

@@ -11,6 +11,7 @@
"dependencies": { "dependencies": {
"@ant-design/icons-vue": "^7.0.1", "@ant-design/icons-vue": "^7.0.1",
"ant-design-vue": "4.x", "ant-design-vue": "4.x",
"licia": "^1.48.0",
"vue": "^3.5.13", "vue": "^3.5.13",
"vue-router": "4" "vue-router": "4"
}, },

8
client/pnpm-lock.yaml generated
View File

@@ -14,6 +14,9 @@ importers:
ant-design-vue: ant-design-vue:
specifier: 4.x specifier: 4.x
version: 4.2.6(vue@3.5.13) version: 4.2.6(vue@3.5.13)
licia:
specifier: ^1.48.0
version: 1.48.0
vue: vue:
specifier: ^3.5.13 specifier: ^3.5.13
version: 3.5.13 version: 3.5.13
@@ -681,6 +684,9 @@ packages:
libphonenumber-js@1.12.5: libphonenumber-js@1.12.5:
resolution: {integrity: sha512-DOjiaVjjSmap12ztyb4QgoFmUe/GbgnEXHu+R7iowk0lzDIjScvPAm8cK9RYTEobbRb0OPlwlZUGTTJPJg13Kw==} resolution: {integrity: sha512-DOjiaVjjSmap12ztyb4QgoFmUe/GbgnEXHu+R7iowk0lzDIjScvPAm8cK9RYTEobbRb0OPlwlZUGTTJPJg13Kw==}
licia@1.48.0:
resolution: {integrity: sha512-bBWiT5CSdEtwuAHiYTJ74yItCjIFdHi4xiFk6BRDfKa+sdCpkUHp69YKb5udNOJlHDzFjNjcMgNZ/+wQIHrB8A==}
lodash-es@4.17.21: lodash-es@4.17.21:
resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==} resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==}
@@ -1489,6 +1495,8 @@ snapshots:
libphonenumber-js@1.12.5: {} libphonenumber-js@1.12.5: {}
licia@1.48.0: {}
lodash-es@4.17.21: {} lodash-es@4.17.21: {}
lodash@4.17.21: {} lodash@4.17.21: {}

View File

@@ -1,3 +1,5 @@
import {isArr} from "licia";
const information = { const information = {
debug: true, debug: true,
baseUrl: 'http://localhost:8080', baseUrl: 'http://localhost:8080',
@@ -18,3 +20,22 @@ export function amisRender(target, amisJson) {
}, },
) )
} }
function parseEdges (edges) {
if (isArr(edges)) {
}
}
export function amisElideGraphQLAdaptor(payload, response, api, context) {
// console.log(payload, response, api, context)
let result = []
console.log(payload)
if (payload.data) {
let items = payload.data[Object.keys(payload.data)[0]]['edges']
for(let item of items) {
result.push(item.node)
}
}
return result
}

View File

@@ -28,17 +28,23 @@ onMounted(() => {
type: 'form', type: 'form',
api: { api: {
method: 'post', method: 'post',
url: `${information.baseUrl}/graphql`, url: `${information.baseUrl}/jsonapi`,
dataType: 'application/json',
data: { data: {
// language=GraphQL data: {
query: 'mutation {\n organization(op: UPSERT, data: {\n organizationName: "苹果"\n }) {\n edges {\n node {\n organizationId\n organizationName\n }\n }\n }\n}', type: 'organization',
attributes: {
name: '${name}'
}
}
}, },
headers: {
'Content-Type': 'application/vnd.api+json'
}
}, },
body: [ body: [
{ {
type: 'input-text', type: 'input-text',
name: 'organizationName', name: 'name',
label: '组织名称', label: '组织名称',
required: true, required: true,
}, },
@@ -47,6 +53,16 @@ onMounted(() => {
}, },
}, },
], ],
api: {
method: 'get',
url: `${information.baseUrl}/jsonapi/organization`,
data: {
page: {
size: '${perPage|default:undefined}',
number: '${page|default:undefined}',
}
},
},
columns: [ columns: [
{ {
name: 'organizationId', name: 'organizationId',

10
pom.xml
View File

@@ -23,6 +23,16 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@@ -1,13 +0,0 @@
package com.lanyuanxiaoyao.server.configuration.amis;
/**
* Crud 响应
*
* @author lanyuanxiaoyao
* @date 2023-07-06
*/
public class AmisItemResponse extends AmisMapResponse {
public void setDetail(Object detail) {
getData().put("item", detail);
}
}

View File

@@ -1,30 +0,0 @@
package com.lanyuanxiaoyao.server.configuration.amis;
/**
* Crud 响应
*
* @author lanyuanxiaoyao
* @date 2023-07-06
*/
public class AmisListResponse extends AmisMapResponse {
public void setData(Iterable<?> list) {
getData().put("items", list);
}
public void setTotal(Long total) {
getData().put("total", total);
}
public void setTotal(Integer total) {
setTotal(total.longValue());
}
public void setData(Iterable<?> list, Long total) {
setData(list);
setTotal(total);
}
public void setData(Iterable<?> list, Integer total) {
setData(list, total.longValue());
}
}

View File

@@ -1,21 +0,0 @@
package com.lanyuanxiaoyao.server.configuration.amis;
import java.util.HashMap;
import java.util.Map;
/**
* Map 响应
*
* @author lanyuanxiaoyao
* @date 2023-07-06
*/
public class AmisMapResponse extends AmisResponse<Map<String, Object>> {
public AmisMapResponse() {
setData(new HashMap<>());
}
public AmisMapResponse setData(String key, Object value) {
getData().put(key, value);
return this;
}
}

View File

@@ -1,106 +0,0 @@
package com.lanyuanxiaoyao.server.configuration.amis;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* Amis 组件结构化返回值
*
* @author lanyuanxiaoyao
* @date 2022-09-21
*/
@ToString
@Getter
@Setter
public class AmisResponse<T> {
private static final int SUCCESS_STATUS = 0;
private static final int ERROR_STATUS = 500;
private static final String SUCCESS_MESSAGE = "成功";
private static final String ERROR_MESSAGE = "错误";
private Integer status;
@JsonProperty("msg")
private String message;
private T data;
public static AmisResponse<Object> responseError() {
return responseError(ERROR_MESSAGE);
}
public static AmisResponse<Object> responseError(String message) {
AmisResponse<Object> response = new AmisResponse<>();
response.setStatus(ERROR_STATUS);
response.setMessage(message);
return response;
}
public static AmisResponse<Object> responseSuccess() {
return responseSuccess(SUCCESS_MESSAGE);
}
public static AmisResponse<Object> responseSuccess(String message) {
AmisResponse<Object> response = new AmisResponse<>();
response.setStatus(SUCCESS_STATUS);
response.setMessage(message);
return response;
}
public static <E> AmisResponse<E> responseSuccess(String message, E data) {
AmisResponse<E> response = new AmisResponse<>();
response.setStatus(SUCCESS_STATUS);
response.setMessage(message);
response.setData(data);
return response;
}
public static <E> AmisResponse<E> responseSuccess(E data) {
return responseSuccess(SUCCESS_MESSAGE, data);
}
public static AmisMapResponse responseMapData() {
AmisMapResponse response = new AmisMapResponse();
response.setStatus(SUCCESS_STATUS);
response.setMessage(SUCCESS_MESSAGE);
return response;
}
public static AmisMapResponse responseMapData(Map<String, Object> data) {
AmisMapResponse response = responseMapData();
response.setData(data);
return response;
}
public static AmisMapResponse responseMapData(String key, Object value) {
AmisMapResponse response = responseMapData();
response.setData(key, value);
return response;
}
public static AmisListResponse responseListData(Iterable<?> data) {
AmisListResponse response = new AmisListResponse();
response.setStatus(SUCCESS_STATUS);
response.setMessage(SUCCESS_MESSAGE);
response.setData(data);
return response;
}
public static AmisListResponse responseListData(Iterable<?> data, Integer total) {
AmisListResponse response = responseListData(data);
response.setTotal(total);
return response;
}
public static AmisListResponse responseListData(Iterable<?> data, Long total) {
AmisListResponse response = responseListData(data);
response.setTotal(total);
return response;
}
public static AmisItemResponse responseItemData(Object detail) {
AmisItemResponse response = new AmisItemResponse();
response.setDetail(detail);
return response;
}
}

View File

@@ -1,6 +1,5 @@
package com.lanyuanxiaoyao.server.controller.base; package com.lanyuanxiaoyao.server.controller.base;
import com.lanyuanxiaoyao.server.configuration.amis.AmisResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -20,8 +19,8 @@ public class ErrorController {
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Throwable.class) @ExceptionHandler(Throwable.class)
public AmisResponse<Object> errorHandler(Throwable throwable) { public String errorHandler(Throwable throwable) {
logger.error("Error", throwable); logger.error("Error", throwable);
return AmisResponse.responseError(throwable.getMessage()); return throwable.getMessage();
} }
} }

View File

@@ -35,17 +35,13 @@ public class Department {
@Id @Id
@GeneratedValue(generator = "snowflakeId") @GeneratedValue(generator = "snowflakeId")
@GenericGenerator(name = "snowflakeId", type = SnowflakeId.IdGenerator.class) @GenericGenerator(name = "snowflakeId", type = SnowflakeId.IdGenerator.class)
private Long departmentId; private Long id;
private String departmentName; private String name;
@ManyToOne(optional = false) @ManyToOne(optional = false)
@JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
private Organization organization; private Organization organization;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "department")
@ToString.Exclude
private Set<User> users;
@ManyToOne @ManyToOne
@JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
private Department parent; private Department parent;

View File

@@ -31,12 +31,8 @@ public class Organization {
@Id @Id
@GeneratedValue(generator = "snowflakeId") @GeneratedValue(generator = "snowflakeId")
@GenericGenerator(name = "snowflakeId", type = SnowflakeId.IdGenerator.class) @GenericGenerator(name = "snowflakeId", type = SnowflakeId.IdGenerator.class)
private Long organizationId; private Long id;
private String organizationName; private String name;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "organization")
@ToString.Exclude
private Set<User> users;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "organization") @OneToMany(fetch = FetchType.LAZY, mappedBy = "organization")
@ToString.Exclude @ToString.Exclude

View File

@@ -1,47 +0,0 @@
package com.lanyuanxiaoyao.server.entity;
import com.lanyuanxiaoyao.server.configuration.Constants;
import com.lanyuanxiaoyao.server.configuration.database.SnowflakeId;
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 lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.GenericGenerator;
/**
* 用户
*
* @author lanyuanxiaoyao
* @version 20250327
*/
@Getter
@Setter
@ToString
@Entity
@Table(name = Constants.DATABASE_TABLE_PREFIX + "user")
@Include
public class User {
@Id
@GeneratedValue(generator = "snowflakeId")
@GenericGenerator(name = "snowflakeId", type = SnowflakeId.IdGenerator.class)
private Long userId;
private String userCode;
private String userNickname;
private String userSecret;
@ManyToOne
@JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
private Organization organization;
@ManyToOne
@JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
private Department department;
}