mirror of https://github.com/hykilpikonna/AquaDX
[maimai2] Add userGeneralData table
parent
c9f80215ca
commit
8b22168df9
|
@ -0,0 +1,26 @@
|
||||||
|
package icu.samnyan.aqua.sega.maimai2.dao.userdata;
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserDetail;
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserGeneralData;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author samnyan (privateamusement@protonmail.com)
|
||||||
|
*/
|
||||||
|
@Repository("Maimai2UserGeneralDataRepository")
|
||||||
|
public interface UserGeneralDataRepository extends JpaRepository<UserGeneralData, Long> {
|
||||||
|
|
||||||
|
List<UserGeneralData> findByUser_Card_ExtId(long userId);
|
||||||
|
|
||||||
|
Optional<UserGeneralData> findByUserAndPropertyKey(UserDetail user, String key);
|
||||||
|
|
||||||
|
Optional<UserGeneralData> findByUser_Card_ExtIdAndPropertyKey(long userId, String key);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserDetail user);
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package icu.samnyan.aqua.sega.maimai2.model.userdata;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is for storing some data only use in aqua
|
||||||
|
* @author samnyan (privateamusement@protonmail.com)
|
||||||
|
*/
|
||||||
|
@Entity(name = "Maimai2UserGeneralData")
|
||||||
|
@Table(name = "maimai2_user_general_data")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class UserGeneralData implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@JsonIgnore
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "user_id")
|
||||||
|
private UserDetail user;
|
||||||
|
|
||||||
|
private String propertyKey;
|
||||||
|
|
||||||
|
@Column(columnDefinition = "TEXT")
|
||||||
|
private String propertyValue;
|
||||||
|
|
||||||
|
public UserGeneralData(UserDetail userData, String key) {
|
||||||
|
this.user = userData;
|
||||||
|
this.propertyKey = key;
|
||||||
|
this.propertyValue = "";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
create table maimai2_user_general_data
|
||||||
|
(
|
||||||
|
id bigint auto_increment
|
||||||
|
primary key,
|
||||||
|
property_key varchar(255) not null,
|
||||||
|
property_value text not null,
|
||||||
|
user_id bigint null,
|
||||||
|
constraint UKiPb2EMwbXzqTUfMun6Y4AeAKx
|
||||||
|
unique (user_id, property_key),
|
||||||
|
constraint FK6BJbvEH8Z22SLbwWKxsb7uarS
|
||||||
|
foreign key (user_id) references maimai2_user_detail (id)
|
||||||
|
);
|
|
@ -0,0 +1,14 @@
|
||||||
|
CREATE TABLE maimai2_user_general_data (
|
||||||
|
id INTEGER,
|
||||||
|
property_key VARCHAR NOT NULL,
|
||||||
|
property_value VARCHAR NOT NULL,
|
||||||
|
user_id BIGINT REFERENCES maimai2_user_detail (id) ON DELETE CASCADE,
|
||||||
|
PRIMARY KEY (
|
||||||
|
id
|
||||||
|
),
|
||||||
|
CONSTRAINT maimai2_user_general_data_uq UNIQUE (
|
||||||
|
property_key,
|
||||||
|
user_id
|
||||||
|
)
|
||||||
|
ON CONFLICT REPLACE
|
||||||
|
);
|
Loading…
Reference in New Issue