feat(web): 新增根据当前登陆用户查询记录
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const information = {
|
||||
debug: true,
|
||||
debug: false,
|
||||
// baseUrl: '',
|
||||
baseUrl: 'http://127.0.0.1:20080',
|
||||
title: '可信供给中心',
|
||||
@@ -269,3 +269,38 @@ export function formInputMultiFileStatic(field, label) {
|
||||
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 {
|
||||
apiGet,
|
||||
apiPost,
|
||||
formCreatedUserAndModifiedUser,
|
||||
formInputClearable,
|
||||
formInputMultiFileStatic,
|
||||
horizontalFormOptions,
|
||||
@@ -10,7 +11,7 @@ import {
|
||||
} from "../constants.js";
|
||||
import {resourceList} from "../../pages/index/tab-data.js";
|
||||
|
||||
function detailForm() {
|
||||
function detailForm(showCreatedUserAndModifiedUser = false) {
|
||||
return {
|
||||
id: 'permission_form',
|
||||
type: 'form',
|
||||
@@ -53,7 +54,8 @@ function detailForm() {
|
||||
required: true,
|
||||
joinValues: false,
|
||||
...inputFileFormItemCommonOptions(undefined, size100MB),
|
||||
}
|
||||
},
|
||||
...(showCreatedUserAndModifiedUser ? formCreatedUserAndModifiedUser() : [])
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -94,7 +96,7 @@ export function permissionDetailDialog(field = 'id') {
|
||||
size: 'md',
|
||||
actions: [],
|
||||
body: {
|
||||
...detailForm(),
|
||||
...detailForm(true),
|
||||
initApi: apiGet(`\${base}/confirmation/detail/\${${field}}`),
|
||||
static: true,
|
||||
data: {
|
||||
|
||||
@@ -2,6 +2,7 @@ import './dialog-resource.css'
|
||||
import {
|
||||
apiGet,
|
||||
apiPost,
|
||||
formCreatedUserAndModifiedUser,
|
||||
formInputClearable,
|
||||
formInputSingleFileStatic,
|
||||
horizontalFormOptions,
|
||||
@@ -10,7 +11,7 @@ import {
|
||||
size500MB
|
||||
} from "../constants.js";
|
||||
|
||||
function detailForm() {
|
||||
function detailForm(showCreatedUserAndModifiedUser = false) {
|
||||
return {
|
||||
type: 'form',
|
||||
...horizontalFormOptions(),
|
||||
@@ -292,7 +293,8 @@ function detailForm() {
|
||||
...inputFileFormItemCommonOptions(undefined, size500MB),
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
...(showCreatedUserAndModifiedUser ? formCreatedUserAndModifiedUser() : [])
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -333,7 +335,7 @@ export function resourceDetailDialog() {
|
||||
actions: [],
|
||||
size: 'md',
|
||||
body: {
|
||||
...detailForm(),
|
||||
...detailForm(true),
|
||||
static: true,
|
||||
initApi: apiGet('${base}/data_resource/detail/${id}'),
|
||||
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 = [
|
||||
{
|
||||
@@ -27,36 +34,7 @@ const dialogBody = [
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
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: '最后修改时间',
|
||||
},
|
||||
]
|
||||
},
|
||||
...formCreatedUserAndModifiedUser(),
|
||||
{
|
||||
type: 'group',
|
||||
body: [
|
||||
|
||||
@@ -79,7 +79,6 @@ export function userAdministratorRegisterDialog() {
|
||||
{ label: '数据提供方', value: 'PROVIDER' },
|
||||
{ label: '数据使用方', value: 'CUSTOMER' },
|
||||
{ label: '审查监管方', value: 'CHECKER' },
|
||||
{ label: '系统管理员', value: 'ADMINISTRATOR' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -59,8 +59,8 @@ useAmis(information => {
|
||||
tabs: [
|
||||
// tabOverview(),
|
||||
// tabMarket(),
|
||||
tabPermissions(),
|
||||
tabData(),
|
||||
tabPermissions(),
|
||||
tabCheck(),
|
||||
tabUser(),
|
||||
tabSettings(),
|
||||
|
||||
@@ -19,9 +19,6 @@ export function resourceList() {
|
||||
...resourceAddDialog()
|
||||
},
|
||||
],
|
||||
rowSelection: {
|
||||
disableOn: '${confirmationId}',
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
label: '名称',
|
||||
|
||||
@@ -51,32 +51,60 @@ public abstract class SimpleService<ENTITY extends SimpleEntity> {
|
||||
}
|
||||
|
||||
public ImmutableSet<ENTITY> list() {
|
||||
return Sets.immutable.ofAll(repository.findAll());
|
||||
User user = userService.currentLoginUser();
|
||||
return Sets.immutable.ofAll(repository.findAll(
|
||||
(root, query, builder) -> builder.equal(root.get("createdUser"), user)
|
||||
));
|
||||
}
|
||||
|
||||
public ImmutableSet<ENTITY> list(ImmutableSet<Long> ids) {
|
||||
return Sets.immutable.ofAll(repository.findAllById(ids.select(ObjectUtil::isNotNull)));
|
||||
User user = userService.currentLoginUser();
|
||||
return Sets.immutable.ofAll(repository.findAll(
|
||||
(root, query, builder) -> builder.and(
|
||||
builder.in(root.get("id")).value(ids.select(ObjectUtil::isNotNull)),
|
||||
builder.equal(root.get("createdUser"), user)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
public ENTITY detail(Long id) {
|
||||
if (ObjectUtil.isNull(id)) {
|
||||
return null;
|
||||
}
|
||||
return repository.findById(id).orElse(null);
|
||||
User user = userService.currentLoginUser();
|
||||
return repository.findOne(
|
||||
(root, query, builder) -> builder.and(
|
||||
builder.equal(root.get("id"), id),
|
||||
builder.equal(root.get("createdUser"), user)
|
||||
)
|
||||
)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public Optional<ENTITY> detailOptional(Long id) {
|
||||
if (ObjectUtil.isNull(id)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return repository.findById(id);
|
||||
User user = userService.currentLoginUser();
|
||||
return repository.findOne(
|
||||
(root, query, builder) -> builder.and(
|
||||
builder.equal(root.get("id"), id),
|
||||
builder.equal(root.get("createdUser"), user)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public ENTITY detailOrThrow(Long id) {
|
||||
if (ObjectUtil.isNull(id)) {
|
||||
throw new IdNotFoundException(id);
|
||||
}
|
||||
return repository.findById(id).orElseThrow(() -> new IdNotFoundException(id));
|
||||
User user = userService.currentLoginUser();
|
||||
return repository.findOne(
|
||||
(root, query, builder) -> builder.and(
|
||||
builder.equal(root.get("id"), id),
|
||||
builder.equal(root.get("createdUser"), user)
|
||||
)
|
||||
).orElseThrow(() -> new IdNotFoundException(id));
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
|
||||
@@ -2,9 +2,11 @@ package com.eshore.gringotts.web.domain.confirmation.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.user.entity.User;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import javax.transaction.Transactional;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
@@ -19,16 +21,16 @@ import org.springframework.stereotype.Repository;
|
||||
public interface ConfirmationRepository extends SimpleRepository<Confirmation, Long> {
|
||||
@Override
|
||||
@EntityGraph(value = "confirmation.list", type = EntityGraph.EntityGraphType.FETCH)
|
||||
List<Confirmation> findAll();
|
||||
List<Confirmation> findAll(Specification<Confirmation> specification);
|
||||
|
||||
@Override
|
||||
@EntityGraph(value = "confirmation.detail", type = EntityGraph.EntityGraphType.FETCH)
|
||||
Optional<Confirmation> findById(Long id);
|
||||
Optional<Confirmation> findOne(Specification<Confirmation> specification);
|
||||
|
||||
Boolean existsByTarget_Id(Long id);
|
||||
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query("update Confirmation confirmation set confirmation.state = ?2 where confirmation.id = ?1")
|
||||
void updateStateById(Long id, Confirmation.State state);
|
||||
@Query("update Confirmation confirmation set confirmation.state = ?2, confirmation.modifiedUser = ?3 where confirmation.id = ?1")
|
||||
void updateStateById(Long id, Confirmation.State state, User modifiedUser);
|
||||
}
|
||||
|
||||
@@ -15,10 +15,12 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class ConfirmationService extends SimpleService<Confirmation> {
|
||||
private final ConfirmationRepository confirmationRepository;
|
||||
private final UserService userService;
|
||||
|
||||
public ConfirmationService(ConfirmationRepository confirmationRepository, UserService userService) {
|
||||
super(confirmationRepository, userService);
|
||||
this.confirmationRepository = confirmationRepository;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,11 +32,11 @@ public class ConfirmationService extends SimpleService<Confirmation> {
|
||||
}
|
||||
|
||||
public void submit(Long id) {
|
||||
confirmationRepository.updateStateById(id, Confirmation.State.CHECKING);
|
||||
confirmationRepository.updateStateById(id, Confirmation.State.CHECKING, userService.currentLoginUser());
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.DataResource;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -12,9 +13,9 @@ import org.springframework.stereotype.Repository;
|
||||
public interface DataResourceRepository extends SimpleRepository<DataResource, Long> {
|
||||
@Override
|
||||
@EntityGraph(value = "data_resource.list", type = EntityGraph.EntityGraphType.FETCH)
|
||||
List<DataResource> findAll();
|
||||
List<DataResource> findAll(Specification<DataResource> specification);
|
||||
|
||||
@Override
|
||||
@EntityGraph(value = "data_resource.detail", type = EntityGraph.EntityGraphType.FETCH)
|
||||
Optional<DataResource> findById(Long id);
|
||||
Optional<DataResource> findOne(Specification<DataResource> specification);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user