From a9f294956c611dd289737632f381b047187d408a Mon Sep 17 00:00:00 2001 From: chanhengseang Date: Mon, 26 May 2025 09:55:08 -0700 Subject: [PATCH] event organizer and rating history --- .../java/com/srr/domain/EventOrganizer.java | 70 +++++++++++++++++++ .../java/com/srr/domain/RatingHistory.java | 43 ++++++++++++ .../java/com/srr/dto/EventOrganizerDto.java | 47 +++++++++++++ .../java/com/srr/dto/RatingHistoryDto.java | 53 ++++++++++++++ .../dto/mapstruct/EventOrganizerMapper.java | 32 +++++++++ .../dto/mapstruct/RatingHistoryMapper.java | 43 ++++++++++++ .../repository/EventOrganizerRepository.java | 39 +++++++++++ .../repository/RatingHistoryRepository.java | 34 +++++++++ 8 files changed, 361 insertions(+) create mode 100644 sport/src/main/java/com/srr/domain/EventOrganizer.java create mode 100644 sport/src/main/java/com/srr/domain/RatingHistory.java create mode 100644 sport/src/main/java/com/srr/dto/EventOrganizerDto.java create mode 100644 sport/src/main/java/com/srr/dto/RatingHistoryDto.java create mode 100644 sport/src/main/java/com/srr/dto/mapstruct/EventOrganizerMapper.java create mode 100644 sport/src/main/java/com/srr/dto/mapstruct/RatingHistoryMapper.java create mode 100644 sport/src/main/java/com/srr/repository/EventOrganizerRepository.java create mode 100644 sport/src/main/java/com/srr/repository/RatingHistoryRepository.java diff --git a/sport/src/main/java/com/srr/domain/EventOrganizer.java b/sport/src/main/java/com/srr/domain/EventOrganizer.java new file mode 100644 index 00000000..9ee6b058 --- /dev/null +++ b/sport/src/main/java/com/srr/domain/EventOrganizer.java @@ -0,0 +1,70 @@ +/* +* Copyright 2019-2025 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.srr.domain; + +import lombok.Data; +import cn.hutool.core.bean.BeanUtil; +import io.swagger.annotations.ApiModelProperty; +import cn.hutool.core.bean.copier.CopyOptions; +import javax.persistence.*; +import javax.persistence.Entity; +import javax.persistence.Table; +import org.hibernate.annotations.*; +import java.sql.Timestamp; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description Event organizer entity +* @author Chanheng +* @date 2025-05-26 +**/ +@Entity +@Data +@Table(name="event_organizer") +public class EventOrganizer implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`id`") + @ApiModelProperty(value = "id", hidden = true) + private Long id; + + @Column(name = "`description`") + @ApiModelProperty(value = "Description") + private String description; + + @Column(name = "`create_time`") + @CreationTimestamp + @ApiModelProperty(value = "Creation time", hidden = true) + private Timestamp createTime; + + @Column(name = "`update_time`") + @UpdateTimestamp + @ApiModelProperty(value = "Update time", hidden = true) + private Timestamp updateTime; + + @Column(name = "`user_id`", nullable = false) + @NotNull + @ApiModelProperty(value = "userId") + private Long userId; + + public void copy(EventOrganizer source){ + BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/sport/src/main/java/com/srr/domain/RatingHistory.java b/sport/src/main/java/com/srr/domain/RatingHistory.java new file mode 100644 index 00000000..8f2602dd --- /dev/null +++ b/sport/src/main/java/com/srr/domain/RatingHistory.java @@ -0,0 +1,43 @@ +package com.srr.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import org.hibernate.annotations.CreationTimestamp; + +import javax.persistence.*; +import java.io.Serializable; +import java.sql.Timestamp; + +@Getter +@Setter +@Entity +public class RatingHistory implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`id`") + @ApiModelProperty(value = "id", hidden = true) + private Long id; + + @ManyToOne + @JoinColumn(name = "player_id") + private Player player; + + @Column(name = "`rate_score`") + @ApiModelProperty(value = "Score") + private Double rateScore; + + @Column(name = "`changes`") + @ApiModelProperty(value = "Changes") + private Double changes; + + @Column(name = "`create_time`") + @CreationTimestamp + @ApiModelProperty(value = "Creation time", hidden = true) + private Timestamp createTime; + + @ManyToOne + @JoinColumn(name = "match_id") + private Match match; +} diff --git a/sport/src/main/java/com/srr/dto/EventOrganizerDto.java b/sport/src/main/java/com/srr/dto/EventOrganizerDto.java new file mode 100644 index 00000000..4514c154 --- /dev/null +++ b/sport/src/main/java/com/srr/dto/EventOrganizerDto.java @@ -0,0 +1,47 @@ +/* +* Copyright 2019-2025 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.srr.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** +* @website https://eladmin.vip +* @description Event organizer data transfer object +* @author Chanheng +* @date 2025-05-26 +**/ +@Data +public class EventOrganizerDto implements Serializable { + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "Description") + private String description; + + @ApiModelProperty(value = "Creation time") + private Timestamp createTime; + + @ApiModelProperty(value = "Update time") + private Timestamp updateTime; + + @ApiModelProperty(value = "User ID") + private Long userId; +} diff --git a/sport/src/main/java/com/srr/dto/RatingHistoryDto.java b/sport/src/main/java/com/srr/dto/RatingHistoryDto.java new file mode 100644 index 00000000..d52fc1bf --- /dev/null +++ b/sport/src/main/java/com/srr/dto/RatingHistoryDto.java @@ -0,0 +1,53 @@ +/* +* Copyright 2019-2025 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.srr.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** +* @website https://eladmin.vip +* @description / +* @author Chanheng +* @date 2025-05-26 +**/ +@Data +public class RatingHistoryDto implements Serializable { + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "Player ID") + private Long playerId; + + @ApiModelProperty(value = "Player name") + private String playerName; + + @ApiModelProperty(value = "Rating score") + private Double rateScore; + + @ApiModelProperty(value = "Score changes") + private Double changes; + + @ApiModelProperty(value = "Creation time") + private Timestamp createTime; + + @ApiModelProperty(value = "Match ID") + private Long matchId; +} diff --git a/sport/src/main/java/com/srr/dto/mapstruct/EventOrganizerMapper.java b/sport/src/main/java/com/srr/dto/mapstruct/EventOrganizerMapper.java new file mode 100644 index 00000000..23463861 --- /dev/null +++ b/sport/src/main/java/com/srr/dto/mapstruct/EventOrganizerMapper.java @@ -0,0 +1,32 @@ +/* +* Copyright 2019-2025 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.srr.dto.mapstruct; + +import me.zhengjie.base.BaseMapper; +import com.srr.domain.EventOrganizer; +import com.srr.dto.EventOrganizerDto; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://eladmin.vip +* @author Chanheng +* @date 2025-05-26 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface EventOrganizerMapper extends BaseMapper { +} diff --git a/sport/src/main/java/com/srr/dto/mapstruct/RatingHistoryMapper.java b/sport/src/main/java/com/srr/dto/mapstruct/RatingHistoryMapper.java new file mode 100644 index 00000000..d5513f5c --- /dev/null +++ b/sport/src/main/java/com/srr/dto/mapstruct/RatingHistoryMapper.java @@ -0,0 +1,43 @@ +/* +* Copyright 2019-2025 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.srr.dto.mapstruct; + +import me.zhengjie.base.BaseMapper; +import com.srr.domain.RatingHistory; +import com.srr.dto.RatingHistoryDto; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://eladmin.vip +* @author Chanheng +* @date 2025-05-26 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface RatingHistoryMapper extends BaseMapper { + + /** + * Entity to DTO mapping with explicit field mappings + * @param entity RatingHistory entity + * @return RatingHistoryDto + */ + @Override + @Mapping(source = "player.id", target = "playerId") + @Mapping(source = "player.name", target = "playerName") + @Mapping(source = "match.id", target = "matchId") + RatingHistoryDto toDto(RatingHistory entity); +} diff --git a/sport/src/main/java/com/srr/repository/EventOrganizerRepository.java b/sport/src/main/java/com/srr/repository/EventOrganizerRepository.java new file mode 100644 index 00000000..f59e4b94 --- /dev/null +++ b/sport/src/main/java/com/srr/repository/EventOrganizerRepository.java @@ -0,0 +1,39 @@ +/* +* Copyright 2019-2025 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.srr.repository; + +import com.srr.domain.EventOrganizer; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** +* @website https://eladmin.vip +* @author Chanheng +* @date 2025-05-26 +**/ +@Repository +public interface EventOrganizerRepository extends JpaRepository, JpaSpecificationExecutor { + + /** + * Find event organizers by user id + * @param userId the user id + * @return list of event organizers + */ + List findByUserId(Long userId); +} diff --git a/sport/src/main/java/com/srr/repository/RatingHistoryRepository.java b/sport/src/main/java/com/srr/repository/RatingHistoryRepository.java new file mode 100644 index 00000000..35354cfb --- /dev/null +++ b/sport/src/main/java/com/srr/repository/RatingHistoryRepository.java @@ -0,0 +1,34 @@ +/* +* Copyright 2019-2025 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.srr.repository; + +import com.srr.domain.RatingHistory; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** +* @website https://eladmin.vip +* @author Chanheng +* @date 2025-05-26 +**/ +@Repository +public interface RatingHistoryRepository extends JpaRepository, JpaSpecificationExecutor { + + List findByPlayerIdOrderByCreateTimeDesc(Long playerId); +} \ No newline at end of file