Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

[RKM66-24] [BE] Sync registration field #1

Merged
merged 7 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/run-unit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@ on:
- dev
- master
- beta
env:
GOPRIVATE: github.com/isd-sgcu/*

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

- name: setup credential
env:
NETRC_CONFIG: ${{ secrets.NETRC_CONFIG }}
run: |
echo "$NETRC_CONFIG" >> /home/runner/.netrc
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4.0.1
with:
go-version: 1.20
go-version: '1.20'

- name: Download dependencies
run: go mod download

- name: Vet
run: |
go vet ./...
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ jobs:
with:
context: .
push: false
tags: test
tags: test
secret-files: |
"netrcConf=/home/runner/.netrc"
8 changes: 8 additions & 0 deletions database/seeds/1655751437484-user.seed.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seed

import (
"math/rand"
"strconv"
"time"

Expand All @@ -26,6 +27,9 @@ func (s Seed) UserSeed1655751437484() error {
FoodRestriction: faker.Word(),
AllergyMedicine: faker.Word(),
Disease: faker.Word(),
EmerPhone: faker.Phonenumber(),
EmerRelation: faker.Word(),
WantBottle: getBool(),
}
err := s.db.Create(&usr).Error

Expand All @@ -47,3 +51,7 @@ func getTitle() string {
title := faker.Word()
return title[0:min(10, len(title))]
}

func getBool() bool {
return rand.Intn(2) == 0
}
9 changes: 5 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ version: "3.9"

services:
local-db:
image: mysql:8.0.28-oracle
image: postgres:15.3-alpine
container_name: rnkm-local-db
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: rnkm-db
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: rnkm-db
volumes:
- ./volumes/mysql:/var/lib/mysql
- ./volumes/postgres:/var/lib/postgresql
ports:
- "5432:5432"

Expand Down
3 changes: 3 additions & 0 deletions internal/entity/user/user.model.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ type User struct {
FoodRestriction string `json:"food_restriction" gorm:"type:text"`
AllergyMedicine string `json:"allergy_medicine" gorm:"type:text"`
Disease string `json:"disease" gorm:"type:text"`
EmerPhone string `json:"emer_phone" gorm:"type:text"`
EmerRelation string `json:"emer_relation" gorm:"type:text"`
WantBottle bool `json:"wants_bottle" gorm:"type:boolean"`
CanSelectBaan *bool `json:"can_select_baan"`
IsVerify *bool `json:"is_verify"`
IsGotTicket *bool `json:"is_got_ticket"`
Expand Down
379 changes: 220 additions & 159 deletions internal/proto/rpkm66/backend/user/v1/user.pb.go

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions internal/service/user/user.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ func (s *serviceImpl) Update(_ context.Context, req *proto.UpdateUserRequest) (r
FoodRestriction: req.FoodRestriction,
AllergyMedicine: req.AllergyMedicine,
Disease: req.Disease,
EmerPhone: req.EmerPhone,
EmerRelation: req.EmerRelation,
WantBottle: req.WantBottle,
}

err = s.repo.Update(req.Id, raw)
Expand Down Expand Up @@ -392,6 +395,9 @@ func DtoToRaw(in *proto.User) (result *user.User, err error) {
FoodRestriction: in.FoodRestriction,
AllergyMedicine: in.AllergyMedicine,
Disease: in.Disease,
EmerPhone: in.EmerPhone,
EmerRelation: in.EmerRelation,
WantBottle: in.WantBottle,
GroupID: groupId,
BaanID: baanId,
CanSelectBaan: &in.CanSelectBaan,
Expand Down Expand Up @@ -433,6 +439,9 @@ func RawToDto(in *user.User, imgUrl string) *proto.User {
FoodRestriction: in.FoodRestriction,
AllergyMedicine: in.AllergyMedicine,
Disease: in.Disease,
EmerPhone: in.EmerPhone,
EmerRelation: in.EmerRelation,
WantBottle: in.WantBottle,
ImageUrl: imgUrl,
CanSelectBaan: *in.CanSelectBaan,
IsVerify: *in.IsVerify,
Expand Down
22 changes: 22 additions & 0 deletions internal/service/user/user.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package user

import (
"context"
"math/rand"
"testing"
"time"

Expand Down Expand Up @@ -61,6 +62,9 @@ func (t *UserServiceTest) SetupTest() {
FoodRestriction: faker.Word(),
AllergyMedicine: faker.Word(),
Disease: faker.Word(),
EmerPhone: faker.Phonenumber(),
EmerRelation: faker.Word(),
WantBottle: rand.Intn(2) == 0,
CanSelectBaan: utils.BoolAdr(true),
IsVerify: utils.BoolAdr(true),
IsGotTicket: utils.BoolAdr(true),
Expand Down Expand Up @@ -159,6 +163,9 @@ func (t *UserServiceTest) SetupTest() {
FoodRestriction: t.User.FoodRestriction,
AllergyMedicine: t.User.AllergyMedicine,
Disease: t.User.Disease,
EmerPhone: t.User.EmerPhone,
EmerRelation: t.User.EmerRelation,
WantBottle: t.User.WantBottle,
CanSelectBaan: *t.User.CanSelectBaan,
IsVerify: *t.User.IsVerify,
BaanId: t.User.BaanID.String(),
Expand All @@ -181,6 +188,9 @@ func (t *UserServiceTest) SetupTest() {
FoodRestriction: t.User.FoodRestriction,
AllergyMedicine: t.User.AllergyMedicine,
Disease: t.User.Disease,
EmerPhone: t.User.EmerPhone,
EmerRelation: t.User.EmerRelation,
WantBottle: t.User.WantBottle,
CanSelectBaan: *t.User.CanSelectBaan,
IsVerify: *t.User.IsVerify,
BaanId: t.User.BaanID.String(),
Expand All @@ -200,6 +210,9 @@ func (t *UserServiceTest) SetupTest() {
FoodRestriction: t.User.FoodRestriction,
AllergyMedicine: t.User.AllergyMedicine,
Disease: t.User.Disease,
EmerPhone: t.User.EmerPhone,
EmerRelation: t.User.EmerRelation,
WantBottle: t.User.WantBottle,
}

t.UpdateUser = &user.User{
Expand All @@ -214,6 +227,9 @@ func (t *UserServiceTest) SetupTest() {
FoodRestriction: t.User.FoodRestriction,
AllergyMedicine: t.User.AllergyMedicine,
Disease: t.User.Disease,
EmerPhone: t.User.EmerPhone,
EmerRelation: t.User.EmerRelation,
WantBottle: t.User.WantBottle,
}
}

Expand Down Expand Up @@ -362,6 +378,9 @@ func (t *UserServiceTest) TestCreateSuccess() {
FoodRestriction: t.User.FoodRestriction,
AllergyMedicine: t.User.AllergyMedicine,
Disease: t.User.Disease,
EmerPhone: t.User.EmerPhone,
EmerRelation: t.User.EmerRelation,
WantBottle: t.User.WantBottle,
CanSelectBaan: t.User.CanSelectBaan,
BaanID: t.User.BaanID,
}
Expand Down Expand Up @@ -397,6 +416,9 @@ func (t *UserServiceTest) TestCreateInternalErr() {
FoodRestriction: t.User.FoodRestriction,
AllergyMedicine: t.User.AllergyMedicine,
Disease: t.User.Disease,
EmerPhone: t.User.EmerPhone,
EmerRelation: t.User.EmerRelation,
WantBottle: t.User.WantBottle,
CanSelectBaan: t.User.CanSelectBaan,
BaanID: t.User.BaanID,
}
Expand Down
16 changes: 11 additions & 5 deletions proto/rpkm66/backend/user/v1/user.proto
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ message User{
string foodRestriction = 13;
string allergyMedicine = 14;
string disease = 15;
string imageUrl = 16;
bool canSelectBaan = 17;
bool isVerify = 18;
string baanId = 19;
bool isGotTicket = 20;
string emerPhone = 16;
string emerRelation = 17;
bool WantBottle = 18;
string imageUrl = 19;
bool canSelectBaan = 20;
bool isVerify = 21;
string baanId = 22;
bool isGotTicket = 23;
}

// FindOne
Expand Down Expand Up @@ -86,6 +89,9 @@ message UpdateUserRequest{
string foodRestriction = 10;
string allergyMedicine = 11;
string disease = 12;
string emerPhone = 13;
string emerRelation = 14;
bool WantBottle = 15;
}

message UpdateUserResponse{
Expand Down
Loading