-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an API to get the repository list by user id
This API can also be used for getting other's repository list, but only the public repository can be got. The test case will be added after finishing the APIs related to repository (such as creating a repository, updating a repository, etc.). See #32.
- Loading branch information
1 parent
0701b7c
commit bbb5cc5
Showing
12 changed files
with
228 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package edu.cmipt.gcs.dao; | ||
|
||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
|
||
import edu.cmipt.gcs.pojo.repository.RepositoryPO; | ||
|
||
public interface RepositoryMapper extends BaseMapper<RepositoryPO> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/edu/cmipt/gcs/pojo/repository/RepositoryDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package edu.cmipt.gcs.pojo.repository; | ||
|
||
import edu.cmipt.gcs.constant.ValidationConstant; | ||
import edu.cmipt.gcs.validation.group.CreateGroup; | ||
import edu.cmipt.gcs.validation.group.UpdateGroup; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.Min; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Null; | ||
import jakarta.validation.constraints.Pattern; | ||
import jakarta.validation.constraints.Size; | ||
|
||
@Schema(description = "Repository Data Transfer Object") | ||
public record RepositoryDTO( | ||
@Schema(description = "Repository ID") | ||
@Null(groups = CreateGroup.class, message = "REPOSITORYDTO_ID_NULL {RepositoryDTO.id.Null}") | ||
@NotNull( | ||
groups = UpdateGroup.class, | ||
message = "REPOSITORYDTO_ID_NOTNULL {RepositoryDTO.id.NotNull}") | ||
String id, | ||
@Schema( | ||
description = "Repository Name", | ||
requiredMode = Schema.RequiredMode.REQUIRED, | ||
example = "gcs") | ||
@Size( | ||
groups = {CreateGroup.class, UpdateGroup.class}, | ||
min = ValidationConstant.MIN_REPOSITORY_NAME_LENGTH, | ||
max = ValidationConstant.MAX_REPOSITORY_NAME_LENGTH, | ||
message = "REPOSITORYDTO_REPOSITORYNAME_SIZE {RepositoryDTO.repositoryName.Size}") | ||
@NotBlank( | ||
groups = {CreateGroup.class}, | ||
message = "REPOSITORYDTO_REPOSITORYNAME_NOTBLANK {RepositoryDTO.repositoryName.NotBlank}") | ||
@Pattern( | ||
regexp = ValidationConstant.REPOSITORY_NAME_PATTERN, | ||
groups = {CreateGroup.class, UpdateGroup.class}, | ||
message = "REPOSITORYNAME_PATTERN_MISMATCH {REPOSITORYNAME_PATTERN_MISMATCH}") | ||
String repositoryName, | ||
@Schema(description = "Repository Description") | ||
@Size( | ||
groups = {CreateGroup.class, UpdateGroup.class}, | ||
min = ValidationConstant.MIN_REPOSITORY_DESCRIPTION_LENGTH, | ||
max = ValidationConstant.MAX_REPOSITORY_DESCRIPTION_LENGTH, | ||
message = "REPOSITORYDTO_REPOSITORYDESCRIPTION_SIZE {RepositoryDTO.repositoryDescription.Size}") | ||
String repositoryDescription, | ||
@Schema(description = "Whether or Not Private Repo") | ||
Boolean isPrivate, | ||
@Schema(description = "Star Count") | ||
@Min(groups = {CreateGroup.class, UpdateGroup.class}, value = 0, message = "REPOSITORYDTO_STAR_MIN {RepositoryDTO.star.Min}") | ||
Integer star, | ||
@Schema(description = "Fork Count") | ||
@Min(groups = {CreateGroup.class, UpdateGroup.class}, value = 0, message = "REPOSITORYDTO_FORK_MIN {RepositoryDTO.fork.Min}") | ||
Integer fork, | ||
@Schema(description = "Watcher Count") | ||
@Min(groups = {CreateGroup.class, UpdateGroup.class}, value = 0, message = "REPOSITORYDTO_WATCHER_MIN {RepositoryDTO.watcher.Min}") | ||
Integer watcher | ||
) {} |
38 changes: 38 additions & 0 deletions
38
src/main/java/edu/cmipt/gcs/pojo/repository/RepositoryPO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package edu.cmipt.gcs.pojo.repository; | ||
|
||
import com.baomidou.mybatisplus.annotation.TableName; | ||
|
||
import java.time.LocalDateTime; | ||
import com.baomidou.mybatisplus.annotation.TableLogic; | ||
import lombok.Data; | ||
|
||
@Data | ||
@TableName("t_repository") | ||
public class RepositoryPO { | ||
private Long id; | ||
private String repositoryName; | ||
private String repositoryDescription; | ||
private Boolean isPrivate; | ||
private Long userId; | ||
private Integer star; | ||
private Integer fork; | ||
private Integer watcher; | ||
private LocalDateTime gmtCreated; | ||
private LocalDateTime gmtUpdated; | ||
@TableLogic private LocalDateTime gmtDeleted; | ||
|
||
public RepositoryPO(RepositoryDTO repositoryDTO, Long userId) { | ||
try { | ||
this.id = Long.valueOf(repositoryDTO.id()); | ||
} catch (NumberFormatException e) { | ||
this.id = null; | ||
} | ||
this.repositoryName = repositoryDTO.repositoryName(); | ||
this.repositoryDescription = repositoryDTO.repositoryDescription(); | ||
this.isPrivate = repositoryDTO.isPrivate(); | ||
this.userId = userId; | ||
this.star = repositoryDTO.star(); | ||
this.fork = repositoryDTO.fork(); | ||
this.watcher = repositoryDTO.watcher(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/edu/cmipt/gcs/pojo/repository/RepositoryVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package edu.cmipt.gcs.pojo.repository; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
public record RepositoryVO( | ||
@Schema(description = "Repository ID") String id, | ||
@Schema(description = "Repository Name") String repositoryName, | ||
@Schema(description = "Repository Description") String repositoryDescription, | ||
@Schema(description = "Whether or Not Private Repo") Boolean isPrivate, | ||
@Schema(description = "Star Count") Integer star, | ||
@Schema(description = "Fork Count") Integer fork, | ||
@Schema(description = "Watcher Count") Integer watcher) { | ||
public RepositoryVO(RepositoryPO repositoryPO) { | ||
this(repositoryPO.getId().toString(), repositoryPO.getRepositoryName(), repositoryPO.getRepositoryDescription(), | ||
repositoryPO.getIsPrivate(), repositoryPO.getStar(), repositoryPO.getFork(), repositoryPO.getWatcher()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package edu.cmipt.gcs.service; | ||
|
||
import com.baomidou.mybatisplus.extension.service.IService; | ||
|
||
import edu.cmipt.gcs.pojo.repository.RepositoryPO; | ||
|
||
public interface RepositoryService extends IService<RepositoryPO> {} |
11 changes: 11 additions & 0 deletions
11
src/main/java/edu/cmipt/gcs/service/RepositoryServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package edu.cmipt.gcs.service; | ||
|
||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||
|
||
import edu.cmipt.gcs.dao.RepositoryMapper; | ||
import edu.cmipt.gcs.pojo.repository.RepositoryPO; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class RepositoryServiceImpl extends ServiceImpl<RepositoryMapper, RepositoryPO> implements RepositoryService {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters