feat: change database to indie_music

main
itao 1 year ago
parent d43c622020
commit 13d34d920b

@ -25,7 +25,7 @@ import java.util.List;
public class TagInfoController {
private final TagService tagService;
@ApiOperation(value = "查询标签列表", notes = "查询标签列表")
@ApiOperation(value = "查询标签信息", notes = "查询标签信息")
@GetMapping("/list")
public Result<PageResult<TagDTO>> page(@Validated TagQueryReq queryReq) {
return Result.success(tagService.queryPage(queryReq));

@ -16,7 +16,7 @@ import java.util.List;
*/
public interface TagDao extends JpaRepository<Tag, String>, JpaSpecificationExecutor<Tag>{
@Query(value = "select distinct id from tb_tag where name_ch = ? or name_en = ?", nativeQuery = true)
@Query(value = "select t from Tag t where t.nameCh=:nameCh or t.nameEn=:nameEn")
List<Tag> findByTagName(String nameCh, String nameEn);
@Modifying

@ -1,23 +1,26 @@
package com.luoo.tag.pojo;
import lombok.Data;
import lombok.*;
import org.hibernate.proxy.HibernateProxy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Id;
import javax.persistence.Table;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Objects;
@Data
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "tb_tag")
@Table(name = "tb_tag_info")
@EntityListeners(AuditingEntityListener.class)
public class Tag implements Serializable {
private static final long serialVersionUID = -5593148272164146667L;
@ -71,4 +74,20 @@ public class Tag implements Serializable {
*/
@LastModifiedDate
private LocalDateTime updateTime;
@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;
Tag tag = (Tag) o;
return getId() != null && Objects.equals(getId(), tag.getId());
}
@Override
public final int hashCode() {
return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
}
}

@ -1,17 +1,23 @@
-- 创建DB
create database if not exists `indie_tag` default charset utf8mb4 collate utf8mb4_general_ci;
use indie_tag;
-- 创建表
drop table if exists indie_tag.tb_tag;
create table indie_tag.tb_tag (
id varchar(100) not null primary key comment '标签ID',
parent_id varchar(100) not null default '' comment '父标签ID(一级标签的父标签ID=空字符串)',
name_ch varchar(100) not null default '' comment '标签中文名称',
name_en varchar(100) not null default '' comment '标签英文名称',
state tinyint not null default 1 comment '状态(0=禁用,1=启用)',
creator_id int default 0 comment '创建人用户ID',
create_time datetime default current_timestamp comment '创建时间',
update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
key idx_update_time(update_time),
key idx_parent_id(parent_id)
) character set utf8mb4 comment '标签表';
drop table if exists indie_music.tb_tag_info;
create table if not exists indie_music.tb_tag_info
(
id varchar(100) not null comment '标签ID'
primary key,
level tinyint(2) default 1 not null comment '层级(1=一级, 2=二级)',
parent_id varchar(100) default '' not null comment '父标签ID(一级标签的父标签ID=空字符串)',
name_ch varchar(100) default '' not null comment '标签中文名称',
name_en varchar(100) default '' not null comment '标签英文名称',
state tinyint(2) default 1 not null comment '状态(0=禁用,1=启用)',
creator_id varchar(64) default '' not null comment '创建人用户ID',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
updater_id varchar(64) default '' not null comment '更新用户ID',
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间'
)
comment '标签表';
create index idx_parent_id
on indie_music.tb_tag_info (parent_id);
create index idx_create_time
on indie_music.tb_tag_info (create_time);

Loading…
Cancel
Save