feat:额外返回审核标记
This commit is contained in:
parent
58395fad39
commit
b08fab9c4a
@ -71,7 +71,8 @@ public class ApprovalController {
|
||||
*/
|
||||
@PostMapping("submit")
|
||||
public Mono<Result<ApprovalDomain>> submit(@Valid @RequestBody ApprovalSubmitDto body) {
|
||||
return moduleDelegateService.submit(body).map(Result::ok);
|
||||
return moduleDelegateService.submit(body).map(Result::ok)
|
||||
.onErrorResume(e -> Mono.just(Result.error(e.getMessage())));
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,7 +4,8 @@ import com.flyfish.framework.annotations.EnumValue;
|
||||
import com.flyfish.framework.annotations.Order;
|
||||
import com.flyfish.framework.annotations.Property;
|
||||
import com.flyfish.framework.approval.enums.ApproveStatus;
|
||||
import com.flyfish.framework.domain.authorized.AuthorizedDomain;
|
||||
import com.flyfish.framework.builder.CriteriaBuilder;
|
||||
import com.flyfish.framework.domain.authorized.AuthorizedQo;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@ -15,10 +16,15 @@ import lombok.Setter;
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApprovalDomainQo extends AuthorizedDomain {
|
||||
public class ApprovalDomainQo<T extends ApprovalDomain> extends AuthorizedQo<T> {
|
||||
|
||||
@Property("审批状态")
|
||||
@Order(50)
|
||||
@EnumValue(ApproveStatus.class)
|
||||
private String status;
|
||||
|
||||
@Override
|
||||
public CriteriaBuilder<T> criteriaBuilder() {
|
||||
return super.criteriaBuilder().with("status", "approveStatus");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
package com.flyfish.framework.approval.domain;
|
||||
|
||||
import com.flyfish.framework.approval.enums.ApproveStatus;
|
||||
import com.flyfish.framework.domain.base.Vo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 包装的审批实体
|
||||
*
|
||||
* @author wangyu
|
||||
*/
|
||||
@Data
|
||||
public abstract class ApprovalDomainVo<T extends ApprovalDomain> implements Vo<T> {
|
||||
|
||||
// 审批状态
|
||||
private String approveStatusName;
|
||||
// 审批状态编码
|
||||
private String approveStatus;
|
||||
// 下一审批人
|
||||
private String nextApprover;
|
||||
|
||||
@Override
|
||||
public Vo<T> from(T po) {
|
||||
this.setApproveStatusName(Optional.ofNullable(po.getApproveStatus()).map(ApproveStatus::getName)
|
||||
.orElse(ApproveStatus.DRAFT.getName()));
|
||||
this.setApproveStatus(Optional.ofNullable(po.getApproveStatus()).map(ApproveStatus::name)
|
||||
.orElse(ApproveStatus.DRAFT.name()));
|
||||
if (po.getNext() != -1) {
|
||||
this.setNextApprover(po.getApprovers().get(po.getNext()));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
@ -10,14 +10,17 @@ import com.flyfish.framework.beans.meta.RestBean;
|
||||
import com.flyfish.framework.domain.base.DomainService;
|
||||
import com.flyfish.framework.exception.biz.InvalidBusinessException;
|
||||
import com.flyfish.framework.service.BaseReactiveService;
|
||||
import com.flyfish.framework.utils.ReflectionUtils;
|
||||
import org.apache.commons.lang3.ClassUtils;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.data.util.CastUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
@ -37,9 +40,14 @@ public class ModuleDelegateService {
|
||||
// 审批的服务们
|
||||
private Map<String, BaseReactiveService<ApprovalDomain>> approvalServices;
|
||||
|
||||
@Autowired(required = false)
|
||||
public void setApprovalServices(List<BaseReactiveService<ApprovalDomain>> services) {
|
||||
@Autowired
|
||||
@SuppressWarnings("all")
|
||||
public void setApprovalServices(ObjectProvider<BaseReactiveService> services) {
|
||||
this.approvalServices = services.stream()
|
||||
.filter(service -> ReflectionUtils.getGenericType(service.getClass())
|
||||
.map(clazz -> ClassUtils.isAssignable(clazz, ApprovalDomain.class))
|
||||
.orElse(false))
|
||||
.map(service -> (BaseReactiveService<ApprovalDomain>) service)
|
||||
.collect(Collectors.toMap(DomainService::getCollectionName, s -> s));
|
||||
}
|
||||
|
||||
@ -50,7 +58,7 @@ public class ModuleDelegateService {
|
||||
* @return 结果
|
||||
*/
|
||||
public BaseReactiveService<ApprovalDomain> getService(String module) {
|
||||
return approvalServices.get(module);
|
||||
return CastUtils.cast(approvalServices.get(module));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,6 +158,9 @@ public class ModuleDelegateService {
|
||||
BaseReactiveService<ApprovalDomain> service = getService(data.getModule());
|
||||
return service.getById(data.getId())
|
||||
.flatMap(domain -> {
|
||||
if (ApproveStatus.DRAFT != domain.getApproveStatus() && ApproveStatus.REJECTED != domain.getApproveStatus()) {
|
||||
return Mono.error(new InvalidBusinessException("该数据已经提交审批,请勿重复提交!"));
|
||||
}
|
||||
domain.setApprovers(data.getApprovers());
|
||||
domain.setApproveStatus(ApproveStatus.PENDING);
|
||||
domain.setNext(0);
|
||||
|
@ -74,7 +74,7 @@ public class BeanController {
|
||||
BeanInfo info = new BeanInfo();
|
||||
if (clazz.isAnnotationPresent(RestBean.class)) {
|
||||
RestBean annotation = clazz.getAnnotation(RestBean.class);
|
||||
info.setType(clazz.getSuperclass().getSimpleName());
|
||||
info.setSuperType(clazz.getSuperclass().getSimpleName());
|
||||
info.setName(annotation.name());
|
||||
info.setCode(annotation.value());
|
||||
info.setSearch(BeanProperty.from(annotation.queryClass()));
|
||||
|
@ -23,6 +23,9 @@ public class BeanInfo {
|
||||
// bean的类型
|
||||
private String type;
|
||||
|
||||
// 父类
|
||||
private String superType;
|
||||
|
||||
// 默认layout
|
||||
private String layout;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user