From d93575aacbd2a70e3fb2b83aa731464127fe3c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E6=AC=A7=EF=BC=88=E6=9E=97=E5=B9=B3=E5=87=A1?= =?UTF-8?q?=EF=BC=89?= Date: Thu, 7 Aug 2025 15:32:12 +0800 Subject: [PATCH] 1 --- .../cn/van/business/model/wx/SuperAdmin.java | 102 ++++++++++++++++++ .../repository/SuperAdminRepository.java | 47 ++++++++ 2 files changed, 149 insertions(+) create mode 100644 src/main/java/cn/van/business/model/wx/SuperAdmin.java create mode 100644 src/main/java/cn/van/business/repository/SuperAdminRepository.java diff --git a/src/main/java/cn/van/business/model/wx/SuperAdmin.java b/src/main/java/cn/van/business/model/wx/SuperAdmin.java new file mode 100644 index 0000000..edf06c3 --- /dev/null +++ b/src/main/java/cn/van/business/model/wx/SuperAdmin.java @@ -0,0 +1,102 @@ +package cn.van.business.model.wx; + +import jakarta.persistence.*; +import lombok.*; +import org.hibernate.proxy.HibernateProxy; + +import java.util.Objects; + +/** + * 超级管理员实体类 + */ +@Getter +@Setter +@ToString +@RequiredArgsConstructor +@AllArgsConstructor +@Entity +@Table(name = "super_admin") +public class SuperAdmin { + + /** + * 主键ID + */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + /** + * 微信ID + */ + @Column(name = "wxid", nullable = false, length = 64) + private String wxid; + + /** + * 姓名 + */ + @Column(name = "name", nullable = false, length = 50) + private String name; + + /** + * 联盟ID + */ + @Column(name = "union_id", nullable = false, length = 64) + private String unionId; + + /** + * 应用密钥 + */ + @Column(name = "app_key", nullable = false, length = 100) + private String appKey; + + /** + * 秘密密钥 + */ + @Column(name = "secret_key", nullable = false, length = 100) + private String secretKey; + + /** + * 是否激活: 0-否, 1-是 + */ + @Column(name = "is_active", nullable = false) + private Integer isActive = 1; + + /** + * 创建时间 + */ + @Column(name = "created_at", nullable = false, updatable = false) + private java.sql.Timestamp createdAt; + + /** + * 更新时间 + */ + @Column(name = "updated_at", nullable = false) + private java.sql.Timestamp updatedAt; + + @PrePersist + protected void onCreate() { + createdAt = new java.sql.Timestamp(System.currentTimeMillis()); + updatedAt = new java.sql.Timestamp(System.currentTimeMillis()); + } + + @PreUpdate + protected void onUpdate() { + updatedAt = new java.sql.Timestamp(System.currentTimeMillis()); + } + + @Override + public final boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + Class oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass(); + Class thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass(); + if (thisEffectiveClass != oEffectiveClass) return false; + SuperAdmin that = (SuperAdmin) o; + return getId() != null && Objects.equals(getId(), that.getId()); + } + + @Override + public final int hashCode() { + return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode(); + } +} diff --git a/src/main/java/cn/van/business/repository/SuperAdminRepository.java b/src/main/java/cn/van/business/repository/SuperAdminRepository.java new file mode 100644 index 0000000..4f4faac --- /dev/null +++ b/src/main/java/cn/van/business/repository/SuperAdminRepository.java @@ -0,0 +1,47 @@ +package cn.van.business.repository; + +import cn.van.business.model.wx.SuperAdmin; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Optional; + +@Repository +public interface SuperAdminRepository extends JpaRepository { + + /** + * 根据微信ID查找超级管理员 + * @param wxid 微信ID + * @return 超级管理员对象 + */ + Optional findByWxid(String wxid); + + /** + * 根据联盟ID查找超级管理员 + * @param unionId 联盟ID + * @return 超级管理员对象 + */ + Optional findByUnionId(String unionId); + + /** + * 根据应用密钥查找超级管理员 + * @param appKey 应用密钥 + * @return 超级管理员对象 + */ + Optional findByAppKey(String appKey); + + /** + * 根据名称查找超级管理员列表 + * @param name 名称 + * @return 超级管理员列表 + */ + List findByName(String name); + + /** + * 查找所有激活状态的超级管理员 + * @param isActive 是否激活 + * @return 超级管理员列表 + */ + List findByIsActive(Integer isActive); +} \ No newline at end of file