1
0

5 Commits

Author SHA1 Message Date
dbdf9c59bb feat(ware): 上架数据产品功能
- 新增数据产品上架相关的对话框组件和页面功能
- 实现数据产品的添加、编辑和详情查看功能
- 添加数据产品相关的实体类、控制器、服务类和仓库接口
2024-12-13 18:18:49 +08:00
8202a27f55 refactor(web): 减少文件夹层级 2024-12-13 17:26:17 +08:00
db05b69122 refactor(web):优化确认服务和数据资源服务的查询逻辑 2024-12-13 17:02:55 +08:00
8abd31cd97 feat(web): 调整权限管理界面和功能 2024-12-12 15:57:49 +08:00
6fad39443c refactor(web): 优化用户对话框字段布局
- 调整角色和账号状态字段的布局方式
- 增加 control 组件以改善字段显示效果
- 在 constants.js 中添加 label属性以支持新布局
2024-12-12 15:53:27 +08:00
60 changed files with 622 additions and 273 deletions

View File

@@ -131,6 +131,7 @@ export function copyField(field, label, tips = '复制', ignoreLength = 0, extra
}
return {
name: field,
label: label,
type: 'wrapper',
size: 'none',
className: 'nowrap',

View File

@@ -16,8 +16,16 @@ const dialogBody = [
{
type: 'group',
body: [
mappingField('role', '角色', userRoleMapping),
mappingField('state', '账号状态', userStateMapping),
{
type: 'control',
label: '角色',
body: mappingField('role', '角色', userRoleMapping, 120),
},
{
type: 'control',
label: '账号状态',
body: mappingField('state', '账号状态', userStateMapping),
}
]
},
...formCreatedUserAndModifiedUser(),

View File

@@ -0,0 +1,3 @@
textarea {
resize: none !important;
}

View File

@@ -0,0 +1,119 @@
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}}`),
},
}
}
}

View File

@@ -5,6 +5,7 @@ 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 {
@@ -58,7 +59,7 @@ useAmis(information => {
tabsMode: 'vertical',
tabs: [
// tabOverview(),
// tabMarket(),
tabMarket(),
tabPermissions(),
tabCheck(),
tabData(),

View File

@@ -1,9 +1,16 @@
import {wareAddDialog} from "../../components/ware/dialog-ware.js";
export function tabMarket() {
return {
title: '数据市场',
icon: 'fa fa-store',
body: [
'hello world'
{
type: 'action',
label: '',
icon: 'fa fa-plus',
...wareAddDialog()
},
]
}
}

View File

@@ -32,85 +32,6 @@ export function tabPermissions() {
body: {
type: 'tabs',
tabs: [
{
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}'),
},
]
},
]),
]
}
},
{
visibleOn: providerOnly,
title: '确权管理',
@@ -190,6 +111,85 @@ 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}'),
},
]
},
]),
]
}
},
]
}
}

View File

@@ -1,8 +1,8 @@
package com.eshore.gringotts.web;
import com.blinkfox.fenix.EnableFenix;
import com.eshore.gringotts.web.domain.user.entity.User;
import com.eshore.gringotts.web.domain.user.service.UserService;
import com.eshore.gringotts.web.domain.entity.User;
import com.eshore.gringotts.web.domain.service.UserService;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;

View File

@@ -1,6 +1,6 @@
package com.eshore.gringotts.web.domain.base.entity;
import com.eshore.gringotts.web.domain.check.entity.CheckOrder;
import com.eshore.gringotts.web.domain.entity.CheckOrder;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EntityListeners;

View File

@@ -1,6 +1,6 @@
package com.eshore.gringotts.web.domain.base.entity;
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
import com.eshore.gringotts.web.domain.entity.DataFile;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.databind.DeserializationContext;

View File

@@ -1,6 +1,6 @@
package com.eshore.gringotts.web.domain.base.entity;
import com.eshore.gringotts.web.domain.user.entity.User;
import com.eshore.gringotts.web.domain.entity.User;
import java.time.LocalDateTime;
import javax.persistence.ConstraintMode;
import javax.persistence.EntityListeners;

View File

@@ -1,6 +1,6 @@
package com.eshore.gringotts.web.domain.base.service;
import com.eshore.gringotts.web.domain.check.entity.CheckOrder;
import com.eshore.gringotts.web.domain.entity.CheckOrder;
import org.eclipse.collections.api.map.ImmutableMap;
/**

View File

@@ -4,7 +4,7 @@ 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.user.service.UserService;
import com.eshore.gringotts.web.domain.service.UserService;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;

View File

@@ -10,8 +10,8 @@ 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.user.entity.User;
import com.eshore.gringotts.web.domain.user.service.UserService;
import com.eshore.gringotts.web.domain.entity.User;
import com.eshore.gringotts.web.domain.service.UserService;
import java.util.Optional;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;

View File

@@ -1,14 +1,14 @@
package com.eshore.gringotts.web.domain.authentication.controller;
package com.eshore.gringotts.web.domain.controller;
import com.eshore.gringotts.web.configuration.amis.AmisResponse;
import com.eshore.gringotts.web.domain.authentication.entity.Authentication;
import com.eshore.gringotts.web.domain.authentication.service.AuthenticationService;
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.resource.service.DataResourceService;
import com.eshore.gringotts.web.domain.upload.service.DataFileService;
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;

View File

@@ -1,10 +1,10 @@
package com.eshore.gringotts.web.domain.check.controller;
package com.eshore.gringotts.web.domain.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.check.entity.CheckOrder;
import com.eshore.gringotts.web.domain.check.service.CheckOrderService;
import com.eshore.gringotts.web.domain.entity.CheckOrder;
import com.eshore.gringotts.web.domain.service.CheckOrderService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

View File

@@ -1,14 +1,14 @@
package com.eshore.gringotts.web.domain.confirmation.controller;
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.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.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.fasterxml.jackson.core.JsonProcessingException;
import java.time.LocalDateTime;
import lombok.Data;

View File

@@ -1,11 +1,11 @@
package com.eshore.gringotts.web.domain.upload.controller;
package com.eshore.gringotts.web.domain.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.upload.service.DataFileService;
import com.eshore.gringotts.web.domain.service.DataFileService;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.ByteArrayInputStream;
import java.io.File;

View File

@@ -1,4 +1,4 @@
package com.eshore.gringotts.web.domain.resource.controller;
package com.eshore.gringotts.web.domain.controller;
import cn.hutool.core.util.EnumUtil;
import cn.hutool.core.util.ObjectUtil;
@@ -7,23 +7,23 @@ 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.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.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.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.time.LocalDateTime;

View File

@@ -1,11 +1,9 @@
package com.eshore.gringotts.web.domain.user.controller;
package com.eshore.gringotts.web.domain.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.user.entity.User;
import com.eshore.gringotts.web.domain.user.service.UserService;
import com.eshore.gringotts.web.domain.entity.User;
import com.eshore.gringotts.web.domain.service.UserService;
import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@@ -1,10 +1,10 @@
package com.eshore.gringotts.web.domain.user.controller;
package com.eshore.gringotts.web.domain.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.user.entity.User;
import com.eshore.gringotts.web.domain.user.service.UserService;
import com.eshore.gringotts.web.domain.entity.User;
import com.eshore.gringotts.web.domain.service.UserService;
import java.time.LocalDateTime;
import lombok.Data;
import org.slf4j.Logger;

View File

@@ -0,0 +1,98 @@
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());
}
}
}

View File

@@ -1,10 +1,8 @@
package com.eshore.gringotts.web.domain.authentication.entity;
package com.eshore.gringotts.web.domain.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 java.time.LocalDateTime;
import java.util.Set;
import javax.persistence.CascadeType;

View File

@@ -1,8 +1,7 @@
package com.eshore.gringotts.web.domain.check.entity;
package com.eshore.gringotts.web.domain.entity;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity;
import com.eshore.gringotts.web.domain.user.entity.User;
import javax.persistence.Column;
import javax.persistence.ConstraintMode;
import javax.persistence.Entity;

View File

@@ -1,10 +1,8 @@
package com.eshore.gringotts.web.domain.confirmation.entity;
package com.eshore.gringotts.web.domain.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 java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.ConstraintMode;

View File

@@ -1,4 +1,4 @@
package com.eshore.gringotts.web.domain.upload.entity;
package com.eshore.gringotts.web.domain.entity;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteEntity;

View File

@@ -1,12 +1,9 @@
package com.eshore.gringotts.web.domain.resource.entity;
package com.eshore.gringotts.web.domain.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.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 com.eshore.gringotts.web.domain.entity.format.ResourceFormat;
import com.eshore.gringotts.web.domain.entity.type.ResourceType;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;

View File

@@ -1,4 +1,4 @@
package com.eshore.gringotts.web.domain.user.entity;
package com.eshore.gringotts.web.domain.entity;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity;

View File

@@ -0,0 +1,70 @@
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;
}

View File

@@ -1,4 +1,4 @@
package com.eshore.gringotts.web.domain.resource.entity.format;
package com.eshore.gringotts.web.domain.entity.format;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;

View File

@@ -1,4 +1,4 @@
package com.eshore.gringotts.web.domain.resource.entity.format;
package com.eshore.gringotts.web.domain.entity.format;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;

View File

@@ -1,4 +1,4 @@
package com.eshore.gringotts.web.domain.resource.entity.format;
package com.eshore.gringotts.web.domain.entity.format;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;

View File

@@ -1,4 +1,4 @@
package com.eshore.gringotts.web.domain.resource.entity.format;
package com.eshore.gringotts.web.domain.entity.format;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;

View File

@@ -1,4 +1,4 @@
package com.eshore.gringotts.web.domain.resource.entity.format;
package com.eshore.gringotts.web.domain.entity.format;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;

View File

@@ -1,4 +1,4 @@
package com.eshore.gringotts.web.domain.resource.entity.format;
package com.eshore.gringotts.web.domain.entity.format;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;
@@ -27,6 +27,8 @@ import org.hibernate.annotations.Where;
@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,
@@ -34,6 +36,4 @@ public abstract class ResourceFormat extends LogicDeleteIdOnlyEntity {
JSON_LINE,
CSV,
}
public abstract Type getFormatType();
}

View File

@@ -1,4 +1,4 @@
package com.eshore.gringotts.web.domain.resource.entity.type;
package com.eshore.gringotts.web.domain.entity.type;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;

View File

@@ -1,4 +1,4 @@
package com.eshore.gringotts.web.domain.resource.entity.type;
package com.eshore.gringotts.web.domain.entity.type;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;

View File

@@ -1,8 +1,8 @@
package com.eshore.gringotts.web.domain.resource.entity.type;
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.upload.entity.DataFile;
import com.eshore.gringotts.web.domain.entity.DataFile;
import javax.persistence.ConstraintMode;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;

View File

@@ -1,4 +1,4 @@
package com.eshore.gringotts.web.domain.resource.entity.type;
package com.eshore.gringotts.web.domain.entity.type;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;

View File

@@ -1,8 +1,8 @@
package com.eshore.gringotts.web.domain.resource.entity.type;
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.upload.entity.DataFile;
import com.eshore.gringotts.web.domain.entity.DataFile;
import javax.persistence.ConstraintMode;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;

View File

@@ -1,4 +1,4 @@
package com.eshore.gringotts.web.domain.resource.entity.type;
package com.eshore.gringotts.web.domain.entity.type;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteIdOnlyEntity;

View File

@@ -1,7 +1,7 @@
package com.eshore.gringotts.web.domain.authentication.repository;
package com.eshore.gringotts.web.domain.repository;
import com.eshore.gringotts.web.domain.authentication.entity.Authentication;
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;

View File

@@ -1,8 +1,8 @@
package com.eshore.gringotts.web.domain.check.repository;
package com.eshore.gringotts.web.domain.repository;
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
import com.eshore.gringotts.web.domain.check.entity.CheckOrder;
import com.eshore.gringotts.web.domain.user.entity.User;
import com.eshore.gringotts.web.domain.entity.CheckOrder;
import com.eshore.gringotts.web.domain.entity.User;
import java.util.List;
import java.util.Optional;
import javax.transaction.Transactional;

View File

@@ -1,7 +1,7 @@
package com.eshore.gringotts.web.domain.confirmation.repository;
package com.eshore.gringotts.web.domain.repository;
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
import com.eshore.gringotts.web.domain.entity.Confirmation;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Sort;

View File

@@ -1,7 +1,7 @@
package com.eshore.gringotts.web.domain.upload.repository;
package com.eshore.gringotts.web.domain.repository;
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
import com.eshore.gringotts.web.domain.entity.DataFile;
import org.springframework.stereotype.Repository;
@Repository

View File

@@ -1,7 +1,7 @@
package com.eshore.gringotts.web.domain.resource.repository;
package com.eshore.gringotts.web.domain.repository;
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
import com.eshore.gringotts.web.domain.resource.entity.DataResource;
import com.eshore.gringotts.web.domain.entity.DataResource;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Sort;

View File

@@ -0,0 +1,9 @@
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> {
}

View File

@@ -0,0 +1,9 @@
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> {
}

View File

@@ -1,7 +1,7 @@
package com.eshore.gringotts.web.domain.user.repository;
package com.eshore.gringotts.web.domain.repository;
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
import com.eshore.gringotts.web.domain.user.entity.User;
import com.eshore.gringotts.web.domain.entity.User;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.EntityGraph;
@@ -21,6 +21,7 @@ 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);
}

View File

@@ -0,0 +1,26 @@
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);
}

View File

@@ -1,12 +0,0 @@
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> {
}

View File

@@ -1,12 +0,0 @@
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> {
}

View File

@@ -1,18 +1,16 @@
package com.eshore.gringotts.web.domain.authentication.service;
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.authentication.entity.Authentication;
import com.eshore.gringotts.web.domain.authentication.entity.Authentication_;
import com.eshore.gringotts.web.domain.authentication.repository.AuthenticationRepository;
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.check.entity.CheckOrder;
import com.eshore.gringotts.web.domain.check.entity.CheckOrder_;
import com.eshore.gringotts.web.domain.check.service.CheckOrderService;
import com.eshore.gringotts.web.domain.user.entity.User;
import com.eshore.gringotts.web.domain.user.service.UserService;
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;
@@ -34,7 +32,7 @@ import org.springframework.stereotype.Service;
* @date 2024-12-02
*/
@Slf4j
@Service("com.eshore.gringotts.web.domain.authentication.service.AuthenticationService")
@Service("com.eshore.gringotts.web.domain.service.AuthenticationService")
public class AuthenticationService extends LogicDeleteService<Authentication> implements CheckingService {
private final AuthenticationRepository authenticationRepository;
private final UserService userService;
@@ -94,7 +92,7 @@ public class AuthenticationService extends LogicDeleteService<Authentication> im
StrUtil.format("数据资源「{}」的授权申请", authentication.getTarget().getName()),
CheckOrder.Type.AUTHENTICATION,
mapper.writeValueAsString(Maps.immutable.of("authenticationId", authentication.getId())),
"com.eshore.gringotts.web.domain.authentication.service.AuthenticationService",
"com.eshore.gringotts.web.domain.service.AuthenticationService",
authentication.getCreatedUser()
));
CheckOrder order = checkOrderService.detailOrThrow(orderId);

View File

@@ -1,14 +1,13 @@
package com.eshore.gringotts.web.domain.check.service;
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.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.entity.CheckOrder_;
import com.eshore.gringotts.web.domain.check.repository.CheckOrderRepository;
import com.eshore.gringotts.web.domain.user.entity.User;
import com.eshore.gringotts.web.domain.user.service.UserService;
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.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

View File

@@ -1,22 +1,22 @@
package com.eshore.gringotts.web.domain.confirmation.service;
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.check.entity.CheckOrder;
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.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.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;
@@ -33,7 +33,7 @@ import org.springframework.stereotype.Service;
* @date 2024-11-26
*/
@Slf4j
@Service("com.eshore.gringotts.web.domain.confirmation.service.ConfirmationService")
@Service("com.eshore.gringotts.web.domain.service.ConfirmationService")
public class ConfirmationService extends SimpleServiceSupport<Confirmation> implements CheckingService {
private final ConfirmationRepository confirmationRepository;
private final CheckOrderService checkOrderService;
@@ -52,15 +52,21 @@ public class ConfirmationService extends SimpleServiceSupport<Confirmation> impl
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.equal(root.get(Confirmation_.order).get(CheckOrder_.target), CheckOrder.Target.ROLE),
builder.equal(root.get(Confirmation_.order).get(CheckOrder_.targetRole), loginUser.getRole())
),
builder.and(
builder.equal(root.get(Confirmation_.order).get(CheckOrder_.target), CheckOrder.Target.USER),
builder.equal(root.get(Confirmation_.order).get(CheckOrder_.targetUser), loginUser)
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)
)
)
)
));
}
@@ -82,7 +88,7 @@ public class ConfirmationService extends SimpleServiceSupport<Confirmation> impl
StrUtil.format("数据资源「{}」的确权申请", confirmation.getTarget().getName()),
CheckOrder.Type.CONFIRMATION,
mapper.writeValueAsString(Maps.immutable.of("confirmationId", confirmation.getId())),
"com.eshore.gringotts.web.domain.confirmation.service.ConfirmationService",
"com.eshore.gringotts.web.domain.service.ConfirmationService",
User.Role.CHECKER
));
CheckOrder order = checkOrderService.detailOrThrow(orderId);

View File

@@ -1,15 +1,14 @@
package com.eshore.gringotts.web.domain.upload.service;
package com.eshore.gringotts.web.domain.service;
import com.eshore.gringotts.web.domain.authentication.entity.Authentication;
import com.eshore.gringotts.web.domain.authentication.entity.Authentication_;
import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport;
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation_;
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
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 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;

View File

@@ -1,24 +1,23 @@
package com.eshore.gringotts.web.domain.resource.service;
package com.eshore.gringotts.web.domain.service;
import com.eshore.gringotts.web.domain.authentication.entity.Authentication;
import com.eshore.gringotts.web.domain.authentication.entity.Authentication_;
import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity;
import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport;
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
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.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.entity.User;
import com.eshore.gringotts.web.domain.user.service.UserService;
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;
@@ -79,23 +78,34 @@ public class DataResourceService extends SimpleServiceSupport<DataResource> {
}
public ImmutableList<DataResource> listNoConfirmation() {
return Lists.immutable.ofAll(dataResourceRepository.findAllByConfirmationIsNull());
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("confirmation");
confirmationJoin.on(builder.equal(confirmationJoin.get("state"), CheckingNeededEntity.State.NORMAL));
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("target"), root),
builder.equal(authenticationRoot.get("createdUser"), userService.currentLoginUser())
builder.equal(authenticationRoot.get(Authentication_.target), root),
builder.equal(authenticationRoot.get(Authentication_.createdUser), userService.currentLoginUser())
);
return builder.exists(authenticationSubquery).not();
return builder.and(
builder.exists(authenticationSubquery).not(),
builder.equal(root.get(DataResource_.createdUser), userService.currentLoginUser())
);
}
));
}

View File

@@ -1,12 +1,12 @@
package com.eshore.gringotts.web.domain.user.service;
package com.eshore.gringotts.web.domain.service;
import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import com.eshore.gringotts.web.domain.user.entity.User;
import com.eshore.gringotts.web.domain.user.repository.UserRepository;
import com.eshore.gringotts.web.domain.entity.User;
import com.eshore.gringotts.web.domain.repository.UserRepository;
import java.time.LocalDateTime;
import java.util.Optional;
import lombok.Data;

View File

@@ -0,0 +1,19 @@
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);
}
}

View File

@@ -3,9 +3,9 @@ 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.check.entity.CheckOrder;
import com.eshore.gringotts.web.domain.check.entity.CheckOrder_;
import com.eshore.gringotts.web.domain.user.entity.User;
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 java.util.function.Supplier;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate;