package com.dne.ems.config;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 这个类提供了空的JPA注解实现，用于在移除JPA依赖后保持代码兼容性。
 * 这些注解不会有任何实际效果，仅用于编译通过。
 */
public class EmptyJpaAnnotations {

    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.TYPE})
    public @interface Entity {
    }

    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.TYPE})
    public @interface Table {
        String name() default "";
        String schema() default "";
        String catalog() default "";
        UniqueConstraint[] uniqueConstraints() default {};
    }

    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.FIELD, ElementType.METHOD})
    public @interface Column {
        String name() default "";
        boolean unique() default false;
        boolean nullable() default true;
        boolean insertable() default true;
        boolean updatable() default true;
        String columnDefinition() default "";
        String table() default "";
        int length() default 255;
        int precision() default 0;
        int scale() default 0;
    }

    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.FIELD, ElementType.METHOD})
    public @interface Id {
    }

    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.FIELD, ElementType.METHOD})
    public @interface GeneratedValue {
        GenerationType strategy() default GenerationType.AUTO;
        String generator() default "";
    }

    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.FIELD, ElementType.METHOD})
    public @interface ManyToOne {
        Class<?> targetEntity() default void.class;
        FetchType fetch() default FetchType.EAGER;
        boolean optional() default true;
        String mappedBy() default "";
        CascadeType[] cascade() default {};
    }

    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.FIELD, ElementType.METHOD})
    public @interface OneToMany {
        Class<?> targetEntity() default void.class;
        String mappedBy() default "";
        CascadeType[] cascade() default {};
        FetchType fetch() default FetchType.LAZY;
        boolean orphanRemoval() default false;
    }

    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.FIELD, ElementType.METHOD})
    public @interface OneToOne {
        Class<?> targetEntity() default void.class;
        String mappedBy() default "";
        CascadeType[] cascade() default {};
        FetchType fetch() default FetchType.EAGER;
        boolean optional() default true;
        boolean orphanRemoval() default false;
    }

    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.FIELD, ElementType.METHOD})
    public @interface ManyToMany {
        Class<?> targetEntity() default void.class;
        String mappedBy() default "";
        CascadeType[] cascade() default {};
        FetchType fetch() default FetchType.LAZY;
    }

    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.FIELD, ElementType.METHOD})
    public @interface JoinColumn {
        String name() default "";
        String referencedColumnName() default "";
        boolean unique() default false;
        boolean nullable() default true;
        boolean insertable() default true;
        boolean updatable() default true;
        String columnDefinition() default "";
        String table() default "";
    }

    @Retention(RetentionPolicy.RUNTIME)
    public @interface UniqueConstraint {
        String name() default "";
        String[] columnNames();
    }

    public enum GenerationType {
        TABLE,
        SEQUENCE,
        IDENTITY,
        AUTO
    }

    public enum FetchType {
        LAZY,
        EAGER
    }

    public enum CascadeType {
        ALL,
        PERSIST,
        MERGE,
        REMOVE,
        REFRESH,
        DETACH
    }
} 