Compare commits
1 Commits
dbdf9c59bb
...
jdk17
| Author | SHA1 | Date | |
|---|---|---|---|
| 6eacbfddd4 |
4
.idea/compiler.xml
generated
4
.idea/compiler.xml
generated
@@ -7,8 +7,8 @@
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="gringotts-chain" />
|
||||
<module name="gringotts-web" />
|
||||
<module name="gringotts-chain" />
|
||||
<module name="gringotts-core" />
|
||||
<module name="gringotts-gateway" />
|
||||
<module name="gringotts-forest" />
|
||||
@@ -24,7 +24,7 @@
|
||||
<module name="gringotts-core" options="-parameters" />
|
||||
<module name="gringotts-forest" options="-parameters" />
|
||||
<module name="gringotts-gateway" options="-parameters" />
|
||||
<module name="gringotts-web" options="-parameters -processor lombok.launch.AnnotationProcessorHider$AnnotationProcessor,org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor" />
|
||||
<module name="gringotts-web" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@@ -1,6 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="mavenCentral" />
|
||||
<option name="name" value="mavenCentral" />
|
||||
|
||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -8,7 +8,7 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="corretto-11" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<artifactId>sa-token-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.retry</groupId>
|
||||
|
||||
@@ -2,10 +2,6 @@ package com.eshore.gringotts.configuration;
|
||||
|
||||
import com.fasterxml.jackson.datatype.eclipsecollections.EclipseCollectionsModule;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
@@ -25,17 +21,9 @@ public class JacksonConfiguration {
|
||||
@Bean
|
||||
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
|
||||
return builder -> {
|
||||
/*
|
||||
* 配置时间格式
|
||||
*/
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
||||
javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(formatter));
|
||||
javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(formatter));
|
||||
|
||||
builder.modules(
|
||||
new EclipseCollectionsModule(),
|
||||
javaTimeModule
|
||||
new JavaTimeModule()
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dtflys.forest</groupId>
|
||||
<artifactId>forest-spring-boot-starter</artifactId>
|
||||
<artifactId>forest-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export const information = {
|
||||
debug: false,
|
||||
const information = {
|
||||
debug: true,
|
||||
// baseUrl: '',
|
||||
baseUrl: 'http://127.0.0.1:20080',
|
||||
title: '可信供给中心',
|
||||
@@ -17,7 +17,6 @@ export function useAmis(amisObject) {
|
||||
struct,
|
||||
{
|
||||
data: {
|
||||
debug: information.debug,
|
||||
base: information.baseUrl,
|
||||
},
|
||||
},
|
||||
@@ -99,7 +98,6 @@ export function inputFileFormItemCommonOptions(accept = '*', maxSize = size5MB)
|
||||
accept: accept,
|
||||
maxSize: maxSize,
|
||||
autoUpload: false,
|
||||
drag: true,
|
||||
startChunkApi: apiPost('${base}/upload/start'),
|
||||
chunkApi: apiPost('${base}/upload/slice'),
|
||||
finishChunkApi: apiPost('${base}/upload/finish'),
|
||||
@@ -131,7 +129,6 @@ export function copyField(field, label, tips = '复制', ignoreLength = 0, extra
|
||||
}
|
||||
return {
|
||||
name: field,
|
||||
label: label,
|
||||
type: 'wrapper',
|
||||
size: 'none',
|
||||
className: 'nowrap',
|
||||
@@ -200,7 +197,7 @@ export function stringField(field, label, width = undefined, wrap = false) {
|
||||
if (width) {
|
||||
data['width'] = width
|
||||
}
|
||||
if (!wrap) {
|
||||
if (wrap) {
|
||||
data['className'] = 'nowrap'
|
||||
}
|
||||
return data
|
||||
@@ -250,11 +247,10 @@ export const userStateMapping = [
|
||||
mappingItem('禁用', 'DISABLED', 'bg-danger'),
|
||||
]
|
||||
|
||||
export const permissionStateMapping = [
|
||||
export const confirmationStateMapping = [
|
||||
mappingItem('未确权', 'NONE'),
|
||||
mappingItem('草稿', 'DRAFT', 'bg-primary'),
|
||||
mappingItem('审查中', 'CHECKING', 'bg-warning'),
|
||||
mappingItem('用户审查中', 'OWNER_CHECKING', 'bg-warning'),
|
||||
mappingItem('通过', 'NORMAL', 'bg-success'),
|
||||
mappingItem('驳回', 'REJECT', 'bg-danger'),
|
||||
]
|
||||
@@ -265,9 +261,8 @@ export const checkTypeMapping = [
|
||||
]
|
||||
|
||||
export const checkOverMapping = [
|
||||
mappingItem('进行中', 'CHECKING', 'bg-warning'),
|
||||
mappingItem('已撤销', 'RETRACT', 'bg-primary'),
|
||||
mappingItem('已办结', 'OVER', 'bg-success'),
|
||||
mappingItem('完结', 'true', 'bg-success'),
|
||||
mappingItem('进行中', 'false', 'bg-primary'),
|
||||
]
|
||||
|
||||
function api(method, url) {
|
||||
@@ -296,11 +291,10 @@ export function arrayOutCheck(array, field) {
|
||||
return `\${!ARRAYINCLUDES(['${array.join("','")}'], ${field})}`
|
||||
}
|
||||
|
||||
export const checkState = {
|
||||
export const confirmationState = {
|
||||
none: 'NONE',
|
||||
draft: 'DRAFT',
|
||||
checking: 'CHECKING',
|
||||
ownerChecking: 'OWNER_CHECKING',
|
||||
normal: 'NORMAL',
|
||||
}
|
||||
|
||||
|
||||
@@ -6,29 +6,14 @@ import {
|
||||
formInputClearable,
|
||||
formInputMultiFileStatic,
|
||||
horizontalFormOptions,
|
||||
information,
|
||||
inputFileFormItemCommonOptions,
|
||||
size100MB
|
||||
} from "../constants.js";
|
||||
import {resourceList} from "../../pages/index/tab-data.js";
|
||||
import {resourceDetailDialog} from "../resource/dialog-resource.js";
|
||||
|
||||
const CONFIRMATION_TYPE = 'confirmation'
|
||||
const AUTHENTICATION_TYPE = 'authentication'
|
||||
|
||||
const CONFIRMATION = {
|
||||
type: 'confirmation',
|
||||
pickerApi: apiGet('${base}/data_resource/list_no_confirmation')
|
||||
}
|
||||
|
||||
const AUTHENTICATION = {
|
||||
type: 'authentication',
|
||||
pickerApi: apiGet('${base}/data_resource/list_no_authentication')
|
||||
}
|
||||
|
||||
function detailForm(pickerApi = apiGet('${base}/data_resource/list'), showCreatedUserAndModifiedUser = false) {
|
||||
function detailForm(showCreatedUserAndModifiedUser = false) {
|
||||
return {
|
||||
debug: information.debug,
|
||||
id: 'permission_form',
|
||||
type: 'form',
|
||||
...horizontalFormOptions(),
|
||||
@@ -49,7 +34,7 @@ function detailForm(pickerApi = apiGet('${base}/data_resource/list'), showCreate
|
||||
size: 'md',
|
||||
valueField: 'id',
|
||||
labelField: 'name',
|
||||
source: pickerApi,
|
||||
source: apiGet('${base}/data_resource/list'),
|
||||
pickerSchema: {
|
||||
...resourceList(),
|
||||
},
|
||||
@@ -70,7 +55,6 @@ function detailForm(pickerApi = apiGet('${base}/data_resource/list'), showCreate
|
||||
},
|
||||
{
|
||||
type: 'textarea',
|
||||
placeholder: '请输入确权说明',
|
||||
label: '确权说明',
|
||||
name: 'description',
|
||||
...formInputClearable,
|
||||
@@ -86,38 +70,12 @@ function detailForm(pickerApi = apiGet('${base}/data_resource/list'), showCreate
|
||||
joinValues: false,
|
||||
...inputFileFormItemCommonOptions(undefined, size100MB),
|
||||
},
|
||||
{
|
||||
visibleOn: `\${${AUTHENTICATION_TYPE}}`,
|
||||
type: 'input-datetime-range',
|
||||
name: 'activeTime',
|
||||
extraName: 'expiredTime',
|
||||
label: '授权时间',
|
||||
required: true,
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
shortcuts: [
|
||||
'7dayslater',
|
||||
'14dayslater',
|
||||
'30dayslater',
|
||||
'180dayslater',
|
||||
'365dayslater',
|
||||
]
|
||||
},
|
||||
...(showCreatedUserAndModifiedUser ? formCreatedUserAndModifiedUser() : [])
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export function confirmationAddDialog() {
|
||||
return permissionAddDialog(CONFIRMATION)
|
||||
}
|
||||
|
||||
export function authenticationAddDialog() {
|
||||
return permissionAddDialog(AUTHENTICATION)
|
||||
}
|
||||
|
||||
function permissionAddDialog(config) {
|
||||
let data = {add: true}
|
||||
data[config.type] = true
|
||||
export function permissionAddDialog() {
|
||||
return {
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
@@ -135,25 +93,17 @@ function permissionAddDialog(config) {
|
||||
}
|
||||
],
|
||||
body: {
|
||||
...detailForm(config.pickerApi),
|
||||
api: apiPost(`\${base}/${config.type}/save`),
|
||||
data: data,
|
||||
...detailForm(),
|
||||
api: apiPost('${base}/confirmation/save'),
|
||||
data: {
|
||||
add: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function confirmationDetailDialog(field = 'id', actions = []) {
|
||||
return permissionDetailDialog(CONFIRMATION, field, actions)
|
||||
}
|
||||
|
||||
export function authenticationDetailDialog(field = 'id', actions = []) {
|
||||
return permissionDetailDialog(AUTHENTICATION, field, actions)
|
||||
}
|
||||
|
||||
function permissionDetailDialog(config, field = 'id', actions = []) {
|
||||
let data = {detail: true}
|
||||
data[config.type] = true
|
||||
export function permissionDetailDialog(field = 'id', actions = []) {
|
||||
return {
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
@@ -161,26 +111,18 @@ function permissionDetailDialog(config, field = 'id', actions = []) {
|
||||
size: 'md',
|
||||
actions: actions,
|
||||
body: {
|
||||
...detailForm(config.pickerApi, true),
|
||||
initApi: apiGet(`\${base}/${config.type}/detail/\${${field}}`),
|
||||
...detailForm(true),
|
||||
initApi: apiGet(`\${base}/confirmation/detail/\${${field}}`),
|
||||
static: true,
|
||||
data: data,
|
||||
data: {
|
||||
detail: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function confirmationEditeDialog(field = 'id') {
|
||||
return permissionEditeDialog(CONFIRMATION, field)
|
||||
}
|
||||
|
||||
export function authenticationEditeDialog(field = 'id') {
|
||||
return permissionEditeDialog(AUTHENTICATION, field)
|
||||
}
|
||||
|
||||
function permissionEditeDialog(config, field = 'id') {
|
||||
let data = {edit: true}
|
||||
data[config.type] = true
|
||||
export function permissionEditeDialog(field = 'id') {
|
||||
return {
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
@@ -198,10 +140,12 @@ function permissionEditeDialog(config, field = 'id') {
|
||||
}
|
||||
],
|
||||
body: {
|
||||
...detailForm(config.pickerApi),
|
||||
api: apiPost(`\${base}/${config.type}/save`),
|
||||
initApi: apiGet(`\${base}/${config.type}/detail/\${${field}}`),
|
||||
data: data,
|
||||
...detailForm(),
|
||||
api: apiPost('${base}/confirmation/save'),
|
||||
initApi: apiGet(`\${base}/confirmation/detail/\${${field}}`),
|
||||
data: {
|
||||
edit: true,
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,16 +16,8 @@ const dialogBody = [
|
||||
{
|
||||
type: 'group',
|
||||
body: [
|
||||
{
|
||||
type: 'control',
|
||||
label: '角色',
|
||||
body: mappingField('role', '角色', userRoleMapping, 120),
|
||||
},
|
||||
{
|
||||
type: 'control',
|
||||
label: '账号状态',
|
||||
body: mappingField('state', '账号状态', userStateMapping),
|
||||
}
|
||||
mappingField('role', '角色', userRoleMapping),
|
||||
mappingField('state', '账号状态', userStateMapping),
|
||||
]
|
||||
},
|
||||
...formCreatedUserAndModifiedUser(),
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
textarea {
|
||||
resize: none !important;
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
import './dialog-ware.css'
|
||||
import {apiGet, apiPost, formInputClearable, horizontalFormOptions, information} from "../constants.js";
|
||||
|
||||
function detailForm() {
|
||||
return {
|
||||
debug: information.debug,
|
||||
type: 'form',
|
||||
...horizontalFormOptions(),
|
||||
horizontal: {
|
||||
left: 2,
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'hidden',
|
||||
name: 'id',
|
||||
},
|
||||
{
|
||||
type: 'input-image',
|
||||
name: 'icon',
|
||||
label: '图标',
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'name',
|
||||
label: '商品名称',
|
||||
maxLength: 10,
|
||||
showCounter: true,
|
||||
required: true,
|
||||
...formInputClearable,
|
||||
},
|
||||
{
|
||||
type: 'textarea',
|
||||
name: 'description',
|
||||
label: '商品简介',
|
||||
required: true,
|
||||
...formInputClearable,
|
||||
showCounter: true,
|
||||
trimContents: true,
|
||||
minRows: 2,
|
||||
maxRows: 2,
|
||||
},
|
||||
{
|
||||
type: 'input-rich-text',
|
||||
name: 'content',
|
||||
label: '商品详情',
|
||||
required: true,
|
||||
options: {
|
||||
min_height: 300,
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export function wareAddDialog() {
|
||||
return {
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '上架数据产品',
|
||||
size: 'md',
|
||||
actions: [
|
||||
{
|
||||
type: 'reset',
|
||||
label: '重置',
|
||||
},
|
||||
{
|
||||
type: 'submit',
|
||||
label: '确定',
|
||||
level: 'primary',
|
||||
}
|
||||
],
|
||||
body: {
|
||||
...detailForm(),
|
||||
api: apiPost(`\${base}/ware/save`),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function wareDetailDialog() {
|
||||
return {
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '确权申请详情',
|
||||
size: 'md',
|
||||
body: {
|
||||
...detailForm(),
|
||||
initApi: apiGet(`\${base}/ware/detail/\${id}`),
|
||||
static: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function wareEditeDialog() {
|
||||
return {
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '确权申请详情',
|
||||
size: 'md',
|
||||
actions: [
|
||||
{
|
||||
type: 'reset',
|
||||
label: '重置',
|
||||
},
|
||||
{
|
||||
type: 'submit',
|
||||
label: '确定',
|
||||
level: 'primary',
|
||||
}
|
||||
],
|
||||
body: {
|
||||
...detailForm(),
|
||||
api: apiPost(`\${base}/ware/save`),
|
||||
initApi: apiGet(`\${base}/ware/detail/\${${field}}`),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import {tabData} from "./tab-data.js";
|
||||
import {tabSettings} from "./tab-settings.js";
|
||||
import {tabCheck} from "./tab-check.js";
|
||||
import {tabPermissions} from "./tab-permissions.js";
|
||||
import {tabMarket} from "./tab-market.js";
|
||||
|
||||
useAmis(information => {
|
||||
return {
|
||||
@@ -59,10 +58,10 @@ useAmis(information => {
|
||||
tabsMode: 'vertical',
|
||||
tabs: [
|
||||
// tabOverview(),
|
||||
tabMarket(),
|
||||
tabPermissions(),
|
||||
// tabMarket(),
|
||||
tabCheck(),
|
||||
tabData(),
|
||||
tabPermissions(),
|
||||
tabUser(),
|
||||
tabSettings(),
|
||||
]
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
stringField,
|
||||
timeField,
|
||||
} from "../../components/constants.js";
|
||||
import {authenticationDetailDialog, confirmationDetailDialog} from "../../components/permission/dialog-permission.js";
|
||||
import {permissionDetailDialog} from "../../components/permission/dialog-permission.js";
|
||||
|
||||
export function tabCheck() {
|
||||
return {
|
||||
@@ -29,18 +29,18 @@ export function tabCheck() {
|
||||
columns: [
|
||||
stringField('description', '描述'),
|
||||
mappingField('type', '类型', checkTypeMapping),
|
||||
mappingField('state', '状态', checkOverMapping),
|
||||
mappingField('over', '状态', checkOverMapping),
|
||||
timeField('createdTime', '创建时间'),
|
||||
stringField('createdUsername', '创建人', 100),
|
||||
timeField('modifiedTime', '最后修改时间'),
|
||||
stringField('modifiedUsername', '最后操作人', 100),
|
||||
operationField('操作', undefined, [
|
||||
{
|
||||
visibleOn: `\${type === 'CONFIRMATION' && state === 'CHECKING'}`,
|
||||
visibleOn: '${!over}',
|
||||
type: 'action',
|
||||
label: '处理',
|
||||
level: 'link',
|
||||
...confirmationDetailDialog(
|
||||
...permissionDetailDialog(
|
||||
'parameters.confirmationId',
|
||||
[
|
||||
{
|
||||
@@ -63,45 +63,11 @@ export function tabCheck() {
|
||||
),
|
||||
},
|
||||
{
|
||||
visibleOn: `\${type === 'CONFIRMATION' && state !== NORMAL}`,
|
||||
visibleOn: '${over}',
|
||||
type: 'action',
|
||||
label: '查看',
|
||||
level: 'link',
|
||||
...confirmationDetailDialog('parameters.confirmationId'),
|
||||
},
|
||||
{
|
||||
visibleOn: `\${type === 'AUTHENTICATION' && state === 'CHECKING'}`,
|
||||
type: 'action',
|
||||
label: '处理',
|
||||
level: 'link',
|
||||
...authenticationDetailDialog(
|
||||
'parameters.authenticationId',
|
||||
[
|
||||
{
|
||||
type: 'action',
|
||||
label: '同意',
|
||||
actionType: 'ajax',
|
||||
close: true,
|
||||
api: apiGet('${base}/check_order/operation/${checkOrderId}/APPLY'),
|
||||
reload: 'check_order_list',
|
||||
},
|
||||
{
|
||||
type: 'action',
|
||||
label: '拒绝',
|
||||
actionType: 'ajax',
|
||||
close: true,
|
||||
api: apiGet('${base}/check_order/operation/${checkOrderId}/REJECT'),
|
||||
reload: 'check_order_list',
|
||||
},
|
||||
],
|
||||
),
|
||||
},
|
||||
{
|
||||
visibleOn: `\${type === 'AUTHENTICATION' && state !== NORMAL}`,
|
||||
type: 'action',
|
||||
label: '查看',
|
||||
level: 'link',
|
||||
...authenticationDetailDialog('parameters.authenticationId'),
|
||||
...permissionDetailDialog('parameters.confirmationId'),
|
||||
},
|
||||
]),
|
||||
],
|
||||
|
||||
@@ -7,11 +7,11 @@ import {
|
||||
apiGet,
|
||||
arrayInCheck,
|
||||
arrayOutCheck,
|
||||
checkState,
|
||||
confirmationState,
|
||||
confirmationStateMapping,
|
||||
crudCommonOptions,
|
||||
mappingField,
|
||||
operationField,
|
||||
permissionStateMapping,
|
||||
timeField,
|
||||
userOnly
|
||||
} from "../../components/constants.js";
|
||||
@@ -40,7 +40,7 @@ export function resourceList() {
|
||||
label: '描述',
|
||||
name: 'description',
|
||||
},
|
||||
mappingField('confirmationState', '确权状态', permissionStateMapping),
|
||||
mappingField('confirmationState', '确权状态', confirmationStateMapping),
|
||||
timeField('createdTime', '创建时间'),
|
||||
operationField('操作', undefined, [
|
||||
{
|
||||
@@ -57,7 +57,7 @@ export function resourceList() {
|
||||
trigger: 'hover',
|
||||
buttons: [
|
||||
{
|
||||
disabledOn: arrayOutCheck([checkState.none, checkState.draft], 'confirmationState'),
|
||||
disabledOn: arrayOutCheck([confirmationState.none, confirmationState.draft], 'confirmationState'),
|
||||
disabledTip: '审查或确权成功后无法编辑',
|
||||
tooltipPlacement: 'top',
|
||||
type: 'action',
|
||||
@@ -66,7 +66,7 @@ export function resourceList() {
|
||||
...resourceEditeDialog(),
|
||||
},
|
||||
{
|
||||
disabledOn: arrayInCheck([checkState.checking], 'confirmationState'),
|
||||
disabledOn: arrayInCheck([confirmationState.checking], 'confirmationState'),
|
||||
disabledTip: '审查中无法删除',
|
||||
tooltipPlacement: 'bottom',
|
||||
type: 'action',
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
import {wareAddDialog} from "../../components/ware/dialog-ware.js";
|
||||
|
||||
export function tabMarket() {
|
||||
return {
|
||||
title: '数据市场',
|
||||
icon: 'fa fa-store',
|
||||
body: [
|
||||
{
|
||||
type: 'action',
|
||||
label: '',
|
||||
icon: 'fa fa-plus',
|
||||
...wareAddDialog()
|
||||
},
|
||||
'hello world'
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,9 @@
|
||||
import {
|
||||
apiGet,
|
||||
arrayInCheck,
|
||||
arrayOutCheck,
|
||||
checkState,
|
||||
confirmationStateMapping,
|
||||
crudCommonOptions,
|
||||
customerOnly,
|
||||
mappingField,
|
||||
operationField,
|
||||
permissionStateMapping,
|
||||
providerOnly,
|
||||
stringField,
|
||||
stringWrapField,
|
||||
@@ -15,12 +11,9 @@ import {
|
||||
userOnly,
|
||||
} from "../../components/constants.js";
|
||||
import {
|
||||
authenticationAddDialog,
|
||||
authenticationDetailDialog,
|
||||
authenticationEditeDialog,
|
||||
confirmationAddDialog,
|
||||
confirmationDetailDialog,
|
||||
confirmationEditeDialog,
|
||||
permissionAddDialog,
|
||||
permissionDetailDialog,
|
||||
permissionEditeDialog,
|
||||
} from "../../components/permission/dialog-permission.js";
|
||||
|
||||
export function tabPermissions() {
|
||||
@@ -47,20 +40,20 @@ export function tabPermissions() {
|
||||
type: 'action',
|
||||
label: '',
|
||||
icon: 'fa fa-plus',
|
||||
...confirmationAddDialog()
|
||||
...permissionAddDialog()
|
||||
},
|
||||
],
|
||||
columns: [
|
||||
stringField('name', '名称', 200),
|
||||
stringWrapField('description', '描述'),
|
||||
mappingField('state', '状态', permissionStateMapping),
|
||||
mappingField('state', '状态', confirmationStateMapping),
|
||||
timeField('createdTime', '创建时间'),
|
||||
operationField('操作', undefined, [
|
||||
{
|
||||
type: 'action',
|
||||
label: '查看',
|
||||
level: 'link',
|
||||
...confirmationDetailDialog(),
|
||||
...permissionDetailDialog(),
|
||||
},
|
||||
{
|
||||
visibleOn: "${state === 'CHECKING'}",
|
||||
@@ -94,7 +87,7 @@ export function tabPermissions() {
|
||||
type: 'action',
|
||||
label: '编辑',
|
||||
level: 'link',
|
||||
...confirmationEditeDialog(),
|
||||
...permissionEditeDialog(),
|
||||
},
|
||||
{
|
||||
disabledOn: "${state === 'CHECKING'}",
|
||||
@@ -112,84 +105,9 @@ export function tabPermissions() {
|
||||
}
|
||||
},
|
||||
{
|
||||
visibleOn: customerOnly,
|
||||
title: '授权管理',
|
||||
body: {
|
||||
type: 'crud',
|
||||
api: {
|
||||
...apiGet('${base}/authentication/list')
|
||||
},
|
||||
...crudCommonOptions(),
|
||||
headerToolbar: [
|
||||
'reload',
|
||||
{
|
||||
type: 'action',
|
||||
label: '',
|
||||
icon: 'fa fa-plus',
|
||||
...authenticationAddDialog()
|
||||
},
|
||||
],
|
||||
columns: [
|
||||
stringField('name', '名称', 200),
|
||||
stringWrapField('description', '描述'),
|
||||
mappingField('state', '状态', permissionStateMapping),
|
||||
timeField('createdTime', '创建时间'),
|
||||
operationField('操作', undefined, [
|
||||
{
|
||||
type: 'action',
|
||||
label: '查看',
|
||||
level: 'link',
|
||||
...authenticationDetailDialog(),
|
||||
},
|
||||
{
|
||||
visibleOn: arrayInCheck([checkState.ownerChecking, checkState.checking], 'state'),
|
||||
type: 'action',
|
||||
label: '撤销',
|
||||
level: 'link',
|
||||
confirmTitle: '确认撤销',
|
||||
confirmText: '确认撤销名称为「${name}」的授权申请吗?',
|
||||
actionType: 'ajax',
|
||||
api: apiGet('${base}/authentication/retract/${id}'),
|
||||
},
|
||||
{
|
||||
visibleOn: arrayInCheck([checkState.draft], 'state'),
|
||||
type: 'action',
|
||||
label: '提交',
|
||||
level: 'link',
|
||||
confirmTitle: '确认提交',
|
||||
confirmText: '确认提交名称为「${name}」的授权申请吗?',
|
||||
actionType: 'ajax',
|
||||
api: apiGet('${base}/authentication/submit/${id}'),
|
||||
},
|
||||
{
|
||||
type: 'dropdown-button',
|
||||
level: 'link',
|
||||
icon: 'fa fa-ellipsis-h',
|
||||
hideCaret: true,
|
||||
trigger: 'hover',
|
||||
buttons: [
|
||||
{
|
||||
disabledOn: arrayOutCheck([checkState.draft], 'state'),
|
||||
type: 'action',
|
||||
label: '编辑',
|
||||
level: 'link',
|
||||
...authenticationEditeDialog(),
|
||||
},
|
||||
{
|
||||
disabledOn: arrayInCheck([checkState.ownerChecking, checkState.checking], 'state'),
|
||||
type: 'action',
|
||||
label: "删除",
|
||||
confirmTitle: '确认删除',
|
||||
confirmText: '确认删除名称为「${name}」的确权申请吗?删除后对应的数据资源处于未确权状态。',
|
||||
actionType: 'ajax',
|
||||
api: apiGet('${base}/authentication/remove/${id}'),
|
||||
},
|
||||
]
|
||||
},
|
||||
]),
|
||||
]
|
||||
}
|
||||
},
|
||||
body: []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
<dependency>
|
||||
<groupId>com.eshore</groupId>
|
||||
<artifactId>gringotts-forest</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -28,12 +34,6 @@
|
||||
<groupId>com.blinkfox</groupId>
|
||||
<artifactId>fenix-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||
<version>${hibernate.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
@@ -43,18 +43,6 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<parameters>true</parameters>
|
||||
<compilerArguments>
|
||||
<processor>
|
||||
lombok.launch.AnnotationProcessorHider$AnnotationProcessor,org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
|
||||
</processor>
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.eshore.gringotts.web;
|
||||
|
||||
import com.blinkfox.fenix.EnableFenix;
|
||||
import com.eshore.gringotts.web.domain.entity.User;
|
||||
import com.eshore.gringotts.web.domain.service.UserService;
|
||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
@@ -10,8 +9,6 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.domain.AuditorAware;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
@@ -44,9 +41,4 @@ public class WebApplication implements ApplicationRunner {
|
||||
// 初始化系统管理员
|
||||
userService.initial();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuditorAware<User> auditorAware(UserService userService) {
|
||||
return userService::currentLoginUserOptional;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
package com.eshore.gringotts.web.domain.entity;
|
||||
package com.eshore.gringotts.web.domain.authentication.entity;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteEntity;
|
||||
import java.time.LocalDateTime;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.DataResource;
|
||||
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EntityListeners;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.JoinTable;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.NamedAttributeNode;
|
||||
import jakarta.persistence.NamedEntityGraph;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.Set;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ConstraintMode;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.NamedAttributeNode;
|
||||
import javax.persistence.NamedEntityGraph;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
/**
|
||||
@@ -50,8 +47,6 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
@NamedAttributeNode(value = "createdUser"),
|
||||
@NamedAttributeNode(value = "modifiedUser"),
|
||||
})
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "authentication" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class Authentication extends CheckingNeededEntity {
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
@@ -60,14 +55,4 @@ public class Authentication extends CheckingNeededEntity {
|
||||
@JoinTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT), inverseForeignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
@ToString.Exclude
|
||||
private Set<DataFile> evidences;
|
||||
/**
|
||||
* 生效时间
|
||||
*/
|
||||
@Column(nullable = false)
|
||||
private LocalDateTime activeTime = LocalDateTime.now();
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
@Column(nullable = false)
|
||||
private LocalDateTime expiredTime = LocalDateTime.now().plusDays(1);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.eshore.gringotts.web.domain.base.controller;
|
||||
|
||||
import com.eshore.gringotts.web.configuration.amis.AmisResponse;
|
||||
import com.eshore.gringotts.web.domain.base.controller.query.Query;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
|
||||
/**
|
||||
@@ -10,6 +9,4 @@ import org.eclipse.collections.api.list.ImmutableList;
|
||||
*/
|
||||
public interface ListController<LIST_ITEM> {
|
||||
AmisResponse<ImmutableList<LIST_ITEM>> list() throws Exception;
|
||||
|
||||
AmisResponse<ImmutableList<LIST_ITEM>> list(Query query) throws Exception;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
package com.eshore.gringotts.web.domain.base.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.eshore.gringotts.web.configuration.amis.AmisResponse;
|
||||
import com.eshore.gringotts.web.domain.base.controller.query.Query;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity;
|
||||
import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -17,7 +13,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-26
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class SimpleControllerSupport<ENTITY extends SimpleEntity, SAVE_ITEM, LIST_ITEM, DETAIL_ITEM> implements SimpleController<SAVE_ITEM, LIST_ITEM, DETAIL_ITEM> {
|
||||
protected static final String SAVE = "/save";
|
||||
protected static final String LIST = "/list";
|
||||
@@ -38,7 +33,7 @@ public abstract class SimpleControllerSupport<ENTITY extends SimpleEntity, SAVE_
|
||||
|
||||
@GetMapping(LIST)
|
||||
@Override
|
||||
public AmisResponse<ImmutableList<LIST_ITEM>> list() throws Exception {
|
||||
public AmisResponse<ImmutableList<LIST_ITEM>> list() {
|
||||
return AmisResponse.responseSuccess(service.list().collect(entity -> {
|
||||
try {
|
||||
return toListItem(entity);
|
||||
@@ -48,25 +43,10 @@ public abstract class SimpleControllerSupport<ENTITY extends SimpleEntity, SAVE_
|
||||
}));
|
||||
}
|
||||
|
||||
@PostMapping(LIST)
|
||||
@Override
|
||||
public AmisResponse<ImmutableList<LIST_ITEM>> list(@RequestBody Query query) throws Exception {
|
||||
if (ObjectUtil.isNull(query)) {
|
||||
return AmisResponse.responseSuccess(Lists.immutable.empty());
|
||||
}
|
||||
return AmisResponse.responseSuccess(service.list(query).collect(entity -> {
|
||||
try {
|
||||
return toListItem(entity);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@GetMapping(DETAIL)
|
||||
@Override
|
||||
public AmisResponse<DETAIL_ITEM> detail(@PathVariable Long id) throws Exception {
|
||||
return AmisResponse.responseSuccess(toDetailItem(service.detailOrThrow(id)));
|
||||
return AmisResponse.responseSuccess(toDetailItem(service.detail(id)));
|
||||
}
|
||||
|
||||
@GetMapping(REMOVE)
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.base.controller.query;
|
||||
|
||||
import lombok.Data;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.eclipse.collections.api.map.ImmutableMap;
|
||||
|
||||
/**
|
||||
* 统一查询
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-12-03
|
||||
*/
|
||||
@Data
|
||||
public class Query {
|
||||
private Queryable query;
|
||||
private ImmutableList<Sortable> sort;
|
||||
private Pageable page;
|
||||
|
||||
@Data
|
||||
public static class Queryable {
|
||||
private ImmutableList<String> nullEqual;
|
||||
private ImmutableList<String> notNullEqual;
|
||||
private ImmutableList<String> empty;
|
||||
private ImmutableList<String> notEmpty;
|
||||
private ImmutableMap<String, ?> equal;
|
||||
private ImmutableMap<String, ?> notEqual;
|
||||
private ImmutableMap<String, String> like;
|
||||
private ImmutableMap<String, String> notLike;
|
||||
private ImmutableMap<String, ?> great;
|
||||
private ImmutableMap<String, ?> less;
|
||||
private ImmutableMap<String, ?> greatEqual;
|
||||
private ImmutableMap<String, ?> lessEqual;
|
||||
private ImmutableMap<String, ImmutableList<?>> in;
|
||||
private ImmutableMap<String, ImmutableList<?>> notIn;
|
||||
private ImmutableMap<String, Between> between;
|
||||
private ImmutableMap<String, Between> notBetween;
|
||||
|
||||
@Data
|
||||
public static class Between {
|
||||
private String start;
|
||||
private String end;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Sortable {
|
||||
private String column;
|
||||
private Direction direction;
|
||||
|
||||
public enum Direction {
|
||||
ASC,
|
||||
DESC,
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Pageable {
|
||||
private Integer page;
|
||||
private Integer size;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,10 @@
|
||||
package com.eshore.gringotts.web.domain.base.entity;
|
||||
|
||||
import com.eshore.gringotts.web.domain.entity.CheckOrder;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.OneToOne;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.EntityListeners;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
@@ -26,10 +22,6 @@ public class CheckingNeededEntity extends LogicDeleteEntity {
|
||||
@Enumerated(EnumType.STRING)
|
||||
private State state = State.DRAFT;
|
||||
|
||||
@OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
|
||||
@ToString.Exclude
|
||||
private CheckOrder order;
|
||||
|
||||
public enum State {
|
||||
/**
|
||||
* 无确权
|
||||
@@ -43,10 +35,6 @@ public class CheckingNeededEntity extends LogicDeleteEntity {
|
||||
* 审查中
|
||||
*/
|
||||
CHECKING,
|
||||
/**
|
||||
* 用户审核
|
||||
*/
|
||||
OWNER_CHECKING,
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.eshore.gringotts.web.domain.base.entity;
|
||||
|
||||
import com.eshore.gringotts.web.domain.entity.DataFile;
|
||||
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.TreeNode;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.eshore.gringotts.web.domain.base.entity;
|
||||
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import jakarta.persistence.EntityListeners;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.eshore.gringotts.web.domain.base.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.EntityListeners;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SoftDelete;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
/**
|
||||
@@ -19,9 +20,8 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
@ToString(callSuper = true)
|
||||
@MappedSuperclass
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@SoftDelete(columnName = "delete")
|
||||
public class LogicDeleteEntity extends SimpleEntity {
|
||||
public static final String LOGIC_DELETE_CLAUSE = "deleted = false";
|
||||
|
||||
@Column(nullable = false)
|
||||
private Boolean deleted = false;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.eshore.gringotts.web.domain.base.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.EntityListeners;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SoftDelete;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
/**
|
||||
@@ -19,9 +20,8 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
@ToString(callSuper = true)
|
||||
@MappedSuperclass
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@SoftDelete(columnName = "delete")
|
||||
public class LogicDeleteIdOnlyEntity extends IdOnlyEntity {
|
||||
public static final String LOGIC_DELETE_CLAUSE = "deleted = false";
|
||||
|
||||
@Column(nullable = false)
|
||||
private Boolean deleted = false;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
package com.eshore.gringotts.web.domain.base.entity;
|
||||
|
||||
import com.eshore.gringotts.web.domain.entity.User;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.EntityListeners;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import java.time.LocalDateTime;
|
||||
import javax.persistence.ConstraintMode;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.OneToOne;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
@@ -35,13 +33,11 @@ public class SimpleEntity extends IdOnlyEntity {
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
@ToString.Exclude
|
||||
@CreatedBy
|
||||
private User createdUser;
|
||||
@LastModifiedDate
|
||||
private LocalDateTime modifiedTime;
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
@ToString.Exclude
|
||||
@LastModifiedBy
|
||||
private User modifiedUser;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.eshore.gringotts.web.domain.base.repository;
|
||||
import com.blinkfox.fenix.jpa.FenixJpaRepository;
|
||||
import com.blinkfox.fenix.specification.FenixJpaSpecificationExecutor;
|
||||
import org.springframework.data.repository.NoRepositoryBean;
|
||||
import org.springframework.data.repository.query.QueryByExampleExecutor;
|
||||
|
||||
/**
|
||||
* 整合一下
|
||||
@@ -12,5 +11,5 @@ import org.springframework.data.repository.query.QueryByExampleExecutor;
|
||||
* @date 2024-11-21
|
||||
*/
|
||||
@NoRepositoryBean
|
||||
public interface SimpleRepository<E, ID> extends FenixJpaRepository<E, ID>, FenixJpaSpecificationExecutor<E>, QueryByExampleExecutor<E> {
|
||||
public interface SimpleRepository<E, ID> extends FenixJpaRepository<E, ID>, FenixJpaSpecificationExecutor<E> {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.eshore.gringotts.web.domain.base.service;
|
||||
|
||||
import com.eshore.gringotts.web.domain.entity.CheckOrder;
|
||||
import com.eshore.gringotts.web.domain.check.entity.CheckOrder;
|
||||
import org.eclipse.collections.api.map.ImmutableMap;
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,15 +4,16 @@ import cn.hutool.core.util.ClassUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteEntity;
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.service.UserService;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.transaction.Transactional;
|
||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.Query;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
|
||||
/**
|
||||
@@ -29,8 +30,13 @@ public abstract class LogicDeleteService<ENTITY extends LogicDeleteEntity> exten
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImmutableList<Predicate> listPredicate(Root<ENTITY> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
return super.listPredicate(root, query, builder).newWith(builder.equal(root.get("deleted"), false));
|
||||
protected ImmutableList<Predicate> extraListPredicates(Root<ENTITY> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
return Lists.immutable.of(builder.equal(root.get("deleted"), false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImmutableList<Predicate> extraDetailPredicates(Root<ENTITY> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
return Lists.immutable.of(builder.equal(root.get("deleted"), false));
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.eshore.gringotts.web.domain.base.service;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.controller.query.Query;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity;
|
||||
import java.util.Optional;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
@@ -17,8 +16,6 @@ public interface SimpleService<ENTITY extends SimpleEntity> {
|
||||
|
||||
ImmutableList<ENTITY> list(ImmutableSet<Long> ids) throws Exception;
|
||||
|
||||
ImmutableList<ENTITY> list(Query query) throws Exception;
|
||||
|
||||
Optional<ENTITY> detailOptional(Long id) throws Exception;
|
||||
|
||||
ENTITY detail(Long id) throws Exception;
|
||||
|
||||
@@ -2,23 +2,18 @@ package com.eshore.gringotts.web.domain.base.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.eshore.gringotts.web.domain.base.controller.query.Query;
|
||||
import com.eshore.gringotts.web.domain.base.entity.IdOnlyEntity_;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity_;
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.entity.User;
|
||||
import com.eshore.gringotts.web.domain.service.UserService;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.util.Optional;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Path;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.transaction.Transactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
@@ -50,144 +45,57 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
entity,
|
||||
targetEntity,
|
||||
CopyOptions.create()
|
||||
.setIgnoreProperties(
|
||||
IdOnlyEntity_.ID,
|
||||
SimpleEntity_.CREATED_USER,
|
||||
SimpleEntity_.CREATED_TIME,
|
||||
SimpleEntity_.MODIFIED_USER,
|
||||
SimpleEntity_.MODIFIED_TIME
|
||||
)
|
||||
.setIgnoreProperties("id", "createdUser", "createdTime", "modifiedUser", "modifiedTime")
|
||||
);
|
||||
entity = targetEntity;
|
||||
}
|
||||
User user = userService.currentLoginUser();
|
||||
if (ObjectUtil.isNull(entity.getCreatedUser())) {
|
||||
entity.setCreatedUser(user);
|
||||
}
|
||||
entity.setModifiedUser(user);
|
||||
entity = repository.save(entity);
|
||||
return entity.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<ENTITY> list() throws Exception {
|
||||
return Lists.immutable.ofAll(repository.findAll(
|
||||
(root, query, builder) ->
|
||||
builder.and(
|
||||
listPredicate(root, query, builder)
|
||||
.reject(ObjectUtil::isNull)
|
||||
.toArray(new Predicate[]{})
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<ENTITY> list(ImmutableSet<Long> ids) throws Exception {
|
||||
public ImmutableList<ENTITY> list() {
|
||||
return Lists.immutable.ofAll(repository.findAll(
|
||||
(root, query, builder) -> {
|
||||
MutableList<Predicate> predicates = Lists.mutable.ofAll(listPredicate(root, query, builder));
|
||||
predicates.add(builder.in(root.get("id")).value(ids));
|
||||
return builder.and(predicates.reject(ObjectUtil::isNull).toArray(new Predicate[predicates.size()]));
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
private <Y> Path<Y> column(Root<ENTITY> root, String column) {
|
||||
String[] columns = StrUtil.splitToArray(column, "/");
|
||||
Path<Y> path = root.get(columns[0]);
|
||||
for (int i = 1; i < columns.length; i++) {
|
||||
path = path.get(columns[i]);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private <Y> Object value(Path<Y> column, Object value) {
|
||||
Class<?> javaType = column.getJavaType();
|
||||
if (EnumUtil.isEnum(javaType)) {
|
||||
return EnumUtil.fromString((Class<Enum>) javaType, (String) value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ImmutableList<Predicate> queryPredicates(Query.Queryable queryable, Root<ENTITY> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
MutableList<Predicate> predicates = Lists.mutable.empty();
|
||||
if (ObjectUtil.isEmpty(queryable)) {
|
||||
return predicates.toImmutable();
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getNullEqual())) {
|
||||
queryable.getNullEqual().forEach(column -> predicates.add(builder.isNull(column(root, column))));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getNotNullEqual())) {
|
||||
queryable.getNotNullEqual().forEach(column -> predicates.add(builder.isNull(column(root, column))));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getEmpty())) {
|
||||
queryable.getEmpty().forEach(column -> predicates.add(builder.isEmpty(column(root, column))));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getNotEmpty())) {
|
||||
queryable.getNotEmpty().forEach(column -> predicates.add(builder.isNotEmpty(column(root, column))));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getEqual())) {
|
||||
queryable.getEqual().forEachKeyValue((column, value) -> {
|
||||
Path<Object> path = column(root, column);
|
||||
predicates.add(builder.equal(path, value(path, value)));
|
||||
});
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getNotEqual())) {
|
||||
queryable.getEqual().forEachKeyValue((column, value) -> {
|
||||
Path<Object> path = column(root, column);
|
||||
predicates.add(builder.notEqual(path, value(path, value)));
|
||||
});
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getLike())) {
|
||||
queryable.getLike().forEachKeyValue((column, value) -> predicates.add(builder.like(column(root, column), value)));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getNotLike())) {
|
||||
queryable.getNotLike().forEachKeyValue((column, value) -> predicates.add(builder.notLike(column(root, column), value)));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getGreat())) {
|
||||
queryable.getGreat().forEachKeyValue((column, value) -> predicates.add(builder.greaterThan(column(root, column), (Comparable<Object>) value)));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getLess())) {
|
||||
queryable.getLess().forEachKeyValue((column, value) -> predicates.add(builder.lessThan(column(root, column), (Comparable<Object>) value)));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getGreatEqual())) {
|
||||
queryable.getGreatEqual().forEachKeyValue((column, value) -> predicates.add(builder.greaterThanOrEqualTo(column(root, column), (Comparable<Object>) value)));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getLessEqual())) {
|
||||
queryable.getLessEqual().forEachKeyValue((column, value) -> predicates.add(builder.lessThanOrEqualTo(column(root, column), (Comparable<Object>) value)));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getIn())) {
|
||||
queryable.getIn().forEachKeyValue((column, value) -> predicates.add(builder.in(column(root, column)).value(value)));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getNotIn())) {
|
||||
queryable.getNotIn().forEachKeyValue((column, value) -> predicates.add(builder.in(column(root, column)).value(value).not()));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getBetween())) {
|
||||
queryable.getBetween().forEachKeyValue((column, value) -> predicates.add(builder.between(column(root, column), value.getStart(), value.getEnd())));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryable.getNotBetween())) {
|
||||
queryable.getNotBetween().forEachKeyValue((column, value) -> predicates.add(builder.between(column(root, column), value.getStart(), value.getEnd())));
|
||||
}
|
||||
return predicates.toImmutable();
|
||||
}
|
||||
|
||||
protected ImmutableList<Predicate> listPredicate(Root<ENTITY> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
User user = userService.currentLoginUser();
|
||||
if (User.isNotAdministrator(user)) {
|
||||
return Lists.immutable.of(builder.equal(root.get(SimpleEntity_.createdUser), user));
|
||||
}
|
||||
return Lists.immutable.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<ENTITY> list(Query listQuery) throws Exception {
|
||||
return Lists.immutable.ofAll(repository.findAll(
|
||||
(root, query, builder) -> {
|
||||
MutableList<Predicate> predicates = Lists.mutable.ofAll(listPredicate(root, query, builder));
|
||||
predicates.addAllIterable(queryPredicates(listQuery.getQuery(), root, query, builder));
|
||||
return builder.and(predicates.reject(ObjectUtil::isNull).toArray(new Predicate[predicates.size()]));
|
||||
MutableList<Predicate> predicates = Lists.mutable.empty();
|
||||
User user = userService.currentLoginUser();
|
||||
if (User.isNotAdministrator(user)) {
|
||||
predicates.add(builder.equal(root.get("createdUser"), user));
|
||||
}
|
||||
predicates.addAllIterable(extraListPredicates(root, query, builder));
|
||||
return builder.and(predicates.toArray(new Predicate[predicates.size()]));
|
||||
},
|
||||
Sort.by(SimpleEntity_.CREATED_TIME).descending()
|
||||
Sort.by("createdTime").descending()
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<ENTITY> list(ImmutableSet<Long> ids) {
|
||||
return Lists.immutable.ofAll(repository.findAll(
|
||||
(root, query, builder) -> {
|
||||
MutableList<Predicate> predicates = Lists.mutable.of(
|
||||
builder.in(root.get("id")).value(ids.select(ObjectUtil::isNotNull))
|
||||
);
|
||||
User user = userService.currentLoginUser();
|
||||
if (User.isNotAdministrator(user)) {
|
||||
predicates.add(builder.equal(root.get("createdUser"), user));
|
||||
}
|
||||
predicates.addAllIterable(extraListPredicates(root, query, builder));
|
||||
return builder.and(predicates.toArray(new Predicate[predicates.size()]));
|
||||
},
|
||||
Sort.by("createdTime").descending()
|
||||
));
|
||||
}
|
||||
|
||||
protected ImmutableList<Predicate> extraListPredicates(Root<ENTITY> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
return Lists.immutable.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ENTITY> detailOptional(Long id) {
|
||||
if (ObjectUtil.isNull(id)) {
|
||||
@@ -195,13 +103,23 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
return repository.findOne(
|
||||
(root, query, builder) -> {
|
||||
MutableList<Predicate> predicates = Lists.mutable.ofAll(listPredicate(root, query, builder));
|
||||
predicates.add(builder.equal(root.get(IdOnlyEntity_.id), id));
|
||||
return builder.and(predicates.reject(ObjectUtil::isNull).toArray(new Predicate[predicates.size()]));
|
||||
MutableList<Predicate> predicates = Lists.mutable.of(
|
||||
builder.equal(root.get("id"), id)
|
||||
);
|
||||
User user = userService.currentLoginUser();
|
||||
if (User.isNotAdministrator(user)) {
|
||||
predicates.add(builder.equal(root.get("createdUser"), user));
|
||||
}
|
||||
predicates.addAllIterable(extraDetailPredicates(root, query, builder));
|
||||
return builder.and(predicates.toArray(new Predicate[predicates.size()]));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
protected ImmutableList<Predicate> extraDetailPredicates(Root<ENTITY> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
return Lists.immutable.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ENTITY detail(Long id) {
|
||||
return detailOrNull(id);
|
||||
@@ -226,10 +144,6 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
public static final class IdNotFoundException extends RuntimeException {
|
||||
public IdNotFoundException() {
|
||||
super("资源不存在");
|
||||
}
|
||||
|
||||
public IdNotFoundException(Long id) {
|
||||
super(StrUtil.format("ID为{}的资源不存在", id));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.eshore.gringotts.web.domain.controller;
|
||||
package com.eshore.gringotts.web.domain.check.controller;
|
||||
|
||||
import com.eshore.gringotts.web.configuration.amis.AmisResponse;
|
||||
import com.eshore.gringotts.web.domain.base.controller.ListController;
|
||||
import com.eshore.gringotts.web.domain.base.controller.query.Query;
|
||||
import com.eshore.gringotts.web.domain.entity.CheckOrder;
|
||||
import com.eshore.gringotts.web.domain.service.CheckOrderService;
|
||||
import com.eshore.gringotts.web.domain.check.entity.CheckOrder;
|
||||
import com.eshore.gringotts.web.domain.check.service.CheckOrderService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -17,8 +16,6 @@ import org.eclipse.collections.api.map.ImmutableMap;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -46,12 +43,6 @@ public class CheckOrderController implements ListController<CheckOrderController
|
||||
return AmisResponse.responseSuccess(checkOrderService.list().collect(this::toListItem));
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
@Override
|
||||
public AmisResponse<ImmutableList<ListItem>> list(@RequestBody Query query) throws Exception {
|
||||
return AmisResponse.responseSuccess(checkOrderService.list().collect(this::toListItem));
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private ListItem toListItem(CheckOrder order) {
|
||||
ListItem item = new ListItem();
|
||||
@@ -59,7 +50,7 @@ public class CheckOrderController implements ListController<CheckOrderController
|
||||
item.setDescription(order.getDescription());
|
||||
item.setType(order.getType());
|
||||
item.setParameters(mapper.readValue(order.getParameters(), new TypeReference<>() {}));
|
||||
item.setState(order.getState());
|
||||
item.setOver(order.getOver());
|
||||
item.setCreatedUsername(order.getCreatedUser().getUsername());
|
||||
item.setCreatedTime(order.getCreatedTime());
|
||||
item.setModifiedUsername(order.getModifiedUser().getUsername());
|
||||
@@ -80,7 +71,7 @@ public class CheckOrderController implements ListController<CheckOrderController
|
||||
private String description;
|
||||
private CheckOrder.Type type;
|
||||
private ImmutableMap<String, Object> parameters;
|
||||
private CheckOrder.State state;
|
||||
private Boolean over;
|
||||
private LocalDateTime createdTime;
|
||||
private String createdUsername;
|
||||
private LocalDateTime modifiedTime;
|
||||
@@ -1,20 +1,21 @@
|
||||
package com.eshore.gringotts.web.domain.entity;
|
||||
package com.eshore.gringotts.web.domain.check.entity;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ConstraintMode;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.NamedAttributeNode;
|
||||
import javax.persistence.NamedEntityGraph;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EntityListeners;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.NamedAttributeNode;
|
||||
import jakarta.persistence.NamedEntityGraph;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@@ -69,8 +70,7 @@ public class CheckOrder extends SimpleEntity {
|
||||
private User.Role targetRole;
|
||||
|
||||
@Column(nullable = false)
|
||||
@Enumerated(EnumType.STRING)
|
||||
private State state = State.CHECKING;
|
||||
private Boolean over = false;
|
||||
|
||||
public CheckOrder(
|
||||
String keyword,
|
||||
@@ -120,10 +120,4 @@ public class CheckOrder extends SimpleEntity {
|
||||
USER,
|
||||
ROLE,
|
||||
}
|
||||
|
||||
public enum State {
|
||||
CHECKING,
|
||||
RETRACT,
|
||||
OVER,
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.eshore.gringotts.web.domain.repository;
|
||||
package com.eshore.gringotts.web.domain.check.repository;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.entity.CheckOrder;
|
||||
import com.eshore.gringotts.web.domain.entity.User;
|
||||
import com.eshore.gringotts.web.domain.check.entity.CheckOrder;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import javax.transaction.Transactional;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
@@ -34,6 +34,6 @@ public interface CheckOrderRepository extends SimpleRepository<CheckOrder, Long>
|
||||
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query("update CheckOrder check set check.state = ?2, check.modifiedUser = ?3, check.modifiedTime = current_timestamp where check.id = ?1")
|
||||
void overById(Long id, CheckOrder.State state, User modifiedUser);
|
||||
@Query("update CheckOrder check set check.over = true, check.modifiedUser = ?2, check.modifiedTime = current_timestamp where check.id = ?1")
|
||||
void overById(Long id, User modifiedUser);
|
||||
}
|
||||
@@ -1,23 +1,16 @@
|
||||
package com.eshore.gringotts.web.domain.service;
|
||||
package com.eshore.gringotts.web.domain.check.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.eshore.gringotts.web.domain.base.service.CheckingService;
|
||||
import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport;
|
||||
import com.eshore.gringotts.web.domain.entity.CheckOrder;
|
||||
import com.eshore.gringotts.web.domain.entity.CheckOrder_;
|
||||
import com.eshore.gringotts.web.domain.entity.User;
|
||||
import com.eshore.gringotts.web.domain.repository.CheckOrderRepository;
|
||||
import com.eshore.gringotts.web.domain.check.entity.CheckOrder;
|
||||
import com.eshore.gringotts.web.domain.check.repository.CheckOrderRepository;
|
||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.eclipse.collections.api.map.ImmutableMap;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
@@ -43,25 +36,6 @@ public class CheckOrderService extends SimpleServiceSupport<CheckOrder> {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImmutableList<Predicate> listPredicate(Root<CheckOrder> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
User user = userService.currentLoginUser();
|
||||
if (User.isAdministrator(user)) {
|
||||
return Lists.immutable.empty();
|
||||
}
|
||||
return Lists.immutable.of(builder.or(
|
||||
builder.equal(root.get(CheckOrder_.createdUser), user),
|
||||
builder.and(
|
||||
builder.equal(root.get(CheckOrder_.target), CheckOrder.Target.USER),
|
||||
builder.equal(root.get(CheckOrder_.targetUser), user)
|
||||
),
|
||||
builder.and(
|
||||
builder.equal(root.get(CheckOrder_.target), CheckOrder.Target.ROLE),
|
||||
builder.equal(root.get(CheckOrder_.targetRole), user.getRole())
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
public void operation(Long id, CheckOrder.Operation operation) throws JsonProcessingException {
|
||||
CheckOrder order = detailOrThrow(id);
|
||||
CheckingService service = applicationContext.getBean(order.getTargetClass(), CheckingService.class);
|
||||
@@ -72,11 +46,7 @@ public class CheckOrderService extends SimpleServiceSupport<CheckOrder> {
|
||||
service.onChecked(order, operation, parameters);
|
||||
}
|
||||
|
||||
public void retract(Long id) {
|
||||
checkOrderRepository.overById(id, CheckOrder.State.RETRACT, userService.currentLoginUser());
|
||||
}
|
||||
|
||||
public void over(Long id) {
|
||||
checkOrderRepository.overById(id, CheckOrder.State.OVER, userService.currentLoginUser());
|
||||
checkOrderRepository.overById(id, userService.currentLoginUser());
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.eshore.gringotts.web.domain.controller;
|
||||
package com.eshore.gringotts.web.domain.confirmation.controller;
|
||||
|
||||
import com.eshore.gringotts.web.configuration.amis.AmisResponse;
|
||||
import com.eshore.gringotts.web.domain.base.controller.SimpleControllerSupport;
|
||||
import com.eshore.gringotts.web.domain.base.entity.FileInfo;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleListItem;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleSaveItem;
|
||||
import com.eshore.gringotts.web.domain.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.service.ConfirmationService;
|
||||
import com.eshore.gringotts.web.domain.service.DataFileService;
|
||||
import com.eshore.gringotts.web.domain.service.DataResourceService;
|
||||
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.confirmation.service.ConfirmationService;
|
||||
import com.eshore.gringotts.web.domain.resource.service.DataResourceService;
|
||||
import com.eshore.gringotts.web.domain.upload.service.DataFileService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
@@ -53,7 +53,7 @@ public class ConfirmationController extends SimpleControllerSupport<Confirmation
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Confirmation fromSaveItem(SaveItem item) throws Exception {
|
||||
protected Confirmation fromSaveItem(SaveItem item) {
|
||||
Confirmation confirmation = new Confirmation();
|
||||
confirmation.setId(item.getId());
|
||||
confirmation.setDescription(item.getDescription());
|
||||
@@ -64,7 +64,14 @@ public class ConfirmationController extends SimpleControllerSupport<Confirmation
|
||||
|
||||
@Override
|
||||
protected ListItem toListItem(Confirmation entity) {
|
||||
return new ListItem(entity);
|
||||
ListItem item = new ListItem();
|
||||
item.setId(entity.getId());
|
||||
item.setName(entity.getTarget().getName());
|
||||
item.setDescription(entity.getDescription());
|
||||
item.setState(entity.getState().name());
|
||||
item.setCreatedUsername(entity.getCreatedUser().getUsername());
|
||||
item.setCreatedTime(entity.getCreatedTime());
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,19 +89,10 @@ public class ConfirmationController extends SimpleControllerSupport<Confirmation
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static final class ListItem extends SimpleListItem<Confirmation> {
|
||||
public static class ListItem extends SimpleListItem<Confirmation> {
|
||||
private String name;
|
||||
private String description;
|
||||
private String state;
|
||||
|
||||
public ListItem(Confirmation confirmation) {
|
||||
this.setId(confirmation.getId());
|
||||
this.setName(confirmation.getTarget().getName());
|
||||
this.setDescription(confirmation.getDescription());
|
||||
this.setState(confirmation.getState().name());
|
||||
this.setCreatedUsername(confirmation.getCreatedUser().getUsername());
|
||||
this.setCreatedTime(confirmation.getCreatedTime());
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -1,28 +1,27 @@
|
||||
package com.eshore.gringotts.web.domain.entity;
|
||||
package com.eshore.gringotts.web.domain.confirmation.entity;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteEntity;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.DataResource;
|
||||
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EntityListeners;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.JoinTable;
|
||||
import jakarta.persistence.NamedAttributeNode;
|
||||
import jakarta.persistence.NamedEntityGraph;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.Set;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.ConstraintMode;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.NamedAttributeNode;
|
||||
import javax.persistence.NamedEntityGraph;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
/**
|
||||
@@ -48,8 +47,6 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
@NamedAttributeNode(value = "createdUser"),
|
||||
@NamedAttributeNode(value = "modifiedUser"),
|
||||
})
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "confirmation" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class Confirmation extends CheckingNeededEntity {
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.eshore.gringotts.web.domain.repository;
|
||||
package com.eshore.gringotts.web.domain.confirmation.repository;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
@@ -29,4 +33,13 @@ public interface ConfirmationRepository extends SimpleRepository<Confirmation, L
|
||||
Optional<Confirmation> findOne(Specification<Confirmation> specification);
|
||||
|
||||
Boolean existsByTarget_Id(Long id);
|
||||
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query("update Confirmation confirmation \n" +
|
||||
"set confirmation.state = ?2, \n" +
|
||||
" confirmation.modifiedUser = ?3, \n" +
|
||||
" confirmation.modifiedTime = current_timestamp \n" +
|
||||
"where confirmation.id = ?1")
|
||||
void updateStateById(Long id, Confirmation.State state, User modifiedUser);
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.eshore.gringotts.web.domain.confirmation.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.eshore.gringotts.web.domain.base.service.CheckingService;
|
||||
import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport;
|
||||
import com.eshore.gringotts.web.domain.check.entity.CheckOrder;
|
||||
import com.eshore.gringotts.web.domain.check.service.CheckOrderService;
|
||||
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.confirmation.repository.ConfirmationRepository;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Maps;
|
||||
import org.eclipse.collections.api.map.ImmutableMap;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-26
|
||||
*/
|
||||
@Slf4j
|
||||
@Service("com.eshore.gringotts.web.domain.confirmation.service.ConfirmationService")
|
||||
public class ConfirmationService extends SimpleServiceSupport<Confirmation> implements CheckingService {
|
||||
private final ConfirmationRepository confirmationRepository;
|
||||
private final UserService userService;
|
||||
private final CheckOrderService checkOrderService;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
public ConfirmationService(ConfirmationRepository confirmationRepository, UserService userService, CheckOrderService checkOrderService, Jackson2ObjectMapperBuilder builder) {
|
||||
super(confirmationRepository, userService);
|
||||
this.confirmationRepository = confirmationRepository;
|
||||
this.userService = userService;
|
||||
this.checkOrderService = checkOrderService;
|
||||
this.mapper = builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long save(Confirmation entity) {
|
||||
if (ObjectUtil.isNull(entity.getId()) && confirmationRepository.existsByTarget_Id(entity.getTarget().getId())) {
|
||||
throw new ConfirmationDuplicatedException();
|
||||
}
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
public void submit(Long id) throws JsonProcessingException {
|
||||
Confirmation confirmation = detailOrThrow(id);
|
||||
log.info("confirmation: {}", confirmation);
|
||||
confirmation.setState(Confirmation.State.CHECKING);
|
||||
checkOrderService.save(new CheckOrder(
|
||||
"confirmation_check",
|
||||
StrUtil.format("数据资源「{}」的确权申请", confirmation.getTarget().getName()),
|
||||
CheckOrder.Type.CONFIRMATION,
|
||||
mapper.writeValueAsString(Maps.immutable.of("confirmationId", confirmation.getId())),
|
||||
"com.eshore.gringotts.web.domain.confirmation.service.ConfirmationService",
|
||||
User.Role.ADMINISTRATOR
|
||||
));
|
||||
save(confirmation);
|
||||
}
|
||||
|
||||
public void retract(Long id) {
|
||||
confirmationRepository.updateStateById(id, Confirmation.State.DRAFT, userService.currentLoginUser());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChecked(CheckOrder order, CheckOrder.Operation operation, ImmutableMap<String, Object> parameters) {
|
||||
if (StrUtil.equals(order.getKeyword(), "confirmation_check")) {
|
||||
Long id = (Long) parameters.get("confirmationId");
|
||||
switch (operation) {
|
||||
case APPLY:
|
||||
confirmationRepository.updateStateById(id, Confirmation.State.NORMAL, userService.currentLoginUser());
|
||||
checkOrderService.over(order.getId());
|
||||
break;
|
||||
case REJECT:
|
||||
confirmationRepository.updateStateById(id, Confirmation.State.DRAFT, userService.currentLoginUser());
|
||||
checkOrderService.over(order.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final class ConfirmationDuplicatedException extends RuntimeException {
|
||||
public ConfirmationDuplicatedException() {
|
||||
super("数据资源已绑定确权申请,无法再次申请");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.controller;
|
||||
|
||||
import com.eshore.gringotts.web.configuration.amis.AmisResponse;
|
||||
import com.eshore.gringotts.web.domain.base.controller.SimpleControllerSupport;
|
||||
import com.eshore.gringotts.web.domain.base.entity.FileInfo;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleListItem;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleSaveItem;
|
||||
import com.eshore.gringotts.web.domain.entity.Authentication;
|
||||
import com.eshore.gringotts.web.domain.service.AuthenticationService;
|
||||
import com.eshore.gringotts.web.domain.service.DataFileService;
|
||||
import com.eshore.gringotts.web.domain.service.DataResourceService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Sets;
|
||||
import org.eclipse.collections.api.set.ImmutableSet;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-12-02
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("authentication")
|
||||
public class AuthenticationController extends SimpleControllerSupport<Authentication, AuthenticationController.SaveItem, AuthenticationController.ListItem, AuthenticationController.DetailItem> {
|
||||
private final AuthenticationService authenticationService;
|
||||
private final DataResourceService dataResourceService;
|
||||
private final DataFileService dataFileService;
|
||||
|
||||
public AuthenticationController(AuthenticationService service, DataResourceService dataResourceService, DataFileService dataFileService) {
|
||||
super(service);
|
||||
this.authenticationService = service;
|
||||
this.dataResourceService = dataResourceService;
|
||||
this.dataFileService = dataFileService;
|
||||
}
|
||||
|
||||
@GetMapping("/submit/{id}")
|
||||
public AmisResponse<Object> submit(@PathVariable Long id) throws JsonProcessingException {
|
||||
authenticationService.submit(id);
|
||||
return AmisResponse.responseSuccess();
|
||||
}
|
||||
|
||||
@GetMapping("/retract/{id}")
|
||||
public AmisResponse<Object> retract(@PathVariable Long id) {
|
||||
authenticationService.retract(id);
|
||||
return AmisResponse.responseSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Authentication fromSaveItem(SaveItem item) throws Exception {
|
||||
Authentication authentication = new Authentication();
|
||||
authentication.setId(item.getId());
|
||||
authentication.setDescription(item.getDescription());
|
||||
authentication.setTarget(dataResourceService.detailOrThrow(item.getTargetId()));
|
||||
authentication.setEvidences(dataFileService.list(item.getEvidenceFiles().collect(FileInfo::getValue)).toSet());
|
||||
authentication.setActiveTime(item.getActiveTime());
|
||||
authentication.setExpiredTime(item.getExpiredTime());
|
||||
return authentication;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListItem toListItem(Authentication entity) {
|
||||
return new ListItem(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DetailItem toDetailItem(Authentication entity) {
|
||||
return new DetailItem(entity);
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class SaveItem extends SimpleSaveItem<Authentication> {
|
||||
private Long targetId;
|
||||
private String description;
|
||||
private ImmutableSet<FileInfo> evidenceFiles;
|
||||
private LocalDateTime activeTime;
|
||||
private LocalDateTime expiredTime;
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static final class ListItem extends SimpleListItem<Authentication> {
|
||||
private String name;
|
||||
private String description;
|
||||
private String state;
|
||||
|
||||
public ListItem(Authentication authentication) {
|
||||
this.setId(authentication.getId());
|
||||
this.setName(authentication.getTarget().getName());
|
||||
this.setDescription(authentication.getDescription());
|
||||
this.setState(authentication.getState().name());
|
||||
this.setCreatedUsername(authentication.getCreatedUser().getUsername());
|
||||
this.setCreatedTime(authentication.getCreatedTime());
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static final class DetailItem extends SaveItem {
|
||||
private String targetName;
|
||||
private LocalDateTime createdTime;
|
||||
private String createdUsername;
|
||||
private LocalDateTime modifiedTime;
|
||||
private String modifiedUsername;
|
||||
|
||||
public DetailItem(Authentication authentication) {
|
||||
this.setId(authentication.getId());
|
||||
this.setTargetId(authentication.getTarget().getId());
|
||||
this.setTargetName(authentication.getTarget().getName());
|
||||
this.setDescription(authentication.getDescription());
|
||||
this.setEvidenceFiles(Sets.immutable.ofAll(authentication.getEvidences()).collect(FileInfo::new));
|
||||
this.setActiveTime(authentication.getActiveTime());
|
||||
this.setExpiredTime(authentication.getExpiredTime());
|
||||
this.setCreatedTime(authentication.getCreatedTime());
|
||||
this.setCreatedUsername(authentication.getCreatedUser().getUsername());
|
||||
this.setModifiedTime(authentication.getModifiedTime());
|
||||
this.setModifiedUsername(authentication.getModifiedUser().getUsername());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.controller;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.controller.SimpleControllerSupport;
|
||||
import com.eshore.gringotts.web.domain.base.entity.FileInfo;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleListItem;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleSaveItem;
|
||||
import com.eshore.gringotts.web.domain.entity.Ware;
|
||||
import com.eshore.gringotts.web.domain.service.DataFileService;
|
||||
import com.eshore.gringotts.web.domain.service.DataResourceService;
|
||||
import com.eshore.gringotts.web.domain.service.WareService;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-12-13
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("ware")
|
||||
public class WareController extends SimpleControllerSupport<Ware, WareController.SaveItem, WareController.ListItem, WareController.DetailItem> {
|
||||
private final DataResourceService dataResourceService;
|
||||
private final DataFileService dataFileService;
|
||||
|
||||
public WareController(WareService service, DataResourceService dataResourceService, DataFileService dataFileService) {
|
||||
super(service);
|
||||
this.dataResourceService = dataResourceService;
|
||||
this.dataFileService = dataFileService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Ware fromSaveItem(SaveItem saveItem) throws Exception {
|
||||
Ware ware = new Ware();
|
||||
ware.setResource(dataResourceService.detailOrThrow(saveItem.getResourceId()));
|
||||
ware.setName(ware.getName());
|
||||
ware.setDescription(saveItem.getDescription());
|
||||
ware.setIcon(dataFileService.detailOrThrow(saveItem.getIcon().getValue()));
|
||||
ware.setContent(saveItem.getContent());
|
||||
return ware;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListItem toListItem(Ware entity) throws Exception {
|
||||
return new ListItem(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DetailItem toDetailItem(Ware entity) throws Exception {
|
||||
return new DetailItem(entity);
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class SaveItem extends SimpleSaveItem<Ware> {
|
||||
private Long resourceId;
|
||||
private String name;
|
||||
private String description;
|
||||
private FileInfo icon;
|
||||
private String content;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ListItem extends SimpleListItem<Ware> {
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
public ListItem(Ware ware) {
|
||||
this.setId(ware.getId());
|
||||
this.setName(ware.getName());
|
||||
this.setDescription(ware.getDescription());
|
||||
this.setCreatedTime(ware.getCreatedTime());
|
||||
this.setCreatedUsername(ware.getCreatedUser().getUsername());
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class DetailItem extends SaveItem {
|
||||
private LocalDateTime createdTime;
|
||||
private String createdUsername;
|
||||
private LocalDateTime modifiedTime;
|
||||
private String modifiedUsername;
|
||||
|
||||
public DetailItem(Ware ware) {
|
||||
this.setId(ware.getId());
|
||||
this.setResourceId(ware.getResource().getId());
|
||||
this.setName(ware.getName());
|
||||
this.setDescription(ware.getDescription());
|
||||
this.setIcon(new FileInfo(ware.getIcon()));
|
||||
this.setContent(ware.getContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.entity;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteEntity;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity;
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ConstraintMode;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.NamedAttributeNode;
|
||||
import javax.persistence.NamedEntityGraph;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-12-13
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
@Entity
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@DynamicUpdate
|
||||
@Table(name = Constants.TABLE_PREFIX + "ware")
|
||||
@NamedEntityGraph(name = "ware.list", attributeNodes = {
|
||||
@NamedAttributeNode(value = "createdUser"),
|
||||
})
|
||||
@NamedEntityGraph(name = "ware.detail", attributeNodes = {
|
||||
@NamedAttributeNode(value = "icon"),
|
||||
@NamedAttributeNode(value = "content"),
|
||||
@NamedAttributeNode(value = "createdUser"),
|
||||
@NamedAttributeNode(value = "modifiedUser"),
|
||||
})
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "ware" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class Ware extends SimpleEntity {
|
||||
@OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.EAGER)
|
||||
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
@ToString.Exclude
|
||||
private DataResource resource;
|
||||
@Column(nullable = false)
|
||||
private String name;
|
||||
@Column(nullable = false)
|
||||
private String description;
|
||||
@OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
|
||||
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
@ToString.Exclude
|
||||
private DataFile icon;
|
||||
@Lob
|
||||
@Basic(fetch = FetchType.LAZY)
|
||||
@ToString.Exclude
|
||||
@Column(nullable = false)
|
||||
private String content;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.entity.format;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
/**
|
||||
* CSV格式
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-20
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@DiscriminatorValue("CSV")
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "resource_format" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteIdOnlyEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class CsvResourceFormat extends ResourceFormat {
|
||||
private String schema;
|
||||
|
||||
@Override
|
||||
public Type getFormatType() {
|
||||
return Type.CSV;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.entity.format;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
/**
|
||||
* JSON line格式
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-20
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@DiscriminatorValue("JSON_LINE")
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "resource_format" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteIdOnlyEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class JsonLineResourceFormat extends ResourceFormat {
|
||||
private String schema;
|
||||
|
||||
@Override
|
||||
public Type getFormatType() {
|
||||
return Type.JSON_LINE;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.entity.format;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
/**
|
||||
* 一个文件就是一个JSON
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-20
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@DiscriminatorValue("JSON")
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "resource_format" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteIdOnlyEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class JsonResourceFormat extends ResourceFormat {
|
||||
private String schema;
|
||||
|
||||
@Override
|
||||
public Type getFormatType() {
|
||||
return Type.JSON;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.entity.format;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
/**
|
||||
* 无格式,文件每行就是一份数据
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-20
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Entity
|
||||
@DiscriminatorValue("LINE")
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "resource_format" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteIdOnlyEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class LineResourceFormat extends ResourceFormat {
|
||||
@Override
|
||||
public Type getFormatType() {
|
||||
return Type.LINE;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.entity.format;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
/**
|
||||
* 无格式,整个文件就是一份数据
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-20
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Entity
|
||||
@DiscriminatorValue("NONE")
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "resource_format" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteIdOnlyEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class NoneResourceFormat extends ResourceFormat {
|
||||
@Override
|
||||
public Type getFormatType() {
|
||||
return Type.NONE;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.entity.type;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;
|
||||
import com.eshore.gringotts.web.domain.entity.DataFile;
|
||||
import javax.persistence.ConstraintMode;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = Constants.TABLE_PREFIX + "resource_type_file")
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "resource_type_file" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteIdOnlyEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class FileResourceType extends ResourceType {
|
||||
@OneToOne
|
||||
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private DataFile file;
|
||||
|
||||
@Override
|
||||
public Type getResourceType() {
|
||||
return Type.FILE;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.repository;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.entity.Authentication;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-12-02
|
||||
*/
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Repository
|
||||
public interface AuthenticationRepository extends SimpleRepository<Authentication, Long> {
|
||||
@Override
|
||||
@EntityGraph(value = "authentication.list", type = EntityGraph.EntityGraphType.FETCH)
|
||||
List<Authentication> findAll(Specification<Authentication> specification);
|
||||
|
||||
@Override
|
||||
@EntityGraph(value = "authentication.list", type = EntityGraph.EntityGraphType.FETCH)
|
||||
List<Authentication> findAll(Specification<Authentication> specification, Sort sort);
|
||||
|
||||
@Override
|
||||
@EntityGraph(value = "authentication.detail", type = EntityGraph.EntityGraphType.FETCH)
|
||||
Optional<Authentication> findOne(Specification<Authentication> specification);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.repository;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.entity.format.ResourceFormat;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface ResourceFormatRepository extends SimpleRepository<ResourceFormat, Long> {
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.repository;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.entity.type.ResourceType;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface ResourceTypeRepository extends SimpleRepository<ResourceType, Long> {
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.repository;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.entity.Ware;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Repository
|
||||
public interface WareRepository extends SimpleRepository<Ware, Long> {
|
||||
@Override
|
||||
@EntityGraph(value = "ware.list", type = EntityGraph.EntityGraphType.FETCH)
|
||||
List<Ware> findAll(Specification<Ware> specification);
|
||||
|
||||
@Override
|
||||
@EntityGraph(value = "ware.list", type = EntityGraph.EntityGraphType.FETCH)
|
||||
List<Ware> findAll(Specification<Ware> specification, Sort sort);
|
||||
|
||||
@Override
|
||||
@EntityGraph(value = "ware.detail", type = EntityGraph.EntityGraphType.FETCH)
|
||||
Optional<Ware> findOne(Specification<Ware> specification);
|
||||
}
|
||||
@@ -1,29 +1,28 @@
|
||||
package com.eshore.gringotts.web.domain.controller;
|
||||
package com.eshore.gringotts.web.domain.resource.controller;
|
||||
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.eshore.gringotts.web.configuration.amis.AmisResponse;
|
||||
import com.eshore.gringotts.web.domain.base.controller.SimpleControllerSupport;
|
||||
import com.eshore.gringotts.web.domain.base.entity.FileInfo;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleListItem;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleSaveItem;
|
||||
import com.eshore.gringotts.web.domain.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.entity.DataFile;
|
||||
import com.eshore.gringotts.web.domain.entity.DataResource;
|
||||
import com.eshore.gringotts.web.domain.entity.format.CsvResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.entity.format.JsonLineResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.entity.format.JsonResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.entity.format.LineResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.entity.format.NoneResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.entity.format.ResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.entity.type.ApiResourceType;
|
||||
import com.eshore.gringotts.web.domain.entity.type.DatabaseResourceType;
|
||||
import com.eshore.gringotts.web.domain.entity.type.FileResourceType;
|
||||
import com.eshore.gringotts.web.domain.entity.type.FtpResourceType;
|
||||
import com.eshore.gringotts.web.domain.entity.type.HDFSResourceType;
|
||||
import com.eshore.gringotts.web.domain.entity.type.ResourceType;
|
||||
import com.eshore.gringotts.web.domain.service.DataFileService;
|
||||
import com.eshore.gringotts.web.domain.service.DataResourceService;
|
||||
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.DataResource;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.format.CsvResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.format.JsonLineResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.format.JsonResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.format.LineResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.format.NoneResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.format.ResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.type.ApiResourceType;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.type.DatabaseResourceType;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.type.FileResourceType;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.type.FtpResourceType;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.type.HDFSResourceType;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.type.ResourceType;
|
||||
import com.eshore.gringotts.web.domain.resource.service.DataResourceService;
|
||||
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
|
||||
import com.eshore.gringotts.web.domain.upload.service.DataFileService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -31,9 +30,7 @@ import java.util.Map;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -48,38 +45,14 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("/data_resource")
|
||||
public class DataResourceController extends SimpleControllerSupport<DataResource, DataResourceController.SaveItem, DataResourceController.ListItem, DataResourceController.DetailItem> {
|
||||
private final ObjectMapper mapper;
|
||||
private final DataResourceService dataResourceService;
|
||||
private final DataFileService dataFileService;
|
||||
|
||||
public DataResourceController(DataResourceService dataResourceService, DataFileService dataFileService, Jackson2ObjectMapperBuilder builder) {
|
||||
super(dataResourceService);
|
||||
this.dataResourceService = dataResourceService;
|
||||
this.dataFileService = dataFileService;
|
||||
this.mapper = builder.build();
|
||||
}
|
||||
|
||||
@GetMapping(LIST + "_no_confirmation")
|
||||
public AmisResponse<ImmutableList<ListItem>> listNoConfirmation() {
|
||||
return AmisResponse.responseSuccess(dataResourceService.listNoConfirmation().collect(entity -> {
|
||||
try {
|
||||
return toListItem(entity);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@GetMapping(LIST + "_no_authentication")
|
||||
public AmisResponse<ImmutableList<ListItem>> listNoAuthentication() {
|
||||
return AmisResponse.responseSuccess(dataResourceService.listNoAuthentication().collect(entity -> {
|
||||
try {
|
||||
return toListItem(entity);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DataResource fromSaveItem(SaveItem item) throws JsonProcessingException {
|
||||
ResourceType type = generateResourceType(item);
|
||||
@@ -1,29 +1,30 @@
|
||||
package com.eshore.gringotts.web.domain.entity;
|
||||
package com.eshore.gringotts.web.domain.resource.entity;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.authentication.entity.Authentication;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteEntity;
|
||||
import com.eshore.gringotts.web.domain.entity.format.ResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.entity.type.ResourceType;
|
||||
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.format.ResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.type.ResourceType;
|
||||
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EntityListeners;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.NamedAttributeNode;
|
||||
import jakarta.persistence.NamedEntityGraph;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.Set;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ConstraintMode;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.NamedAttributeNode;
|
||||
import javax.persistence.NamedEntityGraph;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
@Getter
|
||||
@@ -47,21 +48,19 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
@NamedAttributeNode(value = "createdUser"),
|
||||
@NamedAttributeNode(value = "modifiedUser"),
|
||||
})
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "data_resource" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class DataResource extends LogicDeleteEntity {
|
||||
@Column(nullable = false)
|
||||
private String name;
|
||||
private String description;
|
||||
@OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
|
||||
@OneToOne(cascade = CascadeType.REMOVE)
|
||||
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
@ToString.Exclude
|
||||
private ResourceType type;
|
||||
@OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
|
||||
@OneToOne(cascade = CascadeType.REMOVE)
|
||||
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
@ToString.Exclude
|
||||
private ResourceFormat format;
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@OneToOne(cascade = CascadeType.REMOVE)
|
||||
@JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
@ToString.Exclude
|
||||
private DataFile example;
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.eshore.gringotts.web.domain.resource.entity.format;
|
||||
|
||||
import jakarta.persistence.DiscriminatorValue;
|
||||
import jakarta.persistence.Entity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* CSV格式
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-20
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@DiscriminatorValue("CSV")
|
||||
public class CsvResourceFormat extends ResourceFormat {
|
||||
private String schema;
|
||||
|
||||
@Override
|
||||
public Type getFormatType() {
|
||||
return Type.CSV;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.eshore.gringotts.web.domain.resource.entity.format;
|
||||
|
||||
import jakarta.persistence.DiscriminatorValue;
|
||||
import jakarta.persistence.Entity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* JSON line格式
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-20
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@DiscriminatorValue("JSON_LINE")
|
||||
public class JsonLineResourceFormat extends ResourceFormat {
|
||||
private String schema;
|
||||
|
||||
@Override
|
||||
public Type getFormatType() {
|
||||
return Type.JSON_LINE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.eshore.gringotts.web.domain.resource.entity.format;
|
||||
|
||||
import jakarta.persistence.DiscriminatorValue;
|
||||
import jakarta.persistence.Entity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 一个文件就是一个JSON
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-20
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@DiscriminatorValue("JSON")
|
||||
public class JsonResourceFormat extends ResourceFormat {
|
||||
private String schema;
|
||||
|
||||
@Override
|
||||
public Type getFormatType() {
|
||||
return Type.JSON;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.eshore.gringotts.web.domain.resource.entity.format;
|
||||
|
||||
import jakarta.persistence.DiscriminatorValue;
|
||||
import jakarta.persistence.Entity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 无格式,文件每行就是一份数据
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-20
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Entity
|
||||
@DiscriminatorValue("LINE")
|
||||
public class LineResourceFormat extends ResourceFormat {
|
||||
@Override
|
||||
public Type getFormatType() {
|
||||
return Type.LINE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.eshore.gringotts.web.domain.resource.entity.format;
|
||||
|
||||
import jakarta.persistence.DiscriminatorValue;
|
||||
import jakarta.persistence.Entity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 无格式,整个文件就是一份数据
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-20
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Entity
|
||||
@DiscriminatorValue("NONE")
|
||||
public class NoneResourceFormat extends ResourceFormat {
|
||||
@Override
|
||||
public Type getFormatType() {
|
||||
return Type.NONE;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
package com.eshore.gringotts.web.domain.entity.format;
|
||||
package com.eshore.gringotts.web.domain.resource.entity.format;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.Table;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Inheritance;
|
||||
import jakarta.persistence.InheritanceType;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
/**
|
||||
* 资源格式
|
||||
@@ -24,11 +22,7 @@ import org.hibernate.annotations.Where;
|
||||
@Entity
|
||||
@Table(name = Constants.TABLE_PREFIX + "resource_format")
|
||||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "resource_format" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteIdOnlyEntity.LOGIC_DELETE_CLAUSE)
|
||||
public abstract class ResourceFormat extends LogicDeleteIdOnlyEntity {
|
||||
public abstract Type getFormatType();
|
||||
|
||||
public enum Type {
|
||||
NONE,
|
||||
LINE,
|
||||
@@ -36,4 +30,6 @@ public abstract class ResourceFormat extends LogicDeleteIdOnlyEntity {
|
||||
JSON_LINE,
|
||||
CSV,
|
||||
}
|
||||
|
||||
public abstract Type getFormatType();
|
||||
}
|
||||
@@ -1,17 +1,14 @@
|
||||
package com.eshore.gringotts.web.domain.entity.type;
|
||||
package com.eshore.gringotts.web.domain.resource.entity.type;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -20,8 +17,6 @@ import org.hibernate.annotations.Where;
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = Constants.TABLE_PREFIX + "resource_type_api")
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "resource_type_api" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteIdOnlyEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class ApiResourceType extends ResourceType {
|
||||
@Column(nullable = false)
|
||||
private String url;
|
||||
@@ -1,19 +1,16 @@
|
||||
package com.eshore.gringotts.web.domain.entity.type;
|
||||
package com.eshore.gringotts.web.domain.resource.entity.type;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Table;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -22,8 +19,6 @@ import org.hibernate.annotations.Where;
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = Constants.TABLE_PREFIX + "resource_type_database")
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "resource_type_database" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteIdOnlyEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class DatabaseResourceType extends ResourceType {
|
||||
@Column(nullable = false)
|
||||
private String jdbc;
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.eshore.gringotts.web.domain.resource.entity.type;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = Constants.TABLE_PREFIX + "resource_type_file")
|
||||
public class FileResourceType extends ResourceType {
|
||||
@OneToOne
|
||||
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private DataFile file;
|
||||
|
||||
@Override
|
||||
public Type getResourceType() {
|
||||
return Type.FILE;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,14 @@
|
||||
package com.eshore.gringotts.web.domain.entity.type;
|
||||
package com.eshore.gringotts.web.domain.resource.entity.type;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -20,8 +17,6 @@ import org.hibernate.annotations.Where;
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = Constants.TABLE_PREFIX + "resource_type_ftp")
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "resource_type_ftp" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteIdOnlyEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class FtpResourceType extends ResourceType {
|
||||
@Column(nullable = false)
|
||||
private String url;
|
||||
@@ -1,21 +1,18 @@
|
||||
package com.eshore.gringotts.web.domain.entity.type;
|
||||
package com.eshore.gringotts.web.domain.resource.entity.type;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;
|
||||
import com.eshore.gringotts.web.domain.entity.DataFile;
|
||||
import javax.persistence.ConstraintMode;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -24,8 +21,6 @@ import org.hibernate.annotations.Where;
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = Constants.TABLE_PREFIX + "resource_type_hdfs")
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "resource_type_hdfs" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteIdOnlyEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class HDFSResourceType extends ResourceType {
|
||||
@OneToOne
|
||||
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
@@ -1,16 +1,14 @@
|
||||
package com.eshore.gringotts.web.domain.entity.type;
|
||||
package com.eshore.gringotts.web.domain.resource.entity.type;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.Table;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Inheritance;
|
||||
import jakarta.persistence.InheritanceType;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
/**
|
||||
* 资源类型
|
||||
@@ -24,8 +22,6 @@ import org.hibernate.annotations.Where;
|
||||
@Entity
|
||||
@Table(name = Constants.TABLE_PREFIX + "resource_type")
|
||||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "resource_type" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteIdOnlyEntity.LOGIC_DELETE_CLAUSE)
|
||||
public abstract class ResourceType extends LogicDeleteIdOnlyEntity {
|
||||
public abstract Type getResourceType();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.eshore.gringotts.web.domain.repository;
|
||||
package com.eshore.gringotts.web.domain.resource.repository;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.entity.DataResource;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.DataResource;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -12,17 +12,10 @@ import org.springframework.stereotype.Repository;
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Repository
|
||||
public interface DataResourceRepository extends SimpleRepository<DataResource, Long> {
|
||||
@Override
|
||||
@EntityGraph(value = "data_resource.list", type = EntityGraph.EntityGraphType.FETCH)
|
||||
List<DataResource> findAll(Specification<DataResource> specification);
|
||||
|
||||
@Override
|
||||
@EntityGraph(value = "data_resource.list", type = EntityGraph.EntityGraphType.FETCH)
|
||||
List<DataResource> findAll(Specification<DataResource> specification, Sort sort);
|
||||
|
||||
@EntityGraph(value = "data_resource.list", type = EntityGraph.EntityGraphType.FETCH)
|
||||
List<DataResource> findAllByConfirmationIsNull();
|
||||
|
||||
@Override
|
||||
@EntityGraph(value = "data_resource.detail", type = EntityGraph.EntityGraphType.FETCH)
|
||||
Optional<DataResource> findOne(Specification<DataResource> specification);
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.eshore.gringotts.web.domain.resource.repository;
|
||||
|
||||
import com.blinkfox.fenix.jpa.FenixJpaRepository;
|
||||
import com.blinkfox.fenix.specification.FenixJpaSpecificationExecutor;
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.format.ResourceFormat;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface ResourceFormatRepository extends SimpleRepository<ResourceFormat, Long> {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.eshore.gringotts.web.domain.resource.repository;
|
||||
|
||||
import com.blinkfox.fenix.jpa.FenixJpaRepository;
|
||||
import com.blinkfox.fenix.specification.FenixJpaSpecificationExecutor;
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.type.ResourceType;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface ResourceTypeRepository extends SimpleRepository<ResourceType, Long> {
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.eshore.gringotts.web.domain.resource.service;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.DataResource;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.format.ResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.type.ResourceType;
|
||||
import com.eshore.gringotts.web.domain.resource.repository.DataResourceRepository;
|
||||
import com.eshore.gringotts.web.domain.resource.repository.ResourceFormatRepository;
|
||||
import com.eshore.gringotts.web.domain.resource.repository.ResourceTypeRepository;
|
||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 数据资源服务
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataResourceService extends SimpleServiceSupport<DataResource> {
|
||||
private final ResourceTypeRepository resourceTypeRepository;
|
||||
private final ResourceFormatRepository resourceFormatRepository;
|
||||
|
||||
public DataResourceService(DataResourceRepository repository, ResourceTypeRepository resourceTypeRepository, ResourceFormatRepository resourceFormatRepository, UserService userService) {
|
||||
super(repository, userService);
|
||||
this.resourceTypeRepository = resourceTypeRepository;
|
||||
this.resourceFormatRepository = resourceFormatRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long save(DataResource entity) {
|
||||
ResourceType type = resourceTypeRepository.save(entity.getType());
|
||||
ResourceFormat format = resourceFormatRepository.save(entity.getFormat());
|
||||
entity.setType(type);
|
||||
entity.setFormat(format);
|
||||
return super.save(entity);
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity;
|
||||
import com.eshore.gringotts.web.domain.base.service.CheckingService;
|
||||
import com.eshore.gringotts.web.domain.base.service.LogicDeleteService;
|
||||
import com.eshore.gringotts.web.domain.entity.Authentication;
|
||||
import com.eshore.gringotts.web.domain.entity.Authentication_;
|
||||
import com.eshore.gringotts.web.domain.entity.CheckOrder;
|
||||
import com.eshore.gringotts.web.domain.entity.CheckOrder_;
|
||||
import com.eshore.gringotts.web.domain.entity.User;
|
||||
import com.eshore.gringotts.web.domain.repository.AuthenticationRepository;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.transaction.Transactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.factory.Maps;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.eclipse.collections.api.map.ImmutableMap;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-12-02
|
||||
*/
|
||||
@Slf4j
|
||||
@Service("com.eshore.gringotts.web.domain.service.AuthenticationService")
|
||||
public class AuthenticationService extends LogicDeleteService<Authentication> implements CheckingService {
|
||||
private final AuthenticationRepository authenticationRepository;
|
||||
private final UserService userService;
|
||||
private final CheckOrderService checkOrderService;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
public AuthenticationService(AuthenticationRepository repository, UserService userService, EntityManager manager, CheckOrderService checkOrderService, Jackson2ObjectMapperBuilder builder) {
|
||||
super(repository, userService, manager);
|
||||
this.authenticationRepository = repository;
|
||||
this.userService = userService;
|
||||
this.checkOrderService = checkOrderService;
|
||||
this.mapper = builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImmutableList<Predicate> listPredicate(Root<Authentication> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
User loginUser = userService.currentLoginUser();
|
||||
if (User.isAdministrator(loginUser)) {
|
||||
return Lists.immutable.empty();
|
||||
}
|
||||
return Lists.immutable.of(builder.or(
|
||||
builder.equal(root.get(Authentication_.createdUser), loginUser),
|
||||
builder.and(
|
||||
builder.equal(root.get(Authentication_.order).get(CheckOrder_.target), CheckOrder.Target.ROLE),
|
||||
builder.equal(root.get(Authentication_.order).get(CheckOrder_.targetRole), loginUser.getRole())
|
||||
),
|
||||
builder.and(
|
||||
builder.equal(root.get(Authentication_.order).get(CheckOrder_.target), CheckOrder.Target.USER),
|
||||
builder.equal(root.get(Authentication_.order).get(CheckOrder_.targetUser), loginUser)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long save(Authentication entity) {
|
||||
if (ObjectUtil.isNull(entity.getId()) && authenticationRepository.findOne(
|
||||
(root, query, criteriaBuilder) -> {
|
||||
// TODO 同一个资源的授权时间是否重合
|
||||
// 查询是否存在createdUser为当前登陆用户并且绑定的数据资源是同一个的授权申请
|
||||
return criteriaBuilder.and(
|
||||
criteriaBuilder.equal(root.get("createdUser"), userService.currentLoginUser()),
|
||||
criteriaBuilder.equal(root.get("target"), entity.getTarget())
|
||||
);
|
||||
}
|
||||
).isPresent()) {
|
||||
throw new AuthenticationDuplicatedException();
|
||||
}
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
public void submit(Long id) throws JsonProcessingException {
|
||||
Authentication authentication = detailOrThrow(id);
|
||||
authentication.setState(CheckingNeededEntity.State.OWNER_CHECKING);
|
||||
Long orderId = checkOrderService.save(new CheckOrder(
|
||||
"authentication_owner_check",
|
||||
StrUtil.format("数据资源「{}」的授权申请", authentication.getTarget().getName()),
|
||||
CheckOrder.Type.AUTHENTICATION,
|
||||
mapper.writeValueAsString(Maps.immutable.of("authenticationId", authentication.getId())),
|
||||
"com.eshore.gringotts.web.domain.service.AuthenticationService",
|
||||
authentication.getCreatedUser()
|
||||
));
|
||||
CheckOrder order = checkOrderService.detailOrThrow(orderId);
|
||||
authentication.setOrder(order);
|
||||
save(authentication);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
public void retract(Long id) {
|
||||
Authentication authentication = detailOrThrow(id);
|
||||
authentication.setState(Authentication.State.DRAFT);
|
||||
save(authentication);
|
||||
|
||||
CheckOrder order = authentication.getOrder();
|
||||
order.setState(CheckOrder.State.RETRACT);
|
||||
checkOrderService.save(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
public void onChecked(CheckOrder order, CheckOrder.Operation operation, ImmutableMap<String, Object> parameters) {
|
||||
Long id = (Long) parameters.get("authenticationId");
|
||||
Authentication authentication = detailOrThrow(id);
|
||||
if (StrUtil.equals(order.getKeyword(), "authentication_owner_check")) {
|
||||
switch (operation) {
|
||||
case APPLY:
|
||||
authentication.setState(Authentication.State.CHECKING);
|
||||
order.setKeyword("authentication_checker_check");
|
||||
order.setTarget(CheckOrder.Target.ROLE);
|
||||
order.setTargetRole(User.Role.CHECKER);
|
||||
break;
|
||||
case REJECT:
|
||||
authentication.setState(Authentication.State.DRAFT);
|
||||
order.setState(CheckOrder.State.OVER);
|
||||
break;
|
||||
}
|
||||
} else if (StrUtil.equals(order.getKeyword(), "authentication_checker_check")) {
|
||||
switch (operation) {
|
||||
case APPLY:
|
||||
authentication.setState(Authentication.State.NORMAL);
|
||||
order.setState(CheckOrder.State.OVER);
|
||||
break;
|
||||
case REJECT:
|
||||
authentication.setState(Authentication.State.DRAFT);
|
||||
order.setState(CheckOrder.State.OVER);
|
||||
break;
|
||||
}
|
||||
}
|
||||
save(authentication);
|
||||
checkOrderService.save(order);
|
||||
}
|
||||
|
||||
public static final class AuthenticationDuplicatedException extends RuntimeException {
|
||||
public AuthenticationDuplicatedException() {
|
||||
super("数据资源已绑定该账号的授权申请,无法再次申请");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity;
|
||||
import com.eshore.gringotts.web.domain.base.service.CheckingService;
|
||||
import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport;
|
||||
import com.eshore.gringotts.web.domain.entity.CheckOrder;
|
||||
import com.eshore.gringotts.web.domain.entity.CheckOrder_;
|
||||
import com.eshore.gringotts.web.domain.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.entity.Confirmation_;
|
||||
import com.eshore.gringotts.web.domain.entity.User;
|
||||
import com.eshore.gringotts.web.domain.repository.ConfirmationRepository;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Join;
|
||||
import javax.persistence.criteria.JoinType;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.transaction.Transactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.factory.Maps;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.eclipse.collections.api.map.ImmutableMap;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-26
|
||||
*/
|
||||
@Slf4j
|
||||
@Service("com.eshore.gringotts.web.domain.service.ConfirmationService")
|
||||
public class ConfirmationService extends SimpleServiceSupport<Confirmation> implements CheckingService {
|
||||
private final ConfirmationRepository confirmationRepository;
|
||||
private final CheckOrderService checkOrderService;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
public ConfirmationService(ConfirmationRepository confirmationRepository, UserService userService, CheckOrderService checkOrderService, Jackson2ObjectMapperBuilder builder) {
|
||||
super(confirmationRepository, userService);
|
||||
this.confirmationRepository = confirmationRepository;
|
||||
this.checkOrderService = checkOrderService;
|
||||
this.mapper = builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImmutableList<Predicate> listPredicate(Root<Confirmation> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
User loginUser = userService.currentLoginUser();
|
||||
if (User.isAdministrator(loginUser)) {
|
||||
return Lists.immutable.empty();
|
||||
}
|
||||
Join<Confirmation, CheckOrder> orderJoin = root.join(Confirmation_.order, JoinType.LEFT);
|
||||
return Lists.immutable.of(builder.or(
|
||||
builder.equal(root.get(Confirmation_.createdUser), loginUser),
|
||||
builder.and(
|
||||
builder.isNotNull(orderJoin),
|
||||
builder.or(
|
||||
builder.and(
|
||||
builder.equal(orderJoin.get(CheckOrder_.target), CheckOrder.Target.ROLE),
|
||||
builder.equal(orderJoin.get(CheckOrder_.targetRole), loginUser.getRole())
|
||||
),
|
||||
builder.and(
|
||||
builder.equal(orderJoin.get(CheckOrder_.target), CheckOrder.Target.USER),
|
||||
builder.equal(orderJoin.get(CheckOrder_.targetUser), loginUser)
|
||||
)
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long save(Confirmation entity) {
|
||||
if (ObjectUtil.isNull(entity.getId()) && confirmationRepository.existsByTarget_Id(entity.getTarget().getId())) {
|
||||
throw new ConfirmationDuplicatedException();
|
||||
}
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
public void submit(Long id) throws JsonProcessingException {
|
||||
Confirmation confirmation = detailOrThrow(id);
|
||||
confirmation.setState(Confirmation.State.CHECKING);
|
||||
Long orderId = checkOrderService.save(new CheckOrder(
|
||||
"confirmation_check",
|
||||
StrUtil.format("数据资源「{}」的确权申请", confirmation.getTarget().getName()),
|
||||
CheckOrder.Type.CONFIRMATION,
|
||||
mapper.writeValueAsString(Maps.immutable.of("confirmationId", confirmation.getId())),
|
||||
"com.eshore.gringotts.web.domain.service.ConfirmationService",
|
||||
User.Role.CHECKER
|
||||
));
|
||||
CheckOrder order = checkOrderService.detailOrThrow(orderId);
|
||||
confirmation.setOrder(order);
|
||||
save(confirmation);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
public void retract(Long id) {
|
||||
Confirmation confirmation = detailOrThrow(id);
|
||||
confirmation.setState(CheckingNeededEntity.State.DRAFT);
|
||||
save(confirmation);
|
||||
|
||||
CheckOrder order = confirmation.getOrder();
|
||||
order.setState(CheckOrder.State.RETRACT);
|
||||
checkOrderService.save(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
public void onChecked(CheckOrder order, CheckOrder.Operation operation, ImmutableMap<String, Object> parameters) {
|
||||
if (StrUtil.equals(order.getKeyword(), "confirmation_check")) {
|
||||
Long id = (Long) parameters.get("confirmationId");
|
||||
Confirmation confirmation = detailOrThrow(id);
|
||||
switch (operation) {
|
||||
case APPLY:
|
||||
confirmation.setState(Confirmation.State.NORMAL);
|
||||
order.setState(CheckOrder.State.OVER);
|
||||
break;
|
||||
case REJECT:
|
||||
confirmation.setState(Confirmation.State.DRAFT);
|
||||
order.setState(CheckOrder.State.OVER);
|
||||
break;
|
||||
}
|
||||
save(confirmation);
|
||||
checkOrderService.save(order);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class ConfirmationDuplicatedException extends RuntimeException {
|
||||
public ConfirmationDuplicatedException() {
|
||||
super("数据资源已绑定确权申请,无法再次申请");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.service;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport;
|
||||
import com.eshore.gringotts.web.domain.entity.Authentication;
|
||||
import com.eshore.gringotts.web.domain.entity.Authentication_;
|
||||
import com.eshore.gringotts.web.domain.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.entity.Confirmation_;
|
||||
import com.eshore.gringotts.web.domain.entity.DataFile;
|
||||
import com.eshore.gringotts.web.domain.entity.DataFile_;
|
||||
import com.eshore.gringotts.web.domain.entity.User;
|
||||
import com.eshore.gringotts.web.domain.repository.DataFileRepository;
|
||||
import com.eshore.gringotts.web.helper.EntityHelper;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.persistence.criteria.Subquery;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 上传服务
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-21
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataFileService extends SimpleServiceSupport<DataFile> {
|
||||
private final DataFileRepository dataFileRepository;
|
||||
private final UserService userService;
|
||||
|
||||
public DataFileService(DataFileRepository dataFileRepository, UserService userService) {
|
||||
super(dataFileRepository, userService);
|
||||
this.dataFileRepository = dataFileRepository;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImmutableList<Predicate> listPredicate(Root<DataFile> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
User loginUser = userService.currentLoginUser();
|
||||
if (User.isAdministrator(loginUser)) {
|
||||
return Lists.immutable.empty();
|
||||
}
|
||||
|
||||
Subquery<Confirmation> confirmationSubquery = query.subquery(Confirmation.class);
|
||||
Root<Confirmation> confirmationRoot = confirmationSubquery.from(Confirmation.class);
|
||||
confirmationSubquery.select(confirmationRoot)
|
||||
.where(
|
||||
builder.isMember(root, confirmationRoot.get(Confirmation_.evidences)),
|
||||
EntityHelper.checkNeededEntityPrediction(confirmationRoot, builder, loginUser)
|
||||
);
|
||||
|
||||
Subquery<Authentication> authenticationSubquery = query.subquery(Authentication.class);
|
||||
Root<Authentication> authenticationRoot = authenticationSubquery.from(Authentication.class);
|
||||
authenticationSubquery.select(authenticationRoot)
|
||||
.where(
|
||||
builder.isMember(root, authenticationRoot.get(Authentication_.evidences)),
|
||||
EntityHelper.checkNeededEntityPrediction(authenticationRoot, builder, loginUser)
|
||||
);
|
||||
|
||||
return Lists.immutable.of(builder.or(
|
||||
builder.equal(root.get(DataFile_.createdUser), loginUser),
|
||||
builder.exists(confirmationSubquery),
|
||||
builder.exists(authenticationSubquery)
|
||||
));
|
||||
}
|
||||
|
||||
public Long initialDataFile(String filename) {
|
||||
DataFile dataFile = new DataFile();
|
||||
dataFile.setFilename(filename);
|
||||
return dataFileRepository.save(dataFile).getId();
|
||||
}
|
||||
|
||||
public void updateDataFile(Long id, String path, Long size, String md5) {
|
||||
DataFile dataFile = dataFileRepository.findById(id).orElseThrow(UpdateDataFileFailedException::new);
|
||||
dataFile.setSize(size);
|
||||
dataFile.setMd5(md5);
|
||||
dataFile.setPath(path);
|
||||
User loginUser = userService.currentLoginUser();
|
||||
dataFile.setModifiedUser(loginUser);
|
||||
dataFileRepository.save(dataFile);
|
||||
}
|
||||
|
||||
public static final class DataFileNotFoundException extends RuntimeException {
|
||||
public DataFileNotFoundException() {
|
||||
super("文件未找到,请重新上传");
|
||||
}
|
||||
}
|
||||
|
||||
public static final class UpdateDataFileFailedException extends RuntimeException {
|
||||
public UpdateDataFileFailedException() {
|
||||
super("更新文件信息失败,请重新上传");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.service;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport;
|
||||
import com.eshore.gringotts.web.domain.entity.Authentication;
|
||||
import com.eshore.gringotts.web.domain.entity.Authentication_;
|
||||
import com.eshore.gringotts.web.domain.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.entity.Confirmation_;
|
||||
import com.eshore.gringotts.web.domain.entity.DataResource;
|
||||
import com.eshore.gringotts.web.domain.entity.DataResource_;
|
||||
import com.eshore.gringotts.web.domain.entity.User;
|
||||
import com.eshore.gringotts.web.domain.entity.format.ResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.entity.type.ResourceType;
|
||||
import com.eshore.gringotts.web.domain.repository.DataResourceRepository;
|
||||
import com.eshore.gringotts.web.domain.repository.ResourceFormatRepository;
|
||||
import com.eshore.gringotts.web.domain.repository.ResourceTypeRepository;
|
||||
import com.eshore.gringotts.web.helper.EntityHelper;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Join;
|
||||
import javax.persistence.criteria.JoinType;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.persistence.criteria.Subquery;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 数据资源服务
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataResourceService extends SimpleServiceSupport<DataResource> {
|
||||
private final DataResourceRepository dataResourceRepository;
|
||||
private final ResourceTypeRepository resourceTypeRepository;
|
||||
private final ResourceFormatRepository resourceFormatRepository;
|
||||
private final UserService userService;
|
||||
|
||||
public DataResourceService(DataResourceRepository repository, ResourceTypeRepository resourceTypeRepository, ResourceFormatRepository resourceFormatRepository, UserService userService) {
|
||||
super(repository, userService);
|
||||
this.dataResourceRepository = repository;
|
||||
this.resourceTypeRepository = resourceTypeRepository;
|
||||
this.resourceFormatRepository = resourceFormatRepository;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImmutableList<Predicate> listPredicate(Root<DataResource> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
User loginUser = userService.currentLoginUser();
|
||||
if (User.isAdministrator(loginUser)) {
|
||||
return Lists.immutable.empty();
|
||||
}
|
||||
|
||||
Subquery<Confirmation> confirmationSubquery = query.subquery(Confirmation.class);
|
||||
Root<Confirmation> confirmationRoot = confirmationSubquery.from(Confirmation.class);
|
||||
confirmationSubquery.select(confirmationRoot)
|
||||
.where(
|
||||
builder.equal(confirmationRoot.get(Confirmation_.target), root),
|
||||
EntityHelper.checkNeededEntityPrediction(confirmationRoot, builder, loginUser)
|
||||
);
|
||||
|
||||
Subquery<Authentication> authenticationSubquery = query.subquery(Authentication.class);
|
||||
Root<Authentication> authenticationRoot = authenticationSubquery.from(Authentication.class);
|
||||
authenticationSubquery.select(authenticationRoot)
|
||||
.where(
|
||||
builder.equal(authenticationRoot.get(Authentication_.target), root),
|
||||
EntityHelper.checkNeededEntityPrediction(authenticationRoot, builder, loginUser)
|
||||
);
|
||||
|
||||
return Lists.immutable.of(builder.or(
|
||||
builder.equal(root.get(DataResource_.createdUser), loginUser),
|
||||
builder.exists(confirmationSubquery),
|
||||
builder.exists(authenticationSubquery)
|
||||
));
|
||||
}
|
||||
|
||||
public ImmutableList<DataResource> listNoConfirmation() {
|
||||
return Lists.immutable.ofAll(dataResourceRepository.findAll(
|
||||
(root, query, builder) -> {
|
||||
Join<DataResource, Confirmation> confirmationJoin = root.join(DataResource_.confirmation, JoinType.LEFT);
|
||||
return builder.and(
|
||||
builder.isNull(confirmationJoin.get(Confirmation_.id)),
|
||||
builder.equal(root.get(DataResource_.createdUser), userService.currentLoginUser())
|
||||
);
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
public ImmutableList<DataResource> listNoAuthentication() {
|
||||
return Lists.immutable.ofAll(dataResourceRepository.findAll(
|
||||
(root, query, builder) -> {
|
||||
Join<DataResource, Confirmation> confirmationJoin = root.join(DataResource_.confirmation, JoinType.LEFT);
|
||||
confirmationJoin.on(builder.equal(confirmationJoin.get(Confirmation_.state), Confirmation.State.NORMAL));
|
||||
|
||||
Subquery<Authentication> authenticationSubquery = query.subquery(Authentication.class);
|
||||
Root<Authentication> authenticationRoot = authenticationSubquery.from(Authentication.class);
|
||||
authenticationSubquery.select(authenticationRoot)
|
||||
.where(
|
||||
builder.equal(authenticationRoot.get(Authentication_.target), root),
|
||||
builder.equal(authenticationRoot.get(Authentication_.createdUser), userService.currentLoginUser())
|
||||
);
|
||||
return builder.and(
|
||||
builder.exists(authenticationSubquery).not(),
|
||||
builder.equal(root.get(DataResource_.createdUser), userService.currentLoginUser())
|
||||
);
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long save(DataResource entity) {
|
||||
ResourceType type = resourceTypeRepository.save(entity.getType());
|
||||
ResourceFormat format = resourceFormatRepository.save(entity.getFormat());
|
||||
entity.setType(type);
|
||||
entity.setFormat(format);
|
||||
return super.save(entity);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.eshore.gringotts.web.domain.service;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport;
|
||||
import com.eshore.gringotts.web.domain.entity.Ware;
|
||||
import com.eshore.gringotts.web.domain.repository.WareRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-12-13
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WareService extends SimpleServiceSupport<Ware> {
|
||||
public WareService(WareRepository repository, UserService userService) {
|
||||
super(repository, userService);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.eshore.gringotts.web.domain.controller;
|
||||
package com.eshore.gringotts.web.domain.upload.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.eshore.gringotts.web.configuration.UploadConfiguration;
|
||||
import com.eshore.gringotts.web.configuration.amis.AmisResponse;
|
||||
import com.eshore.gringotts.web.domain.service.DataFileService;
|
||||
import com.eshore.gringotts.web.domain.upload.service.DataFileService;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
@@ -1,15 +1,13 @@
|
||||
package com.eshore.gringotts.web.domain.entity;
|
||||
package com.eshore.gringotts.web.domain.upload.entity;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteEntity;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
@@ -23,8 +21,6 @@ import org.hibernate.annotations.Where;
|
||||
@Entity
|
||||
@DynamicUpdate
|
||||
@Table(name = Constants.TABLE_PREFIX + "data_file")
|
||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "data_file" + " set deleted = true where id = ?")
|
||||
@Where(clause = LogicDeleteEntity.LOGIC_DELETE_CLAUSE)
|
||||
public class DataFile extends LogicDeleteEntity {
|
||||
private String filename;
|
||||
private Long size;
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.eshore.gringotts.web.domain.repository;
|
||||
package com.eshore.gringotts.web.domain.upload.repository;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.entity.DataFile;
|
||||
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.eshore.gringotts.web.domain.upload.service;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport;
|
||||
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
|
||||
import com.eshore.gringotts.web.domain.upload.repository.DataFileRepository;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 上传服务
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-21
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataFileService extends SimpleServiceSupport<DataFile> {
|
||||
private final DataFileRepository dataFileRepository;
|
||||
private final UserService userService;
|
||||
|
||||
public DataFileService(DataFileRepository dataFileRepository, UserService userService) {
|
||||
super(dataFileRepository, userService);
|
||||
this.dataFileRepository = dataFileRepository;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
public DataFile detail(String id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return detail(Long.valueOf(id));
|
||||
}
|
||||
|
||||
public Long initialDataFile(String filename) {
|
||||
DataFile dataFile = new DataFile();
|
||||
dataFile.setFilename(filename);
|
||||
User loginUser = userService.currentLoginUser();
|
||||
dataFile.setCreatedUser(loginUser);
|
||||
dataFile.setModifiedUser(loginUser);
|
||||
return dataFileRepository.save(dataFile).getId();
|
||||
}
|
||||
|
||||
public void updateDataFile(Long id, String path, Long size, String md5) {
|
||||
DataFile dataFile = dataFileRepository.findById(id).orElseThrow(UpdateDataFileFailedException::new);
|
||||
dataFile.setSize(size);
|
||||
dataFile.setMd5(md5);
|
||||
dataFile.setPath(path);
|
||||
User loginUser = userService.currentLoginUser();
|
||||
dataFile.setModifiedUser(loginUser);
|
||||
dataFileRepository.save(dataFile);
|
||||
}
|
||||
|
||||
public static final class DataFileNotFoundException extends RuntimeException {
|
||||
public DataFileNotFoundException() {
|
||||
super("文件未找到,请重新上传");
|
||||
}
|
||||
}
|
||||
|
||||
public static final class UpdateDataFileFailedException extends RuntimeException {
|
||||
public UpdateDataFileFailedException() {
|
||||
super("更新文件信息失败,请重新上传");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.eshore.gringotts.web.domain.controller;
|
||||
package com.eshore.gringotts.web.domain.user.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.eshore.gringotts.web.configuration.amis.AmisResponse;
|
||||
import com.eshore.gringotts.web.domain.entity.User;
|
||||
import com.eshore.gringotts.web.domain.service.UserService;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||
import lombok.Data;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.eshore.gringotts.web.domain.controller;
|
||||
package com.eshore.gringotts.web.domain.user.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.eshore.gringotts.web.configuration.amis.AmisListResponse;
|
||||
import com.eshore.gringotts.web.configuration.amis.AmisResponse;
|
||||
import com.eshore.gringotts.web.domain.entity.User;
|
||||
import com.eshore.gringotts.web.domain.service.UserService;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
import org.slf4j.Logger;
|
||||
@@ -1,20 +1,20 @@
|
||||
package com.eshore.gringotts.web.domain.entity;
|
||||
package com.eshore.gringotts.web.domain.user.entity;
|
||||
|
||||
import com.eshore.gringotts.core.Constants;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.NamedAttributeNode;
|
||||
import jakarta.persistence.NamedEntityGraph;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ConstraintMode;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.NamedAttributeNode;
|
||||
import javax.persistence.NamedEntityGraph;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.eshore.gringotts.web.domain.repository;
|
||||
package com.eshore.gringotts.web.domain.user.repository;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.entity.User;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
@@ -21,7 +21,6 @@ public interface UserRepository extends SimpleRepository<User, Long> {
|
||||
List<User> findAll();
|
||||
|
||||
Boolean existsByUsername(String username);
|
||||
|
||||
@EntityGraph(value = "user.detail", type = EntityGraph.EntityGraphType.FETCH)
|
||||
Optional<User> findByUsername(String username);
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.eshore.gringotts.web.domain.service;
|
||||
package com.eshore.gringotts.web.domain.user.service;
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.eshore.gringotts.web.domain.entity.User;
|
||||
import com.eshore.gringotts.web.domain.repository.UserRepository;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import com.eshore.gringotts.web.domain.user.repository.UserRepository;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
@@ -72,15 +73,7 @@ public class UserService {
|
||||
}
|
||||
|
||||
public User currentLoginUser() {
|
||||
return currentLoginUserOptional().orElseThrow(LoginNotFoundException::new);
|
||||
}
|
||||
|
||||
public Optional<User> currentLoginUserOptional() {
|
||||
try {
|
||||
return userRepository.findById(StpUtil.getLoginIdAsLong());
|
||||
} catch (Throwable throwable) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return userRepository.findById(StpUtil.getLoginIdAsLong()).orElseThrow(LoginNotFoundException::new);
|
||||
}
|
||||
|
||||
private User findUserByUsername(String username) {
|
||||
@@ -136,6 +129,7 @@ public class UserService {
|
||||
*/
|
||||
public void registerFromAdministrator(String username, String password, User.Role role) {
|
||||
User loginUser = currentLoginUser();
|
||||
|
||||
User user = new User();
|
||||
user.setUsername(username);
|
||||
user.setPassword(encryptPassword(password));
|
||||
@@ -143,6 +137,8 @@ public class UserService {
|
||||
user.setState(User.State.NORMAL);
|
||||
user.setCheckedUser(loginUser);
|
||||
user.setCheckedTime(LocalDateTime.now());
|
||||
user.setCreatedUser(loginUser);
|
||||
user.setModifiedUser(loginUser);
|
||||
userRepository.save(user);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
package com.eshore.gringotts.web.helper;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity;
|
||||
import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity_;
|
||||
import com.eshore.gringotts.web.domain.entity.CheckOrder;
|
||||
import com.eshore.gringotts.web.domain.entity.CheckOrder_;
|
||||
import com.eshore.gringotts.web.domain.entity.User;
|
||||
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||
import java.util.function.Supplier;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
@@ -26,16 +21,12 @@ public class EntityHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static Predicate checkNeededEntityPrediction(Root<? extends CheckingNeededEntity> root, CriteriaBuilder builder, User loginUser) {
|
||||
return builder.or(
|
||||
builder.and(
|
||||
builder.equal(root.get(CheckingNeededEntity_.order).get(CheckOrder_.target), CheckOrder.Target.ROLE),
|
||||
builder.equal(root.get(CheckingNeededEntity_.order).get(CheckOrder_.targetRole), loginUser.getRole())
|
||||
),
|
||||
builder.and(
|
||||
builder.equal(root.get(CheckingNeededEntity_.order).get(CheckOrder_.target), CheckOrder.Target.USER),
|
||||
builder.equal(root.get(CheckingNeededEntity_.order).get(CheckOrder_.targetUser), loginUser)
|
||||
)
|
||||
);
|
||||
public static <E extends SimpleEntity> E fillCreatorAndModifier(E entity, UserService service) {
|
||||
User user = service.currentLoginUser();
|
||||
if (ObjectUtil.isNull(entity.getCreatedUser())) {
|
||||
entity.setCreatedUser(user);
|
||||
}
|
||||
entity.setModifiedUser(user);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ spring:
|
||||
multipart:
|
||||
max-file-size: 10MB
|
||||
max-request-size: 20MB
|
||||
jackson:
|
||||
date-format: 'yyyy-MM-dd HH:mm:ss'
|
||||
fenix:
|
||||
print-banner: false
|
||||
print-sql: false
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.eshore.gringotts.web;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.controller.query.Query;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.eclipsecollections.EclipseCollectionsModule;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-12-03
|
||||
*/
|
||||
public class TestQueryParse {
|
||||
public static void main(String[] args) throws JsonProcessingException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.registerModule(new EclipseCollectionsModule());
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
// language=JSON
|
||||
System.out.println(mapper.readValue("{}", Query.class));
|
||||
// language=JSON
|
||||
System.out.println(mapper.readValue("{\n" +
|
||||
" \"query\": {\n" +
|
||||
" \"equal\": {\n" +
|
||||
" \"name\": \"lanyuanxiaoyao\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}", Query.class));
|
||||
// language=JSON
|
||||
System.out.println(mapper.readValue("{\n" +
|
||||
" \"query\": {\n" +
|
||||
" \"equal\": {\n" +
|
||||
" \"name\": \"lanyuanxiaoyao\"\n" +
|
||||
" },\n" +
|
||||
" \"notEqual\": {\n" +
|
||||
" \"username\": \"lanyuanxiaoyao@qq.com\",\n" +
|
||||
" \"password\": \"mingland87\"\n" +
|
||||
" },\n" +
|
||||
" \"great\": {\n" +
|
||||
" \"age\": 12,\n" +
|
||||
" \"createTime\": \"2020-10-12 00:00:00\"\n" +
|
||||
" },\n" +
|
||||
" \"in\": {\n" +
|
||||
" \"age\": [\n" +
|
||||
" 15,\n" +
|
||||
" 18,\n" +
|
||||
" 20\n" +
|
||||
" ]\n" +
|
||||
" },\n" +
|
||||
" \"between\": {\n" +
|
||||
" \"createTime\": {\n" +
|
||||
" \"start\": \"2024-12-03 00:00:00\",\n" +
|
||||
" \"end\": \"2024-12-03 00:00:00\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"sort\": [\n" +
|
||||
" {\n" +
|
||||
" \"column\": \"createTime\",\n" +
|
||||
" \"direction\": \"ASC\"\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"page\": {\n" +
|
||||
" \"size\": 10,\n" +
|
||||
" \"page\": 1\n" +
|
||||
" }\n" +
|
||||
"}", Query.class));
|
||||
}
|
||||
}
|
||||
41
pom.xml
41
pom.xml
@@ -19,18 +19,16 @@
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<spring-boot.version>2.6.15</spring-boot.version>
|
||||
<spring-cloud.version>2021.0.9</spring-cloud.version>
|
||||
<spring-boot.version>3.2.1</spring-boot.version>
|
||||
<spring-cloud.version>2023.0.4</spring-cloud.version>
|
||||
|
||||
<hutool.version>5.8.32</hutool.version>
|
||||
<fisco.sdk.version>2.10.0</fisco.sdk.version>
|
||||
<eclipse-collections.version>11.1.0</eclipse-collections.version>
|
||||
<querydsl.version>5.1.0</querydsl.version>
|
||||
<hibernate.version>5.6.15.Final</hibernate.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -77,7 +75,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dtflys.forest</groupId>
|
||||
<artifactId>forest-spring-boot-starter</artifactId>
|
||||
<artifactId>forest-spring-boot3-starter</artifactId>
|
||||
<version>1.5.36</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -97,24 +95,13 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<artifactId>sa-token-spring-boot3-starter</artifactId>
|
||||
<version>1.39.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.blinkfox</groupId>
|
||||
<artifactId>fenix-spring-boot-starter</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.querydsl</groupId>
|
||||
<artifactId>querydsl-jpa</artifactId>
|
||||
<version>${querydsl.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.querydsl</groupId>
|
||||
<artifactId>querydsl-apt</artifactId>
|
||||
<version>${querydsl.version}</version>
|
||||
<scope>provided</scope>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Others -->
|
||||
@@ -157,6 +144,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<parameters>true</parameters>
|
||||
</configuration>
|
||||
@@ -164,24 +152,11 @@
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<parameters>true</parameters>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.mysema.maven</groupId>
|
||||
<artifactId>apt-maven-plugin</artifactId>
|
||||
<version>1.1.3</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
Reference in New Issue
Block a user