From b48f7af12f279b290ed0563e1ac8f2253f654ff4 Mon Sep 17 00:00:00 2001 From: chanhengseang Date: Sun, 25 May 2025 17:28:12 -0700 Subject: [PATCH 1/5] remove qiniu --- .gitignore | 3 +- README.md | 17 +-- .../src/main/resources/config/application.yml | 2 +- eladmin-tools/pom.xml | 14 +-- .../zhengjie/service/impl/S3ServiceImpl.java | 106 ++---------------- .../main/java/me/zhengjie/utils/S3Util.java | 71 ------------ 6 files changed, 17 insertions(+), 196 deletions(-) delete mode 100644 eladmin-tools/src/main/java/me/zhengjie/utils/S3Util.java diff --git a/.gitignore b/.gitignore index 9acb04ae..d6bdc98a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ */target/* */*.iml /.gradle/ -/application.pid \ No newline at end of file +/application.pid +/eladmin-system/application.pid diff --git a/README.md b/README.md index 708dc19e..804d4c61 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,5 @@ # ELADMIN Backend Management System -[![AUR](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://github.com/elunez/eladmin/blob/master/LICENSE) -[![star](https://gitee.com/elunez/eladmin/badge/star.svg?theme=white)](https://gitee.com/elunez/eladmin) -[![GitHub stars](https://img.shields.io/github/stars/elunez/eladmin.svg?style=social&label=Stars)](https://github.com/elunez/eladmin) -[![GitHub forks](https://img.shields.io/github/forks/elunez/eladmin.svg?style=social&label=Fork)](https://github.com/elunez/eladmin) - ## Project Introduction A front-end and back-end separated management system based on Spring Boot 2.7.18, Spring Boot JPA, JWT, Spring Security, Redis, and Vue. @@ -26,12 +21,6 @@ A MyBatis-Plus version has also been released: | GitHub | https://github.com/elunez/eladmin | https://github.com/elunez/eladmin-web | | Gitee | https://gitee.com/elunez/eladmin | https://gitee.com/elunez/eladmin-web | -## VPS Recommendation - -[![VPS Banner](https://eladmin.vip/images/banner/side.jpeg)](https://bwh81.net/aff.php?aff=70876) - -Use promo code: `BWHCGLUKKB` for a 6.81% discount [See details](https://bwhstock.in/) - ## Main Features - Uses the latest tech stack with rich community resources. @@ -58,7 +47,7 @@ Use promo code: `BWHCGLUKKB` for a 6.81% discount [See details](https://bwhstock - Scheduled Tasks: Integrate Quartz for scheduled tasks, with task logs and task execution status. - Code Generation: High flexibility code generation for front-end and back-end, reducing repetitive work. - Email Tool: Send HTML format emails with rich text. -- Qiniu Cloud Storage: Synchronize Qiniu cloud storage data to the system, no need to log in to Qiniu cloud to operate cloud data. +- AWS Cloud Storage: Synchronize AWS cloud storage data to the system, no need to log in to AWS cloud to operate cloud data. - Alipay Payment: Integrate Alipay payment and provide a test account for self-testing. - Server Monitoring: Monitor server load status. - Operations Management: One-click deployment of your application. @@ -70,7 +59,7 @@ The project uses a modular development approach, with the following structure: - `eladmin-common`: System public module, including various utility classes and public configurations. - `eladmin-system`: System core module and project entry module, also the final module to be packaged and deployed. - `eladmin-logging`: System log module, other modules need to import this module to record logs. -- `eladmin-tools`: Third-party tool module, including email, Qiniu cloud storage, local storage, and Alipay payment. +- `eladmin-tools`: Third-party tool module, including email, AWS cloud storage, local storage - `eladmin-generator`: System code generation module, supporting front-end and back-end CRUD code generation. ## Detailed Structure @@ -100,7 +89,7 @@ The project uses a modular development approach, with the following structure: - eladmin-logging System Log Module - eladmin-tools Third-party Tool Module - email Email tool - - qiniu Qiniu cloud storage tool + - AWS S3 cloud storage tool - alipay Alipay payment tool - local-storage Local storage tool - eladmin-generator System Code Generation Module diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml index 71191c41..3249fbac 100644 --- a/eladmin-system/src/main/resources/config/application.yml +++ b/eladmin-system/src/main/resources/config/application.yml @@ -63,7 +63,7 @@ task: # Queue capacity queue-capacity: 50 -# Qiniu Cloud +# S3 Cloud s3: # File size /M max-size: 15 diff --git a/eladmin-tools/pom.xml b/eladmin-tools/pom.xml index 5801c74d..21a9917a 100644 --- a/eladmin-tools/pom.xml +++ b/eladmin-tools/pom.xml @@ -12,7 +12,6 @@ 1.4.7 - 7.9.3 4.22.57.ALL @@ -31,18 +30,11 @@ ${mail.version} - - com.qiniu - qiniu-java-sdk - ${qiniu.version} + software.amazon.awssdk + s3 + 2.25.22 - - - com.alipay.sdk - alipay-sdk-java - ${alipay.version} - diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/impl/S3ServiceImpl.java b/eladmin-tools/src/main/java/me/zhengjie/service/impl/S3ServiceImpl.java index 1914d528..d204ccfb 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/impl/S3ServiceImpl.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/impl/S3ServiceImpl.java @@ -15,24 +15,15 @@ */ package me.zhengjie.service.impl; -import com.alibaba.fastjson2.JSON; -import com.qiniu.common.QiniuException; -import com.qiniu.http.Response; -import com.qiniu.storage.BucketManager; -import com.qiniu.storage.Configuration; -import com.qiniu.storage.UploadManager; -import com.qiniu.storage.model.DefaultPutRet; -import com.qiniu.storage.model.FileInfo; -import com.qiniu.util.Auth; import lombok.RequiredArgsConstructor; -import me.zhengjie.domain.S3Content; import me.zhengjie.domain.S3Config; +import me.zhengjie.domain.S3Content; +import me.zhengjie.exception.BadRequestException; import me.zhengjie.repository.S3ConfigRepository; import me.zhengjie.repository.S3ContentRepository; +import me.zhengjie.service.S3Service; import me.zhengjie.service.dto.S3QueryCriteria; import me.zhengjie.utils.*; -import me.zhengjie.exception.BadRequestException; -import me.zhengjie.service.S3Service; import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CachePut; @@ -41,6 +32,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; + import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.*; @@ -92,39 +84,7 @@ public class S3ServiceImpl implements S3Service { @Override @Transactional(rollbackFor = Exception.class) public S3Content upload(MultipartFile file, S3Config s3Config) { - FileUtil.checkSize(maxSize, file.getSize()); - if(s3Config.getId() == null){ - throw new BadRequestException("Please add the corresponding configuration first, then operate"); - } - // Construct a configuration class with the specified Zone object - Configuration cfg = new Configuration(S3Util.getRegion(s3Config.getZone())); - UploadManager uploadManager = new UploadManager(cfg); - Auth auth = Auth.create(s3Config.getAccessKey(), s3Config.getSecretKey()); - String upToken = auth.uploadToken(s3Config.getBucket()); - try { - String key = file.getOriginalFilename(); - if(s3ContentRepository.findByKey(key) != null) { - key = S3Util.getKey(key); - } - Response response = uploadManager.put(file.getBytes(), key, upToken); - // Parse the result of successful upload - DefaultPutRet putRet = JSON.parseObject(response.bodyString(), DefaultPutRet.class); - S3Content content = s3ContentRepository.findByKey(FileUtil.getFileNameNoEx(putRet.key)); - if(content == null){ - // Store in database - S3Content s3Content = new S3Content(); - s3Content.setSuffix(FileUtil.getExtensionName(putRet.key)); - s3Content.setBucket(s3Config.getBucket()); - s3Content.setType(s3Config.getType()); - s3Content.setKey(FileUtil.getFileNameNoEx(putRet.key)); - s3Content.setUrl(s3Config.getHost()+"/"+putRet.key); - s3Content.setSize(FileUtil.getSize(Integer.parseInt(String.valueOf(file.getSize())))); - return s3ContentRepository.save(s3Content); - } - return content; - } catch (Exception e) { - throw new BadRequestException(e.getMessage()); - } + return null; } @Override @@ -136,69 +96,19 @@ public class S3ServiceImpl implements S3Service { @Override public String download(S3Content content,S3Config config){ - String finalUrl; - String type = "Public"; - if(type.equals(content.getType())){ - finalUrl = content.getUrl(); - } else { - Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey()); - // 1 hour, can customize link expiration time - long expireInSeconds = 3600; - finalUrl = auth.privateDownloadUrl(content.getUrl(), expireInSeconds); - } - return finalUrl; + return null; } @Override @Transactional(rollbackFor = Exception.class) public void delete(S3Content content, S3Config config) { - // Construct a configuration class with the specified Zone object - Configuration cfg = new Configuration(S3Util.getRegion(config.getZone())); - Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey()); - BucketManager bucketManager = new BucketManager(auth, cfg); - try { - bucketManager.delete(content.getBucket(), content.getKey() + "." + content.getSuffix()); - s3ContentRepository.delete(content); - } catch (QiniuException ex) { - s3ContentRepository.delete(content); - } + } @Override @Transactional(rollbackFor = Exception.class) public void synchronize(S3Config config) { - if(config.getId() == null){ - throw new BadRequestException("Please add the corresponding configuration first, then operate"); - } - // Construct a configuration class with the specified Zone object - Configuration cfg = new Configuration(S3Util.getRegion(config.getZone())); - Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey()); - BucketManager bucketManager = new BucketManager(auth, cfg); - // File name prefix - String prefix = ""; - // Length limit for each iteration, maximum 1000, recommended value 1000 - int limit = 1000; - // Specify directory separator, list all common prefixes (simulate directory listing effect). Default value is empty string - String delimiter = ""; - // List space file list - BucketManager.FileListIterator fileListIterator = bucketManager.createFileListIterator(config.getBucket(), prefix, limit, delimiter); - while (fileListIterator.hasNext()) { - // Process the obtained file list result - S3Content s3Content; - FileInfo[] items = fileListIterator.next(); - for (FileInfo item : items) { - if(s3ContentRepository.findByKey(FileUtil.getFileNameNoEx(item.key)) == null){ - s3Content = new S3Content(); - s3Content.setSize(FileUtil.getSize(Integer.parseInt(String.valueOf(item.fsize)))); - s3Content.setSuffix(FileUtil.getExtensionName(item.key)); - s3Content.setKey(FileUtil.getFileNameNoEx(item.key)); - s3Content.setType(config.getType()); - s3Content.setBucket(config.getBucket()); - s3Content.setUrl(config.getHost()+"/"+item.key); - s3ContentRepository.save(s3Content); - } - } - } + } @Override diff --git a/eladmin-tools/src/main/java/me/zhengjie/utils/S3Util.java b/eladmin-tools/src/main/java/me/zhengjie/utils/S3Util.java deleted file mode 100644 index ed67b836..00000000 --- a/eladmin-tools/src/main/java/me/zhengjie/utils/S3Util.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 me.zhengjie.utils; - -import com.qiniu.storage.Region; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * S3 cloud storage utility class - * @author Zheng Jie - * @date 2018-12-31 - */ -public class S3Util { - - private static final String HUAD = "East China"; - - private static final String HUAB = "North China"; - - private static final String HUAN = "South China"; - - private static final String BEIM = "North America"; - - /** - * Get the corresponding relationship of the machine room - * @param zone machine room name - * @return Region - */ - public static Region getRegion(String zone){ - - if(HUAD.equals(zone)){ - return Region.huadong(); - } else if(HUAB.equals(zone)){ - return Region.huabei(); - } else if(HUAN.equals(zone)){ - return Region.huanan(); - } else if (BEIM.equals(zone)){ - return Region.beimei(); - // Otherwise, it is Southeast Asia - } else { - return Region.qvmHuadong(); - } - } - - /** - * By default, if no key is specified, the hash value of the file content is used as the file name - * @param file file name - * @return String - */ - public static String getKey(String file){ - SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); - Date date = new Date(); - return FileUtil.getFileNameNoEx(file) + "-" + - sdf.format(date) + - "." + - FileUtil.getExtensionName(file); - } -} From a47af368e5eb418bb762cfae22464c24928240dd Mon Sep 17 00:00:00 2001 From: chanhengseang Date: Sun, 25 May 2025 17:35:14 -0700 Subject: [PATCH 2/5] restructure --- eladmin-system/src/main/resources/config/application.yml | 3 +++ sport/src/main/java/com/srr/{service => }/dto/ClubDto.java | 2 +- .../java/com/srr/{service => }/dto/ClubQueryCriteria.java | 2 +- sport/src/main/java/com/srr/{service => }/dto/CourtDto.java | 2 +- .../java/com/srr/{service => }/dto/CourtQueryCriteria.java | 2 +- sport/src/main/java/com/srr/{service => }/dto/EventDto.java | 2 +- .../java/com/srr/{service => }/dto/EventQueryCriteria.java | 2 +- .../src/main/java/com/srr/{service => }/dto/PlayerDto.java | 2 +- .../java/com/srr/{service => }/dto/PlayerQueryCriteria.java | 2 +- sport/src/main/java/com/srr/{service => }/dto/SportDto.java | 2 +- .../java/com/srr/{service => }/dto/SportQueryCriteria.java | 2 +- .../java/com/srr/{service => dto}/mapstruct/ClubMapper.java | 4 ++-- .../com/srr/{service => dto}/mapstruct/CourtMapper.java | 4 ++-- .../com/srr/{service => dto}/mapstruct/EventMapper.java | 4 ++-- .../com/srr/{service => dto}/mapstruct/PlayerMapper.java | 4 ++-- .../com/srr/{service => dto}/mapstruct/SportMapper.java | 4 ++-- sport/src/main/java/com/srr/rest/ClubController.java | 4 ++-- sport/src/main/java/com/srr/rest/CourtController.java | 4 ++-- sport/src/main/java/com/srr/rest/EventController.java | 4 ++-- sport/src/main/java/com/srr/rest/PlayerController.java | 4 ++-- sport/src/main/java/com/srr/rest/SportController.java | 4 ++-- sport/src/main/java/com/srr/service/ClubService.java | 4 ++-- sport/src/main/java/com/srr/service/CourtService.java | 4 ++-- sport/src/main/java/com/srr/service/EventService.java | 4 ++-- sport/src/main/java/com/srr/service/PlayerService.java | 4 ++-- sport/src/main/java/com/srr/service/SportService.java | 6 +++--- .../src/main/java/com/srr/service/impl/ClubServiceImpl.java | 6 +++--- .../main/java/com/srr/service/impl/CourtServiceImpl.java | 6 +++--- .../main/java/com/srr/service/impl/EventServiceImpl.java | 6 +++--- .../main/java/com/srr/service/impl/PlayerServiceImpl.java | 6 +++--- .../main/java/com/srr/service/impl/SportServiceImpl.java | 6 +++--- 31 files changed, 59 insertions(+), 56 deletions(-) rename sport/src/main/java/com/srr/{service => }/dto/ClubDto.java (98%) rename sport/src/main/java/com/srr/{service => }/dto/ClubQueryCriteria.java (97%) rename sport/src/main/java/com/srr/{service => }/dto/CourtDto.java (97%) rename sport/src/main/java/com/srr/{service => }/dto/CourtQueryCriteria.java (97%) rename sport/src/main/java/com/srr/{service => }/dto/EventDto.java (98%) rename sport/src/main/java/com/srr/{service => }/dto/EventQueryCriteria.java (98%) rename sport/src/main/java/com/srr/{service => }/dto/PlayerDto.java (98%) rename sport/src/main/java/com/srr/{service => }/dto/PlayerQueryCriteria.java (97%) rename sport/src/main/java/com/srr/{service => }/dto/SportDto.java (97%) rename sport/src/main/java/com/srr/{service => }/dto/SportQueryCriteria.java (97%) rename sport/src/main/java/com/srr/{service => dto}/mapstruct/ClubMapper.java (92%) rename sport/src/main/java/com/srr/{service => dto}/mapstruct/CourtMapper.java (92%) rename sport/src/main/java/com/srr/{service => dto}/mapstruct/EventMapper.java (92%) rename sport/src/main/java/com/srr/{service => dto}/mapstruct/PlayerMapper.java (92%) rename sport/src/main/java/com/srr/{service => dto}/mapstruct/SportMapper.java (92%) diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml index 3249fbac..1a3ec556 100644 --- a/eladmin-system/src/main/resources/config/application.yml +++ b/eladmin-system/src/main/resources/config/application.yml @@ -68,6 +68,9 @@ s3: # File size /M max-size: 15 +qiniu: + max-size: 15 + # Email verification code validity time/seconds code: expiration: 300 diff --git a/sport/src/main/java/com/srr/service/dto/ClubDto.java b/sport/src/main/java/com/srr/dto/ClubDto.java similarity index 98% rename from sport/src/main/java/com/srr/service/dto/ClubDto.java rename to sport/src/main/java/com/srr/dto/ClubDto.java index ec9b24c7..5a92a20f 100644 --- a/sport/src/main/java/com/srr/service/dto/ClubDto.java +++ b/sport/src/main/java/com/srr/dto/ClubDto.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.dto; +package com.srr.dto; import lombok.Data; import java.sql.Timestamp; diff --git a/sport/src/main/java/com/srr/service/dto/ClubQueryCriteria.java b/sport/src/main/java/com/srr/dto/ClubQueryCriteria.java similarity index 97% rename from sport/src/main/java/com/srr/service/dto/ClubQueryCriteria.java rename to sport/src/main/java/com/srr/dto/ClubQueryCriteria.java index 6e6bf999..2248f329 100644 --- a/sport/src/main/java/com/srr/service/dto/ClubQueryCriteria.java +++ b/sport/src/main/java/com/srr/dto/ClubQueryCriteria.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.dto; +package com.srr.dto; import lombok.Data; import me.zhengjie.annotation.Query; diff --git a/sport/src/main/java/com/srr/service/dto/CourtDto.java b/sport/src/main/java/com/srr/dto/CourtDto.java similarity index 97% rename from sport/src/main/java/com/srr/service/dto/CourtDto.java rename to sport/src/main/java/com/srr/dto/CourtDto.java index 7428ff3e..37c2d395 100644 --- a/sport/src/main/java/com/srr/service/dto/CourtDto.java +++ b/sport/src/main/java/com/srr/dto/CourtDto.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.dto; +package com.srr.dto; import lombok.Data; import java.sql.Timestamp; diff --git a/sport/src/main/java/com/srr/service/dto/CourtQueryCriteria.java b/sport/src/main/java/com/srr/dto/CourtQueryCriteria.java similarity index 97% rename from sport/src/main/java/com/srr/service/dto/CourtQueryCriteria.java rename to sport/src/main/java/com/srr/dto/CourtQueryCriteria.java index 3649a1ad..b739bea8 100644 --- a/sport/src/main/java/com/srr/service/dto/CourtQueryCriteria.java +++ b/sport/src/main/java/com/srr/dto/CourtQueryCriteria.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.dto; +package com.srr.dto; import lombok.Data; import me.zhengjie.annotation.Query; diff --git a/sport/src/main/java/com/srr/service/dto/EventDto.java b/sport/src/main/java/com/srr/dto/EventDto.java similarity index 98% rename from sport/src/main/java/com/srr/service/dto/EventDto.java rename to sport/src/main/java/com/srr/dto/EventDto.java index e7e79ae9..793c4ad7 100644 --- a/sport/src/main/java/com/srr/service/dto/EventDto.java +++ b/sport/src/main/java/com/srr/dto/EventDto.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.dto; +package com.srr.dto; import com.srr.enumeration.Format; import io.swagger.annotations.ApiModelProperty; diff --git a/sport/src/main/java/com/srr/service/dto/EventQueryCriteria.java b/sport/src/main/java/com/srr/dto/EventQueryCriteria.java similarity index 98% rename from sport/src/main/java/com/srr/service/dto/EventQueryCriteria.java rename to sport/src/main/java/com/srr/dto/EventQueryCriteria.java index 61da75c1..e74212d9 100644 --- a/sport/src/main/java/com/srr/service/dto/EventQueryCriteria.java +++ b/sport/src/main/java/com/srr/dto/EventQueryCriteria.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.dto; +package com.srr.dto; import com.srr.enumeration.Format; import lombok.Data; diff --git a/sport/src/main/java/com/srr/service/dto/PlayerDto.java b/sport/src/main/java/com/srr/dto/PlayerDto.java similarity index 98% rename from sport/src/main/java/com/srr/service/dto/PlayerDto.java rename to sport/src/main/java/com/srr/dto/PlayerDto.java index fdfdd921..1ef2deb9 100644 --- a/sport/src/main/java/com/srr/service/dto/PlayerDto.java +++ b/sport/src/main/java/com/srr/dto/PlayerDto.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.dto; +package com.srr.dto; import lombok.Data; import java.sql.Timestamp; diff --git a/sport/src/main/java/com/srr/service/dto/PlayerQueryCriteria.java b/sport/src/main/java/com/srr/dto/PlayerQueryCriteria.java similarity index 97% rename from sport/src/main/java/com/srr/service/dto/PlayerQueryCriteria.java rename to sport/src/main/java/com/srr/dto/PlayerQueryCriteria.java index d0fa0ba1..b627080b 100644 --- a/sport/src/main/java/com/srr/service/dto/PlayerQueryCriteria.java +++ b/sport/src/main/java/com/srr/dto/PlayerQueryCriteria.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.dto; +package com.srr.dto; import lombok.Data; import me.zhengjie.annotation.Query; diff --git a/sport/src/main/java/com/srr/service/dto/SportDto.java b/sport/src/main/java/com/srr/dto/SportDto.java similarity index 97% rename from sport/src/main/java/com/srr/service/dto/SportDto.java rename to sport/src/main/java/com/srr/dto/SportDto.java index f66f2ae9..ae8ae2f8 100644 --- a/sport/src/main/java/com/srr/service/dto/SportDto.java +++ b/sport/src/main/java/com/srr/dto/SportDto.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.dto; +package com.srr.dto; import lombok.Data; import java.sql.Timestamp; diff --git a/sport/src/main/java/com/srr/service/dto/SportQueryCriteria.java b/sport/src/main/java/com/srr/dto/SportQueryCriteria.java similarity index 97% rename from sport/src/main/java/com/srr/service/dto/SportQueryCriteria.java rename to sport/src/main/java/com/srr/dto/SportQueryCriteria.java index 92972699..8364f23a 100644 --- a/sport/src/main/java/com/srr/service/dto/SportQueryCriteria.java +++ b/sport/src/main/java/com/srr/dto/SportQueryCriteria.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.dto; +package com.srr.dto; import lombok.Data; import java.sql.Timestamp; diff --git a/sport/src/main/java/com/srr/service/mapstruct/ClubMapper.java b/sport/src/main/java/com/srr/dto/mapstruct/ClubMapper.java similarity index 92% rename from sport/src/main/java/com/srr/service/mapstruct/ClubMapper.java rename to sport/src/main/java/com/srr/dto/mapstruct/ClubMapper.java index 68f0f0dc..7532000f 100644 --- a/sport/src/main/java/com/srr/service/mapstruct/ClubMapper.java +++ b/sport/src/main/java/com/srr/dto/mapstruct/ClubMapper.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.mapstruct; +package com.srr.dto.mapstruct; import me.zhengjie.base.BaseMapper; import com.srr.domain.Club; -import com.srr.service.dto.ClubDto; +import com.srr.dto.ClubDto; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; diff --git a/sport/src/main/java/com/srr/service/mapstruct/CourtMapper.java b/sport/src/main/java/com/srr/dto/mapstruct/CourtMapper.java similarity index 92% rename from sport/src/main/java/com/srr/service/mapstruct/CourtMapper.java rename to sport/src/main/java/com/srr/dto/mapstruct/CourtMapper.java index 4e6ad258..ebcd6806 100644 --- a/sport/src/main/java/com/srr/service/mapstruct/CourtMapper.java +++ b/sport/src/main/java/com/srr/dto/mapstruct/CourtMapper.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.mapstruct; +package com.srr.dto.mapstruct; import me.zhengjie.base.BaseMapper; import com.srr.domain.Court; -import com.srr.service.dto.CourtDto; +import com.srr.dto.CourtDto; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; diff --git a/sport/src/main/java/com/srr/service/mapstruct/EventMapper.java b/sport/src/main/java/com/srr/dto/mapstruct/EventMapper.java similarity index 92% rename from sport/src/main/java/com/srr/service/mapstruct/EventMapper.java rename to sport/src/main/java/com/srr/dto/mapstruct/EventMapper.java index 41439900..892f2d54 100644 --- a/sport/src/main/java/com/srr/service/mapstruct/EventMapper.java +++ b/sport/src/main/java/com/srr/dto/mapstruct/EventMapper.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.mapstruct; +package com.srr.dto.mapstruct; import me.zhengjie.base.BaseMapper; import com.srr.domain.Event; -import com.srr.service.dto.EventDto; +import com.srr.dto.EventDto; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; diff --git a/sport/src/main/java/com/srr/service/mapstruct/PlayerMapper.java b/sport/src/main/java/com/srr/dto/mapstruct/PlayerMapper.java similarity index 92% rename from sport/src/main/java/com/srr/service/mapstruct/PlayerMapper.java rename to sport/src/main/java/com/srr/dto/mapstruct/PlayerMapper.java index 52641a37..298dc985 100644 --- a/sport/src/main/java/com/srr/service/mapstruct/PlayerMapper.java +++ b/sport/src/main/java/com/srr/dto/mapstruct/PlayerMapper.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.mapstruct; +package com.srr.dto.mapstruct; import me.zhengjie.base.BaseMapper; import com.srr.domain.Player; -import com.srr.service.dto.PlayerDto; +import com.srr.dto.PlayerDto; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; diff --git a/sport/src/main/java/com/srr/service/mapstruct/SportMapper.java b/sport/src/main/java/com/srr/dto/mapstruct/SportMapper.java similarity index 92% rename from sport/src/main/java/com/srr/service/mapstruct/SportMapper.java rename to sport/src/main/java/com/srr/dto/mapstruct/SportMapper.java index 11deff14..3b4eed35 100644 --- a/sport/src/main/java/com/srr/service/mapstruct/SportMapper.java +++ b/sport/src/main/java/com/srr/dto/mapstruct/SportMapper.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.srr.service.mapstruct; +package com.srr.dto.mapstruct; import me.zhengjie.base.BaseMapper; import com.srr.domain.Sport; -import com.srr.service.dto.SportDto; +import com.srr.dto.SportDto; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; diff --git a/sport/src/main/java/com/srr/rest/ClubController.java b/sport/src/main/java/com/srr/rest/ClubController.java index 1195d381..b8bd4ae0 100644 --- a/sport/src/main/java/com/srr/rest/ClubController.java +++ b/sport/src/main/java/com/srr/rest/ClubController.java @@ -18,7 +18,7 @@ package com.srr.rest; import me.zhengjie.annotation.Log; import com.srr.domain.Club; import com.srr.service.ClubService; -import com.srr.service.dto.ClubQueryCriteria; +import com.srr.dto.ClubQueryCriteria; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -30,7 +30,7 @@ import io.swagger.annotations.*; import java.io.IOException; import javax.servlet.http.HttpServletResponse; import me.zhengjie.utils.PageResult; -import com.srr.service.dto.ClubDto; +import com.srr.dto.ClubDto; /** * @website https://eladmin.vip diff --git a/sport/src/main/java/com/srr/rest/CourtController.java b/sport/src/main/java/com/srr/rest/CourtController.java index 5244926f..0a498369 100644 --- a/sport/src/main/java/com/srr/rest/CourtController.java +++ b/sport/src/main/java/com/srr/rest/CourtController.java @@ -18,7 +18,7 @@ package com.srr.rest; import me.zhengjie.annotation.Log; import com.srr.domain.Court; import com.srr.service.CourtService; -import com.srr.service.dto.CourtQueryCriteria; +import com.srr.dto.CourtQueryCriteria; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -30,7 +30,7 @@ import io.swagger.annotations.*; import java.io.IOException; import javax.servlet.http.HttpServletResponse; import me.zhengjie.utils.PageResult; -import com.srr.service.dto.CourtDto; +import com.srr.dto.CourtDto; /** * @website https://eladmin.vip diff --git a/sport/src/main/java/com/srr/rest/EventController.java b/sport/src/main/java/com/srr/rest/EventController.java index bd4c0eb0..296520cd 100644 --- a/sport/src/main/java/com/srr/rest/EventController.java +++ b/sport/src/main/java/com/srr/rest/EventController.java @@ -18,7 +18,7 @@ package com.srr.rest; import me.zhengjie.annotation.Log; import com.srr.domain.Event; import com.srr.service.EventService; -import com.srr.service.dto.EventQueryCriteria; +import com.srr.dto.EventQueryCriteria; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -30,7 +30,7 @@ import io.swagger.annotations.*; import java.io.IOException; import javax.servlet.http.HttpServletResponse; import me.zhengjie.utils.PageResult; -import com.srr.service.dto.EventDto; +import com.srr.dto.EventDto; /** * @website https://eladmin.vip diff --git a/sport/src/main/java/com/srr/rest/PlayerController.java b/sport/src/main/java/com/srr/rest/PlayerController.java index 05c6a284..d1b1b0c8 100644 --- a/sport/src/main/java/com/srr/rest/PlayerController.java +++ b/sport/src/main/java/com/srr/rest/PlayerController.java @@ -18,7 +18,7 @@ package com.srr.rest; import me.zhengjie.annotation.Log; import com.srr.domain.Player; import com.srr.service.PlayerService; -import com.srr.service.dto.PlayerQueryCriteria; +import com.srr.dto.PlayerQueryCriteria; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -30,7 +30,7 @@ import io.swagger.annotations.*; import java.io.IOException; import javax.servlet.http.HttpServletResponse; import me.zhengjie.utils.PageResult; -import com.srr.service.dto.PlayerDto; +import com.srr.dto.PlayerDto; /** * @website https://eladmin.vip diff --git a/sport/src/main/java/com/srr/rest/SportController.java b/sport/src/main/java/com/srr/rest/SportController.java index 49a3ffe1..3616ac85 100644 --- a/sport/src/main/java/com/srr/rest/SportController.java +++ b/sport/src/main/java/com/srr/rest/SportController.java @@ -18,7 +18,7 @@ package com.srr.rest; import me.zhengjie.annotation.Log; import com.srr.domain.Sport; import com.srr.service.SportService; -import com.srr.service.dto.SportQueryCriteria; +import com.srr.dto.SportQueryCriteria; import me.zhengjie.annotation.rest.AnonymousGetMapping; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; @@ -31,7 +31,7 @@ import io.swagger.annotations.*; import java.io.IOException; import javax.servlet.http.HttpServletResponse; import me.zhengjie.utils.PageResult; -import com.srr.service.dto.SportDto; +import com.srr.dto.SportDto; /** * @website https://eladmin.vip diff --git a/sport/src/main/java/com/srr/service/ClubService.java b/sport/src/main/java/com/srr/service/ClubService.java index f08b3caf..92596fb0 100644 --- a/sport/src/main/java/com/srr/service/ClubService.java +++ b/sport/src/main/java/com/srr/service/ClubService.java @@ -16,8 +16,8 @@ package com.srr.service; import com.srr.domain.Club; -import com.srr.service.dto.ClubDto; -import com.srr.service.dto.ClubQueryCriteria; +import com.srr.dto.ClubDto; +import com.srr.dto.ClubQueryCriteria; import org.springframework.data.domain.Pageable; import java.util.List; diff --git a/sport/src/main/java/com/srr/service/CourtService.java b/sport/src/main/java/com/srr/service/CourtService.java index 0f5d4c29..ded12a57 100644 --- a/sport/src/main/java/com/srr/service/CourtService.java +++ b/sport/src/main/java/com/srr/service/CourtService.java @@ -16,8 +16,8 @@ package com.srr.service; import com.srr.domain.Court; -import com.srr.service.dto.CourtDto; -import com.srr.service.dto.CourtQueryCriteria; +import com.srr.dto.CourtDto; +import com.srr.dto.CourtQueryCriteria; import org.springframework.data.domain.Pageable; import java.util.List; diff --git a/sport/src/main/java/com/srr/service/EventService.java b/sport/src/main/java/com/srr/service/EventService.java index 785ab9a9..dec18861 100644 --- a/sport/src/main/java/com/srr/service/EventService.java +++ b/sport/src/main/java/com/srr/service/EventService.java @@ -16,8 +16,8 @@ package com.srr.service; import com.srr.domain.Event; -import com.srr.service.dto.EventDto; -import com.srr.service.dto.EventQueryCriteria; +import com.srr.dto.EventDto; +import com.srr.dto.EventQueryCriteria; import org.springframework.data.domain.Pageable; import java.util.List; diff --git a/sport/src/main/java/com/srr/service/PlayerService.java b/sport/src/main/java/com/srr/service/PlayerService.java index 61c532e1..9265cbb3 100644 --- a/sport/src/main/java/com/srr/service/PlayerService.java +++ b/sport/src/main/java/com/srr/service/PlayerService.java @@ -16,8 +16,8 @@ package com.srr.service; import com.srr.domain.Player; -import com.srr.service.dto.PlayerDto; -import com.srr.service.dto.PlayerQueryCriteria; +import com.srr.dto.PlayerDto; +import com.srr.dto.PlayerQueryCriteria; import org.springframework.data.domain.Pageable; import java.util.List; diff --git a/sport/src/main/java/com/srr/service/SportService.java b/sport/src/main/java/com/srr/service/SportService.java index b7a04a49..61b25cf6 100644 --- a/sport/src/main/java/com/srr/service/SportService.java +++ b/sport/src/main/java/com/srr/service/SportService.java @@ -16,10 +16,10 @@ package com.srr.service; import com.srr.domain.Sport; -import com.srr.service.dto.SportDto; -import com.srr.service.dto.SportQueryCriteria; +import com.srr.dto.SportDto; +import com.srr.dto.SportQueryCriteria; import org.springframework.data.domain.Pageable; -import java.util.Map; + import java.util.List; import java.io.IOException; import javax.servlet.http.HttpServletResponse; diff --git a/sport/src/main/java/com/srr/service/impl/ClubServiceImpl.java b/sport/src/main/java/com/srr/service/impl/ClubServiceImpl.java index 1e1a3cb3..72e4b7f5 100644 --- a/sport/src/main/java/com/srr/service/impl/ClubServiceImpl.java +++ b/sport/src/main/java/com/srr/service/impl/ClubServiceImpl.java @@ -21,9 +21,9 @@ import me.zhengjie.utils.FileUtil; import lombok.RequiredArgsConstructor; import com.srr.repository.ClubRepository; import com.srr.service.ClubService; -import com.srr.service.dto.ClubDto; -import com.srr.service.dto.ClubQueryCriteria; -import com.srr.service.mapstruct.ClubMapper; +import com.srr.dto.ClubDto; +import com.srr.dto.ClubQueryCriteria; +import com.srr.dto.mapstruct.ClubMapper; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; diff --git a/sport/src/main/java/com/srr/service/impl/CourtServiceImpl.java b/sport/src/main/java/com/srr/service/impl/CourtServiceImpl.java index 89f8cff3..f3f67f0b 100644 --- a/sport/src/main/java/com/srr/service/impl/CourtServiceImpl.java +++ b/sport/src/main/java/com/srr/service/impl/CourtServiceImpl.java @@ -21,9 +21,9 @@ import me.zhengjie.utils.FileUtil; import lombok.RequiredArgsConstructor; import com.srr.repository.CourtRepository; import com.srr.service.CourtService; -import com.srr.service.dto.CourtDto; -import com.srr.service.dto.CourtQueryCriteria; -import com.srr.service.mapstruct.CourtMapper; +import com.srr.dto.CourtDto; +import com.srr.dto.CourtQueryCriteria; +import com.srr.dto.mapstruct.CourtMapper; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; diff --git a/sport/src/main/java/com/srr/service/impl/EventServiceImpl.java b/sport/src/main/java/com/srr/service/impl/EventServiceImpl.java index 4bb77398..36285778 100644 --- a/sport/src/main/java/com/srr/service/impl/EventServiceImpl.java +++ b/sport/src/main/java/com/srr/service/impl/EventServiceImpl.java @@ -21,9 +21,9 @@ import me.zhengjie.utils.FileUtil; import lombok.RequiredArgsConstructor; import com.srr.repository.EventRepository; import com.srr.service.EventService; -import com.srr.service.dto.EventDto; -import com.srr.service.dto.EventQueryCriteria; -import com.srr.service.mapstruct.EventMapper; +import com.srr.dto.EventDto; +import com.srr.dto.EventQueryCriteria; +import com.srr.dto.mapstruct.EventMapper; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; diff --git a/sport/src/main/java/com/srr/service/impl/PlayerServiceImpl.java b/sport/src/main/java/com/srr/service/impl/PlayerServiceImpl.java index 528e1e85..384f40d7 100644 --- a/sport/src/main/java/com/srr/service/impl/PlayerServiceImpl.java +++ b/sport/src/main/java/com/srr/service/impl/PlayerServiceImpl.java @@ -21,9 +21,9 @@ import me.zhengjie.utils.FileUtil; import lombok.RequiredArgsConstructor; import com.srr.repository.PlayerRepository; import com.srr.service.PlayerService; -import com.srr.service.dto.PlayerDto; -import com.srr.service.dto.PlayerQueryCriteria; -import com.srr.service.mapstruct.PlayerMapper; +import com.srr.dto.PlayerDto; +import com.srr.dto.PlayerQueryCriteria; +import com.srr.dto.mapstruct.PlayerMapper; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; diff --git a/sport/src/main/java/com/srr/service/impl/SportServiceImpl.java b/sport/src/main/java/com/srr/service/impl/SportServiceImpl.java index eb9fe8af..907389d0 100644 --- a/sport/src/main/java/com/srr/service/impl/SportServiceImpl.java +++ b/sport/src/main/java/com/srr/service/impl/SportServiceImpl.java @@ -21,9 +21,9 @@ import me.zhengjie.utils.FileUtil; import lombok.RequiredArgsConstructor; import com.srr.repository.SportRepository; import com.srr.service.SportService; -import com.srr.service.dto.SportDto; -import com.srr.service.dto.SportQueryCriteria; -import com.srr.service.mapstruct.SportMapper; +import com.srr.dto.SportDto; +import com.srr.dto.SportQueryCriteria; +import com.srr.dto.mapstruct.SportMapper; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; From 009714e38b8c58ff3330869d8f7efdfce8f994f4 Mon Sep 17 00:00:00 2001 From: chanhengseang Date: Sun, 25 May 2025 17:48:50 -0700 Subject: [PATCH 3/5] restructure --- .../db/migration/V7__add_event_status.sql | 4 +++ sport/src/main/java/com/srr/domain/Event.java | 12 +++++++ sport/src/main/java/com/srr/domain/Team.java | 32 +++++++++++++++++++ .../main/java/com/srr/domain/TeamPlayer.java | 31 ++++++++++++++++++ sport/src/main/java/com/srr/dto/EventDto.java | 7 ++++ .../java/com/srr/enumeration/EventStatus.java | 7 ++++ 6 files changed, 93 insertions(+) create mode 100644 eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql create mode 100644 sport/src/main/java/com/srr/domain/Team.java create mode 100644 sport/src/main/java/com/srr/domain/TeamPlayer.java create mode 100644 sport/src/main/java/com/srr/enumeration/EventStatus.java diff --git a/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql b/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql new file mode 100644 index 00000000..41eaf794 --- /dev/null +++ b/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql @@ -0,0 +1,4 @@ +alter table event + add column status varchar(255), + add column is_public bit default 0, + add column allow_wait_list bit default 0; diff --git a/sport/src/main/java/com/srr/domain/Event.java b/sport/src/main/java/com/srr/domain/Event.java index 153872ee..2a114ae0 100644 --- a/sport/src/main/java/com/srr/domain/Event.java +++ b/sport/src/main/java/com/srr/domain/Event.java @@ -15,6 +15,7 @@ */ package com.srr.domain; +import com.srr.enumeration.EventStatus; import com.srr.enumeration.Format; import lombok.Data; import cn.hutool.core.bean.BeanUtil; @@ -114,6 +115,17 @@ public class Event implements Serializable { @ApiModelProperty(value = "createBy") private Long createBy; + @Column(name = "`status`") + @Enumerated(EnumType.STRING) + @ApiModelProperty(value = "status") + private EventStatus status; + + @Column(name = "`is_public`") + private boolean isPublic; + + @Column(name = "`allow_wait_list`") + private boolean allowWaitList; + public void copy(Event source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/sport/src/main/java/com/srr/domain/Team.java b/sport/src/main/java/com/srr/domain/Team.java new file mode 100644 index 00000000..3b6b07a3 --- /dev/null +++ b/sport/src/main/java/com/srr/domain/Team.java @@ -0,0 +1,32 @@ +package com.srr.domain; + +import io.swagger.annotations.ApiModelProperty; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +@Entity +@Table(name = "`team`") +public class Team implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`id`") + @ApiModelProperty(value = "id", hidden = true) + private Long id; + + @Column(name = "`name`") + @ApiModelProperty(value = "Name") + private String name; + + @Column(name = "`team_size`") + @ApiModelProperty(value = "Team size") + private int teamSize; + + @OneToMany(mappedBy = "team") + @JoinTable(name = "team_players", + joinColumns = {@JoinColumn(name = "team_id",referencedColumnName = "id")}) + @ApiModelProperty(value = "Players") + private List players; // +} diff --git a/sport/src/main/java/com/srr/domain/TeamPlayer.java b/sport/src/main/java/com/srr/domain/TeamPlayer.java new file mode 100644 index 00000000..1e09bb27 --- /dev/null +++ b/sport/src/main/java/com/srr/domain/TeamPlayer.java @@ -0,0 +1,31 @@ +package com.srr.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.persistence.*; +import java.io.Serializable; + +@Getter +@Setter +@Entity +@Table(name = "`team_player`") +public class TeamPlayer implements Serializable { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`id`") + @ApiModelProperty(value = "id", hidden = true) + private Long id; + + @ManyToOne + @JoinColumn(name = "team_id") + private Team team; + + @ManyToOne + @JoinColumn(name = "player_id") + private Player player; + + @Column(name = "`is_checked_in`") + private boolean isCheckedIn; +} diff --git a/sport/src/main/java/com/srr/dto/EventDto.java b/sport/src/main/java/com/srr/dto/EventDto.java index 793c4ad7..b83aed93 100644 --- a/sport/src/main/java/com/srr/dto/EventDto.java +++ b/sport/src/main/java/com/srr/dto/EventDto.java @@ -15,6 +15,7 @@ */ package com.srr.dto; +import com.srr.enumeration.EventStatus; import com.srr.enumeration.Format; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -78,4 +79,10 @@ public class EventDto implements Serializable { @ApiModelProperty(value = "createBy") private Long createBy; + + private EventStatus status; + + private boolean isPublic; + + private boolean allowWaitList; } \ No newline at end of file diff --git a/sport/src/main/java/com/srr/enumeration/EventStatus.java b/sport/src/main/java/com/srr/enumeration/EventStatus.java new file mode 100644 index 00000000..aa10d100 --- /dev/null +++ b/sport/src/main/java/com/srr/enumeration/EventStatus.java @@ -0,0 +1,7 @@ +package com.srr.enumeration; + +public enum EventStatus { + OPEN, + IN_PROGRESS, + CLOSED +} From 69b559997d601694cd92e1f5c66886bca9517361 Mon Sep 17 00:00:00 2001 From: chanhengseang Date: Sun, 25 May 2025 18:02:40 -0700 Subject: [PATCH 4/5] add team --- .../db/migration/V7__add_event_status.sql | 16 +++++++ sport/src/main/java/com/srr/domain/Team.java | 10 ++-- sport/src/main/java/com/srr/dto/TeamDto.java | 47 +++++++++++++++++++ .../main/java/com/srr/dto/TeamPlayerDto.java | 46 ++++++++++++++++++ .../srr/repository/TeamPlayerRepository.java | 28 +++++++++++ .../com/srr/repository/TeamRepository.java | 28 +++++++++++ 6 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 sport/src/main/java/com/srr/dto/TeamDto.java create mode 100644 sport/src/main/java/com/srr/dto/TeamPlayerDto.java create mode 100644 sport/src/main/java/com/srr/repository/TeamPlayerRepository.java create mode 100644 sport/src/main/java/com/srr/repository/TeamRepository.java diff --git a/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql b/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql index 41eaf794..a63844f9 100644 --- a/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql +++ b/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql @@ -2,3 +2,19 @@ alter table event add column status varchar(255), add column is_public bit default 0, add column allow_wait_list bit default 0; + +CREATE TABLE team ( + id BIGINT PRIMARY KEY AUTO_INCREMENT, + event_id BIGINT references event(id), + name VARCHAR(255), + team_size INT default 2 +); + +CREATE TABLE team_player ( + id BIGINT PRIMARY KEY AUTO_INCREMENT, + team_id BIGINT, + player_id BIGINT, + is_checked_in BIT DEFAULT 0, + CONSTRAINT fk_team FOREIGN KEY (team_id) REFERENCES team(id), + CONSTRAINT fk_player FOREIGN KEY (player_id) REFERENCES player(id) +); diff --git a/sport/src/main/java/com/srr/domain/Team.java b/sport/src/main/java/com/srr/domain/Team.java index 3b6b07a3..eec9db85 100644 --- a/sport/src/main/java/com/srr/domain/Team.java +++ b/sport/src/main/java/com/srr/domain/Team.java @@ -16,6 +16,10 @@ public class Team implements Serializable { @ApiModelProperty(value = "id", hidden = true) private Long id; + @ManyToOne + @JoinColumn(name = "event_id") + private Event event; + @Column(name = "`name`") @ApiModelProperty(value = "Name") private String name; @@ -25,8 +29,6 @@ public class Team implements Serializable { private int teamSize; @OneToMany(mappedBy = "team") - @JoinTable(name = "team_players", - joinColumns = {@JoinColumn(name = "team_id",referencedColumnName = "id")}) - @ApiModelProperty(value = "Players") - private List players; // + @ApiModelProperty(value = "teamPlayers") + private List teamPlayers; } diff --git a/sport/src/main/java/com/srr/dto/TeamDto.java b/sport/src/main/java/com/srr/dto/TeamDto.java new file mode 100644 index 00000000..b0af611d --- /dev/null +++ b/sport/src/main/java/com/srr/dto/TeamDto.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.util.List; + +/** +* @website https://eladmin.vip +* @description / +* @author Chanheng +* @date 2025-05-25 +**/ +@Data +public class TeamDto implements Serializable { + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "Event") + private Long eventId; + + @ApiModelProperty(value = "Name") + private String name; + + @ApiModelProperty(value = "Team size") + private Integer teamSize; + + @ApiModelProperty(value = "Team players") + private List teamPlayers; +} diff --git a/sport/src/main/java/com/srr/dto/TeamPlayerDto.java b/sport/src/main/java/com/srr/dto/TeamPlayerDto.java new file mode 100644 index 00000000..644821c3 --- /dev/null +++ b/sport/src/main/java/com/srr/dto/TeamPlayerDto.java @@ -0,0 +1,46 @@ +/* +* 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; + +/** +* @website https://eladmin.vip +* @description / +* @author Chanheng +* @date 2025-05-25 +**/ +@Data +public class TeamPlayerDto implements Serializable { + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "Team id") + private Long teamId; + + @ApiModelProperty(value = "Player id") + private Long playerId; + + @ApiModelProperty(value = "Player name") + private String playerName; + + @ApiModelProperty(value = "Is checked in") + private Boolean isCheckedIn; +} diff --git a/sport/src/main/java/com/srr/repository/TeamPlayerRepository.java b/sport/src/main/java/com/srr/repository/TeamPlayerRepository.java new file mode 100644 index 00000000..23ddc250 --- /dev/null +++ b/sport/src/main/java/com/srr/repository/TeamPlayerRepository.java @@ -0,0 +1,28 @@ +/* +* 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.TeamPlayer; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://eladmin.vip +* @author Chanheng +* @date 2025-05-25 +**/ +public interface TeamPlayerRepository extends JpaRepository, JpaSpecificationExecutor { +} diff --git a/sport/src/main/java/com/srr/repository/TeamRepository.java b/sport/src/main/java/com/srr/repository/TeamRepository.java new file mode 100644 index 00000000..a1f3f030 --- /dev/null +++ b/sport/src/main/java/com/srr/repository/TeamRepository.java @@ -0,0 +1,28 @@ +/* +* 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.Team; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://eladmin.vip +* @author Chanheng +* @date 2025-05-25 +**/ +public interface TeamRepository extends JpaRepository, JpaSpecificationExecutor { +} From e7b914c00bdeeea10b8c66e3305dfca548d94d3b Mon Sep 17 00:00:00 2001 From: chanhengseang Date: Sun, 25 May 2025 18:14:57 -0700 Subject: [PATCH 5/5] add Match --- .../db/migration/V7__add_event_status.sql | 1 + sport/src/main/java/com/srr/domain/Match.java | 49 +++++++++++++++++++ .../main/java/com/srr/domain/MatchGroup.java | 28 +++++++++++ .../main/java/com/srr/domain/TeamPlayer.java | 3 ++ sport/src/main/java/com/srr/dto/MatchDto.java | 49 +++++++++++++++++++ .../main/java/com/srr/dto/MatchGroupDto.java | 40 +++++++++++++++ .../main/java/com/srr/dto/TeamPlayerDto.java | 3 ++ .../srr/repository/MatchGroupRepository.java | 28 +++++++++++ .../com/srr/repository/MatchRepository.java | 28 +++++++++++ 9 files changed, 229 insertions(+) create mode 100644 sport/src/main/java/com/srr/domain/Match.java create mode 100644 sport/src/main/java/com/srr/domain/MatchGroup.java create mode 100644 sport/src/main/java/com/srr/dto/MatchDto.java create mode 100644 sport/src/main/java/com/srr/dto/MatchGroupDto.java create mode 100644 sport/src/main/java/com/srr/repository/MatchGroupRepository.java create mode 100644 sport/src/main/java/com/srr/repository/MatchRepository.java diff --git a/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql b/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql index a63844f9..aa29a517 100644 --- a/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql +++ b/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql @@ -14,6 +14,7 @@ CREATE TABLE team_player ( id BIGINT PRIMARY KEY AUTO_INCREMENT, team_id BIGINT, player_id BIGINT, + score DOUBLE DEFAULT NULL, is_checked_in BIT DEFAULT 0, CONSTRAINT fk_team FOREIGN KEY (team_id) REFERENCES team(id), CONSTRAINT fk_player FOREIGN KEY (player_id) REFERENCES player(id) diff --git a/sport/src/main/java/com/srr/domain/Match.java b/sport/src/main/java/com/srr/domain/Match.java new file mode 100644 index 00000000..4054233a --- /dev/null +++ b/sport/src/main/java/com/srr/domain/Match.java @@ -0,0 +1,49 @@ +package com.srr.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.persistence.*; +import java.io.Serializable; + +@Entity +@Setter +@Getter +public class Match implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`id`") + @ApiModelProperty(value = "id", hidden = true) + private Long id; + + @ManyToOne + @JoinColumn(name = "match_group_id") + private MatchGroup matchGroup; + + @ManyToOne + @JoinColumn(name = "team_player_a_id") + private TeamPlayer teamPlayerA; + + @Column(name = "`score_a`") + @ApiModelProperty(value = "Score A") + private int scoreA; + + @Column(name = "`team_a_win`") + private boolean teamAWin; + + @Column(name = "`score_b`") + @ApiModelProperty(value = "Score B") + private int scoreB; + + @Column(name = "`team_b_win`") + private boolean teamBWin; + + @ManyToOne + @JoinColumn(name = "team_player_b_id") + private TeamPlayer teamPlayerB; + + @Column(name = "`score_verified`") + private boolean scoreVerified; +} diff --git a/sport/src/main/java/com/srr/domain/MatchGroup.java b/sport/src/main/java/com/srr/domain/MatchGroup.java new file mode 100644 index 00000000..e538a2df --- /dev/null +++ b/sport/src/main/java/com/srr/domain/MatchGroup.java @@ -0,0 +1,28 @@ +package com.srr.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.persistence.*; +import java.io.Serializable; + +@Getter +@Setter +@Entity +public class MatchGroup implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`id`") + @ApiModelProperty(value = "id", hidden = true) + private Long id; + + @Column(name = "`name`") + @ApiModelProperty(value = "Name") + private String name; + + @ManyToOne + @JoinColumn(name = "event_id") + private Event event; +} diff --git a/sport/src/main/java/com/srr/domain/TeamPlayer.java b/sport/src/main/java/com/srr/domain/TeamPlayer.java index 1e09bb27..844173b1 100644 --- a/sport/src/main/java/com/srr/domain/TeamPlayer.java +++ b/sport/src/main/java/com/srr/domain/TeamPlayer.java @@ -22,6 +22,9 @@ public class TeamPlayer implements Serializable { @JoinColumn(name = "team_id") private Team team; + @Column(name = "`score`") + private Double score; + @ManyToOne @JoinColumn(name = "player_id") private Player player; diff --git a/sport/src/main/java/com/srr/dto/MatchDto.java b/sport/src/main/java/com/srr/dto/MatchDto.java new file mode 100644 index 00000000..232033b1 --- /dev/null +++ b/sport/src/main/java/com/srr/dto/MatchDto.java @@ -0,0 +1,49 @@ +/* +* 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; + +/** +* @website https://eladmin.vip +* @description / +* @author Chanheng +* @date 2025-05-25 +**/ +@Data +public class MatchDto implements Serializable { + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "Match Group id") + private Long matchGroupId; + + @ApiModelProperty(value = "Team 1 id") + private Long team1Id; + + @ApiModelProperty(value = "Team 2 id") + private Long team2Id; + + @ApiModelProperty(value = "Score Team 1") + private Integer scoreTeam1; + + @ApiModelProperty(value = "Score Team 2") + private Integer scoreTeam2; +} diff --git a/sport/src/main/java/com/srr/dto/MatchGroupDto.java b/sport/src/main/java/com/srr/dto/MatchGroupDto.java new file mode 100644 index 00000000..ac560961 --- /dev/null +++ b/sport/src/main/java/com/srr/dto/MatchGroupDto.java @@ -0,0 +1,40 @@ +/* +* 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; + +/** +* @website https://eladmin.vip +* @description / +* @author Chanheng +* @date 2025-05-25 +**/ +@Data +public class MatchGroupDto implements Serializable { + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "Name") + private String name; + + @ApiModelProperty(value = "Event id") + private Long eventId; +} diff --git a/sport/src/main/java/com/srr/dto/TeamPlayerDto.java b/sport/src/main/java/com/srr/dto/TeamPlayerDto.java index 644821c3..c02c1666 100644 --- a/sport/src/main/java/com/srr/dto/TeamPlayerDto.java +++ b/sport/src/main/java/com/srr/dto/TeamPlayerDto.java @@ -41,6 +41,9 @@ public class TeamPlayerDto implements Serializable { @ApiModelProperty(value = "Player name") private String playerName; + @ApiModelProperty(value = "Score") + private Double score; + @ApiModelProperty(value = "Is checked in") private Boolean isCheckedIn; } diff --git a/sport/src/main/java/com/srr/repository/MatchGroupRepository.java b/sport/src/main/java/com/srr/repository/MatchGroupRepository.java new file mode 100644 index 00000000..f788ee89 --- /dev/null +++ b/sport/src/main/java/com/srr/repository/MatchGroupRepository.java @@ -0,0 +1,28 @@ +/* +* 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.MatchGroup; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://eladmin.vip +* @author Chanheng +* @date 2025-05-25 +**/ +public interface MatchGroupRepository extends JpaRepository, JpaSpecificationExecutor { +} diff --git a/sport/src/main/java/com/srr/repository/MatchRepository.java b/sport/src/main/java/com/srr/repository/MatchRepository.java new file mode 100644 index 00000000..51113f3f --- /dev/null +++ b/sport/src/main/java/com/srr/repository/MatchRepository.java @@ -0,0 +1,28 @@ +/* +* 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.Match; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://eladmin.vip +* @author Chanheng +* @date 2025-05-25 +**/ +public interface MatchRepository extends JpaRepository, JpaSpecificationExecutor { +}