Compare commits
2 Commits
aba9a1716c
...
66bf1b9242
| Author | SHA1 | Date | |
|---|---|---|---|
| 66bf1b9242 | |||
| efe393835c |
@@ -1,5 +1,5 @@
|
|||||||
const information = {
|
const information = {
|
||||||
debug: true,
|
debug: false,
|
||||||
// baseUrl: '',
|
// baseUrl: '',
|
||||||
baseUrl: 'http://127.0.0.1:20080',
|
baseUrl: 'http://127.0.0.1:20080',
|
||||||
title: '可信供给中心',
|
title: '可信供给中心',
|
||||||
@@ -269,3 +269,38 @@ export function formInputMultiFileStatic(field, label) {
|
|||||||
columns: formInputFileStaticColumns,
|
columns: formInputFileStaticColumns,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function formCreatedUserAndModifiedUser() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
type: 'group',
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
type: 'input-text',
|
||||||
|
name: 'createdUsername',
|
||||||
|
label: '创建人',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'input-datetime',
|
||||||
|
name: 'createdTime',
|
||||||
|
label: '创建时间',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'group',
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
type: 'input-text',
|
||||||
|
name: 'modifiedUsername',
|
||||||
|
label: '最后修改人',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'input-datetime',
|
||||||
|
name: 'modifiedTime',
|
||||||
|
label: '最后修改时间',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import './dialog-permission.css'
|
|||||||
import {
|
import {
|
||||||
apiGet,
|
apiGet,
|
||||||
apiPost,
|
apiPost,
|
||||||
|
formCreatedUserAndModifiedUser,
|
||||||
formInputClearable,
|
formInputClearable,
|
||||||
formInputMultiFileStatic,
|
formInputMultiFileStatic,
|
||||||
horizontalFormOptions,
|
horizontalFormOptions,
|
||||||
@@ -10,7 +11,7 @@ import {
|
|||||||
} from "../constants.js";
|
} from "../constants.js";
|
||||||
import {resourceList} from "../../pages/index/tab-data.js";
|
import {resourceList} from "../../pages/index/tab-data.js";
|
||||||
|
|
||||||
function detailForm() {
|
function detailForm(showCreatedUserAndModifiedUser = false) {
|
||||||
return {
|
return {
|
||||||
id: 'permission_form',
|
id: 'permission_form',
|
||||||
type: 'form',
|
type: 'form',
|
||||||
@@ -53,7 +54,8 @@ function detailForm() {
|
|||||||
required: true,
|
required: true,
|
||||||
joinValues: false,
|
joinValues: false,
|
||||||
...inputFileFormItemCommonOptions(undefined, size100MB),
|
...inputFileFormItemCommonOptions(undefined, size100MB),
|
||||||
}
|
},
|
||||||
|
...(showCreatedUserAndModifiedUser ? formCreatedUserAndModifiedUser() : [])
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,7 +96,7 @@ export function permissionDetailDialog(field = 'id') {
|
|||||||
size: 'md',
|
size: 'md',
|
||||||
actions: [],
|
actions: [],
|
||||||
body: {
|
body: {
|
||||||
...detailForm(),
|
...detailForm(true),
|
||||||
initApi: apiGet(`\${base}/confirmation/detail/\${${field}}`),
|
initApi: apiGet(`\${base}/confirmation/detail/\${${field}}`),
|
||||||
static: true,
|
static: true,
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import './dialog-resource.css'
|
|||||||
import {
|
import {
|
||||||
apiGet,
|
apiGet,
|
||||||
apiPost,
|
apiPost,
|
||||||
|
formCreatedUserAndModifiedUser,
|
||||||
formInputClearable,
|
formInputClearable,
|
||||||
formInputSingleFileStatic,
|
formInputSingleFileStatic,
|
||||||
horizontalFormOptions,
|
horizontalFormOptions,
|
||||||
@@ -10,7 +11,7 @@ import {
|
|||||||
size500MB
|
size500MB
|
||||||
} from "../constants.js";
|
} from "../constants.js";
|
||||||
|
|
||||||
function detailForm() {
|
function detailForm(showCreatedUserAndModifiedUser = false) {
|
||||||
return {
|
return {
|
||||||
type: 'form',
|
type: 'form',
|
||||||
...horizontalFormOptions(),
|
...horizontalFormOptions(),
|
||||||
@@ -292,7 +293,8 @@ function detailForm() {
|
|||||||
...inputFileFormItemCommonOptions(undefined, size500MB),
|
...inputFileFormItemCommonOptions(undefined, size500MB),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
...(showCreatedUserAndModifiedUser ? formCreatedUserAndModifiedUser() : [])
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -333,7 +335,7 @@ export function resourceDetailDialog() {
|
|||||||
actions: [],
|
actions: [],
|
||||||
size: 'md',
|
size: 'md',
|
||||||
body: {
|
body: {
|
||||||
...detailForm(),
|
...detailForm(true),
|
||||||
static: true,
|
static: true,
|
||||||
initApi: apiGet('${base}/data_resource/detail/${id}'),
|
initApi: apiGet('${base}/data_resource/detail/${id}'),
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
import {apiGet, horizontalFormOptions, mappingField, userRoleMapping, userStateMapping} from "../constants.js";
|
import {
|
||||||
|
apiGet,
|
||||||
|
formCreatedUserAndModifiedUser,
|
||||||
|
horizontalFormOptions,
|
||||||
|
mappingField,
|
||||||
|
userRoleMapping,
|
||||||
|
userStateMapping
|
||||||
|
} from "../constants.js";
|
||||||
|
|
||||||
const dialogBody = [
|
const dialogBody = [
|
||||||
{
|
{
|
||||||
@@ -27,36 +34,7 @@ const dialogBody = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
...formCreatedUserAndModifiedUser(),
|
||||||
type: 'group',
|
|
||||||
body: [
|
|
||||||
{
|
|
||||||
type: 'input-text',
|
|
||||||
name: 'createdUsername',
|
|
||||||
label: '创建人',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'input-datetime',
|
|
||||||
name: 'createdTime',
|
|
||||||
label: '创建时间',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'group',
|
|
||||||
body: [
|
|
||||||
{
|
|
||||||
type: 'input-text',
|
|
||||||
name: 'modifiedUsername',
|
|
||||||
label: '最后修改人',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'input-datetime',
|
|
||||||
name: 'modifiedTime',
|
|
||||||
label: '最后修改时间',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
type: 'group',
|
type: 'group',
|
||||||
body: [
|
body: [
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ export function userAdministratorRegisterDialog() {
|
|||||||
{ label: '数据提供方', value: 'PROVIDER' },
|
{ label: '数据提供方', value: 'PROVIDER' },
|
||||||
{ label: '数据使用方', value: 'CUSTOMER' },
|
{ label: '数据使用方', value: 'CUSTOMER' },
|
||||||
{ label: '审查监管方', value: 'CHECKER' },
|
{ label: '审查监管方', value: 'CHECKER' },
|
||||||
{ label: '系统管理员', value: 'ADMINISTRATOR' },
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ useAmis(information => {
|
|||||||
tabs: [
|
tabs: [
|
||||||
// tabOverview(),
|
// tabOverview(),
|
||||||
// tabMarket(),
|
// tabMarket(),
|
||||||
tabPermissions(),
|
|
||||||
tabData(),
|
tabData(),
|
||||||
|
tabPermissions(),
|
||||||
tabCheck(),
|
tabCheck(),
|
||||||
tabUser(),
|
tabUser(),
|
||||||
tabSettings(),
|
tabSettings(),
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ export function resourceList() {
|
|||||||
...resourceAddDialog()
|
...resourceAddDialog()
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
rowSelection: {
|
|
||||||
disableOn: '${confirmationId}',
|
|
||||||
},
|
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
label: '名称',
|
label: '名称',
|
||||||
|
|||||||
@@ -9,10 +9,14 @@ 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.entity.User;
|
||||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import javax.persistence.criteria.Predicate;
|
||||||
import javax.transaction.Transactional;
|
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.Sets;
|
import org.eclipse.collections.api.factory.Sets;
|
||||||
|
import org.eclipse.collections.api.list.MutableList;
|
||||||
import org.eclipse.collections.api.set.ImmutableSet;
|
import org.eclipse.collections.api.set.ImmutableSet;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author lanyuanxiaoyao
|
* @author lanyuanxiaoyao
|
||||||
@@ -51,32 +55,59 @@ public abstract class SimpleService<ENTITY extends SimpleEntity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableSet<ENTITY> list() {
|
public ImmutableSet<ENTITY> list() {
|
||||||
return Sets.immutable.ofAll(repository.findAll());
|
return Sets.immutable.ofAll(repository.findAll(
|
||||||
|
(root, query, builder) -> {
|
||||||
|
MutableList<Predicate> predicates = Lists.mutable.empty();
|
||||||
|
User user = userService.currentLoginUser();
|
||||||
|
if (User.isNotAdministrator(user)) {
|
||||||
|
predicates.add(builder.equal(root.get("createdUser"), user));
|
||||||
|
}
|
||||||
|
return builder.and(predicates.toArray(new Predicate[predicates.size()]));
|
||||||
|
},
|
||||||
|
Sort.by("createdTime").descending()
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableSet<ENTITY> list(ImmutableSet<Long> ids) {
|
public ImmutableSet<ENTITY> list(ImmutableSet<Long> ids) {
|
||||||
return Sets.immutable.ofAll(repository.findAllById(ids.select(ObjectUtil::isNotNull)));
|
return Sets.immutable.ofAll(repository.findAll(
|
||||||
}
|
(root, query, builder) -> {
|
||||||
|
MutableList<Predicate> predicates = Lists.mutable.of(
|
||||||
public ENTITY detail(Long id) {
|
builder.in(root.get("id")).value(ids.select(ObjectUtil::isNotNull))
|
||||||
if (ObjectUtil.isNull(id)) {
|
);
|
||||||
return null;
|
User user = userService.currentLoginUser();
|
||||||
}
|
if (User.isNotAdministrator(user)) {
|
||||||
return repository.findById(id).orElse(null);
|
predicates.add(builder.equal(root.get("createdUser"), user));
|
||||||
|
}
|
||||||
|
return builder.and(predicates.toArray(new Predicate[predicates.size()]));
|
||||||
|
},
|
||||||
|
Sort.by("createdTime").descending()
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ENTITY> detailOptional(Long id) {
|
public Optional<ENTITY> detailOptional(Long id) {
|
||||||
if (ObjectUtil.isNull(id)) {
|
if (ObjectUtil.isNull(id)) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
return repository.findById(id);
|
return repository.findOne(
|
||||||
|
(root, query, builder) -> {
|
||||||
|
MutableList<Predicate> predicates = Lists.mutable.of(
|
||||||
|
builder.equal(root.get("id"), id)
|
||||||
|
);
|
||||||
|
User user = userService.currentLoginUser();
|
||||||
|
if (User.isNotAdministrator(user)) {
|
||||||
|
predicates.add(builder.equal(root.get("createdUser"), user));
|
||||||
|
}
|
||||||
|
return builder.and(predicates.toArray(new Predicate[predicates.size()]));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ENTITY detail(Long id) {
|
||||||
|
return detailOptional(id).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ENTITY detailOrThrow(Long id) {
|
public ENTITY detailOrThrow(Long id) {
|
||||||
if (ObjectUtil.isNull(id)) {
|
return detailOptional(id).orElseThrow(() -> new IdNotFoundException(id));
|
||||||
throw new IdNotFoundException(id);
|
|
||||||
}
|
|
||||||
return repository.findById(id).orElseThrow(() -> new IdNotFoundException(id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackOn = Throwable.class)
|
@Transactional(rollbackOn = Throwable.class)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
|
|||||||
import com.eshore.gringotts.web.domain.confirmation.service.ConfirmationService;
|
import com.eshore.gringotts.web.domain.confirmation.service.ConfirmationService;
|
||||||
import com.eshore.gringotts.web.domain.resource.service.DataResourceService;
|
import com.eshore.gringotts.web.domain.resource.service.DataResourceService;
|
||||||
import com.eshore.gringotts.web.domain.upload.service.DataFileService;
|
import com.eshore.gringotts.web.domain.upload.service.DataFileService;
|
||||||
|
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;
|
||||||
@@ -97,6 +98,10 @@ public class ConfirmationController extends SimpleController<Confirmation, Confi
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public static final class DetailItem extends SaveItem {
|
public static final class DetailItem extends SaveItem {
|
||||||
private String targetName;
|
private String targetName;
|
||||||
|
private LocalDateTime createdTime;
|
||||||
|
private String createdUsername;
|
||||||
|
private LocalDateTime modifiedTime;
|
||||||
|
private String modifiedUsername;
|
||||||
|
|
||||||
public DetailItem(Confirmation confirmation) {
|
public DetailItem(Confirmation confirmation) {
|
||||||
this.setId(confirmation.getId());
|
this.setId(confirmation.getId());
|
||||||
@@ -104,6 +109,10 @@ public class ConfirmationController extends SimpleController<Confirmation, Confi
|
|||||||
this.setTargetName(confirmation.getTarget().getName());
|
this.setTargetName(confirmation.getTarget().getName());
|
||||||
this.setDescription(confirmation.getDescription());
|
this.setDescription(confirmation.getDescription());
|
||||||
this.setEvidenceFiles(Sets.immutable.ofAll(confirmation.getEvidences()).collect(FileInfo::new));
|
this.setEvidenceFiles(Sets.immutable.ofAll(confirmation.getEvidences()).collect(FileInfo::new));
|
||||||
|
this.setCreatedTime(confirmation.getCreatedTime());
|
||||||
|
this.setCreatedUsername(confirmation.getCreatedUser().getUsername());
|
||||||
|
this.setModifiedTime(confirmation.getModifiedTime());
|
||||||
|
this.setModifiedUsername(confirmation.getModifiedUser().getUsername());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import javax.persistence.CascadeType;
|
|||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.ConstraintMode;
|
import javax.persistence.ConstraintMode;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EntityListeners;
|
||||||
import javax.persistence.EnumType;
|
import javax.persistence.EnumType;
|
||||||
import javax.persistence.Enumerated;
|
import javax.persistence.Enumerated;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -24,6 +25,7 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import org.hibernate.annotations.DynamicUpdate;
|
import org.hibernate.annotations.DynamicUpdate;
|
||||||
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 确权
|
* 确权
|
||||||
@@ -36,6 +38,7 @@ import org.hibernate.annotations.DynamicUpdate;
|
|||||||
@ToString
|
@ToString
|
||||||
@Entity
|
@Entity
|
||||||
@DynamicUpdate
|
@DynamicUpdate
|
||||||
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
@Table(name = Constants.TABLE_PREFIX + "confirmation")
|
@Table(name = Constants.TABLE_PREFIX + "confirmation")
|
||||||
@NamedEntityGraph(name = "confirmation.list", attributeNodes = {
|
@NamedEntityGraph(name = "confirmation.list", attributeNodes = {
|
||||||
@NamedAttributeNode(value = "target"),
|
@NamedAttributeNode(value = "target"),
|
||||||
@@ -54,6 +57,7 @@ public class Confirmation extends SimpleEntity {
|
|||||||
private String description;
|
private String description;
|
||||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||||
@JoinTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT), inverseForeignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
@JoinTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT), inverseForeignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||||
|
@ToString.Exclude
|
||||||
private Set<DataFile> evidences;
|
private Set<DataFile> evidences;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
|
|||||||
@@ -2,9 +2,12 @@ package com.eshore.gringotts.web.domain.confirmation.repository;
|
|||||||
|
|
||||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
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 com.eshore.gringotts.web.domain.user.entity.User;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.data.jpa.repository.EntityGraph;
|
import org.springframework.data.jpa.repository.EntityGraph;
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
@@ -19,16 +22,16 @@ import org.springframework.stereotype.Repository;
|
|||||||
public interface ConfirmationRepository extends SimpleRepository<Confirmation, Long> {
|
public interface ConfirmationRepository extends SimpleRepository<Confirmation, Long> {
|
||||||
@Override
|
@Override
|
||||||
@EntityGraph(value = "confirmation.list", type = EntityGraph.EntityGraphType.FETCH)
|
@EntityGraph(value = "confirmation.list", type = EntityGraph.EntityGraphType.FETCH)
|
||||||
List<Confirmation> findAll();
|
List<Confirmation> findAll(Specification<Confirmation> specification, Sort sort);
|
||||||
|
|
||||||
@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> findOne(Specification<Confirmation> specification);
|
||||||
|
|
||||||
Boolean existsByTarget_Id(Long id);
|
Boolean existsByTarget_Id(Long id);
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query("update Confirmation confirmation set confirmation.state = ?2 where confirmation.id = ?1")
|
@Query("update Confirmation confirmation set confirmation.state = ?2, confirmation.modifiedUser = ?3, confirmation.modifiedTime = current_timestamp where confirmation.id = ?1")
|
||||||
void updateStateById(Long id, Confirmation.State state);
|
void updateStateById(Long id, Confirmation.State state, User modifiedUser);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.eshore.gringotts.web.domain.confirmation.service;
|
package com.eshore.gringotts.web.domain.confirmation.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.eshore.gringotts.web.domain.base.service.SimpleService;
|
import com.eshore.gringotts.web.domain.base.service.SimpleService;
|
||||||
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.confirmation.repository.ConfirmationRepository;
|
||||||
@@ -15,26 +16,28 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class ConfirmationService extends SimpleService<Confirmation> {
|
public class ConfirmationService extends SimpleService<Confirmation> {
|
||||||
private final ConfirmationRepository confirmationRepository;
|
private final ConfirmationRepository confirmationRepository;
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
public ConfirmationService(ConfirmationRepository confirmationRepository, UserService userService) {
|
public ConfirmationService(ConfirmationRepository confirmationRepository, UserService userService) {
|
||||||
super(confirmationRepository, userService);
|
super(confirmationRepository, userService);
|
||||||
this.confirmationRepository = confirmationRepository;
|
this.confirmationRepository = confirmationRepository;
|
||||||
|
this.userService = userService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long save(Confirmation entity) {
|
public Long save(Confirmation entity) {
|
||||||
if (confirmationRepository.existsByTarget_Id(entity.getTarget().getId())) {
|
if (ObjectUtil.isNull(entity.getId()) && confirmationRepository.existsByTarget_Id(entity.getTarget().getId())) {
|
||||||
throw new ConfirmationDuplicatedException();
|
throw new ConfirmationDuplicatedException();
|
||||||
}
|
}
|
||||||
return super.save(entity);
|
return super.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void submit(Long id) {
|
public void submit(Long id) {
|
||||||
confirmationRepository.updateStateById(id, Confirmation.State.CHECKING);
|
confirmationRepository.updateStateById(id, Confirmation.State.CHECKING, userService.currentLoginUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void retract(Long id) {
|
public void retract(Long id) {
|
||||||
confirmationRepository.updateStateById(id, Confirmation.State.DRAFT);
|
confirmationRepository.updateStateById(id, Confirmation.State.DRAFT, userService.currentLoginUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class ConfirmationDuplicatedException extends RuntimeException {
|
public static final class ConfirmationDuplicatedException extends RuntimeException {
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
|||||||
import com.eshore.gringotts.web.domain.resource.entity.DataResource;
|
import com.eshore.gringotts.web.domain.resource.entity.DataResource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.data.jpa.repository.EntityGraph;
|
import org.springframework.data.jpa.repository.EntityGraph;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@@ -12,9 +14,9 @@ import org.springframework.stereotype.Repository;
|
|||||||
public interface DataResourceRepository extends SimpleRepository<DataResource, Long> {
|
public interface DataResourceRepository extends SimpleRepository<DataResource, Long> {
|
||||||
@Override
|
@Override
|
||||||
@EntityGraph(value = "data_resource.list", type = EntityGraph.EntityGraphType.FETCH)
|
@EntityGraph(value = "data_resource.list", type = EntityGraph.EntityGraphType.FETCH)
|
||||||
List<DataResource> findAll();
|
List<DataResource> findAll(Specification<DataResource> specification, Sort sort);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@EntityGraph(value = "data_resource.detail", type = EntityGraph.EntityGraphType.FETCH)
|
@EntityGraph(value = "data_resource.detail", type = EntityGraph.EntityGraphType.FETCH)
|
||||||
Optional<DataResource> findById(Long id);
|
Optional<DataResource> findOne(Specification<DataResource> specification);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,42 @@ public class User extends SimpleEntity {
|
|||||||
@ToString.Exclude
|
@ToString.Exclude
|
||||||
private User checkedUser;
|
private User checkedUser;
|
||||||
|
|
||||||
|
public static boolean isAdministrator(User user) {
|
||||||
|
return Role.ADMINISTRATOR.equals(user.role);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isNotAdministrator(User user) {
|
||||||
|
return !isAdministrator(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isChecker(User user) {
|
||||||
|
return Role.CHECKER.equals(user.role);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isNotChecker(User user) {
|
||||||
|
return !isChecker(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isProvider(User user) {
|
||||||
|
return Role.PROVIDER.equals(user.role);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isNotProvider(User user) {
|
||||||
|
return !isProvider(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isCustomer(User user) {
|
||||||
|
return Role.CUSTOMER.equals(user.role);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isNotCustomer(User user) {
|
||||||
|
return !isCustomer(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isUser(User user) {
|
||||||
|
return isProvider(user) || isCustomer(user);
|
||||||
|
}
|
||||||
|
|
||||||
public enum State {
|
public enum State {
|
||||||
/**
|
/**
|
||||||
* 审查中
|
* 审查中
|
||||||
|
|||||||
Reference in New Issue
Block a user