fix(web): 优化文件上传适配
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
const information = {
|
const information = {
|
||||||
debug: false,
|
debug: true,
|
||||||
// baseUrl: '',
|
// baseUrl: '',
|
||||||
baseUrl: 'http://127.0.0.1:20080',
|
baseUrl: 'http://127.0.0.1:20080',
|
||||||
title: '可信供给中心',
|
title: '可信供给中心',
|
||||||
@@ -170,6 +170,13 @@ export const userStateMapping = [
|
|||||||
mappingItem('禁用', 'DISABLED', 'bg-danger'),
|
mappingItem('禁用', 'DISABLED', 'bg-danger'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export const confirmationStateMapping = [
|
||||||
|
mappingItem('草稿', 'DRAFT', 'bg-primary'),
|
||||||
|
mappingItem('审查中', 'CHECKING', 'bg-warning'),
|
||||||
|
mappingItem('通过', 'NORMAL', 'bg-success'),
|
||||||
|
mappingItem('驳回', 'REJECT', 'bg-danger'),
|
||||||
|
]
|
||||||
|
|
||||||
function api(method, url) {
|
function api(method, url) {
|
||||||
return {
|
return {
|
||||||
method: method,
|
method: method,
|
||||||
@@ -211,15 +218,7 @@ export const formInputClearable = {
|
|||||||
clearValueOnEmpty: true,
|
clearValueOnEmpty: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formInputFileStatic(field, label) {
|
const formInputFileStaticColumns = [
|
||||||
return {
|
|
||||||
visibleOn: '${detail}',
|
|
||||||
type: 'input-table',
|
|
||||||
label: label,
|
|
||||||
name: field,
|
|
||||||
required: true,
|
|
||||||
resizable: false,
|
|
||||||
columns: [
|
|
||||||
{
|
{
|
||||||
name: 'filename',
|
name: 'filename',
|
||||||
label: '文件名',
|
label: '文件名',
|
||||||
@@ -243,6 +242,30 @@ export function formInputFileStatic(field, label) {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export function formInputSingleFileStatic(field, label) {
|
||||||
|
return {
|
||||||
|
visibleOn: '${detail}',
|
||||||
|
type: 'control',
|
||||||
|
label: label,
|
||||||
|
required: true,
|
||||||
|
body: {
|
||||||
|
type: 'table',
|
||||||
|
source: `\${${field}|asArray}`,
|
||||||
|
columns: formInputFileStaticColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formInputMultiFileStatic(field, label) {
|
||||||
|
return {
|
||||||
|
visibleOn: '${detail}',
|
||||||
|
type: 'input-table',
|
||||||
|
label: label,
|
||||||
|
name: field,
|
||||||
|
required: true,
|
||||||
|
resizable: false,
|
||||||
|
columns: formInputFileStaticColumns,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
apiGet,
|
apiGet,
|
||||||
apiPost,
|
apiPost,
|
||||||
formInputClearable,
|
formInputClearable,
|
||||||
formInputFileStatic,
|
formInputMultiFileStatic,
|
||||||
horizontalFormOptions,
|
horizontalFormOptions,
|
||||||
inputFileFormItemCommonOptions,
|
inputFileFormItemCommonOptions,
|
||||||
size100MB
|
size100MB
|
||||||
@@ -43,15 +43,15 @@ function detailForm() {
|
|||||||
name: 'description',
|
name: 'description',
|
||||||
...formInputClearable,
|
...formInputClearable,
|
||||||
},
|
},
|
||||||
formInputFileStatic('evidenceIds', '相关材料'),
|
formInputMultiFileStatic('evidenceFiles', '相关材料'),
|
||||||
{
|
{
|
||||||
visibleOn: '${!detail}',
|
visibleOn: '${!detail}',
|
||||||
type: 'input-file',
|
type: 'input-file',
|
||||||
label: '相关材料',
|
label: '相关材料',
|
||||||
name: 'evidenceIds',
|
name: 'evidenceFiles',
|
||||||
multiple: true,
|
multiple: true,
|
||||||
required: true,
|
required: true,
|
||||||
extractValue: true,
|
joinValues: false,
|
||||||
...inputFileFormItemCommonOptions(undefined, size100MB),
|
...inputFileFormItemCommonOptions(undefined, size100MB),
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -76,7 +76,6 @@ export function permissionAddDialog() {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
body: {
|
body: {
|
||||||
debug: true,
|
|
||||||
...detailForm(),
|
...detailForm(),
|
||||||
api: apiPost('${base}/confirmation/save'),
|
api: apiPost('${base}/confirmation/save'),
|
||||||
data: {
|
data: {
|
||||||
@@ -95,7 +94,6 @@ export function permissionDetailDialog(field = 'id') {
|
|||||||
size: 'md',
|
size: 'md',
|
||||||
actions: [],
|
actions: [],
|
||||||
body: {
|
body: {
|
||||||
debug: true,
|
|
||||||
...detailForm(),
|
...detailForm(),
|
||||||
initApi: apiGet(`\${base}/confirmation/detail/\${${field}}`),
|
initApi: apiGet(`\${base}/confirmation/detail/\${${field}}`),
|
||||||
static: true,
|
static: true,
|
||||||
@@ -106,3 +104,32 @@ export function permissionDetailDialog(field = 'id') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function permissionEditeDialog(field = 'id') {
|
||||||
|
return {
|
||||||
|
actionType: 'dialog',
|
||||||
|
dialog: {
|
||||||
|
title: '确权申请详情',
|
||||||
|
size: 'md',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
type: 'reset',
|
||||||
|
label: '重置',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'submit',
|
||||||
|
label: '确定',
|
||||||
|
level: 'primary',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
body: {
|
||||||
|
...detailForm(),
|
||||||
|
api: apiPost('${base}/confirmation/save'),
|
||||||
|
initApi: apiGet(`\${base}/confirmation/detail/\${${field}}`),
|
||||||
|
data: {
|
||||||
|
edit: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
apiGet,
|
apiGet,
|
||||||
apiPost,
|
apiPost,
|
||||||
formInputClearable,
|
formInputClearable,
|
||||||
formInputFileStatic,
|
formInputSingleFileStatic,
|
||||||
horizontalFormOptions,
|
horizontalFormOptions,
|
||||||
inputFileFormItemCommonOptions,
|
inputFileFormItemCommonOptions,
|
||||||
size1GB,
|
size1GB,
|
||||||
@@ -12,7 +12,6 @@ import {
|
|||||||
|
|
||||||
function detailForm() {
|
function detailForm() {
|
||||||
return {
|
return {
|
||||||
debug: true,
|
|
||||||
type: 'form',
|
type: 'form',
|
||||||
...horizontalFormOptions(),
|
...horizontalFormOptions(),
|
||||||
horizontal: {
|
horizontal: {
|
||||||
@@ -87,7 +86,7 @@ function detailForm() {
|
|||||||
visibleOn: "${resourceType === 'FILE'}",
|
visibleOn: "${resourceType === 'FILE'}",
|
||||||
type: 'fieldSet',
|
type: 'fieldSet',
|
||||||
body: [
|
body: [
|
||||||
formInputFileStatic('file', '数据文件'),
|
formInputSingleFileStatic('file', '数据文件'),
|
||||||
{
|
{
|
||||||
visibleOn: "${!detail}",
|
visibleOn: "${!detail}",
|
||||||
type: 'input-file',
|
type: 'input-file',
|
||||||
@@ -96,10 +95,8 @@ function detailForm() {
|
|||||||
name: 'file',
|
name: 'file',
|
||||||
multiple: false,
|
multiple: false,
|
||||||
required: true,
|
required: true,
|
||||||
|
joinValues: false,
|
||||||
...inputFileFormItemCommonOptions('.zip', size1GB),
|
...inputFileFormItemCommonOptions('.zip', size1GB),
|
||||||
autoFill: {
|
|
||||||
fileId: '${value}'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -143,29 +140,27 @@ function detailForm() {
|
|||||||
visibleOn: "${resourceType === 'HDFS'}",
|
visibleOn: "${resourceType === 'HDFS'}",
|
||||||
type: 'fieldSet',
|
type: 'fieldSet',
|
||||||
body: [
|
body: [
|
||||||
formInputFileStatic('coreSiteFile', 'core-site.xml'),
|
formInputSingleFileStatic('coreSiteFile', 'core-site.xml'),
|
||||||
{
|
{
|
||||||
visibleOn: "${!detail}",
|
visibleOn: "${!detail}",
|
||||||
type: 'input-file',
|
type: 'input-file',
|
||||||
label: 'core-site.xml',
|
label: 'core-site.xml',
|
||||||
name: 'coreSiteFile',
|
name: 'coreSiteFile',
|
||||||
|
multiple: false,
|
||||||
required: true,
|
required: true,
|
||||||
|
joinValues: false,
|
||||||
...inputFileFormItemCommonOptions('.xml'),
|
...inputFileFormItemCommonOptions('.xml'),
|
||||||
autoFill: {
|
|
||||||
coreSiteFileId: '${value}'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
formInputFileStatic('hdfsSiteFile', 'hdfs-site.xml'),
|
formInputSingleFileStatic('hdfsSiteFile', 'hdfs-site.xml'),
|
||||||
{
|
{
|
||||||
visibleOn: "${!detail}",
|
visibleOn: "${!detail}",
|
||||||
type: 'input-file',
|
type: 'input-file',
|
||||||
label: 'hdfs-site.xml',
|
label: 'hdfs-site.xml',
|
||||||
name: 'hdfsSiteFile',
|
name: 'hdfsSiteFile',
|
||||||
|
multiple: false,
|
||||||
required: true,
|
required: true,
|
||||||
|
joinValues: false,
|
||||||
...inputFileFormItemCommonOptions('.xml'),
|
...inputFileFormItemCommonOptions('.xml'),
|
||||||
autoFill: {
|
|
||||||
hdfsSiteFileId: '${value}'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -285,17 +280,16 @@ function detailForm() {
|
|||||||
label: 'JSON格式',
|
label: 'JSON格式',
|
||||||
language: 'json',
|
language: 'json',
|
||||||
},
|
},
|
||||||
formInputFileStatic('exampleFile', '资源示例'),
|
formInputSingleFileStatic('exampleFile', '资源示例'),
|
||||||
{
|
{
|
||||||
visibleOn: "${!detail}",
|
visibleOn: "${!detail}",
|
||||||
type: 'input-file',
|
type: 'input-file',
|
||||||
label: '资源示例',
|
label: '资源示例',
|
||||||
name: 'exampleFile',
|
name: 'exampleFile',
|
||||||
description: '可以上传用于作为格式示范的样例数据',
|
description: '可以上传用于作为格式示范的样例数据',
|
||||||
|
multiple: false,
|
||||||
|
joinValues: false,
|
||||||
...inputFileFormItemCommonOptions(undefined, size500MB),
|
...inputFileFormItemCommonOptions(undefined, size500MB),
|
||||||
autoFill: {
|
|
||||||
exampleFileId: '${value}'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ export function resourceList() {
|
|||||||
...resourceAddDialog()
|
...resourceAddDialog()
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
rowSelection: {
|
||||||
|
disableOn: '${confirmationId}',
|
||||||
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
label: '名称',
|
label: '名称',
|
||||||
@@ -57,6 +60,7 @@ export function resourceList() {
|
|||||||
trigger: 'hover',
|
trigger: 'hover',
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
|
disabledOn: '${confirmationId}',
|
||||||
type: 'action',
|
type: 'action',
|
||||||
label: '编辑',
|
label: '编辑',
|
||||||
level: 'link',
|
level: 'link',
|
||||||
@@ -65,7 +69,7 @@ export function resourceList() {
|
|||||||
{
|
{
|
||||||
disabledOn: '${confirmationId}',
|
disabledOn: '${confirmationId}',
|
||||||
type: 'action',
|
type: 'action',
|
||||||
label: "${IF(confirmationId, '删除(确权中)', '删除')}",
|
label: "删除",
|
||||||
confirmTitle: '确认删除',
|
confirmTitle: '确认删除',
|
||||||
confirmText: '确认删除名称为「${name}」的数据资源吗?',
|
confirmText: '确认删除名称为「${name}」的数据资源吗?',
|
||||||
actionType: 'ajax',
|
actionType: 'ajax',
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
import {apiGet, crudCommonOptions, providerOnly, userOnly} from "../../components/constants.js";
|
import {
|
||||||
import {permissionAddDialog, permissionDetailDialog} from "../../components/permission/dialog-permission.js";
|
apiGet,
|
||||||
|
confirmationStateMapping,
|
||||||
|
crudCommonOptions,
|
||||||
|
mappingField,
|
||||||
|
providerOnly,
|
||||||
|
userOnly
|
||||||
|
} from "../../components/constants.js";
|
||||||
|
import {
|
||||||
|
permissionAddDialog,
|
||||||
|
permissionDetailDialog,
|
||||||
|
permissionEditeDialog
|
||||||
|
} from "../../components/permission/dialog-permission.js";
|
||||||
|
|
||||||
export function tabPermissions() {
|
export function tabPermissions() {
|
||||||
return {
|
return {
|
||||||
@@ -37,6 +48,12 @@ export function tabPermissions() {
|
|||||||
label: '描述',
|
label: '描述',
|
||||||
name: 'description',
|
name: 'description',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: '状态',
|
||||||
|
width: 80,
|
||||||
|
align: 'center',
|
||||||
|
...mappingField('state', confirmationStateMapping)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
width: 150,
|
width: 150,
|
||||||
@@ -58,9 +75,49 @@ export function tabPermissions() {
|
|||||||
...permissionDetailDialog(),
|
...permissionDetailDialog(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
visibleOn: "${state === 'CHECKING'}",
|
||||||
|
type: 'action',
|
||||||
|
label: '撤销',
|
||||||
|
level: 'link',
|
||||||
|
confirmTitle: '确认撤销',
|
||||||
|
confirmText: '确认撤销名称为「${name}」的确权申请吗?',
|
||||||
|
actionType: 'ajax',
|
||||||
|
api: apiGet('${base}/confirmation/retract/${id}'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visibleOn: "${state === 'DRAFT' || state === 'REJECT'}",
|
||||||
|
type: 'action',
|
||||||
|
label: '提交',
|
||||||
|
level: 'link',
|
||||||
|
confirmTitle: '确认提交',
|
||||||
|
confirmText: '确认提交名称为「${name}」的确权申请吗?',
|
||||||
|
actionType: 'ajax',
|
||||||
|
api: apiGet('${base}/confirmation/submit/${id}'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'dropdown-button',
|
||||||
|
level: 'link',
|
||||||
|
icon: 'fa fa-ellipsis-h',
|
||||||
|
hideCaret: true,
|
||||||
|
trigger: 'hover',
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
disabledOn: "${state === 'CHECKING'}",
|
||||||
type: 'action',
|
type: 'action',
|
||||||
label: '编辑',
|
label: '编辑',
|
||||||
level: 'link',
|
level: 'link',
|
||||||
|
...permissionEditeDialog(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
disabledOn: "${state === 'CHECKING'}",
|
||||||
|
type: 'action',
|
||||||
|
label: "删除",
|
||||||
|
confirmTitle: '确认删除',
|
||||||
|
confirmText: '确认删除名称为「${name}」的确权申请吗?',
|
||||||
|
actionType: 'ajax',
|
||||||
|
api: apiGet('${base}/confirmation/remove/${id}'),
|
||||||
|
},
|
||||||
|
]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public abstract class SimpleController<ENTITY extends SimpleEntity, SAVE_ITEM, L
|
|||||||
protected static final String DETAIL = "/detail/{id}";
|
protected static final String DETAIL = "/detail/{id}";
|
||||||
protected static final String REMOVE = "/remove/{id}";
|
protected static final String REMOVE = "/remove/{id}";
|
||||||
|
|
||||||
protected final SimpleService<ENTITY> service;
|
private final SimpleService<ENTITY> service;
|
||||||
|
|
||||||
public SimpleController(SimpleService<ENTITY> service) {
|
public SimpleController(SimpleService<ENTITY> service) {
|
||||||
this.service = service;
|
this.service = service;
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
package com.eshore.gringotts.web.domain.base.entity;
|
package com.eshore.gringotts.web.domain.base.entity;
|
||||||
|
|
||||||
import com.eshore.gringotts.web.domain.upload.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;
|
||||||
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
import java.io.IOException;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@@ -8,18 +15,37 @@ import lombok.NoArgsConstructor;
|
|||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@JsonDeserialize(using = FileInfo.FileInfoDeserializer.class)
|
||||||
public final class FileInfo {
|
public final class FileInfo {
|
||||||
private Long id;
|
private String id;
|
||||||
private String name;
|
private String name;
|
||||||
private String filename;
|
private String filename;
|
||||||
private Long value;
|
private Long value;
|
||||||
private String state;
|
private String state;
|
||||||
|
|
||||||
public FileInfo(DataFile dataFile) {
|
public FileInfo(DataFile dataFile) {
|
||||||
this.id = dataFile.getId();
|
this.id = dataFile.getId().toString();
|
||||||
this.name = dataFile.getFilename();
|
this.name = dataFile.getFilename();
|
||||||
this.filename = dataFile.getFilename();
|
this.filename = dataFile.getFilename();
|
||||||
this.value = dataFile.getId();
|
this.value = dataFile.getId();
|
||||||
this.state = "uploaded";
|
this.state = "uploaded";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final class FileInfoDeserializer extends JsonDeserializer<FileInfo> {
|
||||||
|
@Override
|
||||||
|
public FileInfo deserialize(JsonParser parser, DeserializationContext context) throws IOException {
|
||||||
|
TreeNode root = parser.readValueAsTree();
|
||||||
|
if (root instanceof ObjectNode) {
|
||||||
|
ObjectNode node = (ObjectNode) root;
|
||||||
|
return new FileInfo(
|
||||||
|
node.get("id").asText(),
|
||||||
|
node.get("name").asText(),
|
||||||
|
node.get("filename").asText(),
|
||||||
|
node.get("value").asLong(),
|
||||||
|
node.get("state").asText()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ import org.eclipse.collections.api.set.ImmutableSet;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class SimpleService<ENTITY extends SimpleEntity> {
|
public abstract class SimpleService<ENTITY extends SimpleEntity> {
|
||||||
protected final SimpleRepository<ENTITY, Long> repository;
|
private final SimpleRepository<ENTITY, Long> repository;
|
||||||
protected final UserService userService;
|
private final UserService userService;
|
||||||
|
|
||||||
public SimpleService(SimpleRepository<ENTITY, Long> repository, UserService userService) {
|
public SimpleService(SimpleRepository<ENTITY, Long> repository, UserService userService) {
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.eshore.gringotts.web.domain.confirmation.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.SimpleController;
|
import com.eshore.gringotts.web.domain.base.controller.SimpleController;
|
||||||
import com.eshore.gringotts.web.domain.base.entity.FileInfo;
|
import com.eshore.gringotts.web.domain.base.entity.FileInfo;
|
||||||
import com.eshore.gringotts.web.domain.base.entity.SimpleDetailItem;
|
|
||||||
import com.eshore.gringotts.web.domain.base.entity.SimpleListItem;
|
import com.eshore.gringotts.web.domain.base.entity.SimpleListItem;
|
||||||
import com.eshore.gringotts.web.domain.base.entity.SimpleSaveItem;
|
import com.eshore.gringotts.web.domain.base.entity.SimpleSaveItem;
|
||||||
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
|
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
|
||||||
@@ -14,6 +14,8 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.collections.api.factory.Sets;
|
import org.eclipse.collections.api.factory.Sets;
|
||||||
import org.eclipse.collections.api.set.ImmutableSet;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@@ -25,22 +27,36 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("confirmation")
|
@RequestMapping("confirmation")
|
||||||
public class ConfirmationController extends SimpleController<Confirmation, ConfirmationController.SaveItem, ConfirmationController.ListItem, ConfirmationController.DetailItem> {
|
public class ConfirmationController extends SimpleController<Confirmation, ConfirmationController.SaveItem, ConfirmationController.ListItem, ConfirmationController.DetailItem> {
|
||||||
|
private final ConfirmationService confirmationService;
|
||||||
private final DataResourceService dataResourceService;
|
private final DataResourceService dataResourceService;
|
||||||
private final DataFileService dataFileService;
|
private final DataFileService dataFileService;
|
||||||
|
|
||||||
public ConfirmationController(ConfirmationService service, DataResourceService dataResourceService, DataFileService dataFileService) {
|
public ConfirmationController(ConfirmationService service, ConfirmationService confirmationService, DataResourceService dataResourceService, DataFileService dataFileService) {
|
||||||
super(service);
|
super(service);
|
||||||
|
this.confirmationService = confirmationService;
|
||||||
this.dataResourceService = dataResourceService;
|
this.dataResourceService = dataResourceService;
|
||||||
this.dataFileService = dataFileService;
|
this.dataFileService = dataFileService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/submit/{id}")
|
||||||
|
public AmisResponse<Object> submit(@PathVariable Long id) {
|
||||||
|
confirmationService.submit(id);
|
||||||
|
return AmisResponse.responseSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/retract/{id}")
|
||||||
|
public AmisResponse<Object> retract(@PathVariable Long id) {
|
||||||
|
confirmationService.retract(id);
|
||||||
|
return AmisResponse.responseSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Confirmation fromSaveItem(SaveItem item) {
|
protected Confirmation fromSaveItem(SaveItem item) {
|
||||||
Confirmation confirmation = new Confirmation();
|
Confirmation confirmation = new Confirmation();
|
||||||
confirmation.setId(item.getId());
|
confirmation.setId(item.getId());
|
||||||
confirmation.setDescription(item.getDescription());
|
confirmation.setDescription(item.getDescription());
|
||||||
confirmation.setTarget(dataResourceService.detailOrThrow(item.getTargetId()));
|
confirmation.setTarget(dataResourceService.detailOrThrow(item.getTargetId()));
|
||||||
confirmation.setEvidences(dataFileService.list(item.getEvidenceIds()).toSet());
|
confirmation.setEvidences(dataFileService.list(item.getEvidenceFiles().collect(FileInfo::getValue)).toSet());
|
||||||
return confirmation;
|
return confirmation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,13 +66,14 @@ public class ConfirmationController extends SimpleController<Confirmation, Confi
|
|||||||
item.setId(entity.getId());
|
item.setId(entity.getId());
|
||||||
item.setName(entity.getTarget().getName());
|
item.setName(entity.getTarget().getName());
|
||||||
item.setDescription(entity.getDescription());
|
item.setDescription(entity.getDescription());
|
||||||
|
item.setState(entity.getState().name());
|
||||||
item.setCreatedUsername(entity.getCreatedUser().getUsername());
|
item.setCreatedUsername(entity.getCreatedUser().getUsername());
|
||||||
item.setCreatedTime(entity.getCreatedTime());
|
item.setCreatedTime(entity.getCreatedTime());
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DetailItem toDetailItem(Confirmation entity) throws Exception {
|
protected DetailItem toDetailItem(Confirmation entity) {
|
||||||
return new DetailItem(entity);
|
return new DetailItem(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +82,7 @@ public class ConfirmationController extends SimpleController<Confirmation, Confi
|
|||||||
public static class SaveItem extends SimpleSaveItem<Confirmation> {
|
public static class SaveItem extends SimpleSaveItem<Confirmation> {
|
||||||
private Long targetId;
|
private Long targetId;
|
||||||
private String description;
|
private String description;
|
||||||
private ImmutableSet<Long> evidenceIds;
|
private ImmutableSet<FileInfo> evidenceFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -73,31 +90,20 @@ public class ConfirmationController extends SimpleController<Confirmation, Confi
|
|||||||
public static class ListItem extends SimpleListItem<Confirmation> {
|
public static class ListItem extends SimpleListItem<Confirmation> {
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
|
private String state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public static final class DetailItem extends SimpleDetailItem<Confirmation> {
|
public static final class DetailItem extends SaveItem {
|
||||||
private Long targetId;
|
|
||||||
private String targetName;
|
private String targetName;
|
||||||
private String description;
|
|
||||||
private ImmutableSet<FileInfo> evidenceIds;
|
|
||||||
|
|
||||||
public DetailItem(Confirmation confirmation) {
|
public DetailItem(Confirmation confirmation) {
|
||||||
this.setId(confirmation.getId());
|
this.setId(confirmation.getId());
|
||||||
this.setTargetId(confirmation.getTarget().getId());
|
this.setTargetId(confirmation.getTarget().getId());
|
||||||
this.setTargetName(confirmation.getTarget().getName());
|
this.setTargetName(confirmation.getTarget().getName());
|
||||||
this.setDescription(confirmation.getDescription());
|
this.setDescription(confirmation.getDescription());
|
||||||
this.setEvidenceIds(
|
this.setEvidenceFiles(Sets.immutable.ofAll(confirmation.getEvidences()).collect(FileInfo::new));
|
||||||
Sets.immutable.ofAll(confirmation.getEvidences())
|
|
||||||
.collect(file -> new FileInfo(
|
|
||||||
file.getId(),
|
|
||||||
file.getFilename(),
|
|
||||||
file.getFilename(),
|
|
||||||
file.getId(),
|
|
||||||
"uploaded"
|
|
||||||
))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,9 +57,13 @@ public class Confirmation extends SimpleEntity {
|
|||||||
private Set<DataFile> evidences;
|
private Set<DataFile> evidences;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private State state = State.CHECKING;
|
private State state = State.DRAFT;
|
||||||
|
|
||||||
public enum State {
|
public enum State {
|
||||||
|
/**
|
||||||
|
* 草稿
|
||||||
|
*/
|
||||||
|
DRAFT,
|
||||||
/**
|
/**
|
||||||
* 审查中
|
* 审查中
|
||||||
*/
|
*/
|
||||||
@@ -69,8 +73,8 @@ public class Confirmation extends SimpleEntity {
|
|||||||
*/
|
*/
|
||||||
NORMAL,
|
NORMAL,
|
||||||
/**
|
/**
|
||||||
* 禁用
|
* 驳回
|
||||||
*/
|
*/
|
||||||
DISABLED,
|
REJECT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
|||||||
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
|
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
import org.springframework.data.jpa.repository.EntityGraph;
|
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;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,4 +24,11 @@ public interface ConfirmationRepository extends SimpleRepository<Confirmation, L
|
|||||||
@Override
|
@Override
|
||||||
@EntityGraph(value = "confirmation.detail", type = EntityGraph.EntityGraphType.FETCH)
|
@EntityGraph(value = "confirmation.detail", type = EntityGraph.EntityGraphType.FETCH)
|
||||||
Optional<Confirmation> findById(Long id);
|
Optional<Confirmation> findById(Long id);
|
||||||
|
|
||||||
|
Boolean existsByTarget_Id(Long id);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Modifying
|
||||||
|
@Query("update Confirmation confirmation set confirmation.state = ?2 where confirmation.id = ?1")
|
||||||
|
void updateStateById(Long id, Confirmation.State state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,32 @@ import org.springframework.stereotype.Service;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class ConfirmationService extends SimpleService<Confirmation> {
|
public class ConfirmationService extends SimpleService<Confirmation> {
|
||||||
public ConfirmationService(ConfirmationRepository repository, UserService userService) {
|
private final ConfirmationRepository confirmationRepository;
|
||||||
super(repository, userService);
|
|
||||||
|
public ConfirmationService(ConfirmationRepository confirmationRepository, UserService userService) {
|
||||||
|
super(confirmationRepository, userService);
|
||||||
|
this.confirmationRepository = confirmationRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long save(Confirmation entity) {
|
||||||
|
if (confirmationRepository.existsByTarget_Id(entity.getTarget().getId())) {
|
||||||
|
throw new ConfirmationDuplicatedException();
|
||||||
|
}
|
||||||
|
return super.save(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submit(Long id) {
|
||||||
|
confirmationRepository.updateStateById(id, Confirmation.State.CHECKING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void retract(Long id) {
|
||||||
|
confirmationRepository.updateStateById(id, Confirmation.State.DRAFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class ConfirmationDuplicatedException extends RuntimeException {
|
||||||
|
public ConfirmationDuplicatedException() {
|
||||||
|
super("数据资源已绑定确权申请,无法再次申请");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.eshore.gringotts.web.domain.order.entity;
|
||||||
|
|
||||||
|
import com.eshore.gringotts.core.Constants;
|
||||||
|
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EntityListeners;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.hibernate.annotations.DynamicUpdate;
|
||||||
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工单
|
||||||
|
*
|
||||||
|
* @author lanyuanxiaoyao
|
||||||
|
* @date 2024-11-27
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
@Entity
|
||||||
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
|
@DynamicUpdate
|
||||||
|
@Table(name = Constants.TABLE_PREFIX + "work_order")
|
||||||
|
public class WorkOrder extends SimpleEntity {
|
||||||
|
@Column(nullable = false)
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
}
|
||||||
@@ -29,8 +29,6 @@ import java.util.Map;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.collections.api.factory.Lists;
|
|
||||||
import org.eclipse.collections.api.list.ImmutableList;
|
|
||||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -64,7 +62,9 @@ public class DataResourceController extends SimpleController<DataResource, DataR
|
|||||||
dataResource.setDescription(item.getDescription());
|
dataResource.setDescription(item.getDescription());
|
||||||
dataResource.setType(type);
|
dataResource.setType(type);
|
||||||
dataResource.setFormat(format);
|
dataResource.setFormat(format);
|
||||||
dataResource.setExample(dataFileService.detail(item.getExampleFileId()));
|
if (ObjectUtil.isNotNull(item.getExampleFile())) {
|
||||||
|
dataResource.setExample(dataFileService.detail(item.getExampleFile().getValue()));
|
||||||
|
}
|
||||||
return dataResource;
|
return dataResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,8 +102,7 @@ public class DataResourceController extends SimpleController<DataResource, DataR
|
|||||||
break;
|
break;
|
||||||
case FILE:
|
case FILE:
|
||||||
FileResourceType fileType = (FileResourceType) dataResource.getType();
|
FileResourceType fileType = (FileResourceType) dataResource.getType();
|
||||||
item.setFileId(fileType.getFile().getId());
|
item.setFile(new FileInfo(fileType.getFile()));
|
||||||
item.setFile(Lists.immutable.of(new FileInfo(fileType.getFile())));
|
|
||||||
break;
|
break;
|
||||||
case DATABASE:
|
case DATABASE:
|
||||||
DatabaseResourceType databaseType = (DatabaseResourceType) dataResource.getType();
|
DatabaseResourceType databaseType = (DatabaseResourceType) dataResource.getType();
|
||||||
@@ -114,10 +113,8 @@ public class DataResourceController extends SimpleController<DataResource, DataR
|
|||||||
break;
|
break;
|
||||||
case HDFS:
|
case HDFS:
|
||||||
HDFSResourceType hdfsType = (HDFSResourceType) dataResource.getType();
|
HDFSResourceType hdfsType = (HDFSResourceType) dataResource.getType();
|
||||||
item.setCoreSiteFileId(hdfsType.getCoreSite().getId());
|
item.setCoreSiteFile(new FileInfo(hdfsType.getCoreSite()));
|
||||||
item.setCoreSiteFile(Lists.immutable.of(new FileInfo(hdfsType.getCoreSite())));
|
item.setHdfsSiteFile(new FileInfo(hdfsType.getHdfsSite()));
|
||||||
item.setHdfsSiteFileId(hdfsType.getHdfsSite().getId());
|
|
||||||
item.setHdfsSiteFile(Lists.immutable.of(new FileInfo(hdfsType.getHdfsSite())));
|
|
||||||
break;
|
break;
|
||||||
case FTP:
|
case FTP:
|
||||||
FtpResourceType ftpType = (FtpResourceType) dataResource.getType();
|
FtpResourceType ftpType = (FtpResourceType) dataResource.getType();
|
||||||
@@ -150,8 +147,7 @@ public class DataResourceController extends SimpleController<DataResource, DataR
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNotNull(dataResource.getExample())) {
|
if (ObjectUtil.isNotNull(dataResource.getExample())) {
|
||||||
item.setExampleFileId(dataResource.getExample().getId());
|
item.setExampleFile(new FileInfo(dataResource.getExample()));
|
||||||
item.setExampleFile(Lists.immutable.of(new FileInfo(dataResource.getExample())));
|
|
||||||
}
|
}
|
||||||
item.setCreatedUsername(dataResource.getCreatedUser().getUsername());
|
item.setCreatedUsername(dataResource.getCreatedUser().getUsername());
|
||||||
item.setCreatedTime(dataResource.getCreatedTime());
|
item.setCreatedTime(dataResource.getCreatedTime());
|
||||||
@@ -167,7 +163,7 @@ public class DataResourceController extends SimpleController<DataResource, DataR
|
|||||||
type = new ApiResourceType(item.getApiUrl(), item.getApiUsername(), item.getApiPassword());
|
type = new ApiResourceType(item.getApiUrl(), item.getApiUsername(), item.getApiPassword());
|
||||||
break;
|
break;
|
||||||
case FILE:
|
case FILE:
|
||||||
DataFile dataFile = dataFileService.detail(item.getFileId());
|
DataFile dataFile = dataFileService.detail(item.getFile().getValue());
|
||||||
type = new FileResourceType(dataFile);
|
type = new FileResourceType(dataFile);
|
||||||
break;
|
break;
|
||||||
case DATABASE:
|
case DATABASE:
|
||||||
@@ -179,7 +175,7 @@ public class DataResourceController extends SimpleController<DataResource, DataR
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case HDFS:
|
case HDFS:
|
||||||
type = new HDFSResourceType(dataFileService.detail(item.getCoreSiteFileId()), dataFileService.detail(item.getHdfsSiteFileId()));
|
type = new HDFSResourceType(dataFileService.detail(item.getCoreSiteFile().getValue()), dataFileService.detail(item.getHdfsSiteFile().getValue()));
|
||||||
break;
|
break;
|
||||||
case FTP:
|
case FTP:
|
||||||
type = new FtpResourceType(item.getFtpUrl(), item.getFtpUsername(), item.getFtpPassword(), item.getFtpPath(), item.getFtpRegexFilter());
|
type = new FtpResourceType(item.getFtpUrl(), item.getFtpUsername(), item.getFtpPassword(), item.getFtpPath(), item.getFtpRegexFilter());
|
||||||
@@ -222,13 +218,13 @@ public class DataResourceController extends SimpleController<DataResource, DataR
|
|||||||
private String apiUrl;
|
private String apiUrl;
|
||||||
private String apiUsername;
|
private String apiUsername;
|
||||||
private String apiPassword;
|
private String apiPassword;
|
||||||
private Long fileId;
|
private FileInfo file;
|
||||||
private String databaseType;
|
private String databaseType;
|
||||||
private String databaseJdbc;
|
private String databaseJdbc;
|
||||||
private String databaseUsername;
|
private String databaseUsername;
|
||||||
private String databasePassword;
|
private String databasePassword;
|
||||||
private Long coreSiteFileId;
|
private FileInfo coreSiteFile;
|
||||||
private Long hdfsSiteFileId;
|
private FileInfo hdfsSiteFile;
|
||||||
private String ftpUrl;
|
private String ftpUrl;
|
||||||
private String ftpUsername;
|
private String ftpUsername;
|
||||||
private String ftpPassword;
|
private String ftpPassword;
|
||||||
@@ -242,7 +238,7 @@ public class DataResourceController extends SimpleController<DataResource, DataR
|
|||||||
private String jsonLineSchemaText;
|
private String jsonLineSchemaText;
|
||||||
private Map<?, ?> csvSchema;
|
private Map<?, ?> csvSchema;
|
||||||
private String csvSchemaText;
|
private String csvSchemaText;
|
||||||
private Long exampleFileId;
|
private FileInfo exampleFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -261,11 +257,6 @@ public class DataResourceController extends SimpleController<DataResource, DataR
|
|||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public static final class DetailItem extends SaveItem {
|
public static final class DetailItem extends SaveItem {
|
||||||
private Long id;
|
|
||||||
private ImmutableList<FileInfo> file;
|
|
||||||
private ImmutableList<FileInfo> coreSiteFile;
|
|
||||||
private ImmutableList<FileInfo> hdfsSiteFile;
|
|
||||||
private ImmutableList<FileInfo> exampleFile;
|
|
||||||
private LocalDateTime createdTime;
|
private LocalDateTime createdTime;
|
||||||
private String createdUsername;
|
private String createdUsername;
|
||||||
private LocalDateTime modifiedTime;
|
private LocalDateTime modifiedTime;
|
||||||
|
|||||||
@@ -34,15 +34,15 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/upload")
|
@RequestMapping("/upload")
|
||||||
public class UploadController {
|
public class DataFileController {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(UploadController.class);
|
private static final Logger logger = LoggerFactory.getLogger(DataFileController.class);
|
||||||
|
|
||||||
private final DataFileService dataFileService;
|
private final DataFileService dataFileService;
|
||||||
private final String uploadFolderPath;
|
private final String uploadFolderPath;
|
||||||
private final String cacheFolderPath;
|
private final String cacheFolderPath;
|
||||||
private final String sliceFolderPath;
|
private final String sliceFolderPath;
|
||||||
|
|
||||||
public UploadController(UploadConfiguration uploadConfiguration, DataFileService dataFileService) {
|
public DataFileController(UploadConfiguration uploadConfiguration, DataFileService dataFileService) {
|
||||||
this.dataFileService = dataFileService;
|
this.dataFileService = dataFileService;
|
||||||
|
|
||||||
this.uploadFolderPath = uploadConfiguration.getUploadPath();
|
this.uploadFolderPath = uploadConfiguration.getUploadPath();
|
||||||
@@ -17,8 +17,13 @@ import org.springframework.stereotype.Service;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class DataFileService extends SimpleService<DataFile> {
|
public class DataFileService extends SimpleService<DataFile> {
|
||||||
public DataFileService(DataFileRepository repository, UserService userService) {
|
private final DataFileRepository dataFileRepository;
|
||||||
super(repository, userService);
|
private final UserService userService;
|
||||||
|
|
||||||
|
public DataFileService(DataFileRepository dataFileRepository, UserService userService) {
|
||||||
|
super(dataFileRepository, userService);
|
||||||
|
this.dataFileRepository = dataFileRepository;
|
||||||
|
this.userService = userService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataFile detail(String id) {
|
public DataFile detail(String id) {
|
||||||
@@ -34,17 +39,17 @@ public class DataFileService extends SimpleService<DataFile> {
|
|||||||
User loginUser = userService.currentLoginUser();
|
User loginUser = userService.currentLoginUser();
|
||||||
dataFile.setCreatedUser(loginUser);
|
dataFile.setCreatedUser(loginUser);
|
||||||
dataFile.setModifiedUser(loginUser);
|
dataFile.setModifiedUser(loginUser);
|
||||||
return repository.save(dataFile).getId();
|
return dataFileRepository.save(dataFile).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateDataFile(Long id, String path, Long size, String md5) {
|
public void updateDataFile(Long id, String path, Long size, String md5) {
|
||||||
DataFile dataFile = repository.findById(id).orElseThrow(UpdateDataFileFailedException::new);
|
DataFile dataFile = dataFileRepository.findById(id).orElseThrow(UpdateDataFileFailedException::new);
|
||||||
dataFile.setSize(size);
|
dataFile.setSize(size);
|
||||||
dataFile.setMd5(md5);
|
dataFile.setMd5(md5);
|
||||||
dataFile.setPath(path);
|
dataFile.setPath(path);
|
||||||
User loginUser = userService.currentLoginUser();
|
User loginUser = userService.currentLoginUser();
|
||||||
dataFile.setModifiedUser(loginUser);
|
dataFile.setModifiedUser(loginUser);
|
||||||
repository.save(dataFile);
|
dataFileRepository.save(dataFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class DataFileNotFoundException extends RuntimeException {
|
public static final class DataFileNotFoundException extends RuntimeException {
|
||||||
|
|||||||
Reference in New Issue
Block a user