feat(web): 实现数据产品上架审核功能
- 新增数据产品列表、详情、编辑等功能页面 - 实现数据产品提交审核、撤销审核、同意审核等操作 - 优化数据产品相关API接口,支持审核功能 - 重构部分代码以支持新功能
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
export const information = {
|
export const information = {
|
||||||
debug: true,
|
debug: false,
|
||||||
// baseUrl: '',
|
// baseUrl: '',
|
||||||
baseUrl: 'http://127.0.0.1:20080',
|
baseUrl: 'http://127.0.0.1:20080',
|
||||||
title: '可信供给中心',
|
title: '可信供给中心',
|
||||||
@@ -262,6 +262,7 @@ export const permissionStateMapping = [
|
|||||||
export const checkTypeMapping = [
|
export const checkTypeMapping = [
|
||||||
mappingItem('确权审查', 'CONFIRMATION', 'bg-blue-500'),
|
mappingItem('确权审查', 'CONFIRMATION', 'bg-blue-500'),
|
||||||
mappingItem('授权审查', 'AUTHENTICATION', 'bg-purple-500'),
|
mappingItem('授权审查', 'AUTHENTICATION', 'bg-purple-500'),
|
||||||
|
mappingItem('上架审查', 'MARKET', 'bg-green-500'),
|
||||||
]
|
]
|
||||||
|
|
||||||
export const checkOverMapping = [
|
export const checkOverMapping = [
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {resourceDetailDialog} from '../resource/dialog-resource.js'
|
|||||||
|
|
||||||
function detailForm() {
|
function detailForm() {
|
||||||
return {
|
return {
|
||||||
|
id: 'ware-form',
|
||||||
debug: information.debug,
|
debug: information.debug,
|
||||||
type: 'form',
|
type: 'form',
|
||||||
...horizontalFormOptions(),
|
...horizontalFormOptions(),
|
||||||
@@ -17,13 +18,38 @@ function detailForm() {
|
|||||||
name: 'id',
|
name: 'id',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
visibleOn: '${!detail}',
|
||||||
type: 'input-image',
|
type: 'input-image',
|
||||||
name: 'icon',
|
name: 'icon',
|
||||||
label: '图标',
|
label: '图标',
|
||||||
required: true,
|
required: true,
|
||||||
receiver: apiPost("${base}/upload"),
|
receiver: apiPost("${base}/upload"),
|
||||||
autoFill: {
|
onEvent: {
|
||||||
iconId: '${id}',
|
success: {
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
actionType: 'setValue',
|
||||||
|
componentId: 'ware-form',
|
||||||
|
args: {
|
||||||
|
value: {
|
||||||
|
iconId: '${event.data.result.id}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visibleOn: '${detail}',
|
||||||
|
type: 'control',
|
||||||
|
name: 'icon',
|
||||||
|
label: '图标',
|
||||||
|
required: true,
|
||||||
|
body: {
|
||||||
|
type: 'image',
|
||||||
|
src: '${icon}',
|
||||||
|
innerClassName: 'no-border',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -79,7 +105,7 @@ function detailForm() {
|
|||||||
name: 'content',
|
name: 'content',
|
||||||
label: '商品详情',
|
label: '商品详情',
|
||||||
required: true,
|
required: true,
|
||||||
receiver: '',
|
receiver: apiPost("${base}/upload"),
|
||||||
options: {
|
options: {
|
||||||
min_height: 300,
|
min_height: 300,
|
||||||
}
|
}
|
||||||
@@ -108,21 +134,28 @@ export function wareAddDialog() {
|
|||||||
body: {
|
body: {
|
||||||
...detailForm(),
|
...detailForm(),
|
||||||
api: apiPost(`\${base}/ware/save`),
|
api: apiPost(`\${base}/ware/save`),
|
||||||
|
data: {
|
||||||
|
add: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function wareDetailDialog() {
|
export function wareDetailDialog(field = 'id', actions = []) {
|
||||||
return {
|
return {
|
||||||
actionType: 'dialog',
|
actionType: 'dialog',
|
||||||
dialog: {
|
dialog: {
|
||||||
title: '确权申请详情',
|
title: '数据产品详情',
|
||||||
size: 'md',
|
size: 'md',
|
||||||
|
actions: actions,
|
||||||
body: {
|
body: {
|
||||||
...detailForm(),
|
...detailForm(),
|
||||||
initApi: apiGet(`\${base}/ware/detail/\${id}`),
|
initApi: apiGet(`\${base}/ware/detail/\${${field}}`),
|
||||||
static: true,
|
static: true,
|
||||||
|
data: {
|
||||||
|
detail: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,7 +165,7 @@ export function wareEditeDialog() {
|
|||||||
return {
|
return {
|
||||||
actionType: 'dialog',
|
actionType: 'dialog',
|
||||||
dialog: {
|
dialog: {
|
||||||
title: '确权申请详情',
|
title: '数据产品详情',
|
||||||
size: 'md',
|
size: 'md',
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
@@ -148,7 +181,10 @@ export function wareEditeDialog() {
|
|||||||
body: {
|
body: {
|
||||||
...detailForm(),
|
...detailForm(),
|
||||||
api: apiPost(`\${base}/ware/save`),
|
api: apiPost(`\${base}/ware/save`),
|
||||||
initApi: apiGet(`\${base}/ware/detail/\${${field}}`),
|
initApi: apiGet(`\${base}/ware/detail/\${id}`),
|
||||||
|
data: {
|
||||||
|
edit: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
timeField,
|
timeField,
|
||||||
} from "../../components/constants.js";
|
} from "../../components/constants.js";
|
||||||
import {authenticationDetailDialog, confirmationDetailDialog} from "../../components/permission/dialog-permission.js";
|
import {authenticationDetailDialog, confirmationDetailDialog} from "../../components/permission/dialog-permission.js";
|
||||||
|
import {wareDetailDialog} from "../../components/ware/dialog-ware.js";
|
||||||
|
|
||||||
export function tabCheck() {
|
export function tabCheck() {
|
||||||
return {
|
return {
|
||||||
@@ -103,6 +104,40 @@ export function tabCheck() {
|
|||||||
level: 'link',
|
level: 'link',
|
||||||
...authenticationDetailDialog('parameters.authenticationId'),
|
...authenticationDetailDialog('parameters.authenticationId'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
visibleOn: `\${type === 'MARKET' && state === 'CHECKING'}`,
|
||||||
|
type: 'action',
|
||||||
|
label: '处理',
|
||||||
|
level: 'link',
|
||||||
|
...wareDetailDialog(
|
||||||
|
'parameters.wareId',
|
||||||
|
[
|
||||||
|
{
|
||||||
|
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 === 'MARKET' && state !== NORMAL}`,
|
||||||
|
type: 'action',
|
||||||
|
label: '查看',
|
||||||
|
level: 'link',
|
||||||
|
...wareDetailDialog('parameters.wareId'),
|
||||||
|
},
|
||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,16 +1,132 @@
|
|||||||
import {wareAddDialog} from "../../components/ware/dialog-ware.js";
|
import {wareAddDialog, wareDetailDialog, wareEditeDialog} from "../../components/ware/dialog-ware.js";
|
||||||
|
import {
|
||||||
|
apiGet,
|
||||||
|
crudCommonOptions,
|
||||||
|
mappingField,
|
||||||
|
operationField,
|
||||||
|
permissionStateMapping,
|
||||||
|
timeField
|
||||||
|
} from "../../components/constants.js";
|
||||||
|
|
||||||
|
function listColumns() {
|
||||||
|
return {
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
name: 'name',
|
||||||
|
label: '名称',
|
||||||
|
width: 200,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'description',
|
||||||
|
label: '描述',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visibleOn: '${!public}',
|
||||||
|
...mappingField('state', '状态', permissionStateMapping)
|
||||||
|
},
|
||||||
|
timeField('createdTime', '创建时间'),
|
||||||
|
operationField('操作', undefined, [
|
||||||
|
{
|
||||||
|
type: 'action',
|
||||||
|
label: '查看',
|
||||||
|
level: 'link',
|
||||||
|
...wareDetailDialog(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visibleOn: "${state === 'CHECKING'}",
|
||||||
|
type: 'action',
|
||||||
|
label: '撤销',
|
||||||
|
level: 'link',
|
||||||
|
confirmTitle: '确认撤销',
|
||||||
|
confirmText: '确认撤销名称为「${name}」的确权申请吗?',
|
||||||
|
actionType: 'ajax',
|
||||||
|
api: apiGet('${base}/ware/retract/${id}'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visibleOn: "${state === 'DRAFT' || state === 'REJECT'}",
|
||||||
|
type: 'action',
|
||||||
|
label: '提交',
|
||||||
|
level: 'link',
|
||||||
|
confirmTitle: '确认提交',
|
||||||
|
confirmText: '确认提交名称为「${name}」的确权申请吗?',
|
||||||
|
actionType: 'ajax',
|
||||||
|
api: apiGet('${base}/ware/submit/${id}'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visibleOn: "${!public}",
|
||||||
|
type: 'dropdown-button',
|
||||||
|
level: 'link',
|
||||||
|
icon: 'fa fa-ellipsis-h',
|
||||||
|
hideCaret: true,
|
||||||
|
trigger: 'hover',
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
disabledOn: "${state !== 'DRAFT'}",
|
||||||
|
type: 'action',
|
||||||
|
label: '编辑',
|
||||||
|
level: 'link',
|
||||||
|
...wareEditeDialog(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
disabledOn: "${state === 'CHECKING'}",
|
||||||
|
type: 'action',
|
||||||
|
label: "删除",
|
||||||
|
confirmTitle: '确认删除',
|
||||||
|
confirmText: '确认删除名称为「${name}」的确权申请吗?删除后对应的数据资源处于未确权状态。',
|
||||||
|
actionType: 'ajax',
|
||||||
|
api: apiGet('${base}/ware/remove/${id}'),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function tabMarket() {
|
export function tabMarket() {
|
||||||
return {
|
return {
|
||||||
title: '数据市场',
|
title: '数据市场',
|
||||||
icon: 'fa fa-store',
|
icon: 'fa fa-store',
|
||||||
|
reload: true,
|
||||||
body: [
|
body: [
|
||||||
|
{
|
||||||
|
type: 'tabs',
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
title: '公开数据',
|
||||||
|
body: {
|
||||||
|
type: 'crud',
|
||||||
|
api: apiGet('${base}/ware/list_public'),
|
||||||
|
...crudCommonOptions(),
|
||||||
|
headerToolbar: [
|
||||||
|
'reload',
|
||||||
|
],
|
||||||
|
data: {
|
||||||
|
public: true
|
||||||
|
},
|
||||||
|
...listColumns(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '我的数据',
|
||||||
|
body: {
|
||||||
|
type: 'crud',
|
||||||
|
api: apiGet('${base}/ware/list'),
|
||||||
|
...crudCommonOptions(),
|
||||||
|
headerToolbar: [
|
||||||
|
'reload',
|
||||||
{
|
{
|
||||||
type: 'action',
|
type: 'action',
|
||||||
label: '',
|
label: '',
|
||||||
icon: 'fa fa-plus',
|
icon: 'fa fa-plus',
|
||||||
...wareAddDialog()
|
...wareAddDialog()
|
||||||
},
|
},
|
||||||
|
],
|
||||||
|
...listColumns(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.eshore.gringotts.web.configuration;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lanyuanxiaoyao
|
||||||
|
* @date 2024-12-17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ConfigurationProperties(prefix = "gringotts.host")
|
||||||
|
@Configuration
|
||||||
|
public class HostConfiguration {
|
||||||
|
private String prefix = "http://127.0.0.1:20080";
|
||||||
|
}
|
||||||
@@ -3,8 +3,7 @@ package com.eshore.gringotts.web.configuration;
|
|||||||
import cn.dev33.satoken.interceptor.SaInterceptor;
|
import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||||
import cn.dev33.satoken.router.SaRouter;
|
import cn.dev33.satoken.router.SaRouter;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import org.slf4j.Logger;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
@@ -12,13 +11,12 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||||||
/**
|
/**
|
||||||
* web配置
|
* web配置
|
||||||
*
|
*
|
||||||
* @author lanyuanxiaoyao
|
* @author wn
|
||||||
* @date 2024-11-14
|
* @since 2024-11-14
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SaTokenConfiguration implements WebMvcConfigurer {
|
public class SaTokenConfiguration implements WebMvcConfigurer {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SaTokenConfiguration.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
registry
|
registry
|
||||||
@@ -31,6 +29,7 @@ public class SaTokenConfiguration implements WebMvcConfigurer {
|
|||||||
.notMatch("/assets/**")
|
.notMatch("/assets/**")
|
||||||
.notMatch("/pages/**")
|
.notMatch("/pages/**")
|
||||||
.notMatch("/user/**")
|
.notMatch("/user/**")
|
||||||
|
.notMatch("/upload/download/**")
|
||||||
.check(r -> {
|
.check(r -> {
|
||||||
try {
|
try {
|
||||||
StpUtil.checkLogin();
|
StpUtil.checkLogin();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import cn.hutool.core.io.FileUtil;
|
|||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
|
import com.eshore.gringotts.web.configuration.HostConfiguration;
|
||||||
import com.eshore.gringotts.web.configuration.UploadConfiguration;
|
import com.eshore.gringotts.web.configuration.UploadConfiguration;
|
||||||
import com.eshore.gringotts.web.configuration.amis.AmisResponse;
|
import com.eshore.gringotts.web.configuration.amis.AmisResponse;
|
||||||
import com.eshore.gringotts.web.domain.entity.DataFile;
|
import com.eshore.gringotts.web.domain.entity.DataFile;
|
||||||
@@ -19,9 +20,8 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.collections.api.list.ImmutableList;
|
import org.eclipse.collections.api.list.ImmutableList;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@@ -37,17 +37,18 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
* @author lanyuanxiaoyao
|
* @author lanyuanxiaoyao
|
||||||
* @date 2024-11-21
|
* @date 2024-11-21
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/upload")
|
@RequestMapping("/upload")
|
||||||
public class DataFileController {
|
public class DataFileController {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DataFileController.class);
|
private final HostConfiguration hostConfiguration;
|
||||||
|
|
||||||
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 DataFileController(UploadConfiguration uploadConfiguration, DataFileService dataFileService) {
|
public DataFileController(HostConfiguration hostConfiguration, UploadConfiguration uploadConfiguration, DataFileService dataFileService) {
|
||||||
|
this.hostConfiguration = hostConfiguration;
|
||||||
this.dataFileService = dataFileService;
|
this.dataFileService = dataFileService;
|
||||||
|
|
||||||
this.uploadFolderPath = uploadConfiguration.getUploadPath();
|
this.uploadFolderPath = uploadConfiguration.getUploadPath();
|
||||||
@@ -59,7 +60,7 @@ public class DataFileController {
|
|||||||
public AmisResponse<FinishResponse> upload(@RequestParam("file") MultipartFile file) throws IOException {
|
public AmisResponse<FinishResponse> upload(@RequestParam("file") MultipartFile file) throws IOException {
|
||||||
String filename = file.getOriginalFilename();
|
String filename = file.getOriginalFilename();
|
||||||
Long id = dataFileService.initialDataFile(filename);
|
Long id = dataFileService.initialDataFile(filename);
|
||||||
String url = StrUtil.format("/upload/download/{}", id);
|
String url = StrUtil.format("{}/upload/download/{}", hostConfiguration.getPrefix(), id);
|
||||||
byte[] bytes = file.getBytes();
|
byte[] bytes = file.getBytes();
|
||||||
String originMd5 = SecureUtil.md5(new ByteArrayInputStream(bytes));
|
String originMd5 = SecureUtil.md5(new ByteArrayInputStream(bytes));
|
||||||
File targetFile = new File(StrUtil.format("{}/{}", uploadFolderPath, originMd5));
|
File targetFile = new File(StrUtil.format("{}/{}", uploadFolderPath, originMd5));
|
||||||
@@ -80,7 +81,7 @@ public class DataFileController {
|
|||||||
|
|
||||||
@GetMapping("/download/{id}")
|
@GetMapping("/download/{id}")
|
||||||
public void download(@PathVariable Long id, HttpServletResponse response) throws IOException {
|
public void download(@PathVariable Long id, HttpServletResponse response) throws IOException {
|
||||||
DataFile dataFile = dataFileService.detailOrThrow(id);
|
DataFile dataFile = dataFileService.downloadFile(id);
|
||||||
File targetFile = new File(dataFile.getPath());
|
File targetFile = new File(dataFile.getPath());
|
||||||
response.setHeader("Access-Control-Expose-Headers", "Content-Type");
|
response.setHeader("Access-Control-Expose-Headers", "Content-Type");
|
||||||
response.setHeader("Content-Type", dataFile.getType());
|
response.setHeader("Content-Type", dataFile.getType());
|
||||||
@@ -91,7 +92,7 @@ public class DataFileController {
|
|||||||
|
|
||||||
@PostMapping("/start")
|
@PostMapping("/start")
|
||||||
public AmisResponse<StartResponse> start(@RequestBody StartRequest request) {
|
public AmisResponse<StartResponse> start(@RequestBody StartRequest request) {
|
||||||
logger.info("Request: {}", request);
|
log.info("Request: {}", request);
|
||||||
Long id = dataFileService.initialDataFile(request.filename);
|
Long id = dataFileService.initialDataFile(request.filename);
|
||||||
return AmisResponse.responseSuccess(new StartResponse(id.toString()));
|
return AmisResponse.responseSuccess(new StartResponse(id.toString()));
|
||||||
}
|
}
|
||||||
@@ -158,7 +159,7 @@ public class DataFileController {
|
|||||||
request.uploadId,
|
request.uploadId,
|
||||||
request.filename,
|
request.filename,
|
||||||
request.uploadId.toString(),
|
request.uploadId.toString(),
|
||||||
StrUtil.format("/upload/download/{}", request.uploadId)
|
StrUtil.format("{}/upload/download/{}", hostConfiguration.getPrefix(), request.uploadId)
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("合并文件失败");
|
throw new RuntimeException("合并文件失败");
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.eshore.gringotts.web.domain.controller;
|
package com.eshore.gringotts.web.domain.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.eshore.gringotts.web.configuration.HostConfiguration;
|
||||||
|
import com.eshore.gringotts.web.configuration.amis.AmisResponse;
|
||||||
import com.eshore.gringotts.web.domain.base.controller.SimpleControllerSupport;
|
import com.eshore.gringotts.web.domain.base.controller.SimpleControllerSupport;
|
||||||
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;
|
||||||
@@ -7,33 +10,59 @@ import com.eshore.gringotts.web.domain.entity.Ware;
|
|||||||
import com.eshore.gringotts.web.domain.service.DataFileService;
|
import com.eshore.gringotts.web.domain.service.DataFileService;
|
||||||
import com.eshore.gringotts.web.domain.service.DataResourceService;
|
import com.eshore.gringotts.web.domain.service.DataResourceService;
|
||||||
import com.eshore.gringotts.web.domain.service.WareService;
|
import com.eshore.gringotts.web.domain.service.WareService;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
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.list.ImmutableList;
|
||||||
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author lanyuanxiaoyao
|
* @author lanyuanxiaoyao
|
||||||
* @date 2024-12-13
|
* @version 2024-12-13
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("ware")
|
@RequestMapping("ware")
|
||||||
public class WareController extends SimpleControllerSupport<Ware, WareController.SaveItem, WareController.ListItem, WareController.DetailItem> {
|
public class WareController extends SimpleControllerSupport<Ware, WareController.SaveItem, WareController.ListItem, WareController.DetailItem> {
|
||||||
|
private final HostConfiguration hostConfiguration;
|
||||||
|
private final WareService wareService;
|
||||||
private final DataResourceService dataResourceService;
|
private final DataResourceService dataResourceService;
|
||||||
private final DataFileService dataFileService;
|
private final DataFileService dataFileService;
|
||||||
|
|
||||||
public WareController(WareService service, DataResourceService dataResourceService, DataFileService dataFileService) {
|
public WareController(HostConfiguration hostConfiguration, WareService service, DataResourceService dataResourceService, DataFileService dataFileService) {
|
||||||
super(service);
|
super(service);
|
||||||
|
this.hostConfiguration = hostConfiguration;
|
||||||
|
this.wareService = service;
|
||||||
this.dataResourceService = dataResourceService;
|
this.dataResourceService = dataResourceService;
|
||||||
this.dataFileService = dataFileService;
|
this.dataFileService = dataFileService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping(LIST + "_public")
|
||||||
|
public AmisResponse<ImmutableList<ListItem>> listPublic() throws Exception {
|
||||||
|
return AmisResponse.responseSuccess(wareService.listPublic().collect(this::toListItem));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/submit/{id}")
|
||||||
|
public AmisResponse<Object> submit(@PathVariable Long id) throws JsonProcessingException {
|
||||||
|
wareService.submit(id);
|
||||||
|
return AmisResponse.responseSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/retract/{id}")
|
||||||
|
public AmisResponse<Object> retract(@PathVariable Long id) {
|
||||||
|
wareService.retract(id);
|
||||||
|
return AmisResponse.responseSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Ware fromSaveItem(SaveItem saveItem) throws Exception {
|
protected Ware fromSaveItem(SaveItem saveItem) {
|
||||||
Ware ware = new Ware();
|
Ware ware = new Ware();
|
||||||
|
ware.setId(saveItem.getId());
|
||||||
ware.setResource(dataResourceService.detailOrThrow(saveItem.getResourceId()));
|
ware.setResource(dataResourceService.detailOrThrow(saveItem.getResourceId()));
|
||||||
ware.setName(saveItem.getName());
|
ware.setName(saveItem.getName());
|
||||||
ware.setDescription(saveItem.getDescription());
|
ware.setDescription(saveItem.getDescription());
|
||||||
@@ -43,13 +72,33 @@ public class WareController extends SimpleControllerSupport<Ware, WareController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ListItem toListItem(Ware entity) throws Exception {
|
protected ListItem toListItem(Ware entity) {
|
||||||
return new ListItem(entity);
|
ListItem item = new ListItem();
|
||||||
|
item.setId(entity.getId());
|
||||||
|
item.setName(entity.getName());
|
||||||
|
item.setDescription(entity.getDescription());
|
||||||
|
item.setState(entity.getState().name());
|
||||||
|
item.setCreatedTime(entity.getCreatedTime());
|
||||||
|
item.setCreatedUsername(entity.getCreatedUser().getUsername());
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DetailItem toDetailItem(Ware entity) throws Exception {
|
protected DetailItem toDetailItem(Ware entity) {
|
||||||
return new DetailItem(entity);
|
DetailItem item = new DetailItem();
|
||||||
|
item.setId(entity.getId());
|
||||||
|
item.setResourceId(entity.getResource().getId());
|
||||||
|
item.setResourceName(entity.getResource().getName());
|
||||||
|
item.setName(entity.getName());
|
||||||
|
item.setDescription(entity.getDescription());
|
||||||
|
item.setIconId(entity.getIcon().getId());
|
||||||
|
item.setContent(entity.getContent());
|
||||||
|
item.setIcon(StrUtil.format("{}/upload/download/{}", hostConfiguration.getPrefix(), entity.getIcon().getId()));
|
||||||
|
item.setCreatedTime(entity.getCreatedTime());
|
||||||
|
item.setCreatedUsername(entity.getCreatedUser().getUsername());
|
||||||
|
item.setModifiedTime(entity.getModifiedTime());
|
||||||
|
item.setModifiedUsername(entity.getModifiedUser().getUsername());
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -67,33 +116,17 @@ public class WareController extends SimpleControllerSupport<Ware, WareController
|
|||||||
public static class ListItem extends SimpleListItem<Ware> {
|
public static class ListItem extends SimpleListItem<Ware> {
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
|
private String state;
|
||||||
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
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public static class DetailItem extends SaveItem {
|
public static class DetailItem extends SaveItem {
|
||||||
|
private String icon;
|
||||||
private String resourceName;
|
private String resourceName;
|
||||||
private LocalDateTime createdTime;
|
private LocalDateTime createdTime;
|
||||||
private String createdUsername;
|
private String createdUsername;
|
||||||
private LocalDateTime modifiedTime;
|
private LocalDateTime modifiedTime;
|
||||||
private String modifiedUsername;
|
private String modifiedUsername;
|
||||||
|
|
||||||
public DetailItem(Ware ware) {
|
|
||||||
this.setId(ware.getId());
|
|
||||||
this.setResourceId(ware.getResource().getId());
|
|
||||||
this.setResourceName(ware.getResource().getName());
|
|
||||||
this.setName(ware.getName());
|
|
||||||
this.setDescription(ware.getDescription());
|
|
||||||
this.setIconId(ware.getIcon().getId());
|
|
||||||
this.setContent(ware.getContent());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ public class CheckOrder extends SimpleEntity {
|
|||||||
public enum Type {
|
public enum Type {
|
||||||
CONFIRMATION,
|
CONFIRMATION,
|
||||||
AUTHENTICATION,
|
AUTHENTICATION,
|
||||||
|
MARKET,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Target {
|
public enum Target {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.eshore.gringotts.web.domain.entity;
|
package com.eshore.gringotts.web.domain.entity;
|
||||||
|
|
||||||
import com.eshore.gringotts.core.Constants;
|
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.base.entity.LogicDeleteEntity;
|
||||||
import javax.persistence.Basic;
|
import javax.persistence.Basic;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
@@ -48,7 +49,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
|||||||
})
|
})
|
||||||
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "ware" + " set deleted = true where id = ?")
|
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "ware" + " set deleted = true where id = ?")
|
||||||
@Where(clause = LogicDeleteEntity.LOGIC_DELETE_CLAUSE)
|
@Where(clause = LogicDeleteEntity.LOGIC_DELETE_CLAUSE)
|
||||||
public class Ware extends LogicDeleteEntity {
|
public class Ware extends CheckingNeededEntity {
|
||||||
@OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.EAGER)
|
@OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.EAGER)
|
||||||
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||||
@ToString.Exclude
|
@ToString.Exclude
|
||||||
@@ -57,7 +58,7 @@ public class Ware extends LogicDeleteEntity {
|
|||||||
private String name;
|
private String name;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String description;
|
private String description;
|
||||||
@OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
|
@OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
|
||||||
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||||
@ToString.Exclude
|
@ToString.Exclude
|
||||||
private DataFile icon;
|
private DataFile icon;
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ public class DataFileService extends SimpleServiceSupport<DataFile> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DataFile downloadFile(Long id) {
|
||||||
|
return dataFileRepository.findOne((root, query, builder) -> builder.equal(root.get(DataFile_.id), id)).orElseThrow(DataFileNotFoundException::new);
|
||||||
|
}
|
||||||
|
|
||||||
public Long initialDataFile(String filename) {
|
public Long initialDataFile(String filename) {
|
||||||
DataFile dataFile = new DataFile();
|
DataFile dataFile = new DataFile();
|
||||||
dataFile.setFilename(filename);
|
dataFile.setFilename(filename);
|
||||||
|
|||||||
@@ -1,9 +1,21 @@
|
|||||||
package com.eshore.gringotts.web.domain.service;
|
package com.eshore.gringotts.web.domain.service;
|
||||||
|
|
||||||
|
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.base.service.SimpleServiceSupport;
|
||||||
|
import com.eshore.gringotts.web.domain.entity.CheckOrder;
|
||||||
|
import com.eshore.gringotts.web.domain.entity.User;
|
||||||
import com.eshore.gringotts.web.domain.entity.Ware;
|
import com.eshore.gringotts.web.domain.entity.Ware;
|
||||||
import com.eshore.gringotts.web.domain.repository.WareRepository;
|
import com.eshore.gringotts.web.domain.repository.WareRepository;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,9 +23,71 @@ import org.springframework.stereotype.Service;
|
|||||||
* @date 2024-12-13
|
* @date 2024-12-13
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service("com.eshore.gringotts.web.domain.service.WareService")
|
||||||
public class WareService extends SimpleServiceSupport<Ware> {
|
public class WareService extends SimpleServiceSupport<Ware> implements CheckingService {
|
||||||
public WareService(WareRepository repository, UserService userService) {
|
private final WareRepository wareRepository;
|
||||||
|
private final CheckOrderService checkOrderService;
|
||||||
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
|
public WareService(WareRepository repository, UserService userService, CheckOrderService checkOrderService, Jackson2ObjectMapperBuilder builder) {
|
||||||
super(repository, userService);
|
super(repository, userService);
|
||||||
|
this.wareRepository = repository;
|
||||||
|
this.checkOrderService = checkOrderService;
|
||||||
|
this.mapper = builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImmutableList<Ware> listPublic() {
|
||||||
|
return Lists.immutable.ofAll(
|
||||||
|
wareRepository.findAll((root, query, builder) -> builder.equal(root.get("state"), Ware.State.NORMAL))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackOn = Throwable.class)
|
||||||
|
@Override
|
||||||
|
public void onChecked(CheckOrder order, CheckOrder.Operation operation, ImmutableMap<String, Object> parameters) {
|
||||||
|
if (StrUtil.equals(order.getKeyword(), "ware_check")) {
|
||||||
|
Long wareId = (Long) parameters.get("wareId");
|
||||||
|
Ware ware = detailOrThrow(wareId);
|
||||||
|
switch (operation) {
|
||||||
|
case APPLY:
|
||||||
|
ware.setState(Ware.State.NORMAL);
|
||||||
|
order.setState(CheckOrder.State.OVER);
|
||||||
|
break;
|
||||||
|
case REJECT:
|
||||||
|
ware.setState(Ware.State.DRAFT);
|
||||||
|
order.setState(CheckOrder.State.OVER);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
save(ware);
|
||||||
|
checkOrderService.save(order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackOn = Throwable.class)
|
||||||
|
public void submit(Long id) throws JsonProcessingException {
|
||||||
|
Ware ware = detailOrThrow(id);
|
||||||
|
ware.setState(Ware.State.CHECKING);
|
||||||
|
Long orderId = checkOrderService.save(new CheckOrder(
|
||||||
|
"ware_check",
|
||||||
|
StrUtil.format("数据资源「{}」的上架申请", ware.getName()),
|
||||||
|
CheckOrder.Type.MARKET,
|
||||||
|
mapper.writeValueAsString(Maps.immutable.of("wareId", ware.getId())),
|
||||||
|
"com.eshore.gringotts.web.domain.service.WareService",
|
||||||
|
User.Role.CHECKER
|
||||||
|
));
|
||||||
|
CheckOrder order = checkOrderService.detailOrThrow(orderId);
|
||||||
|
ware.setOrder(order);
|
||||||
|
save(ware);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackOn = Throwable.class)
|
||||||
|
public void retract(Long id) {
|
||||||
|
Ware ware = detailOrThrow(id);
|
||||||
|
ware.setState(Ware.State.DRAFT);
|
||||||
|
save(ware);
|
||||||
|
|
||||||
|
CheckOrder order = ware.getOrder();
|
||||||
|
order.setState(CheckOrder.State.RETRACT);
|
||||||
|
checkOrderService.save(order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user