First commit

This commit is contained in:
2025-10-14 15:12:24 +08:00
commit 4bf21639c1
370 changed files with 93952 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
package link.at17.mid.tushare.interfaces;
import java.util.Objects;
import org.springframework.stereotype.Component;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import jakarta.annotation.PostConstruct;
import link.at17.mid.tushare.service.ConfigService;
import link.at17.mid.tushare.system.util.SpringContextHolder;
/**
* 配置项必须实现该接口
*
* @author Doghole
*
*/
@Component
public interface IConfig<T extends IConfig<T>> {
@SuppressWarnings("unchecked")
public default boolean saveOrUpdate() {
return SpringContextHolder.getBean(ConfigService.class).saveOrUpdate((T)this);
}
/**
* 保存前处理。无论 @ConfigInfo 是否设置 save = true 都会调用
*/
@SuppressWarnings("unchecked")
public default T afterSaving() {
return (T) this;
}
/**
* 保存后处理。无论 @ConfigInfo 是否设置 save = true 都会调用
*/
@SuppressWarnings("unchecked")
public default T beforeSaving() {
return (T) this;
}
/**
* 合并到 other且返回合并后的 other
* @return
*/
public default T mergeTo(T other) {
if (!Objects.equals(this, other)) {
BeanUtil.copyProperties(this, other,
CopyOptions.create().setIgnoreNullValue(true));
}
return other;
}
/**
* 合并其他,并返回本身
* @param other
* @return
*/
@SuppressWarnings("unchecked")
public default T mergeFrom(T other) {
if (!Objects.equals(this, other)) {
BeanUtil.copyProperties(other, this,
CopyOptions.create().setIgnoreNullValue(true));
}
return (T) this;
}
/**
* 初始化完成之后的方法,会在
* <code><i>beanFactory</i>.autowireBean(bean)</code>
* 和
* <code><i>beanFactory</i>.initializeBean(bean, beanName)</code>
* 后执行。<br>
* @see quant.rich.emoney.config.ConfigServiceFactoryBean
*/
@PostConstruct
public default void afterBeanInit() {}
public static class Views {
public static class Persistence {}
}
}