-
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.
Merge pull request #47 from CMIPT/kaiser-crud
Add an API for getting the repository list by user id.
- Loading branch information
Showing
12 changed files
with
257 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
75 changes: 75 additions & 0 deletions
75
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,75 @@ | ||
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) {} |
39 changes: 39 additions & 0 deletions
39
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,39 @@ | ||
package edu.cmipt.gcs.pojo.repository; | ||
|
||
import com.baomidou.mybatisplus.annotation.TableLogic; | ||
import com.baomidou.mybatisplus.annotation.TableName; | ||
|
||
import lombok.Data; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@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(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
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,23 @@ | ||
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> {} |
12 changes: 12 additions & 0 deletions
12
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,12 @@ | ||
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