Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
bookpanda committed Jun 21, 2024
1 parent 1af0c76 commit 4959ac9
Show file tree
Hide file tree
Showing 10 changed files with 435 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
workflow_dispatch:
push:
branches:
- beta
- dev

jobs:
build-go:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Install Protoc
uses: arduino/setup-protoc@v2

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.3'

- name: Set up protoc-gen-go
run: go install google.golang.org/protobuf/cmd/[email protected]

- name: Set up protoc-gen-go-grpc
run: go install google.golang.org/grpc/cmd/[email protected]

- name: Build
run: make go
- name: Pushes to another repository
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.GO_DEPLOY_KEY }}
with:
source-directory: go
destination-github-username: 'isd-sgcu'
destination-repository-name: 'rpkm67-go-proto'
user-email: [email protected]
target-branch: ${{ steps.extract_branch.outputs.branch }}
create-target-branch-if-needed: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
.idea
.DS_store
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: go

go:
mkdir -p go
-cd go; go mod init github.com/isd-sgcu/johnjud-go-proto
perl scripts/go/go.pl
cd go; go mod tidy

# absoluate package
# find . -name *.proto -exec protoc --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative --proto_path=. --go_out=go --go-grpc_out=go {} \;
92 changes: 92 additions & 0 deletions rpkm67/auth/auth/v1/auth.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
syntax = "proto3";

package rpkm67.auth.auth.v1;

option go_package = "rpkm67/auth/auth/v1";

service AuthService {
rpc Validate(ValidateRequest) returns (ValidateResponse) {}
rpc RefreshToken(RefreshTokenRequest) returns (RefreshTokenResponse) {}
rpc SignUp(SignUpRequest) returns (SignUpResponse) {}
rpc SignIn(SignInRequest) returns (SignInResponse) {}
rpc SignOut(SignOutRequest) returns (SignOutResponse) {}
rpc ForgotPassword(ForgotPasswordRequest) returns (ForgotPasswordResponse) {}
rpc ResetPassword(ResetPasswordRequest) returns (ResetPasswordResponse) {}
}

message Credential{
string accessToken = 1;
string refreshToken = 2;
int32 expiresIn = 3;
}

// Validate
message ValidateRequest{
string token = 1;
}

message ValidateResponse{
string userId = 1;
string role = 2;
}

// Redeem Refresh Token
message RefreshTokenRequest{
string refreshToken = 1;
}

message RefreshTokenResponse{
Credential credential = 1;
}

// Sign up
message SignUpRequest {
string studentId = 1;
string password = 2;
string firstname = 3;
string lastname = 4;
string tel = 5;
string role = 6;
}

message SignUpResponse {
Credential credential = 1;
}

// Sign in
message SignInRequest {
string studentId = 1;
string password = 2;
}

message SignInResponse {
Credential credential = 1;
}

// Sign out
message SignOutRequest {
string token = 1;
}

message SignOutResponse {
bool isSuccess = 1;
}

// Forgot password
message ForgotPasswordRequest {
string tel = 1;
}

message ForgotPasswordResponse {
string url = 1;
}

// Reset password
message ResetPasswordRequest {
string token = 1;
string password = 2;
}

message ResetPasswordResponse {
bool isSuccess = 1;
}
67 changes: 67 additions & 0 deletions rpkm67/auth/user/v1/user.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
syntax = "proto3";

package rpkm67.auth.user.v1;

option go_package = "rpkm67/auth/user/v1";

service UserService {
rpc Create(CreateRequest) returns (CreateResponse){}
rpc FindOne(FindOneRequest) returns (FindOneResponse){}
// rpc Update(UpdateUserRequest) returns (UpdateUserResponse){}
// rpc Delete(DeleteRequest) returns (DeleteResponse){}
}

message User{
string id = 1;
string studentId = 2;
string password = 3;
string firstname = 4;
string lastname = 5;
string tel = 6;
string role = 7;
}

// Create
message CreateRequest{
string studentId = 1;
string password = 2;
string firstname = 3;
string lastname = 4;
string tel = 5;
string role = 6;
}

