Compare commits
34 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f0cd788587 | ||
|
0d4dc1e63d | ||
|
cf026e8939 | ||
|
6f7bb3cbea | ||
|
9be28a426b | ||
|
73891dca70 | ||
|
39fe3ace5d | ||
|
ffd026c421 | ||
70fffa0f06 | |||
59ab17aa0c | |||
0cf030a57a | |||
|
ea79cc5ae4 | ||
|
a0417f6409 | ||
|
7ac9fdd8e3 | ||
|
dce7f7a63f | ||
|
eb4b732416 | ||
|
764d25f15c | ||
|
3bd0119fbf | ||
|
a2ebeb1526 | ||
|
67db4da315 | ||
|
58bdc3276b | ||
|
1669aa5f7a | ||
|
9a6fbb6c1a | ||
|
e2ec8874f5 | ||
|
b9028c3aa5 | ||
|
95e5b1800a | ||
|
20beef41a4 | ||
|
1a0adaa97b | ||
|
ac3ac3b68d | ||
|
b184f27e5a | ||
|
c894278022 | ||
|
5058f4e19c | ||
|
7fcd7c6e02 | ||
|
274febda39 |
@ -4,7 +4,7 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>flyfish-framework</artifactId>
|
||||
<groupId>com.flyfish.framework</groupId>
|
||||
<groupId>dev.flyfish.framework</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@ -12,8 +12,8 @@
|
||||
<artifactId>flyfish-approval</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -28,7 +28,7 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.flyfish.framework</groupId>
|
||||
<groupId>dev.flyfish.framework</groupId>
|
||||
<artifactId>flyfish-web</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
@ -1,11 +0,0 @@
|
||||
package com.flyfish.framework.approval.repository;
|
||||
|
||||
import com.flyfish.framework.approval.domain.record.ApproveRecord;
|
||||
import com.flyfish.framework.repository.DefaultReactiveRepository;
|
||||
|
||||
/**
|
||||
* 审批记录仓库
|
||||
* @author wangyu
|
||||
*/
|
||||
public interface ApproveRecordRepository extends DefaultReactiveRepository<ApproveRecord> {
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.flyfish.framework.approval.auditor;
|
||||
package dev.flyfish.framework.approval.auditor;
|
||||
|
||||
import com.flyfish.framework.approval.domain.ApprovalDomain;
|
||||
import com.flyfish.framework.approval.enums.ApproveStatus;
|
||||
import com.flyfish.framework.auditor.ReactiveBeanAuditor;
|
||||
import dev.flyfish.framework.approval.domain.ApprovalDomain;
|
||||
import dev.flyfish.framework.approval.enums.ApproveStatus;
|
||||
import dev.flyfish.framework.auditor.ReactiveBeanAuditor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.flyfish.framework.approval.auditor;
|
||||
package dev.flyfish.framework.approval.auditor;
|
||||
|
||||
import com.flyfish.framework.approval.domain.record.ApproveRecord;
|
||||
import com.flyfish.framework.auditor.ReactiveBeanAuditor;
|
||||
import dev.flyfish.framework.approval.domain.record.ApproveRecord;
|
||||
import dev.flyfish.framework.auditor.ReactiveBeanAuditor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
@ -1,24 +1,24 @@
|
||||
package com.flyfish.framework.approval.controller;
|
||||
package dev.flyfish.framework.approval.controller;
|
||||
|
||||
import com.flyfish.framework.approval.domain.ApprovalDomain;
|
||||
import com.flyfish.framework.approval.domain.record.ApproveRecord;
|
||||
import com.flyfish.framework.approval.domain.record.ApproveRecordListVo;
|
||||
import com.flyfish.framework.approval.domain.record.ApproveRecordQo;
|
||||
import com.flyfish.framework.approval.domain.submit.ApprovalSubmitDto;
|
||||
import com.flyfish.framework.approval.domain.todo.ApprovalDto;
|
||||
import com.flyfish.framework.approval.domain.todo.ApprovalListVo;
|
||||
import com.flyfish.framework.approval.service.ApproveRecordService;
|
||||
import com.flyfish.framework.approval.service.ModuleDelegateService;
|
||||
import com.flyfish.framework.bean.Result;
|
||||
import com.flyfish.framework.configuration.annotations.CurrentUser;
|
||||
import com.flyfish.framework.configuration.annotations.PagedQuery;
|
||||
import com.flyfish.framework.domain.base.Vo;
|
||||
import com.flyfish.framework.domain.po.User;
|
||||
import dev.flyfish.framework.approval.domain.ApprovalDomain;
|
||||
import dev.flyfish.framework.approval.domain.record.ApproveRecord;
|
||||
import dev.flyfish.framework.approval.domain.record.ApproveRecordListVo;
|
||||
import dev.flyfish.framework.approval.domain.record.ApproveRecordQo;
|
||||
import dev.flyfish.framework.approval.domain.submit.ApprovalSubmitDto;
|
||||
import dev.flyfish.framework.approval.domain.todo.ApprovalDto;
|
||||
import dev.flyfish.framework.approval.domain.todo.ApprovalListVo;
|
||||
import dev.flyfish.framework.approval.service.ApproveRecordService;
|
||||
import dev.flyfish.framework.approval.service.ModuleDelegateService;
|
||||
import dev.flyfish.framework.bean.Result;
|
||||
import dev.flyfish.framework.configuration.annotations.CurrentUser;
|
||||
import dev.flyfish.framework.configuration.annotations.PagedQuery;
|
||||
import dev.flyfish.framework.domain.base.Vo;
|
||||
import dev.flyfish.framework.domain.po.User;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
@ -1,8 +1,8 @@
|
||||
package com.flyfish.framework.approval.controller;
|
||||
package dev.flyfish.framework.approval.controller;
|
||||
|
||||
import com.flyfish.framework.approval.domain.record.ApproveRecord;
|
||||
import com.flyfish.framework.approval.domain.record.ApproveRecordQo;
|
||||
import com.flyfish.framework.controller.reactive.ReactiveBaseController;
|
||||
import dev.flyfish.framework.approval.domain.record.ApproveRecord;
|
||||
import dev.flyfish.framework.approval.domain.record.ApproveRecordQo;
|
||||
import dev.flyfish.framework.controller.reactive.ReactiveBaseController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.flyfish.framework.approval.domain;
|
||||
package dev.flyfish.framework.approval.domain;
|
||||
|
||||
import com.flyfish.framework.annotations.Property;
|
||||
import com.flyfish.framework.approval.enums.ApproveStatus;
|
||||
import com.flyfish.framework.domain.authorized.AuthorizedDomain;
|
||||
import dev.flyfish.framework.annotations.Property;
|
||||
import dev.flyfish.framework.approval.enums.ApproveStatus;
|
||||
import dev.flyfish.framework.domain.authorized.AuthorizedDomain;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.flyfish.framework.approval.domain;
|
||||
package dev.flyfish.framework.approval.domain;
|
||||
|
||||
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.AuthorizedQo;
|
||||
import com.flyfish.framework.query.QueryDefinition;
|
||||
import dev.flyfish.framework.annotations.EnumValue;
|
||||
import dev.flyfish.framework.annotations.Order;
|
||||
import dev.flyfish.framework.annotations.Property;
|
||||
import dev.flyfish.framework.approval.enums.ApproveStatus;
|
||||
import dev.flyfish.framework.domain.authorized.AuthorizedQo;
|
||||
import dev.flyfish.framework.query.QueryDefinition;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.flyfish.framework.approval.domain;
|
||||
package dev.flyfish.framework.approval.domain;
|
||||
|
||||
import com.flyfish.framework.approval.enums.ApproveStatus;
|
||||
import com.flyfish.framework.domain.base.Vo;
|
||||
import dev.flyfish.framework.approval.enums.ApproveStatus;
|
||||
import dev.flyfish.framework.domain.base.Vo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Optional;
|
@ -1,20 +1,18 @@
|
||||
package com.flyfish.framework.approval.domain.record;
|
||||
package dev.flyfish.framework.approval.domain.record;
|
||||
|
||||
import com.flyfish.framework.approval.enums.ApproveAction;
|
||||
import com.flyfish.framework.domain.base.AuditDomain;
|
||||
import dev.flyfish.framework.annotations.Entity;
|
||||
import dev.flyfish.framework.annotations.Property;
|
||||
import dev.flyfish.framework.approval.enums.ApproveAction;
|
||||
import dev.flyfish.framework.domain.base.AuditDomain;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
/**
|
||||
* 审批记录
|
||||
*
|
||||
* @author wangyu
|
||||
*/
|
||||
@Document(collection = "approve-records")
|
||||
@Table("t_approve_records")
|
||||
@Entity(table = "t_approve_records", collection = "approve-records")
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApproveRecord extends AuditDomain {
|
||||
@ -26,11 +24,11 @@ public class ApproveRecord extends AuditDomain {
|
||||
private String module;
|
||||
|
||||
// 模块名称
|
||||
@Column("module_name")
|
||||
@Property(column = "module_name")
|
||||
private String moduleName;
|
||||
|
||||
// 数据id
|
||||
@Column("data_id")
|
||||
@Property(column = "data_id")
|
||||
private String dataId;
|
||||
|
||||
// 审批人
|
@ -1,12 +1,11 @@
|
||||
package com.flyfish.framework.approval.domain.record;
|
||||
package dev.flyfish.framework.approval.domain.record;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.flyfish.framework.approval.enums.ApproveAction;
|
||||
import com.flyfish.framework.domain.base.Vo;
|
||||
import dev.flyfish.framework.approval.enums.ApproveAction;
|
||||
import dev.flyfish.framework.domain.base.Vo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
@ -1,7 +1,7 @@
|
||||
package com.flyfish.framework.approval.domain.record;
|
||||
package dev.flyfish.framework.approval.domain.record;
|
||||
|
||||
import com.flyfish.framework.domain.base.NameLikeQo;
|
||||
import com.flyfish.framework.query.QueryDefinition;
|
||||
import dev.flyfish.framework.domain.base.NameLikeQo;
|
||||
import dev.flyfish.framework.query.QueryDefinition;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.flyfish.framework.approval.domain.submit;
|
||||
package dev.flyfish.framework.approval.domain.submit;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
@ -1,10 +1,10 @@
|
||||
package com.flyfish.framework.approval.domain.todo;
|
||||
package dev.flyfish.framework.approval.domain.todo;
|
||||
|
||||
import com.flyfish.framework.approval.enums.ApproveAction;
|
||||
import dev.flyfish.framework.approval.enums.ApproveAction;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 审批dto
|
@ -1,12 +1,11 @@
|
||||
package com.flyfish.framework.approval.domain.todo;
|
||||
package dev.flyfish.framework.approval.domain.todo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.flyfish.framework.approval.domain.record.ApproveRecord;
|
||||
import com.flyfish.framework.domain.base.Vo;
|
||||
import dev.flyfish.framework.approval.domain.record.ApproveRecord;
|
||||
import dev.flyfish.framework.domain.base.Vo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 待审批列表vo
|
@ -1,6 +1,6 @@
|
||||
package com.flyfish.framework.approval.enums;
|
||||
package dev.flyfish.framework.approval.enums;
|
||||
|
||||
import com.flyfish.framework.enums.NamedEnum;
|
||||
import dev.flyfish.framework.enums.NamedEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.flyfish.framework.approval.enums;
|
||||
package dev.flyfish.framework.approval.enums;
|
||||
|
||||
import com.flyfish.framework.enums.NamedEnum;
|
||||
import dev.flyfish.framework.enums.NamedEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
@ -0,0 +1,11 @@
|
||||
package dev.flyfish.framework.approval.repository;
|
||||
|
||||
import dev.flyfish.framework.approval.domain.record.ApproveRecord;
|
||||
import dev.flyfish.framework.repository.DefaultReactiveRepository;
|
||||
|
||||
/**
|
||||
* 审批记录仓库
|
||||
* @author wangyu
|
||||
*/
|
||||
public interface ApproveRecordRepository extends DefaultReactiveRepository<ApproveRecord> {
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.flyfish.framework.approval.service;
|
||||
package dev.flyfish.framework.approval.service;
|
||||
|
||||
import com.flyfish.framework.approval.domain.record.ApproveRecord;
|
||||
import com.flyfish.framework.service.impl.BaseReactiveServiceImpl;
|
||||
import dev.flyfish.framework.approval.domain.record.ApproveRecord;
|
||||
import dev.flyfish.framework.service.impl.BaseReactiveServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
@ -1,15 +1,15 @@
|
||||
package com.flyfish.framework.approval.service;
|
||||
package dev.flyfish.framework.approval.service;
|
||||
|
||||
import com.flyfish.framework.approval.domain.ApprovalDomain;
|
||||
import com.flyfish.framework.approval.domain.record.ApproveRecord;
|
||||
import com.flyfish.framework.approval.domain.submit.ApprovalSubmitDto;
|
||||
import com.flyfish.framework.approval.domain.todo.ApprovalDto;
|
||||
import com.flyfish.framework.approval.enums.ApproveAction;
|
||||
import com.flyfish.framework.approval.enums.ApproveStatus;
|
||||
import com.flyfish.framework.beans.meta.RestBean;
|
||||
import com.flyfish.framework.exception.biz.InvalidBusinessException;
|
||||
import com.flyfish.framework.service.BaseReactiveService;
|
||||
import com.flyfish.framework.utils.ReflectionUtils;
|
||||
import dev.flyfish.framework.approval.domain.ApprovalDomain;
|
||||
import dev.flyfish.framework.approval.domain.record.ApproveRecord;
|
||||
import dev.flyfish.framework.approval.domain.submit.ApprovalSubmitDto;
|
||||
import dev.flyfish.framework.approval.domain.todo.ApprovalDto;
|
||||
import dev.flyfish.framework.approval.enums.ApproveAction;
|
||||
import dev.flyfish.framework.approval.enums.ApproveStatus;
|
||||
import dev.flyfish.framework.beans.meta.RestBean;
|
||||
import dev.flyfish.framework.exception.biz.InvalidBusinessException;
|
||||
import dev.flyfish.framework.service.BaseReactiveService;
|
||||
import dev.flyfish.framework.utils.ReflectionUtils;
|
||||
import org.apache.commons.lang3.ClassUtils;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -19,7 +19,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
@ -4,7 +4,7 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>flyfish-framework</artifactId>
|
||||
<groupId>com.flyfish.framework</groupId>
|
||||
<groupId>dev.flyfish.framework</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@ -12,8 +12,8 @@
|
||||
<artifactId>flyfish-backup</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -28,7 +28,7 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.flyfish.framework</groupId>
|
||||
<groupId>dev.flyfish.framework</groupId>
|
||||
<artifactId>flyfish-web</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
@ -1,12 +0,0 @@
|
||||
package com.flyfish.framework.backup.repository;
|
||||
|
||||
import com.flyfish.framework.backup.domain.Backup;
|
||||
import com.flyfish.framework.repository.DefaultReactiveRepository;
|
||||
|
||||
/**
|
||||
* 备份仓库
|
||||
*
|
||||
* @author wangyu
|
||||
*/
|
||||
public interface BackupRepository extends DefaultReactiveRepository<Backup> {
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.backup.config;
|
||||
package dev.flyfish.framework.backup.config;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.backup.config;
|
||||
package dev.flyfish.framework.backup.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
@ -1,15 +1,15 @@
|
||||
package com.flyfish.framework.backup.controller;
|
||||
package dev.flyfish.framework.backup.controller;
|
||||
|
||||
import com.flyfish.framework.backup.domain.Backup;
|
||||
import com.flyfish.framework.backup.scheduler.BackupScheduler;
|
||||
import com.flyfish.framework.bean.Result;
|
||||
import com.flyfish.framework.controller.reactive.ReactiveBaseController;
|
||||
import com.flyfish.framework.domain.base.NameLikeQo;
|
||||
import dev.flyfish.framework.backup.domain.Backup;
|
||||
import dev.flyfish.framework.backup.scheduler.BackupScheduler;
|
||||
import dev.flyfish.framework.bean.Result;
|
||||
import dev.flyfish.framework.controller.reactive.ReactiveBaseController;
|
||||
import dev.flyfish.framework.domain.base.NameLikeQo;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 备份controller
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.backup.controller;
|
||||
package dev.flyfish.framework.backup.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
@ -1,12 +1,11 @@
|
||||
package com.flyfish.framework.backup.domain;
|
||||
package dev.flyfish.framework.backup.domain;
|
||||
|
||||
import com.flyfish.framework.domain.base.AuditDomain;
|
||||
import com.flyfish.framework.enums.NamedEnum;
|
||||
import dev.flyfish.framework.annotations.Entity;
|
||||
import dev.flyfish.framework.domain.base.AuditDomain;
|
||||
import dev.flyfish.framework.enums.NamedEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
/**
|
||||
* 系统备份
|
||||
@ -15,8 +14,7 @@ import org.springframework.data.relational.core.mapping.Table;
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Document(collection = "backups")
|
||||
@Table("t_backup")
|
||||
@Entity(collection = "backups", table = "t_backup")
|
||||
public class Backup extends AuditDomain {
|
||||
|
||||
// 文件路径
|
@ -1,6 +1,6 @@
|
||||
package com.flyfish.framework.backup.domain;
|
||||
package dev.flyfish.framework.backup.domain;
|
||||
|
||||
import com.flyfish.framework.annotations.Property;
|
||||
import dev.flyfish.framework.annotations.Property;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
@ -0,0 +1,12 @@
|
||||
package dev.flyfish.framework.backup.repository;
|
||||
|
||||
import dev.flyfish.framework.backup.domain.Backup;
|
||||
import dev.flyfish.framework.repository.DefaultReactiveRepository;
|
||||
|
||||
/**
|
||||
* 备份仓库
|
||||
*
|
||||
* @author wangyu
|
||||
*/
|
||||
public interface BackupRepository extends DefaultReactiveRepository<Backup> {
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.backup.scheduler;
|
||||
package dev.flyfish.framework.backup.scheduler;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
@ -1,11 +1,11 @@
|
||||
package com.flyfish.framework.backup.scheduler;
|
||||
package dev.flyfish.framework.backup.scheduler;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.flyfish.framework.backup.domain.Backup;
|
||||
import com.flyfish.framework.context.DateContext;
|
||||
import com.flyfish.framework.domain.base.DomainService;
|
||||
import com.flyfish.framework.query.Query;
|
||||
import com.flyfish.framework.repository.ReactiveEntityOperations;
|
||||
import dev.flyfish.framework.backup.domain.Backup;
|
||||
import dev.flyfish.framework.context.DateContext;
|
||||
import dev.flyfish.framework.domain.base.DomainService;
|
||||
import dev.flyfish.framework.query.Query;
|
||||
import dev.flyfish.framework.repository.ReactiveEntityOperations;
|
||||
import dev.flyfish.framework.utils.JacksonUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -95,7 +95,7 @@ public class BackupScheduler {
|
||||
.thenMany(Flux.fromIterable(this.collections))
|
||||
.flatMap(info -> operations
|
||||
.findAll(Query.empty(), CastUtils.cast(info)).collectList()
|
||||
.map(list -> new BackupIndex.BackupContent(info.getJavaType().getSimpleName(), JSON.toJSONBytes(list)))
|
||||
.map(list -> new BackupIndex.BackupContent(info.getJavaType().getSimpleName(), JacksonUtil.toBytes(list)))
|
||||
)
|
||||
.flatMap(content -> writeContents(content, parent))
|
||||
.collectList()
|
||||
@ -113,7 +113,7 @@ public class BackupScheduler {
|
||||
return item;
|
||||
}).collect(Collectors.toList()));
|
||||
// 写入备份结果
|
||||
return write(JSON.toJSONBytes(index), parent + "/meta.json");
|
||||
return write(JacksonUtil.toBytes(index), parent + "/meta.json");
|
||||
})
|
||||
.then(Mono.defer(() -> {
|
||||
backup.setLog("成功备份");
|
@ -1,7 +1,7 @@
|
||||
package com.flyfish.framework.backup.service;
|
||||
package dev.flyfish.framework.backup.service;
|
||||
|
||||
import com.flyfish.framework.backup.domain.Backup;
|
||||
import com.flyfish.framework.service.impl.BaseReactiveServiceImpl;
|
||||
import dev.flyfish.framework.backup.domain.Backup;
|
||||
import dev.flyfish.framework.service.impl.BaseReactiveServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.flyfish.framework.backup.service;
|
||||
package dev.flyfish.framework.backup.service;
|
||||
|
||||
import com.flyfish.framework.backup.config.VersionProperties;
|
||||
import com.flyfish.framework.backup.domain.Version;
|
||||
import org.springframework.stereotype.Service;
|
||||
import dev.flyfish.framework.backup.config.VersionProperties;
|
||||
import dev.flyfish.framework.backup.domain.Version;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
28
flyfish-bean/pom.xml
Normal file
28
flyfish-bean/pom.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>dev.flyfish.framework</groupId>
|
||||
<artifactId>flyfish-framework</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>flyfish-bean</artifactId>
|
||||
<name>flyfish-parser</name>
|
||||
<description>飞鱼解析器</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1 @@
|
||||
package dev.flyfish.framework.beans.enums;
|
@ -0,0 +1 @@
|
||||
package dev.flyfish.framework.beans.meta;
|
@ -1,11 +1,12 @@
|
||||
package com.flyfish.framework.beans.meta.parser;
|
||||
package dev.flyfish.framework.beans.meta.parser;
|
||||
|
||||
import com.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationBatchChain;
|
||||
import com.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationChain;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationBatchChain;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationChain;
|
||||
import org.springframework.core.annotation.MergedAnnotation;
|
||||
import org.springframework.core.annotation.MergedAnnotations;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
|
||||
/**
|
||||
* 基于spring annotations最高级封装
|
||||
@ -17,6 +18,16 @@ import java.lang.annotation.Annotation;
|
||||
*/
|
||||
public interface BeanPropertyAnnotations {
|
||||
|
||||
/**
|
||||
* 来自反射
|
||||
*
|
||||
* @param annotated 字段
|
||||
* @return 结果
|
||||
*/
|
||||
static BeanPropertyAnnotations from(AnnotatedElement annotated) {
|
||||
return new SimpleBeanPropertyAnnotations(annotated);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有某个注解
|
||||
*
|
||||
@ -42,6 +53,15 @@ public interface BeanPropertyAnnotations {
|
||||
*/
|
||||
<A extends Annotation> BeanPropertyAnnotationChain<A, MergedAnnotation<A>> as(Class<A> annotationType);
|
||||
|
||||
/**
|
||||
* 判断某个注解是否存在,存在则交给consumer进行处理,仅取得找到的第一个注解
|
||||
*
|
||||
* @param annotationType 注解类型
|
||||
* @param <A> 泛型
|
||||
* @return 结果
|
||||
*/
|
||||
<A extends Annotation> BeanPropertyAnnotationChain<A, MergedAnnotation<A>> as(String annotationType);
|
||||
|
||||
/**
|
||||
* 判断某个注解是否存在,存在则交给consumer进行处理,取得所有注解并自动判断复数形式
|
||||
*
|
||||
@ -54,6 +74,18 @@ public interface BeanPropertyAnnotations {
|
||||
<A extends Annotation, L extends Annotation> BeanPropertyAnnotationBatchChain<A, MergedAnnotation<A>> as(
|
||||
Class<A> annotationType, Class<L> listType);
|
||||
|
||||
/**
|
||||
* 判断某个注解是否存在,存在则交给consumer进行处理,取得所有注解并自动判断复数形式
|
||||
*
|
||||
* @param annotationType 注解类型
|
||||
* @param listType 列表类型
|
||||
* @param <A> 泛型
|
||||
* @param <L> 列表泛型
|
||||
* @return 结果
|
||||
*/
|
||||
<A extends Annotation, L extends Annotation> BeanPropertyAnnotationBatchChain<A, MergedAnnotation<A>> as(
|
||||
String annotationType, String listType);
|
||||
|
||||
/**
|
||||
* 设置上一步结果
|
||||
*
|
||||
@ -69,6 +101,22 @@ public interface BeanPropertyAnnotations {
|
||||
*/
|
||||
boolean last();
|
||||
|
||||
/**
|
||||
* 设置缓存的值
|
||||
*
|
||||
* @param value 值
|
||||
* @param <T> 值泛型
|
||||
*/
|
||||
<T> BeanPropertyAnnotations value(T value);
|
||||
|
||||
/**
|
||||
* 返回上一步的值
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @return 结果
|
||||
*/
|
||||
<T> T value();
|
||||
|
||||
/**
|
||||
* 返回空的运行链
|
||||
*
|
||||
@ -84,4 +132,17 @@ public interface BeanPropertyAnnotations {
|
||||
* @return 结果
|
||||
*/
|
||||
<A extends Annotation, E> BeanPropertyAnnotationBatchChain<A, E> batchEmpty();
|
||||
|
||||
/**
|
||||
* 强制类型转换
|
||||
*
|
||||
* @param bean 入参
|
||||
* @param <T> 入参泛型
|
||||
* @param <R> 出参泛型
|
||||
* @return 结果
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
static <T, R> R cast(T bean) {
|
||||
return (R) bean;
|
||||
}
|
||||
}
|
@ -1,22 +1,24 @@
|
||||
package com.flyfish.framework.beans.meta.parser;
|
||||
package dev.flyfish.framework.beans.meta.parser;
|
||||
|
||||
import com.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationBatchChain;
|
||||
import com.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationChain;
|
||||
import com.flyfish.framework.beans.meta.parser.chain.impl.EmptyAnnotationBatchChain;
|
||||
import com.flyfish.framework.beans.meta.parser.chain.impl.EmptyAnnotationChain;
|
||||
import com.flyfish.framework.beans.meta.parser.chain.impl.SimpleAnnotationBatchChain;
|
||||
import com.flyfish.framework.beans.meta.parser.chain.impl.SimpleAnnotationChain;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationBatchChain;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationChain;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.impl.EmptyAnnotationBatchChain;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.impl.EmptyAnnotationChain;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.impl.SimpleAnnotationBatchChain;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.impl.SimpleAnnotationChain;
|
||||
import org.springframework.core.annotation.MergedAnnotation;
|
||||
import org.springframework.core.annotation.MergedAnnotations;
|
||||
import org.springframework.data.util.CastUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations.cast;
|
||||
|
||||
/**
|
||||
* bean属性注解容器
|
||||
*
|
||||
@ -24,14 +26,15 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class SimpleBeanPropertyAnnotations implements BeanPropertyAnnotations {
|
||||
|
||||
private final Field field;
|
||||
private final AnnotatedElement field;
|
||||
|
||||
private final MergedAnnotations annotations;
|
||||
private final EmptyAnnotationChain<? extends Annotation, ?> emptyChain = new EmptyAnnotationChain<>(this);
|
||||
private final EmptyAnnotationBatchChain<? extends Annotation, ?> emptyBatchChain = new EmptyAnnotationBatchChain<>(this);
|
||||
private boolean last;
|
||||
private Object value;
|
||||
|
||||
public SimpleBeanPropertyAnnotations(Field field) {
|
||||
SimpleBeanPropertyAnnotations(AnnotatedElement field) {
|
||||
this.field = field;
|
||||
this.annotations = null == field ? MergedAnnotations.from() : MergedAnnotations.from(field);
|
||||
}
|
||||
@ -67,6 +70,7 @@ public class SimpleBeanPropertyAnnotations implements BeanPropertyAnnotations {
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("Duplicates")
|
||||
public <A extends Annotation> BeanPropertyAnnotationChain<A, MergedAnnotation<A>> as(Class<A> annotationType) {
|
||||
if (null != field && !this.last) {
|
||||
MergedAnnotation<A> annotation = this.annotations.get(annotationType);
|
||||
@ -77,6 +81,24 @@ public class SimpleBeanPropertyAnnotations implements BeanPropertyAnnotations {
|
||||
return empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断某个注解是否存在,存在则交给consumer进行处理,仅取得找到的第一个注解
|
||||
*
|
||||
* @param annotationType 注解类型
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("Duplicates")
|
||||
public <A extends Annotation> BeanPropertyAnnotationChain<A, MergedAnnotation<A>> as(String annotationType) {
|
||||
if (null != field && !this.last) {
|
||||
MergedAnnotation<A> annotation = this.annotations.get(annotationType);
|
||||
if (annotation.isPresent()) {
|
||||
return new SimpleAnnotationChain<>(this.last(true), annotation);
|
||||
}
|
||||
}
|
||||
return empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断某个注解是否存在,存在则交给consumer进行处理,取得所有注解并自动判断复数形式
|
||||
*
|
||||
@ -98,7 +120,7 @@ public class SimpleBeanPropertyAnnotations implements BeanPropertyAnnotations {
|
||||
List<MergedAnnotation<A>> values = this.annotations.stream(annotationType)
|
||||
.filter(MergedAnnotation::isPresent)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(values)) {
|
||||
if (!CollectionUtils.isEmpty(values)) {
|
||||
return new SimpleAnnotationBatchChain<>(this.last(true), values);
|
||||
}
|
||||
}
|
||||
@ -106,6 +128,39 @@ public class SimpleBeanPropertyAnnotations implements BeanPropertyAnnotations {
|
||||
return batchEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断某个注解是否存在,存在则交给consumer进行处理,取得所有注解并自动判断复数形式
|
||||
*
|
||||
* @param annotationType 注解类型
|
||||
* @param listType 列表类型
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <A extends Annotation, L extends Annotation> BeanPropertyAnnotationBatchChain<A, MergedAnnotation<A>> as(String annotationType, String listType) {
|
||||
if (null != field && !this.last) {
|
||||
MergedAnnotation<L> annotation = this.annotations.get(listType);
|
||||
// 存在注解容器,读取之
|
||||
if (annotation.isPresent()) {
|
||||
List<MergedAnnotation<A>> picked = annotation.getValue("value")
|
||||
.map(value -> Arrays.asList((MergedAnnotation<A>[]) value))
|
||||
.orElse(Collections.emptyList());
|
||||
if (!CollectionUtils.isEmpty(picked)) {
|
||||
return new SimpleAnnotationBatchChain<>(this.last(true), picked);
|
||||
}
|
||||
}
|
||||
// 不存在或为空,查找直接注解的(大多数是一个)
|
||||
List<MergedAnnotation<A>> values = this.annotations.<A>stream(annotationType)
|
||||
.filter(MergedAnnotation::isPresent)
|
||||
.collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(values)) {
|
||||
return new SimpleAnnotationBatchChain<>(this.last(true), values);
|
||||
}
|
||||
}
|
||||
// 啥也没,返回空
|
||||
return batchEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置上一步结果
|
||||
*
|
||||
@ -128,6 +183,27 @@ public class SimpleBeanPropertyAnnotations implements BeanPropertyAnnotations {
|
||||
return this.last;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置缓存的值
|
||||
*
|
||||
* @param value 值
|
||||
*/
|
||||
@Override
|
||||
public <T> BeanPropertyAnnotations value(T value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回上一步的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public <T> T value() {
|
||||
return cast(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回空的运行链
|
||||
*
|
||||
@ -135,7 +211,7 @@ public class SimpleBeanPropertyAnnotations implements BeanPropertyAnnotations {
|
||||
*/
|
||||
@Override
|
||||
public <A extends Annotation, E> BeanPropertyAnnotationChain<A, E> empty() {
|
||||
return CastUtils.cast(emptyChain);
|
||||
return cast(emptyChain);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,6 +221,6 @@ public class SimpleBeanPropertyAnnotations implements BeanPropertyAnnotations {
|
||||
*/
|
||||
@Override
|
||||
public <A extends Annotation, E> BeanPropertyAnnotationBatchChain<A, E> batchEmpty() {
|
||||
return CastUtils.cast(emptyBatchChain);
|
||||
return cast(emptyBatchChain);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.flyfish.framework.beans.meta.parser.chain;
|
||||
package dev.flyfish.framework.beans.meta.parser.chain;
|
||||
|
||||
import com.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations;
|
||||
import dev.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations;
|
||||
|
||||
/**
|
||||
* 链式支持
|
||||
@ -24,7 +24,16 @@ public interface AnnotationChainSupport {
|
||||
BeanPropertyAnnotations or();
|
||||
|
||||
/**
|
||||
* 主动停止操作,会清空前面的状态
|
||||
* 当前值是否存在
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
void end();
|
||||
boolean isPresent();
|
||||
|
||||
/**
|
||||
* 主动停止操作,会清空前面的状态
|
||||
*
|
||||
* @return 结束状态,true则是以值结束,false以空结束
|
||||
*/
|
||||
boolean end();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.beans.meta.parser.chain;
|
||||
package dev.flyfish.framework.beans.meta.parser.chain;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.List;
|
||||
@ -64,12 +64,19 @@ public interface BeanPropertyAnnotationBatchChain<A extends Annotation, T> exten
|
||||
*/
|
||||
BeanPropertyAnnotationBatchChain<A, T> empty(Runnable fallback);
|
||||
|
||||
/**
|
||||
* 将多值合并为单值
|
||||
*
|
||||
* @param reducer 合并器
|
||||
* @param <R> 返回泛型
|
||||
* @return 结果
|
||||
*/
|
||||
<R> BeanPropertyAnnotationChain<A, R> reduce(Function<List<T>, R> reducer);
|
||||
|
||||
/**
|
||||
* 获取所有结果为list
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
List<A> synthesize();
|
||||
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.beans.meta.parser.chain;
|
||||
package dev.flyfish.framework.beans.meta.parser.chain;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.function.Consumer;
|
||||
@ -70,4 +70,10 @@ public interface BeanPropertyAnnotationChain<A extends Annotation, T> extends An
|
||||
*/
|
||||
A synthesize();
|
||||
|
||||
/**
|
||||
* 获取缓存的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
T get();
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.flyfish.framework.beans.meta.parser.chain.impl;
|
||||
package dev.flyfish.framework.beans.meta.parser.chain.impl;
|
||||
|
||||
import com.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations;
|
||||
import com.flyfish.framework.beans.meta.parser.chain.AnnotationChainSupport;
|
||||
import dev.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.AnnotationChainSupport;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
@ -10,7 +10,7 @@ import lombok.RequiredArgsConstructor;
|
||||
* @author wangyu
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class BasicAnnotationChainSupport implements AnnotationChainSupport {
|
||||
abstract class BasicAnnotationChainSupport implements AnnotationChainSupport {
|
||||
|
||||
// 父级
|
||||
protected final BeanPropertyAnnotations parent;
|
||||
@ -22,7 +22,7 @@ public class BasicAnnotationChainSupport implements AnnotationChainSupport {
|
||||
*/
|
||||
@Override
|
||||
public BeanPropertyAnnotations and() {
|
||||
return parent.last(false);
|
||||
return cache().last(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,14 +32,23 @@ public class BasicAnnotationChainSupport implements AnnotationChainSupport {
|
||||
*/
|
||||
@Override
|
||||
public BeanPropertyAnnotations or() {
|
||||
return parent;
|
||||
return cache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 主动停止操作,会清空前面的状态
|
||||
*/
|
||||
@Override
|
||||
public void end() {
|
||||
parent.last(false);
|
||||
public boolean end() {
|
||||
boolean result = isPresent();
|
||||
parent.last(false).value(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存值逻辑
|
||||
*
|
||||
* @return 父亲
|
||||
*/
|
||||
protected abstract BeanPropertyAnnotations cache();
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.flyfish.framework.beans.meta.parser.chain.impl;
|
||||
package dev.flyfish.framework.beans.meta.parser.chain.impl;
|
||||
|
||||
import com.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations;
|
||||
import com.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationBatchChain;
|
||||
import org.springframework.data.util.CastUtils;
|
||||
import dev.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationBatchChain;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationChain;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Collections;
|
||||
@ -12,6 +12,8 @@ import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static dev.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations.cast;
|
||||
|
||||
/**
|
||||
* 单例的,空实现
|
||||
*
|
||||
@ -32,7 +34,7 @@ public class EmptyAnnotationBatchChain<A extends Annotation, T> extends BasicAnn
|
||||
*/
|
||||
@Override
|
||||
public <R> BeanPropertyAnnotationBatchChain<A, R> map(Function<T, R> mapper) {
|
||||
return CastUtils.cast(this);
|
||||
return cast(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,6 +95,27 @@ public class EmptyAnnotationBatchChain<A extends Annotation, T> extends BasicAnn
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将多值合并为单值
|
||||
*
|
||||
* @param reducer 合并器
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public <R> BeanPropertyAnnotationChain<A, R> reduce(Function<List<T>, R> reducer) {
|
||||
return parent.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否存在值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean isPresent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有结果为list
|
||||
*
|
||||
@ -103,4 +126,14 @@ public class EmptyAnnotationBatchChain<A extends Annotation, T> extends BasicAnn
|
||||
parent.last(false);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存值逻辑
|
||||
*
|
||||
* @return 父亲
|
||||
*/
|
||||
@Override
|
||||
protected BeanPropertyAnnotations cache() {
|
||||
return parent;
|
||||
}
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
package com.flyfish.framework.beans.meta.parser.chain.impl;
|
||||
package dev.flyfish.framework.beans.meta.parser.chain.impl;
|
||||
|
||||
import com.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations;
|
||||
import com.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationChain;
|
||||
import org.springframework.data.util.CastUtils;
|
||||
import dev.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationChain;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.function.Consumer;
|
||||
@ -10,6 +9,8 @@ import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static dev.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations.cast;
|
||||
|
||||
/**
|
||||
* 单例的,空实现
|
||||
*
|
||||
@ -31,7 +32,7 @@ public class EmptyAnnotationChain<A extends Annotation, T> extends BasicAnnotati
|
||||
*/
|
||||
@Override
|
||||
public <R> BeanPropertyAnnotationChain<A, R> map(Function<T, R> mapper) {
|
||||
return CastUtils.cast(this);
|
||||
return cast(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,6 +65,7 @@ public class EmptyAnnotationChain<A extends Annotation, T> extends BasicAnnotati
|
||||
*/
|
||||
@Override
|
||||
public BeanPropertyAnnotationChain<A, T> then(Consumer<T> consumer) {
|
||||
markParent();
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -75,6 +77,7 @@ public class EmptyAnnotationChain<A extends Annotation, T> extends BasicAnnotati
|
||||
*/
|
||||
@Override
|
||||
public BeanPropertyAnnotationChain<A, T> exists(Runnable handler) {
|
||||
markParent();
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -92,6 +95,16 @@ public class EmptyAnnotationChain<A extends Annotation, T> extends BasicAnnotati
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前值是否存在
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean isPresent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接获取结果
|
||||
*
|
||||
@ -101,4 +114,36 @@ public class EmptyAnnotationChain<A extends Annotation, T> extends BasicAnnotati
|
||||
public A synthesize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前数据
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public T get() {
|
||||
// 从空的占位访问,访问上次的结果
|
||||
return parent.value();
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存值逻辑
|
||||
*
|
||||
* @return 父亲
|
||||
*/
|
||||
@Override
|
||||
protected BeanPropertyAnnotations cache() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 需要判定之前的值。当我们进入空链,且调用了then,
|
||||
* 代表在没值的时候下次尝试用or时仍可获取值(and总是成立)
|
||||
*/
|
||||
private void markParent() {
|
||||
// 当且仅当链上没有值,才尝试置为false,供后续使用
|
||||
if (null == parent.value()) {
|
||||
parent.last(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package com.flyfish.framework.beans.meta.parser.chain.impl;
|
||||
package dev.flyfish.framework.beans.meta.parser.chain.impl;
|
||||
|
||||
import com.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations;
|
||||
import com.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationBatchChain;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import dev.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationBatchChain;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationChain;
|
||||
import org.springframework.core.annotation.MergedAnnotation;
|
||||
import org.springframework.data.util.CastUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Collections;
|
||||
@ -16,6 +16,8 @@ import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations.cast;
|
||||
|
||||
/**
|
||||
* 简单的批量注解链式实现
|
||||
*
|
||||
@ -50,8 +52,8 @@ public class SimpleAnnotationBatchChain<A extends Annotation, T> extends BasicAn
|
||||
return parent.batchEmpty();
|
||||
}
|
||||
this.mapped = true;
|
||||
this.values = CastUtils.cast(list);
|
||||
return CastUtils.cast(this);
|
||||
this.values = cast(list);
|
||||
return cast(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,6 +122,28 @@ public class SimpleAnnotationBatchChain<A extends Annotation, T> extends BasicAn
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将多值合并为单值
|
||||
*
|
||||
* @param reducer 合并器
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public <R> BeanPropertyAnnotationChain<A, R> reduce(Function<List<T>, R> reducer) {
|
||||
R reduced = reducer.apply(values);
|
||||
return new SimpleAnnotationChain<>(parent, reduced);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否存在值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean isPresent() {
|
||||
return !CollectionUtils.isEmpty(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有结果为list
|
||||
*
|
||||
@ -131,4 +155,14 @@ public class SimpleAnnotationBatchChain<A extends Annotation, T> extends BasicAn
|
||||
return mapped ? Collections.emptyList() : this.values.stream().map(item -> (MergedAnnotation<A>) item)
|
||||
.map(MergedAnnotation::synthesize).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存值逻辑
|
||||
*
|
||||
* @return 父亲
|
||||
*/
|
||||
@Override
|
||||
protected BeanPropertyAnnotations cache() {
|
||||
return parent.value(values);
|
||||
}
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
package com.flyfish.framework.beans.meta.parser.chain.impl;
|
||||
package dev.flyfish.framework.beans.meta.parser.chain.impl;
|
||||
|
||||
import com.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations;
|
||||
import com.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationChain;
|
||||
import dev.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations;
|
||||
import dev.flyfish.framework.beans.meta.parser.chain.BeanPropertyAnnotationChain;
|
||||
import org.springframework.core.annotation.MergedAnnotation;
|
||||
import org.springframework.data.util.CastUtils;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.function.Consumer;
|
||||
@ -11,6 +10,8 @@ import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static dev.flyfish.framework.beans.meta.parser.BeanPropertyAnnotations.cast;
|
||||
|
||||
/**
|
||||
* 简单的注解链
|
||||
*
|
||||
@ -40,8 +41,8 @@ public class SimpleAnnotationChain<A extends Annotation, T> extends BasicAnnotat
|
||||
if (null == value) {
|
||||
return parent.empty();
|
||||
}
|
||||
this.value = CastUtils.cast(value);
|
||||
return CastUtils.cast(this);
|
||||
this.value = cast(value);
|
||||
return cast(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,6 +111,16 @@ public class SimpleAnnotationChain<A extends Annotation, T> extends BasicAnnotat
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前值是否存在
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean isPresent() {
|
||||
return null != value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接获取结果
|
||||
*
|
||||
@ -121,4 +132,24 @@ public class SimpleAnnotationChain<A extends Annotation, T> extends BasicAnnotat
|
||||
parent.last(false);
|
||||
return value instanceof MergedAnnotation ? ((MergedAnnotation<A>) value).synthesize() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public T get() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存值逻辑
|
||||
*
|
||||
* @return 父亲
|
||||
*/
|
||||
@Override
|
||||
protected BeanPropertyAnnotations cache() {
|
||||
return parent.value(value);
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>flyfish-framework</artifactId>
|
||||
<groupId>com.flyfish.framework</groupId>
|
||||
<groupId>dev.flyfish.framework</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@ -47,13 +47,17 @@
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<groupId>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.bean;
|
||||
package dev.flyfish.framework.bean;
|
||||
|
||||
/**
|
||||
* Created by wangyu on 2017/8/23.
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.bean;
|
||||
package dev.flyfish.framework.bean;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.bean;
|
||||
package dev.flyfish.framework.bean;
|
||||
|
||||
/**
|
||||
* ${DESCRIPTION}
|
@ -0,0 +1,11 @@
|
||||
package dev.flyfish.framework.bean;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 对象map
|
||||
*
|
||||
* @author wangyu
|
||||
*/
|
||||
public class ObjectMap extends HashMap<String, Object> {
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.bean;
|
||||
package dev.flyfish.framework.bean;
|
||||
|
||||
/**
|
||||
* Created by Wangyu on 2017/6/11.
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.bean;
|
||||
package dev.flyfish.framework.bean;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
@ -57,4 +57,4 @@ public class PageBean<T> {
|
||||
public void setSize(Integer size) {
|
||||
this.size = size;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.bean;
|
||||
package dev.flyfish.framework.bean;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
@ -1,6 +1,6 @@
|
||||
package com.flyfish.framework.bean;
|
||||
package dev.flyfish.framework.bean;
|
||||
|
||||
import com.flyfish.framework.constant.Frameworks;
|
||||
import dev.flyfish.framework.constant.Frameworks;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.bean;
|
||||
package dev.flyfish.framework.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.bean;
|
||||
package dev.flyfish.framework.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -1,7 +1,7 @@
|
||||
package com.flyfish.framework.bean.auth;
|
||||
package dev.flyfish.framework.bean.auth;
|
||||
|
||||
import com.flyfish.framework.bean.BaseResponse;
|
||||
import com.flyfish.framework.constant.RestCodeConstants;
|
||||
import dev.flyfish.framework.bean.BaseResponse;
|
||||
import dev.flyfish.framework.constant.RestCodeConstants;
|
||||
|
||||
/**
|
||||
* Created by wangyu on 2017/8/23.
|
@ -1,7 +1,7 @@
|
||||
package com.flyfish.framework.bean.auth;
|
||||
package dev.flyfish.framework.bean.auth;
|
||||
|
||||
import com.flyfish.framework.bean.BaseResponse;
|
||||
import com.flyfish.framework.constant.RestCodeConstants;
|
||||
import dev.flyfish.framework.bean.BaseResponse;
|
||||
import dev.flyfish.framework.constant.RestCodeConstants;
|
||||
|
||||
/**
|
||||
* Created by wangyu on 2017/8/25.
|
@ -1,7 +1,7 @@
|
||||
package com.flyfish.framework.compiler;
|
||||
package dev.flyfish.framework.compiler;
|
||||
|
||||
import com.flyfish.framework.compiler.support.DelegateJavaCompiler;
|
||||
import com.flyfish.framework.compiler.support.SimpleJavaCompiler;
|
||||
import dev.flyfish.framework.compiler.support.DelegateJavaCompiler;
|
||||
import dev.flyfish.framework.compiler.support.SimpleJavaCompiler;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import java.io.Closeable;
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.compiler.core;
|
||||
package dev.flyfish.framework.compiler.core;
|
||||
|
||||
/**
|
||||
* 静态访问器
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.compiler.core;
|
||||
package dev.flyfish.framework.compiler.core;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
@ -21,4 +21,11 @@ public abstract class DynamicClassLoader extends URLClassLoader {
|
||||
* @return 结果
|
||||
*/
|
||||
public abstract Map<String, byte[]> getClassBytes();
|
||||
|
||||
/**
|
||||
* 将指定的类二进制替换为其他类
|
||||
*
|
||||
* @param path 目标类路径
|
||||
*/
|
||||
public abstract void replace(String name, String path);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.compiler.core;
|
||||
package dev.flyfish.framework.compiler.core;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
@ -1,7 +1,13 @@
|
||||
package com.flyfish.framework.compiler.core;
|
||||
package dev.flyfish.framework.compiler.core;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -30,6 +36,21 @@ class MemoryClassLoader extends DynamicClassLoader {
|
||||
return classBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(String name, String path) {
|
||||
String actualPath = "classpath:" + path;
|
||||
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
try {
|
||||
Resource[] resources = resolver.getResources(actualPath);
|
||||
if (ArrayUtils.isNotEmpty(resources)) {
|
||||
byte[] content = StreamUtils.copyToByteArray(resources[0].getInputStream());
|
||||
classBytes.put(name, content);
|
||||
defineClass(name, content);
|
||||
}
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修复获取package为null的问题,定义并验证class
|
||||
*
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.compiler.core;
|
||||
package dev.flyfish.framework.compiler.core;
|
||||
|
||||
import lombok.Getter;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.compiler.core;
|
||||
package dev.flyfish.framework.compiler.core;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.flyfish.framework.compiler.support;
|
||||
package dev.flyfish.framework.compiler.support;
|
||||
|
||||
import com.flyfish.framework.compiler.DynamicJavaCompiler;
|
||||
import com.flyfish.framework.compiler.core.VendorJavaCompiler;
|
||||
import dev.flyfish.framework.compiler.DynamicJavaCompiler;
|
||||
import dev.flyfish.framework.compiler.core.VendorJavaCompiler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.compiler.support;
|
||||
package dev.flyfish.framework.compiler.support;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
@ -1,6 +1,6 @@
|
||||
package com.flyfish.framework.compiler.support;
|
||||
package dev.flyfish.framework.compiler.support;
|
||||
|
||||
import com.flyfish.framework.compiler.DynamicJavaCompiler;
|
||||
import dev.flyfish.framework.compiler.DynamicJavaCompiler;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@ -57,7 +57,7 @@ public class SimpleJavaCompiler implements DynamicJavaCompiler {
|
||||
options, null, Collections.singletonList(fileObject));
|
||||
// 阻塞编译
|
||||
if (BooleanUtils.isTrue(task.call())) {
|
||||
return "com.flyfish.project." + name;
|
||||
return "dev.flyfish.project." + name;
|
||||
}
|
||||
return null;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.compiler.support;
|
||||
package dev.flyfish.framework.compiler.support;
|
||||
|
||||
import javax.tools.SimpleJavaFileObject;
|
||||
import java.io.IOException;
|
@ -1,6 +1,6 @@
|
||||
package com.flyfish.framework.compiler.template;
|
||||
package dev.flyfish.framework.compiler.template;
|
||||
|
||||
import com.flyfish.framework.compiler.support.JavaSource;
|
||||
import dev.flyfish.framework.compiler.support.JavaSource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.util.CastUtils;
|
||||
import org.springframework.util.StreamUtils;
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.config;
|
||||
package dev.flyfish.framework.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.constant;
|
||||
package dev.flyfish.framework.constant;
|
||||
|
||||
/**
|
||||
* Created by wangyu on 2017/8/29.
|
@ -1,6 +1,6 @@
|
||||
package com.flyfish.framework.constant;
|
||||
package dev.flyfish.framework.constant;
|
||||
|
||||
import com.flyfish.framework.config.FrameworkConfiguration;
|
||||
import dev.flyfish.framework.config.FrameworkConfiguration;
|
||||
|
||||
/**
|
||||
* 框架静态配置
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.constant;
|
||||
package dev.flyfish.framework.constant;
|
||||
|
||||
/**
|
||||
* 异步接口常量
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.constant;
|
||||
package dev.flyfish.framework.constant;
|
||||
|
||||
/**
|
||||
* Created by wangyu on 2017/8/23.
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.constant;
|
||||
package dev.flyfish.framework.constant;
|
||||
|
||||
/**
|
||||
* ${DESCRIPTION}
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.context;
|
||||
package dev.flyfish.framework.context;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.context;
|
||||
package dev.flyfish.framework.context;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.flyfish.framework.context;
|
||||
package dev.flyfish.framework.context;
|
||||
|
||||
import com.flyfish.framework.utils.Assert;
|
||||
import dev.flyfish.framework.utils.Assert;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanInitializationException;
|
||||
import org.springframework.context.ApplicationContext;
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.enums;
|
||||
package dev.flyfish.framework.enums;
|
||||
|
||||
/**
|
||||
* 空白的枚举
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.enums;
|
||||
package dev.flyfish.framework.enums;
|
||||
|
||||
/**
|
||||
* 基于标识码的枚举基类
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.enums;
|
||||
package dev.flyfish.framework.enums;
|
||||
|
||||
/**
|
||||
* 带有名称字段的枚举
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.enums;
|
||||
package dev.flyfish.framework.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.enums;
|
||||
package dev.flyfish.framework.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.enums;
|
||||
package dev.flyfish.framework.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.exception;
|
||||
package dev.flyfish.framework.exception;
|
||||
|
||||
/**
|
||||
* Created by wangyu on 2017/9/8.
|
@ -1,8 +1,8 @@
|
||||
package com.flyfish.framework.exception.auth;
|
||||
package dev.flyfish.framework.exception.auth;
|
||||
|
||||
|
||||
import com.flyfish.framework.constant.CommonConstants;
|
||||
import com.flyfish.framework.exception.BaseException;
|
||||
import dev.flyfish.framework.constant.CommonConstants;
|
||||
import dev.flyfish.framework.exception.BaseException;
|
||||
|
||||
/**
|
||||
* Created by wangyu on 2017/9/12.
|
@ -1,8 +1,8 @@
|
||||
package com.flyfish.framework.exception.auth;
|
||||
package dev.flyfish.framework.exception.auth;
|
||||
|
||||
|
||||
import com.flyfish.framework.constant.CommonConstants;
|
||||
import com.flyfish.framework.exception.BaseException;
|
||||
import dev.flyfish.framework.constant.CommonConstants;
|
||||
import dev.flyfish.framework.exception.BaseException;
|
||||
|
||||
/**
|
||||
* Created by wangyu on 2017/9/10.
|
@ -1,8 +1,8 @@
|
||||
package com.flyfish.framework.exception.auth;
|
||||
package dev.flyfish.framework.exception.auth;
|
||||
|
||||
|
||||
import com.flyfish.framework.constant.CommonConstants;
|
||||
import com.flyfish.framework.exception.BaseException;
|
||||
import dev.flyfish.framework.constant.CommonConstants;
|
||||
import dev.flyfish.framework.exception.BaseException;
|
||||
|
||||
/**
|
||||
* Created by wangyu on 2017/9/10.
|
@ -1,8 +1,8 @@
|
||||
package com.flyfish.framework.exception.auth;
|
||||
package dev.flyfish.framework.exception.auth;
|
||||
|
||||
|
||||
import com.flyfish.framework.constant.CommonConstants;
|
||||
import com.flyfish.framework.exception.BaseException;
|
||||
import dev.flyfish.framework.constant.CommonConstants;
|
||||
import dev.flyfish.framework.exception.BaseException;
|
||||
|
||||
/**
|
||||
* Created by wangyu on 2017/9/8.
|
@ -1,8 +1,8 @@
|
||||
package com.flyfish.framework.exception.auth;
|
||||
package dev.flyfish.framework.exception.auth;
|
||||
|
||||
|
||||
import com.flyfish.framework.constant.CommonConstants;
|
||||
import com.flyfish.framework.exception.BaseException;
|
||||
import dev.flyfish.framework.constant.CommonConstants;
|
||||
import dev.flyfish.framework.exception.BaseException;
|
||||
|
||||
/**
|
||||
* Created by wangyu on 2017/9/8.
|
@ -1,6 +1,6 @@
|
||||
package com.flyfish.framework.exception.biz;
|
||||
package dev.flyfish.framework.exception.biz;
|
||||
|
||||
import com.flyfish.framework.exception.BaseException;
|
||||
import dev.flyfish.framework.exception.BaseException;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.flyfish.framework.exception.biz;
|
||||
package dev.flyfish.framework.exception.biz;
|
||||
|
||||
import com.flyfish.framework.exception.BaseException;
|
||||
import dev.flyfish.framework.exception.BaseException;
|
||||
|
||||
/**
|
||||
* 业务限制异常
|
@ -1,6 +1,6 @@
|
||||
package com.flyfish.framework.utils;
|
||||
package dev.flyfish.framework.utils;
|
||||
|
||||
import com.flyfish.framework.exception.biz.InvalidBusinessException;
|
||||
import dev.flyfish.framework.exception.biz.InvalidBusinessException;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.utils;
|
||||
package dev.flyfish.framework.utils;
|
||||
|
||||
/**
|
||||
* 构建器表示
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.utils;
|
||||
package dev.flyfish.framework.utils;
|
||||
|
||||
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
@ -13,7 +13,11 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 内部的包扫描器,提供特定注解扫描
|
||||
@ -61,6 +65,13 @@ public class ClassPathResourceScanner extends ClassPathScanningCandidateComponen
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析具体类型
|
||||
*
|
||||
* @param bf bean定义
|
||||
* @param cl 类加载器
|
||||
* @return 结果
|
||||
*/
|
||||
private Class<?> resolveType(BeanDefinition bf, ClassLoader cl) {
|
||||
if (null != bf.getBeanClassName()) {
|
||||
try {
|
||||
@ -78,23 +89,19 @@ public class ClassPathResourceScanner extends ClassPathScanningCandidateComponen
|
||||
* @param packageNames 包名
|
||||
* @return 结果
|
||||
*/
|
||||
public Set<Class<?>> scan(Collection<String> packageNames) {
|
||||
public Stream<Class<?>> scan(Collection<String> packageNames) {
|
||||
// 获取扫描器的ClassLoader,保证同源
|
||||
ClassLoader cl = this.getClass().getClassLoader();
|
||||
Set<Class<?>> scanned = new HashSet<>();
|
||||
for (String packageName : packageNames) {
|
||||
Set<BeanDefinition> bfs = findCandidateComponents(packageName);
|
||||
// 不存在,不要浪费性能
|
||||
if (CollectionUtils.isEmpty(bfs)) continue;
|
||||
// 代理并生成子类,并注册到ioc容器
|
||||
for (BeanDefinition bf : bfs) {
|
||||
Class<?> resolved = resolveType(bf, cl);
|
||||
if (null != resolved) {
|
||||
scanned.add(resolved);
|
||||
}
|
||||
}
|
||||
}
|
||||
return scanned;
|
||||
Stream<Class<?>> stream = packageNames.stream()
|
||||
.flatMap(packageName -> {
|
||||
Set<BeanDefinition> bfs = findCandidateComponents(packageName);
|
||||
// 不存在,不要浪费性能
|
||||
if (CollectionUtils.isEmpty(bfs)) return Stream.empty();
|
||||
// 代理并生成子类,并注册到ioc容器
|
||||
return bfs.stream().map(bf -> resolveType(bf, cl)).filter(Objects::nonNull);
|
||||
});
|
||||
// 额外返回,以保证类型正确
|
||||
return stream.distinct();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,7 +110,7 @@ public class ClassPathResourceScanner extends ClassPathScanningCandidateComponen
|
||||
* @param packageNames 包名
|
||||
* @return 结果
|
||||
*/
|
||||
public Set<Class<?>> scan(String... packageNames) {
|
||||
public Stream<Class<?>> scan(String... packageNames) {
|
||||
return scan(Arrays.asList(packageNames));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.flyfish.framework.utils;
|
||||
package dev.flyfish.framework.utils;
|
||||
|
||||
/**
|
||||
* 实体类相关工具类
|
@ -1,7 +1,7 @@
|
||||
package com.flyfish.framework.utils;
|
||||
package dev.flyfish.framework.utils;
|
||||
|
||||
|
||||
import com.flyfish.framework.enums.CodeBasedEnum;
|
||||
import dev.flyfish.framework.enums.CodeBasedEnum;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
|
@ -1,20 +1,19 @@
|
||||
package com.flyfish.framework.utils;
|
||||
package dev.flyfish.framework.utils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Jackson序列化工具类
|
||||
@ -59,8 +58,8 @@ public final class JacksonUtil {
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
// JsonGenerator.Feature for configuring low-level JSON generation:
|
||||
|
||||
// to force escaping of non-ASCII characters:
|
||||
mapper.configure(JsonGenerator.Feature.ESCAPE_NON_ASCII, true);
|
||||
mapper.setLocale(Locale.CHINESE);
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
}
|
||||
|
||||
public static <T> T fromJson(final String json) {
|
||||
@ -72,8 +71,20 @@ public final class JacksonUtil {
|
||||
return readValue(json, reference);
|
||||
}
|
||||
|
||||
public static <T> T fromJson(final String json, JavaType type) {
|
||||
if (StringUtils.isBlank(json)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return mapper.readValue(json, type);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> T fromJson(final String json, Class<T> clazz) {
|
||||
if (null == json || "".equals(json)) {
|
||||
if (StringUtils.isBlank(json)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
@ -111,6 +122,7 @@ public final class JacksonUtil {
|
||||
}
|
||||
|
||||
public static Optional<String> toJson(final Object obj) {
|
||||
if (null == obj) return Optional.empty();
|
||||
try {
|
||||
return Optional.of(mapper.writeValueAsString(obj));
|
||||
} catch (JsonProcessingException e) {
|
||||
@ -119,6 +131,24 @@ public final class JacksonUtil {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public static String toPrettyJson(final Object obj) {
|
||||
try {
|
||||
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(obj);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] toBytes(final Object obj) {
|
||||
try {
|
||||
return mapper.writeValueAsBytes(obj);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static <T> T readValue(String json, TypeReference<T> valueTypeRef) {
|
||||
if (null == json || "".equals(json)) {
|
||||
return null;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user