message CreateResponse{
User user = 1;
}

// FindOne
message FindOneRequest{
string id = 1;
}

message FindOneResponse{
User user = 1;
}

// Update
// message UpdateUserRequest{
// string id = 1;
// string email = 2;
// string password = 3;
// string firstname = 4;
// string lastname = 5;
// }

// message UpdateUserResponse{
// User user = 1;
// }

// Delete
// message DeleteRequest{
// string id = 1;
// }

// message DeleteResponse{
// bool success = 1;
// }
60 changes: 60 additions & 0 deletions rpkm67/backend/baan/v1/baan.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
syntax = "proto3";

package rpkm67.backend.baan.v1;

option go_package = "rpkm67/backend/baan/v1";

service BaanService {
rpc FindAllBaan(FindAllBaanRequest) returns (FindAllBaanResponse) {}
rpc FindOneBaan(FindOneBaanRequest) returns (FindOneBaanResponse) {}
}

enum BaanSize{
UNKNOWN = 0;
S = 1;
M = 2;
L = 3;
XL = 4;
XXL = 5;
}

message Baan{
string id = 1;
string nameTH = 2;
string descriptionTH = 3;
string nameEN = 4;
string descriptionEN = 5;
BaanSize size = 6;
string facebook = 7;
string facebookUrl = 8;
string instagram = 9;
string instagramUrl = 10;
string line = 11;
string lineUrl = 12;
string imageUrl = 13;
}

message BaanInfo{
string id = 1;
string nameTH = 2;
string nameEN = 3;
string imageUrl = 4;
BaanSize size = 5;
}

// Find All Baan
message FindAllBaanRequest{
}

message FindAllBaanResponse{
repeated Baan baans = 1;
}

// Find Baan
message FindOneBaanRequest{
string id = 1;
}

message FindOneBaanResponse{
Baan baan = 1;
}
45 changes: 45 additions & 0 deletions rpkm67/backend/selection/v1/selection.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
syntax = "proto3";

package rpkm67.backend.selection.v1;

option go_package = "rpkm67/backend/selection/v1";

service SelectionService {
rpc Create(CreateSelectionRequest) returns (CreateSelectionResponse){}
rpc FindByStudentId(FindByStudentIdSelectionRequest) returns (FindByStudentIdSelectionResponse) {}
rpc Update(UpdateSelectionRequest) returns (UpdateSelectionResponse){}
}

message Selection{
string id = 1;
string userId = 2;
repeated string baanIds = 3;
}

// Create
message CreateSelectionRequest{
string userId = 1;
repeated string baanIds = 2;
}

message CreateSelectionResponse{
Selection selection = 1;
}

// FindByStudentId
message FindByStudentIdSelectionRequest{
string userId = 1;
}

message FindByStudentIdSelectionResponse{
Selection selection = 1;
}

// Update
message UpdateSelectionRequest{
Selection selection = 1;
}

message UpdateSelectionResponse{
bool success = 1;
}
35 changes: 35 additions & 0 deletions rpkm67/checkin/checkin/v1/checkin.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
syntax = "proto3";

package rpkm67.checkin.checkin.v1;

option go_package = "rpkm67/checkin/checkin/v1";

service CheckInService {
rpc Create(CreateCheckInRequest) returns (CreateCheckInResponse){}
rpc FindByStudentId(FindByStudentIdCheckInRequest) returns (FindByStudentIdCheckInResponse){}
}

message CheckIn{
string id = 1;
string studentId = 2;
string event = 3;
}

// Create
message CreateCheckInRequest{
string studentId = 1;
string event = 2;
}

message CreateCheckInResponse{
CheckIn checkIn = 1;
}

// FindByStudentId
message FindByStudentIdCheckInRequest{
string studentId = 1;
}

message FindByStudentIdCheckInResponse{
repeated CheckIn checkIns = 1;
}
Loading

0 comments on commit 4959ac9

Please sign in to comment.