├── .env ├── .github └── workflows │ └── ci.yml ├── .gitmodules ├── Makefile ├── api ├── casbin │ ├── model.conf │ └── policy.csv ├── handler │ ├── admin.go │ ├── blacklist.go │ ├── handler.go │ ├── hr.go │ └── minio.go ├── middleware │ └── middleware.go ├── router.go └── token │ └── token.go ├── cmd └── main.go ├── docker-compose.yml ├── dockerfile ├── docs ├── docs.go ├── swagger.json └── swagger.yaml ├── go.mod ├── go.sum ├── internal ├── config │ └── getEnv.go ├── genproto │ ├── auth │ │ ├── auth.pb.go │ │ ├── auth_grpc.pb.go │ │ ├── common1.pb.go │ │ ├── user.pb.go │ │ └── user_grpc.pb.go │ └── black_list │ │ ├── admin.pb.go │ │ ├── admin_grpc.pb.go │ │ ├── black_list.pb.go │ │ ├── black_list_grpc.pb.go │ │ ├── common.pb.go │ │ ├── hr.pb.go │ │ └── hr_grpc.pb.go ├── media │ ├── invoice.txt │ └── nbu.pdf └── scripts │ └── gen-proto.sh └── pkg ├── app └── app.go ├── clients └── client.go ├── genai └── connect.go ├── helper ├── findname.go ├── helper.go └── pdftotxt.go └── minio └── connect.go /.env: -------------------------------------------------------------------------------- 1 | LOG_PATH=logs/info.log 2 | 3 | BLACKLIST_PORT=:6666 4 | AUTH_PORT=:5555 5 | API_GATEWAY=:3333 6 | API_KEY=AIzaSyAORjAZXuI6BpTZy9X79e4f51235_aLWzo -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Medical MOnitoring 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Checkout our repository 16 | uses: actions/checkout@v4 17 | 18 | - name: Deploy 19 | uses: appleboy/ssh-action@master 20 | with: 21 | host: ${{ secrets.SSH_HOST }} 22 | username: ${{ secrets.SSH_USER }} 23 | key: ${{ secrets.SSH_PRIVATE_KEY }} 24 | port: ${{ secrets.SSH_PORT }} 25 | script: | 26 | pwd 27 | ls 28 | cd ~/project/blacklist/api-gateway_blacklist 29 | sudo docker compose down 30 | git pull origin main 31 | sudo docker compose up --build -d 32 | sudo docker compose up -d -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "black_list_submodule"] 2 | path = black_list_submodule 3 | url = git@github.com:mirjalilova/black_list_submodule.git 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CURRENT_DIR=$(shell pwd) 2 | 3 | proto-gen: 4 | ./internal/scripts/gen-proto.sh ${CURRENT_DIR} 5 | exp: 6 | export DBURL='postgres://postgres:1234@localhost:5432/blacklist?sslmode=disable' 7 | 8 | mig-run: 9 | migrate create -ext sql -dir migrations -seq create_table 10 | 11 | mig-up: 12 | migrate -database 'postgres://postgres:1234@localhost:5432/blacklist?sslmode=disable' -path migrations up 13 | 14 | mig-down: 15 | migrate -database 'postgres://postgres:1234@localhost:5432/blacklist?sslmode=disable' -path migrations down 16 | 17 | 18 | gen-protoAll: 19 | protoc --go_out=./ \ 20 | --go-grpc_out=./ \ 21 | blacklist_submodule/black_list_service/*.proto 22 | 23 | swag-gen: 24 | ~/go/bin/swag init -g ./api/router.go -o docs force 1 25 | run: 26 | go run main.go -------------------------------------------------------------------------------- /api/casbin/model.conf: -------------------------------------------------------------------------------- 1 | [request_definition] 2 | r = sub, obj, act 3 | 4 | [policy_definition] 5 | p = sub, obj, act 6 | 7 | [policy_effect] 8 | e = some(where (p.eft == allow)) 9 | 10 | [matchers] 11 | m = r.sub == p.sub && r.obj == p.obj && r.act == p.act -------------------------------------------------------------------------------- /api/casbin/policy.csv: -------------------------------------------------------------------------------- 1 | p, unauthorized, /, GET 2 | 3 | p, superadmin, /admin/change_role, PUT 4 | p, superadmin, /admin/approve/:user_id, POST 5 | p, superadmin, /admin/hr_list, GET 6 | p, superadmin, /admin/delete_hr/:hr_id, DELETE 7 | p, superadmin, /admin/users, GET 8 | 9 | p, superadmin, /employee/create, POST 10 | p, superadmin, /employee/:employee_id, GET 11 | p, superadmin, /employee/all, GET 12 | p, superadmin, /employee/update/:employee_id, PUT 13 | p, superadmin, /employee/:employee_id, DELETE 14 | 15 | p, superadmin, /blacklist/add, POST 16 | p, superadmin, /blacklist/all, GET 17 | p, superadmin, /blacklist/remove/:employee_id,DELETE 18 | p, superadmin, /blacklist/daily, GET 19 | p, superadmin, /blacklist/weekly, GET 20 | p, superadmin, /blacklist/monthly, GET 21 | 22 | p, admin, /admin/approve/:user_id, POST 23 | p, admin, /admin/hr_list, GET 24 | p, admin, /admin/delete_hr/:hr_id, DELETE 25 | p, admin, /admin/users, GET 26 | 27 | p, admin, /employee/create, POST 28 | p, admin, /employee/:employee_id, GET 29 | p, admin, /employee/all, GET 30 | p, admin, /employee/update/:employee_id, PUT 31 | p, admin, /employee/:employee_id, DELETE 32 | 33 | p, admin, /blacklist/daily, GET 34 | p, admin, /blacklist/weekly, GET 35 | p, admin, /blacklist/monthly, GET 36 | 37 | p, hr, /employee/create, POST 38 | p, hr, /employee/:employee_id, GET 39 | p, hr, /employee/all, GET 40 | p, hr, /employee/update/:employee_id, PUT 41 | p, hr, /employee/:employee_id, DELETE 42 | 43 | p, hr, /blacklist/add, POST 44 | p, hr, /blacklist/all, GET 45 | p, hr, /blacklist/remove/:employee_id, DELETE 46 | p, hr, /blacklist/daily, GET 47 | p, hr, /blacklist/weekly, GET 48 | p, hr, /blacklist/monthly, GET 49 | 50 | p, employee, /blacklist/daily, GET 51 | p, employee, /blacklist/weekly, GET 52 | p, employee, /blacklist/monthly, GET 53 | 54 | p, user, /blacklist/daily, GET 55 | p, user, /blacklist/weekly, GET 56 | p, user, /blacklist/monthly, GET -------------------------------------------------------------------------------- /api/handler/admin.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | "strconv" 7 | 8 | "github.com/gin-gonic/gin" 9 | md "github.com/mirjalilova/api-gateway_blacklist/api/middleware" 10 | pb "github.com/mirjalilova/api-gateway_blacklist/internal/genproto/black_list" 11 | 12 | // rd "github.com/mirjalilova/api-gateway_blacklist/pkg/helper" 13 | "golang.org/x/exp/slog" 14 | ) 15 | 16 | // @Summary Create a new hr 17 | // @Description Create a new hr 18 | // @Tags Admin 19 | // @Accept json 20 | // @Produce json 21 | // @Security BearerAuth 22 | // @Param user_id path string true "USER ID" 23 | // @Success 200 {object} string "HR created successfully" 24 | // @Failure 400 {object} string "error": "error message" 25 | // @Router /admin/approve/{user_id} [post] 26 | func (h *HandlerStruct) Approve(c *gin.Context) { 27 | user_id := c.Param("user_id") 28 | approved_by := getuserId(c) 29 | 30 | req := &pb.CreateHR{ 31 | UserId: user_id, 32 | ApprovedBy: approved_by, 33 | } 34 | 35 | _, err := h.Clients.AdminClient.Approve(context.Background(), req) 36 | 37 | if err != nil { 38 | slog.Error("Error approving HR: ", err) 39 | c.JSON(400, gin.H{"error": err}) 40 | return 41 | } 42 | 43 | // Clear relevant cache keys 44 | // h.Redis.Del(c, "allhr:") 45 | 46 | slog.Error("HR approved successfully") 47 | c.JSON(200, gin.H{"message": "HR approved successfully"}) 48 | } 49 | 50 | // @Summary Get hr 51 | // @Description Get hr 52 | // @Tags Admin 53 | // @Accept json 54 | // @Produce json 55 | // @Security BearerAuth 56 | // @Param hr_id query string true "HR Id" 57 | // @Success 200 {object} black_list.Hr 58 | // @Failure 400 {object} string "Bad Request" 59 | // @Failure 500 {object} string "Internal Server Error" 60 | // @Router /admin/hr/{hr_id} [get] 61 | func (h *HandlerStruct) GetHR(c *gin.Context) { 62 | userId := c.Query("hr_id") 63 | 64 | req := &pb.GetById{ 65 | Id: userId, 66 | } 67 | 68 | res, err := h.Clients.AdminClient.GetHRById(context.Background(), req) 69 | if err!= nil { 70 | slog.Error("failed to get hr: %v", err) 71 | c.JSON(http.StatusInternalServerError, gin.H{"error": err}) 72 | return 73 | } 74 | 75 | slog.Info("HR retrieved successfully") 76 | c.JSON(http.StatusOK, res) 77 | } 78 | 79 | // @Summary Get hr list 80 | // @Description Get hr list 81 | // @Tags Admin 82 | // @Accept json 83 | // @Produce json 84 | // @Security BearerAuth 85 | // @Param limit query int false "Limit" 86 | // @Param offset query int false "Offset" 87 | // @Success 200 {object} black_list.GetAllHRRes 88 | // @Failure 400 {object} string "Bad Request" 89 | // @Failure 500 {object} string "Internal Server Error" 90 | // @Router /admin/hr_list [get] 91 | func (h *HandlerStruct) ListHR(c *gin.Context) { 92 | limit := c.Query("limit") 93 | offset := c.Query("offset") 94 | 95 | limitValue := 10 96 | offsetValue := 1 97 | 98 | if limit != "" { 99 | parsedLimit, err := strconv.Atoi(limit) 100 | if err != nil { 101 | slog.Error("Invalid limit value", err) 102 | c.JSON(400, gin.H{"error": "Invalid limit value"}) 103 | return 104 | } 105 | limitValue = parsedLimit 106 | } 107 | 108 | if offset != "" { 109 | parsedOffset, err := strconv.Atoi(offset) 110 | if err != nil { 111 | slog.Error("Invalid offset value", err) 112 | c.JSON(400, gin.H{"error": "Invalid offset value"}) 113 | return 114 | } 115 | offsetValue = parsedOffset 116 | } 117 | 118 | req := &pb.Filter{ 119 | Limit: int32(limitValue), 120 | Offset: int32(offsetValue), 121 | } 122 | 123 | // cacheKey := "allhr:" 124 | 125 | // res := pb.GetAllHRRes{} 126 | 127 | // err := rd.GetCachedData(c, h.Redis, cacheKey, &res) 128 | // if err == nil { 129 | // slog.Info("Weekly data retrieved from cache") 130 | // c.JSON(200, res) 131 | // return 132 | // } 133 | 134 | resp, err := h.Clients.AdminClient.ListHR(context.Background(), req) 135 | if err != nil { 136 | slog.Error("Error getting HR list: ", err) 137 | c.JSON(400, gin.H{"error": err}) 138 | return 139 | } 140 | 141 | // res = *resp 142 | 143 | // rd.CacheData(c, h.Redis, cacheKey, res) 144 | 145 | slog.Info("HR list retrieved successfully") 146 | c.JSON(200, resp) 147 | } 148 | 149 | // @Summary Delete HR 150 | // @Description Delete HR 151 | // @Tags Admin 152 | // @Accept json 153 | // @Produce json 154 | // @Security BearerAuth 155 | // @Param hr_id query string true "HR ID" 156 | // @Success 200 {object} string "HR deleted successfully" 157 | // @Failure 400 {object} string "error": "error message" 158 | // @Router /admin/delete_hr/{hr_id} [delete] 159 | func (h *HandlerStruct) DeleteHR(c *gin.Context) { 160 | hr_id := c.Query("hr_id") 161 | 162 | req := &pb.GetById{ 163 | Id: hr_id, 164 | } 165 | 166 | _, err := h.Clients.AdminClient.Delete(context.Background(), req) 167 | if err != nil { 168 | slog.Error("Error deleting Genetic Data: ", err) 169 | c.JSON(400, gin.H{"error": err}) 170 | return 171 | } 172 | 173 | // Clear relevant cache keys 174 | // h.Redis.Del(c, "allhr:") 175 | 176 | slog.Info("HR deleted successfully") 177 | c.JSON(200, "HR deleted successfully") 178 | } 179 | 180 | func getuserId(ctx *gin.Context) string { 181 | user_id, err := md.GetUserId(ctx.Request) 182 | if err != nil { 183 | ctx.JSON(http.StatusInternalServerError, gin.H{"error": err}) 184 | return "" 185 | } 186 | return user_id 187 | } 188 | 189 | // @Summary Get all users 190 | // @Description Get all users 191 | // @Tags Admin 192 | // @Accept json 193 | // @Produce json 194 | // @Security BearerAuth 195 | // @Param username query string false "UserName" 196 | // @Param full_name query string false "Full Name" 197 | // @Param limit query int false "Limit" 198 | // @Param offset query int false "Offset" 199 | // @Success 200 {object} black_list.ListUserRes 200 | // @Failure 400 {object} string "Bad Request" 201 | // @Failure 500 {object} string "Internal Server Error" 202 | // @Router /admin/users [get] 203 | func (h *HandlerStruct) GetAllUsers(c *gin.Context) { 204 | limit := c.Query("limit") 205 | offset := c.Query("offset") 206 | username := c.Query("username") 207 | fullName := c.Query("full_name") 208 | 209 | limitValue := 10 210 | offsetValue := 1 211 | 212 | if limit != "" { 213 | parsedLimit, err := strconv.Atoi(limit) 214 | if err != nil { 215 | slog.Error("Invalid limit value", err) 216 | c.JSON(400, gin.H{"error": "Invalid limit value"}) 217 | return 218 | } 219 | limitValue = parsedLimit 220 | } 221 | 222 | if offset != "" { 223 | parsedOffset, err := strconv.Atoi(offset) 224 | if err != nil { 225 | slog.Error("Invalid offset value", err) 226 | c.JSON(400, gin.H{"error": "Invalid offset value"}) 227 | return 228 | } 229 | offsetValue = parsedOffset 230 | } 231 | 232 | req := &pb.ListUserReq{ 233 | Username: username, 234 | FullName: fullName, 235 | Filter: &pb.Filter{ 236 | Limit: int32(limitValue), 237 | Offset: int32(offsetValue), 238 | }, 239 | } 240 | 241 | res, err := h.Clients.AdminClient.GetAllUsers(context.Background(), req) 242 | if err != nil { 243 | slog.Error("failed to get all users: %v", err) 244 | c.JSON(http.StatusInternalServerError, gin.H{"error": err}) 245 | return 246 | } 247 | 248 | c.JSON(http.StatusOK, res) 249 | } 250 | 251 | // @Summary Change role 252 | // @Description Change role of a user 253 | // @Tags Admin 254 | // @Accept json 255 | // @Produce json 256 | // @Security BearerAuth 257 | // @Param user body black_list.ChangeRoleReq true "Employee" 258 | // @Success 200 {object} string "Employee updated successfully" 259 | // @Failure 400 {string} Error "Bad Request" 260 | // @Failure 404 {string} Error "Not Found" 261 | // @Failure 500 {string} Error "Internal Server Error" 262 | // @Router /admin/change_role [PUT] 263 | func (h *HandlerStruct) ChangeRole(c *gin.Context) { 264 | var req pb.ChangeRoleReq 265 | 266 | if err := c.ShouldBindJSON(&req); err != nil { 267 | slog.Error("failed to bind JSON: %v", err) 268 | c.JSON(http.StatusBadRequest, gin.H{"error": err}) 269 | return 270 | } 271 | 272 | _, err := h.Clients.AdminClient.ChangeRole(context.Background(), &req) 273 | if err != nil { 274 | slog.Error("failed to update user: %v", err) 275 | c.JSON(http.StatusInternalServerError, gin.H{"error": err}) 276 | return 277 | } 278 | 279 | slog.Info("Role updated successfully") 280 | c.JSON(http.StatusOK, "Role updated successfully") 281 | } 282 | 283 | // @Summary Get user 284 | // @Description Get user 285 | // @Tags Admin 286 | // @Accept json 287 | // @Produce json 288 | // @Security BearerAuth 289 | // @Param user_id query string true "User Id" 290 | // @Success 200 {object} black_list.UserRes 291 | // @Failure 400 {object} string "Bad Request" 292 | // @Failure 500 {object} string "Internal Server Error" 293 | // @Router /admin/user/{user_id} [get] 294 | func (h *HandlerStruct) GetUser(c *gin.Context) { 295 | userId := c.Query("user_id") 296 | 297 | req := &pb.GetById{ 298 | Id: userId, 299 | } 300 | 301 | res, err := h.Clients.AdminClient.GetUserById(context.Background(), req) 302 | if err!= nil { 303 | slog.Error("failed to get user: %v", err) 304 | c.JSON(http.StatusInternalServerError, gin.H{"error": err}) 305 | return 306 | } 307 | 308 | slog.Info("User retrieved successfully") 309 | c.JSON(http.StatusOK, res) 310 | } -------------------------------------------------------------------------------- /api/handler/blacklist.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "context" 5 | "strconv" 6 | 7 | // rd "github.com/mirjalilova/api-gateway_blacklist/pkg/helper" 8 | "github.com/gin-gonic/gin" 9 | pb "github.com/mirjalilova/api-gateway_blacklist/internal/genproto/black_list" 10 | "golang.org/x/exp/slog" 11 | ) 12 | 13 | // @Summary Add employee to black list 14 | // @Description Add employee to black list 15 | // @Tags Black List 16 | // @Accept json 17 | // @Produce json 18 | // @Security BearerAuth 19 | // @Param data body black_list.BlackListBody true "Add employee" 20 | // @Success 200 {string} string "Add employee to blacklist successfully" 21 | // @Failure 400 {string} Error "Bad Request" 22 | // @Failure 404 {string} Error "Not Found" 23 | // @Failure 500 {string} Error "Internal Server Error" 24 | // @Router /blacklist/add [POST] 25 | func (h *HandlerStruct) AddEmployee(c *gin.Context) { 26 | var body pb.BlackListBody 27 | if err := c.ShouldBindJSON(&body); err != nil { 28 | slog.Error("Failed to bind JSON", err) 29 | c.JSON(400, gin.H{"error": err}) 30 | return 31 | } 32 | 33 | req := &pb.BlackListCreate{ 34 | EmployeeId: body.EmployeeId, 35 | Reason: body.Reason, 36 | AddedBy: getuserId(c), 37 | } 38 | _, err := h.Clients.BlacklistClient.Add(context.Background(), req) 39 | if err != nil { 40 | slog.Error("Error while adding employee to blacklist", err) 41 | c.JSON(400, gin.H{"error": err}) 42 | return 43 | } 44 | 45 | // Clear relevant cache keys 46 | // h.Redis.Del(c, "daily:", "weekly:", "monthly:") 47 | 48 | slog.Info("Add employee to blacklist successfully") 49 | c.JSON(200, gin.H{"message": "Add employee to blacklist successfully"}) 50 | } 51 | 52 | // @Summary Get all employee from blacklist 53 | // @Description Get all employee from blacklist 54 | // @Tags Black List 55 | // @Accept json 56 | // @Produce json 57 | // @Security BearerAuth 58 | // @Param limit query int false "Limit" 59 | // @Param offset query int false "Offset" 60 | // @Success 200 {object} black_list.Reports 61 | // @Failure 400 {string} Error "Bad Request" 62 | // @Failure 404 {string} Error "Not Found" 63 | // @Failure 500 {string} Error "Internal Server Error" 64 | // @Router /blacklist/all [GET] 65 | func (h *HandlerStruct) GetAll(c *gin.Context) { 66 | limit := c.Query("limit") 67 | offset := c.Query("offset") 68 | 69 | limitValue := 10 70 | offsetValue := 1 71 | 72 | if limit != "" { 73 | parsedLimit, err := strconv.Atoi(limit) 74 | if err != nil { 75 | slog.Error("Invalid limit value") 76 | c.JSON(400, gin.H{"error": "Invalid limit value"}) 77 | return 78 | } 79 | limitValue = parsedLimit 80 | } 81 | 82 | if offset != "" { 83 | parsedOffset, err := strconv.Atoi(offset) 84 | if err != nil { 85 | slog.Error("Invalid offset value", err) 86 | c.JSON(400, gin.H{"error": "Invalid offset value"}) 87 | return 88 | } 89 | offsetValue = parsedOffset 90 | } 91 | 92 | req := &pb.Filter{ 93 | Limit: int32(limitValue), 94 | Offset: int32(offsetValue), 95 | } 96 | 97 | // cacheKey := "allblacklist:" 98 | 99 | // res := pb.GetAllBlackListRes{} 100 | 101 | // err := rd.GetCachedData(c, h.Redis, cacheKey, &res) 102 | // if err == nil { 103 | // slog.Info("Weekly data retrieved from cache") 104 | // c.JSON(200, res) 105 | // return 106 | // } 107 | 108 | resp, err := h.Clients.BlacklistClient.GetAll(context.Background(), req) 109 | if err != nil { 110 | slog.Error("Error while getting blacklist", err) 111 | c.JSON(400, gin.H{"error": err}) 112 | return 113 | } 114 | 115 | // res = *resp 116 | 117 | // rd.CacheData(c, h.Redis, cacheKey, res) 118 | 119 | slog.Info("Employee getting successfully from blacklist") 120 | c.JSON(200, resp) 121 | } 122 | 123 | // @Summary Remove employee from blacklist 124 | // @Description Remove employee from blacklist 125 | // @Tags Black List 126 | // @Accept json 127 | // @Produce json 128 | // @Security BearerAuth 129 | // @Param employee_id path string true "Employee Id" 130 | // @Success 200 {string} string "Removed employee successfully from blacklist" 131 | // @Failure 400 {string} Error "Bad Request" 132 | // @Failure 404 {string} Error "Not Found" 133 | // @Failure 500 {string} Error "Internal Server Error" 134 | // @Router /blacklist/remove/{employee_id} [DELETE] 135 | func (h *HandlerStruct) RemoveEmployee(c *gin.Context) { 136 | id := c.Param("employee_id") 137 | 138 | req := &pb.RemoveReq{ 139 | EmployeeId: id, 140 | AddedBy: getuserId(c), 141 | } 142 | 143 | _, err := h.Clients.BlacklistClient.Remove(context.Background(), req) 144 | if err != nil { 145 | slog.Error("Error while remove employee from blacklist", err) 146 | c.JSON(400, gin.H{"error": err}) 147 | return 148 | } 149 | 150 | // Clear relevant cache keys 151 | // h.Redis.Del(c, "daily:", "weekly:", "monthly:") 152 | 153 | slog.Info("Removed employee successfully from blacklist") 154 | c.JSON(200, "Removed employee successfully from blacklist") 155 | } 156 | 157 | // @Summary Monitoring daily blacklist 158 | // @Description Monitoring daily blacklist 159 | // @Tags Monitoring 160 | // @Accept json 161 | // @Produce json 162 | // @Security BearerAuth 163 | // @Param limit query int false "Limit" 164 | // @Param offset query int false "Offset" 165 | // @Success 200 {object} black_list.Reports 166 | // @Failure 400 {string} Error "Bad Request" 167 | // @Failure 404 {string} Error "Not Found" 168 | // @Failure 500 {string} Error "Internal Server Error" 169 | // @Router /blacklist/daily [GET] 170 | func (h *HandlerStruct) GetDaily(c *gin.Context) { 171 | 172 | if h.Redis == nil { 173 | slog.Error("Redis client is not initialized") 174 | c.JSON(500, gin.H{"error": "Internal Server Error"}) 175 | return 176 | } 177 | 178 | limit := c.Query("limit") 179 | offset := c.Query("offset") 180 | 181 | limitValue := 10 182 | offsetValue := 1 183 | 184 | if limit != "" { 185 | parsedLimit, err := strconv.Atoi(limit) 186 | if err != nil { 187 | slog.Error("Invalid limit value") 188 | c.JSON(400, gin.H{"error": "Invalid limit value"}) 189 | return 190 | } 191 | limitValue = parsedLimit 192 | } 193 | 194 | if offset != "" { 195 | parsedOffset, err := strconv.Atoi(offset) 196 | if err != nil { 197 | slog.Error("Invalid offset value") 198 | c.JSON(400, gin.H{"error": "Invalid offset value"}) 199 | return 200 | } 201 | offsetValue = parsedOffset 202 | } 203 | 204 | req := &pb.Filter{ 205 | Limit: int32(limitValue), 206 | Offset: int32(offsetValue), 207 | } 208 | 209 | // cacheKey := "daily:" 210 | 211 | // res := pb.Reports{} 212 | 213 | // err := rd.GetCachedData(c, h.Redis, cacheKey, &res) 214 | // if err == nil { 215 | // slog.Info("Daily data retrieved from cache") 216 | // c.JSON(200, res) 217 | // return 218 | // } 219 | 220 | resp, err := h.Clients.BlacklistClient.MonitoringDailyReport(context.Background(), req) 221 | if err != nil { 222 | slog.Error("Error while getting daily blacklist", err) 223 | c.JSON(400, gin.H{"error": err}) 224 | return 225 | } 226 | 227 | // res = *resp 228 | 229 | // rd.CacheData(c, h.Redis, cacheKey, res) 230 | 231 | slog.Info("Daily blacklist retrieved successfully") 232 | c.JSON(200, resp) 233 | } 234 | 235 | // @Summary Monitoring weekly blacklist 236 | // @Description Monitoring weekly blacklist 237 | // @Tags Monitoring 238 | // @Accept json 239 | // @Produce json 240 | // @Security BearerAuth 241 | // @Param limit query int false "Limit" 242 | // @Param offset query int false "Offset" 243 | // @Success 200 {object} black_list.Reports 244 | // @Failure 400 {string} Error "Bad Request" 245 | // @Failure 404 {string} Error "Not Found" 246 | // @Failure 500 {string} Error "Internal Server Error" 247 | // @Router /blacklist/weekly [GET] 248 | func (h *HandlerStruct) GetWeekly(c *gin.Context) { 249 | limit := c.Query("limit") 250 | offset := c.Query("offset") 251 | 252 | limitValue := 10 253 | offsetValue := 1 254 | 255 | if limit != "" { 256 | parsedLimit, err := strconv.Atoi(limit) 257 | if err != nil { 258 | slog.Error("Invalid limit value") 259 | c.JSON(400, gin.H{"error": "Invalid limit value"}) 260 | return 261 | } 262 | limitValue = parsedLimit 263 | } 264 | 265 | if offset != "" { 266 | parsedOffset, err := strconv.Atoi(offset) 267 | if err != nil { 268 | slog.Error("Invalid offset value") 269 | c.JSON(400, gin.H{"error": "Invalid offset value"}) 270 | return 271 | } 272 | offsetValue = parsedOffset 273 | } 274 | 275 | req := &pb.Filter{ 276 | Limit: int32(limitValue), 277 | Offset: int32(offsetValue), 278 | } 279 | 280 | // cacheKey := "weekly:" 281 | 282 | // res := pb.Reports{} 283 | 284 | // err := rd.GetCachedData(c, h.Redis, cacheKey, &res) 285 | // if err == nil { 286 | // slog.Info("Weekly data retrieved from cache") 287 | // c.JSON(200, res) 288 | // return 289 | // } 290 | 291 | resp, err := h.Clients.BlacklistClient.MonitoringWeeklyReport(context.Background(), req) 292 | if err != nil { 293 | slog.Error("Error while getting daily blacklist", "err", err) 294 | c.JSON(400, gin.H{"error": err}) 295 | return 296 | } 297 | 298 | // res = *resp 299 | 300 | // rd.CacheData(c, h.Redis, cacheKey, res) 301 | 302 | slog.Info("Weekly blacklist retrieved successfully") 303 | c.JSON(200, resp) 304 | } 305 | 306 | // @Summary Monitoring monthly blacklist 307 | // @Description Monitoring monthly blacklist 308 | // @Tags Monitoring 309 | // @Accept json 310 | // @Produce json 311 | // @Security BearerAuth 312 | // @Param limit query int false "Limit" 313 | // @Param offset query int false "Offset" 314 | // @Success 200 {object} black_list.Reports 315 | // @Failure 400 {string} Error "Bad Request" 316 | // @Failure 404 {string} Error "Not Found" 317 | // @Failure 500 {string} Error "Internal Server Error" 318 | // @Router /blacklist/monthly [GET] 319 | func (h *HandlerStruct) GetMonthly(c *gin.Context) { 320 | limit := c.Query("limit") 321 | offset := c.Query("offset") 322 | 323 | limitValue := 10 324 | offsetValue := 1 325 | 326 | if limit != "" { 327 | parsedLimit, err := strconv.Atoi(limit) 328 | if err != nil { 329 | slog.Error("Invalid limit value") 330 | c.JSON(400, gin.H{"error": "Invalid limit value"}) 331 | return 332 | } 333 | limitValue = parsedLimit 334 | } 335 | 336 | if offset != "" { 337 | parsedOffset, err := strconv.Atoi(offset) 338 | if err != nil { 339 | slog.Error("Invalid offset value") 340 | c.JSON(400, gin.H{"error": "Invalid offset value"}) 341 | return 342 | } 343 | offsetValue = parsedOffset 344 | } 345 | 346 | req := &pb.Filter{ 347 | Limit: int32(limitValue), 348 | Offset: int32(offsetValue), 349 | } 350 | 351 | // cacheKey := "monthly:" 352 | 353 | // res := pb.Reports{} 354 | 355 | // err := rd.GetCachedData(c, h.Redis, cacheKey, &res) 356 | // if err == nil { 357 | // slog.Info("Monthly data retrieved from cache") 358 | // c.JSON(200, res) 359 | // return 360 | // } 361 | 362 | resp, err := h.Clients.BlacklistClient.MonitoringMonthlyReport(context.Background(), req) 363 | if err != nil { 364 | slog.Error("Error while getting daily blacklist", err) 365 | c.JSON(400, gin.H{"error": err}) 366 | return 367 | } 368 | 369 | // res = *resp 370 | 371 | // rd.CacheData(c, h.Redis, cacheKey, res) 372 | 373 | slog.Info("Monthly blacklist retrieved successfully") 374 | c.JSON(200, resp) 375 | } 376 | 377 | // @Summary View logs on blacklist 378 | // @Description View logs on blacklist 379 | // @Tags Logs 380 | // @Accept json 381 | // @Produce json 382 | // @Security BearerAuth 383 | // @Param limit query int false "Limit" 384 | // @Param offset query int false "Offset" 385 | // @Success 200 {object} black_list.Logs 386 | // @Failure 400 {string} Error "Bad Request" 387 | // @Failure 404 {string} Error "Not Found" 388 | // @Failure 500 {string} Error "Internal Server Error" 389 | // @Router /blacklist/logs [GET] 390 | func (h *HandlerStruct) ViewLogs(c *gin.Context) { 391 | limit := c.Query("limit") 392 | offset := c.Query("offset") 393 | 394 | limitValue := 10 395 | offsetValue := 1 396 | 397 | if limit != "" { 398 | parsedLimit, err := strconv.Atoi(limit) 399 | if err != nil { 400 | slog.Error("Invalid limit value") 401 | c.JSON(400, gin.H{"error": "Invalid limit value"}) 402 | return 403 | } 404 | limitValue = parsedLimit 405 | } 406 | 407 | if offset != "" { 408 | parsedOffset, err := strconv.Atoi(offset) 409 | if err != nil { 410 | slog.Error("Invalid offset value") 411 | c.JSON(400, gin.H{"error": "Invalid offset value"}) 412 | return 413 | } 414 | offsetValue = parsedOffset 415 | } 416 | 417 | req := &pb.Filter{ 418 | Limit: int32(limitValue), 419 | Offset: int32(offsetValue), 420 | } 421 | 422 | resp, err := h.Clients.BlacklistClient.ViewLogs(context.Background(), req) 423 | if err != nil { 424 | slog.Error("Error while getting logs", err) 425 | c.JSON(400, gin.H{"error": err}) 426 | return 427 | } 428 | slog.Info("Logs retrieved successfully") 429 | c.JSON(200, resp) 430 | } 431 | -------------------------------------------------------------------------------- /api/handler/handler.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "github.com/go-redis/redis/v8" 5 | "github.com/google/generative-ai-go/genai" 6 | "github.com/mirjalilova/api-gateway_blacklist/internal/config" 7 | "github.com/mirjalilova/api-gateway_blacklist/pkg/clients" 8 | "github.com/mirjalilova/api-gateway_blacklist/pkg/minio" 9 | ) 10 | 11 | type HandlerStruct struct { 12 | Clients clients.Clients 13 | Redis *redis.Client 14 | Minio *minio.MinIO 15 | Genai *genai.ChatSession 16 | } 17 | 18 | func NewHandlerStruct(cnf *config.Config, rd *redis.Client, mn *minio.MinIO, gn *genai.ChatSession) *HandlerStruct { 19 | return &HandlerStruct{ 20 | Clients: *clients.NewClients(*cnf), 21 | Redis: rd, 22 | Minio: mn, 23 | Genai: gn, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /api/handler/hr.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "context" 5 | "strconv" 6 | 7 | "github.com/gin-gonic/gin" 8 | pb "github.com/mirjalilova/api-gateway_blacklist/internal/genproto/black_list" 9 | "golang.org/x/exp/slog" 10 | ) 11 | 12 | // @Summary CREATE EMPLOYEE 13 | // @Description This api create employee 14 | // @Tags Employee 15 | // @Accept json 16 | // @Produce json 17 | // @Security BearerAuth 18 | // @Param data body black_list.EmployeeCreateBody true "Employee" 19 | // @Success 201 {object} string "Employee created successfully" 20 | // @Failure 400 {string} Error "Bad Request" 21 | // @Failure 404 {string} Error "Not Found" 22 | // @Failure 500 {string} Error "Internal Server Error" 23 | // @Router /employee/create [POST] 24 | func (h *HandlerStruct) CreateEmployee(c *gin.Context) { 25 | body := &pb.EmployeeCreateBody{} 26 | 27 | if err := c.ShouldBindJSON(&body); err != nil { 28 | slog.Error("Failed to bind JSON: ", err) 29 | c.JSON(400, gin.H{"error": err}) 30 | return 31 | } 32 | 33 | req := &pb.EmployeeCreate{ 34 | UserId: body.UserId, 35 | Position: body.Position, 36 | HrId: getuserId(c), 37 | } 38 | _, err := h.Clients.HrClient.Create(context.Background(), req) 39 | if err != nil { 40 | slog.Error("Error while create employee: ", err) 41 | c.JSON(400, gin.H{"error": err}) 42 | return 43 | } 44 | 45 | slog.Info("Employee created successfully") 46 | c.JSON(200, "Employee created successfully") 47 | } 48 | 49 | // @Summary GET EMPLOYEE 50 | // @Description This api get employee by id 51 | // @Tags Employee 52 | // @Accept json 53 | // @Produce json 54 | // @Security BearerAuth 55 | // @Param employee_id path string true "Employee ID" 56 | // @Success 200 {object} black_list.Employee 57 | // @Failure 400 {string} Error "Bad Request" 58 | // @Failure 404 {string} Error "Not Found" 59 | // @Failure 500 {string} Error "Internal Server Error" 60 | // @Router /employee/{employee_id} [GET] 61 | func (h *HandlerStruct) GetEmployee(c *gin.Context) { 62 | id := c.Param("employee_id") 63 | 64 | req := &pb.GetById{ 65 | Id: id, 66 | } 67 | 68 | employee, err := h.Clients.HrClient.Get(context.Background(), req) 69 | if err != nil { 70 | slog.Error("Error while getting employee: ", err) 71 | c.JSON(400, gin.H{"error": err}) 72 | return 73 | } 74 | 75 | slog.Info("Employee getting successfully") 76 | c.JSON(200, gin.H{"employee": employee}) 77 | } 78 | 79 | // @Summary GET ALL EMPLOYEES 80 | // @Description This API gets all employees 81 | // @Tags Employee 82 | // @Accept json 83 | // @Produce json 84 | // @Security BearerAuth 85 | // @Param position query string false "Position" 86 | // @Param limit query int false "Limit" 87 | // @Param offset query int false "Offset" 88 | // @Success 200 {object} black_list.ListEmployeeRes 89 | // @Failure 400 {string} Error "Bad Request" 90 | // @Failure 404 {string} Error "Not Found" 91 | // @Failure 500 {string} Error "Internal Server Error" 92 | // @Router /employee/all [GET] 93 | func (h *HandlerStruct) GetAllEmployees(c *gin.Context) { 94 | position := c.Query("position") 95 | limit := c.Query("limit") 96 | offset := c.Query("offset") 97 | 98 | limitValue := 10 99 | offsetValue := 1 100 | 101 | if limit != "" { 102 | parsedLimit, err := strconv.Atoi(limit) 103 | if err != nil { 104 | slog.Error("Invalid limit value", err) 105 | c.JSON(400, gin.H{"error": "Invalid limit value"}) 106 | return 107 | } 108 | limitValue = parsedLimit 109 | } 110 | 111 | if offset != "" { 112 | parsedOffset, err := strconv.Atoi(offset) 113 | if err != nil { 114 | slog.Error("Invalid offset value", err) 115 | c.JSON(400, gin.H{"error": "Invalid offset value"}) 116 | return 117 | } 118 | offsetValue = parsedOffset 119 | } 120 | 121 | req := &pb.ListEmployeeReq{ 122 | Position: position, 123 | Filter: &pb.Filter{ 124 | Limit: int32(limitValue), 125 | Offset: int32(offsetValue), 126 | }, 127 | } 128 | 129 | employees, err := h.Clients.HrClient.GetAll(context.Background(), req) 130 | if err != nil { 131 | slog.Error("Error while getting employees") 132 | c.JSON(500, gin.H{"error": err}) 133 | return 134 | } 135 | 136 | slog.Info("Employees getting successfully") 137 | c.JSON(200, employees) 138 | } 139 | 140 | // @Summary UPDATES EMPLOYEE 141 | // @Description This api updatedes employee 142 | // @Tags Employee 143 | // @Accept json 144 | // @Produce json 145 | // @Security BearerAuth 146 | // @Param employee_id query string false "Employee Id" 147 | // @Param employee body black_list.UpdateReqBody true "Employee" 148 | // @Success 200 {object} string "Employee updated successfully" 149 | // @Failure 400 {string} Error "Bad Request" 150 | // @Failure 404 {string} Error "Not Found" 151 | // @Failure 500 {string} Error "Internal Server Error" 152 | // @Router /employee/update/{employee_id} [PUT] 153 | func (h *HandlerStruct) UpdateEmployee(c *gin.Context) { 154 | id := c.Query("employee_id") 155 | 156 | var body pb.UpdateReqBody 157 | 158 | if err := c.ShouldBindJSON(&body); err != nil { 159 | slog.Error("Failed to bind JSON: ", err) 160 | c.JSON(400, gin.H{"error": err}) 161 | return 162 | } 163 | 164 | req := &pb.UpdateReq{ 165 | Id: id, 166 | Position: body.Position, 167 | HrId: body.HrId, 168 | } 169 | _, err := h.Clients.HrClient.Update(context.Background(), req) 170 | if err != nil { 171 | slog.Error("Error while updating employee") 172 | c.JSON(400, gin.H{"error": err}) 173 | return 174 | } 175 | 176 | slog.Info("Employee updated successfully") 177 | c.JSON(200, gin.H{"message": "Employee updated successfully"}) 178 | } 179 | 180 | // @Summary DELETES EMPLOYEE 181 | // @Description This api deletes employee 182 | // @Tags Employee 183 | // @Accept json 184 | // @Produce json 185 | // @Security BearerAuth 186 | // @Param employee_id path string true "Employee" 187 | // @Success 200 {object} string "Employee deleted successfully" 188 | // @Failure 400 {string} Error "Bad Request" 189 | // @Failure 404 {string} Error "Not Found" 190 | // @Failure 500 {string} Error "Internal Server Error" 191 | // @Router /employee/{employee_id} [DELETE] 192 | func (h *HandlerStruct) DeleteEmployee(c *gin.Context) { 193 | id := c.Param("employee_id") 194 | 195 | req := &pb.GetById{ 196 | Id: id, 197 | } 198 | 199 | _, err := h.Clients.HrClient.Delete(context.Background(), req) 200 | if err != nil { 201 | slog.Error("Error while deleting employee") 202 | c.JSON(400, gin.H{"error": err}) 203 | return 204 | } 205 | 206 | slog.Info("Employee deleted successfully") 207 | c.JSON(200, gin.H{"message": "Employee deleted successfully"}) 208 | } 209 | -------------------------------------------------------------------------------- /api/handler/minio.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "mime/multipart" 5 | "net/http" 6 | "os" 7 | "path/filepath" 8 | 9 | "github.com/gin-gonic/gin" 10 | "github.com/mirjalilova/api-gateway_blacklist/pkg/helper" 11 | "golang.org/x/exp/slog" 12 | ) 13 | 14 | type File struct { 15 | File *multipart.FileHeader `form:"file" binding:"required"` 16 | } 17 | 18 | // File upload 19 | // @Security BearerAuth 20 | // @Summary File upload 21 | // @Description File upload 22 | // @Tags file-upload 23 | // @Accept multipart/form-data 24 | // @Produce json 25 | // @Param file formData file true "File" 26 | // @Router /file-upload [post] 27 | // @Success 200 {object} string 28 | func (h *HandlerStruct) UploadFile(c *gin.Context) { 29 | var file File 30 | 31 | err := c.ShouldBind(&file) 32 | if err != nil { 33 | slog.Error("Error binding request body", err) 34 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) 35 | return 36 | } 37 | 38 | ext := filepath.Ext(file.File.Filename) 39 | if ext != ".pdf" { 40 | slog.Error("Invalid file format", file.File.Filename) 41 | c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid file format. Only PDF allowed."}) 42 | return 43 | } 44 | 45 | uploadDir := "./internal/media/" 46 | if _, err := os.Stat(uploadDir); os.IsNotExist(err) { 47 | err := os.MkdirAll(uploadDir, os.ModePerm) 48 | if err != nil { 49 | slog.Error("Error creating media directory", err) 50 | c.JSON(http.StatusInternalServerError, gin.H{"error": "Error creating media directory"}) 51 | return 52 | } 53 | } 54 | 55 | uploadPath := filepath.Join(uploadDir, file.File.Filename) 56 | 57 | if err := c.SaveUploadedFile(file.File, uploadPath); err != nil { 58 | slog.Error("Error saving file", err) 59 | c.JSON(http.StatusInternalServerError, gin.H{"error": "Error saving file"}) 60 | return 61 | } 62 | 63 | _, err = h.Minio.Upload(file.File.Filename, uploadPath) 64 | if err != nil { 65 | slog.Error("Error uploading file to MinIO", err) 66 | c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) 67 | return 68 | } 69 | 70 | filePathTXT, err := helper.ConvertationToTXT(uploadPath) 71 | if err != nil { 72 | slog.Error("Error converting PDF to text", err) 73 | c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to convert PDF to text"}) 74 | return 75 | } 76 | 77 | os.Remove(uploadPath) 78 | 79 | name, err := helper.GetName(h.Genai, filePathTXT) 80 | if err != nil { 81 | slog.Error("Error extracting name from PDF", err) 82 | c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to extract name from PDF"}) 83 | return 84 | } 85 | 86 | c.JSON(http.StatusCreated, gin.H{ 87 | "message": "File successfully uploaded", 88 | "Full Name": name, 89 | }) 90 | } 91 | -------------------------------------------------------------------------------- /api/middleware/middleware.go: -------------------------------------------------------------------------------- 1 | package middlerware 2 | 3 | import ( 4 | "errors" 5 | "net/http" 6 | "strings" 7 | 8 | "github.com/casbin/casbin/v2" 9 | "github.com/gin-gonic/gin" 10 | "github.com/golang-jwt/jwt" 11 | token "github.com/mirjalilova/api-gateway_blacklist/api/token" 12 | "golang.org/x/exp/slog" 13 | ) 14 | 15 | const ( 16 | key = "secret_key" 17 | ) 18 | 19 | func NewAuth(enforce *casbin.Enforcer) gin.HandlerFunc { 20 | 21 | return func(ctx *gin.Context) { 22 | allow, err := CheckPermission(ctx.FullPath(), ctx.Request, enforce) 23 | 24 | if err != nil { 25 | valid, _ := err.(jwt.ValidationError) 26 | if valid.Errors == jwt.ValidationErrorExpired { 27 | RequireRefresh(ctx) 28 | } else { 29 | RequirePermission(ctx) 30 | } 31 | } else if !allow { 32 | RequirePermission(ctx) 33 | } 34 | ctx.Next() 35 | } 36 | 37 | } 38 | 39 | func GetRole(r *http.Request) (string, error) { 40 | var ( 41 | claims jwt.MapClaims 42 | err error 43 | ) 44 | 45 | jwtToken := r.Header.Get("Authorization") 46 | if jwtToken == "" { 47 | return "unauthorized", nil 48 | } else if strings.Contains(jwtToken, "Basic") { 49 | return "unauthorized", nil 50 | } 51 | 52 | // if !strings.HasPrefix(jwtToken, "Bearer ") { 53 | // return "unauthorized", errors.New("invalid authorization header format") 54 | // } 55 | 56 | tokenString := strings.TrimPrefix(jwtToken, "Bearer ") 57 | 58 | claims, err = token.ExtractClaims(tokenString, key) 59 | 60 | if err != nil { 61 | slog.Error("Error while extracting claims: ", err) 62 | return "unauthorized", err 63 | } 64 | 65 | role, ok := claims["role"].(string) 66 | if !ok { 67 | return "unauthorized", errors.New("role claim not found") 68 | } 69 | 70 | return role, nil 71 | } 72 | 73 | func CheckPermission(path string, r *http.Request, enforcer *casbin.Enforcer) (bool, error) { 74 | role, err := GetRole(r) 75 | if err != nil { 76 | slog.Error("Error while getting role from token: ", err) 77 | return false, err 78 | } 79 | method := r.Method 80 | 81 | // slog.Info("Checking permission for role: ", role, " path: ", path, " method:", method) 82 | 83 | allowed, err := enforcer.Enforce(role, path, method) 84 | if err != nil { 85 | slog.Error("Error while comparing role from csv list: ", err) 86 | return false, err 87 | } 88 | 89 | return allowed, nil 90 | } 91 | 92 | func GetUserId(r *http.Request) (string, error) { 93 | jwtToken := r.Header.Get("Authorization") 94 | 95 | if jwtToken == "" || strings.Contains(jwtToken, "Basic") { 96 | return "unauthorized", nil 97 | } 98 | 99 | // if !strings.HasPrefix(jwtToken, "Bearer ") { 100 | // return "unauthorized", errors.New("invalid authorization header format") 101 | // } 102 | 103 | tokenString := strings.TrimPrefix(jwtToken, "Bearer ") 104 | 105 | claims, err := token.ExtractClaims(tokenString, key) 106 | if err != nil { 107 | slog.Error("Error while extracting claims: ", err) 108 | return "unauthorized", err 109 | } 110 | 111 | userID, ok := claims["user_id"].(string) 112 | if !ok { 113 | return "unauthorized", errors.New("user_id claim not found") 114 | } 115 | return userID, nil 116 | } 117 | 118 | func InvalidToken(c *gin.Context) { 119 | c.AbortWithStatusJSON(http.StatusForbidden, gin.H{ 120 | "error": "Invalid token !!!", 121 | }) 122 | } 123 | 124 | // RequirePermission handles responses for insufficient permissions 125 | func RequirePermission(c *gin.Context) { 126 | c.AbortWithStatusJSON(http.StatusForbidden, gin.H{ 127 | "error": "Permission denied", 128 | }) 129 | } 130 | 131 | // RequireRefresh handles responses for expired access tokens 132 | func RequireRefresh(c *gin.Context) { 133 | c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{ 134 | "error": "Access token expired", 135 | }) 136 | } 137 | -------------------------------------------------------------------------------- /api/router.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/mirjalilova/api-gateway_blacklist/api/handler" 7 | // middlerware "github.com/mirjalilova/api-gateway_blacklist/api/middleware" 8 | _ "github.com/mirjalilova/api-gateway_blacklist/docs" 9 | "golang.org/x/exp/slog" 10 | 11 | "github.com/casbin/casbin/v2" 12 | 13 | "github.com/gin-gonic/gin" 14 | swaggerFiles "github.com/swaggo/files" 15 | ginSwagger "github.com/swaggo/gin-swagger" 16 | ) 17 | 18 | // @title Black List API Gateway 19 | // @version 1.0 20 | // @description API for Black List Service 21 | // @securityDefinitions.apikey BearerAuth 22 | // @in header 23 | // @name Authorization 24 | func NewGin(h *handler.HandlerStruct) *gin.Engine { 25 | router := gin.Default() 26 | 27 | enforcer, err := casbin.NewEnforcer("./api/casbin/model.conf", "./api/casbin/policy.csv") 28 | if err != nil { 29 | slog.Error("Error while initializing casbin enforcer: %v", err) 30 | } 31 | 32 | if enforcer == nil { 33 | slog.Error("Enforcer is nil after initialization!") 34 | } else { 35 | slog.Info("Enforcer initialized successfully.") 36 | } 37 | 38 | // corsConfig := cors.Config{ 39 | // AllowOrigins: []string{"http://localhost", "http://localhost:8080"}, 40 | // AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, 41 | // AllowHeaders: []string{"Origin", "Authorization", "Content-Type"}, 42 | // AllowCredentials: true, 43 | // } 44 | router.Use(CORSMiddleware()) 45 | // router.Use(cors.New(corsConfig)) 46 | 47 | // url := ginSwagger.URL("swagger/doc.json") 48 | router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) 49 | 50 | allowed, err := enforcer.Enforce("admin", "/admin/hr_list", "GET") 51 | slog.Info("Permission allowed: %v, Error: %v", allowed, err) 52 | 53 | admin := router.Group("/admin")//.Use(middlerware.NewAuth(enforcer)) 54 | { 55 | admin.POST("/approve/:user_id", h.Approve) 56 | admin.GET("/hr_list", h.ListHR) 57 | admin.DELETE("/delete_hr/:hr_id", h.DeleteHR) 58 | admin.GET("/users", h.GetAllUsers) 59 | admin.PUT("/change_role", h.ChangeRole) 60 | admin.GET("/user/:user_id", h.GetUser) 61 | admin.GET("/hr/:hr_id", h.GetHR) 62 | } 63 | 64 | hr := router.Group("/employee")//.Use(middlerware.NewAuth(enforcer)) 65 | { 66 | hr.POST("/create", h.CreateEmployee) 67 | hr.GET("/:employee_id", h.GetEmployee) 68 | hr.GET("/all", h.GetAllEmployees) 69 | hr.PUT("/update/:employee_id", h.UpdateEmployee) 70 | hr.DELETE("/:employee_id", h.DeleteEmployee) 71 | } 72 | 73 | bk := router.Group("/blacklist")//.Use(middlerware.NewAuth(enforcer)) 74 | { 75 | bk.POST("/add", h.AddEmployee) 76 | bk.GET("/all", h.GetAll) 77 | bk.DELETE("/remove/:employee_id", h.RemoveEmployee) 78 | bk.GET("/daily", h.GetDaily) 79 | bk.GET("/weekly", h.GetWeekly) 80 | bk.GET("/monthly", h.GetMonthly) 81 | bk.GET("/logs", h.ViewLogs) 82 | } 83 | 84 | router.POST("/file-upload", h.UploadFile) 85 | 86 | return router 87 | } 88 | 89 | func CORSMiddleware() gin.HandlerFunc { 90 | return func(c *gin.Context) { 91 | c.Writer.Header().Set("Access-Control-Allow-Origin", "*") 92 | c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE") 93 | c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization") 94 | 95 | if c.Request.Method == "OPTIONS" { 96 | c.AbortWithStatus(http.StatusOK) 97 | return 98 | } 99 | 100 | c.Next() 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /api/token/token.go: -------------------------------------------------------------------------------- 1 | package tokens 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "log" 7 | 8 | "github.com/golang-jwt/jwt" 9 | ) 10 | 11 | 12 | 13 | func VerifyToken(tokenString string) error { 14 | secretKey := []byte("secret") 15 | token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) { 16 | return secretKey, nil 17 | }) 18 | 19 | if err != nil { 20 | return err 21 | } 22 | 23 | if !token.Valid { 24 | return fmt.Errorf("invalid token") 25 | } 26 | 27 | return nil 28 | } 29 | 30 | func ExtractClaims(tokenStr, key string) (jwt.MapClaims, error) { 31 | var ( 32 | token *jwt.Token 33 | err error 34 | ) 35 | 36 | keyFunc := func(token *jwt.Token) (interface{}, error) { 37 | return []byte(key), nil 38 | } 39 | token, err = jwt.Parse(tokenStr, keyFunc) 40 | log.Println("token",err) 41 | if err != nil { 42 | return nil, err 43 | } 44 | 45 | claims, ok := token.Claims.(jwt.MapClaims) 46 | if !(ok && token.Valid) { 47 | return nil, errors.New("invalid token") 48 | } 49 | 50 | return claims, nil 51 | } 52 | 53 | -------------------------------------------------------------------------------- /cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/mirjalilova/api-gateway_blacklist/internal/config" 5 | "github.com/mirjalilova/api-gateway_blacklist/pkg/app" 6 | 7 | ) 8 | 9 | func main() { 10 | // Load configuration and start the API Gateway 11 | cfg := config.Load() 12 | 13 | // Set up runtime profiling if enabled 14 | app.Run(&cfg) 15 | } 16 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.9' 2 | 3 | services: 4 | # API Gateway 5 | gateway: 6 | container_name: gateway 7 | build: . 8 | ports: 9 | - "3333:3333" 10 | volumes: 11 | - ./internal/media:/app/internal/media 12 | networks: 13 | - ntwrk 14 | 15 | # MinIO Service 16 | minio: 17 | image: minio/minio 18 | container_name: minio 19 | environment: 20 | - MINIO_ROOT_USER=minioadmin 21 | - MINIO_ROOT_PASSWORD=minioadmin123 22 | ports: 23 | - "9000:9000" # MinIO API Port 24 | - "9001:9001" # MinIO Console Port 25 | command: server /data --console-address ":9001" 26 | volumes: 27 | - minio_data:/data 28 | networks: 29 | - ntwrk 30 | 31 | networks: 32 | ntwrk: 33 | name: ntwrk 34 | external: true 35 | 36 | volumes: 37 | minio_data: -------------------------------------------------------------------------------- /dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.22.4 AS builder 2 | 3 | WORKDIR /app 4 | 5 | COPY go.mod go.sum ./ 6 | 7 | 8 | RUN go mod download 9 | 10 | COPY . . 11 | 12 | RUN CGO_ENABLED=0 GOOS=linux go build -o gateway ./cmd/ 13 | 14 | FROM alpine:latest 15 | WORKDIR /app 16 | COPY .env . 17 | 18 | COPY --from=builder /app/gateway . 19 | COPY --from=builder /app/api/casbin/model.conf ./api/casbin/ 20 | COPY --from=builder /app/api/casbin/policy.csv ./api/casbin/ 21 | 22 | EXPOSE 3333 23 | 24 | CMD ["./gateway"] -------------------------------------------------------------------------------- /docs/swagger.yaml: -------------------------------------------------------------------------------- 1 | definitions: 2 | black_list.BlackListBody: 3 | properties: 4 | employee_id: 5 | type: string 6 | reason: 7 | type: string 8 | type: object 9 | black_list.ChangeRoleReq: 10 | properties: 11 | role: 12 | type: string 13 | user_id: 14 | type: string 15 | type: object 16 | black_list.Employee: 17 | properties: 18 | DateOfBirth: 19 | type: string 20 | Email: 21 | type: string 22 | FullName: 23 | type: string 24 | hr_id: 25 | type: string 26 | id: 27 | type: string 28 | is_blocked: 29 | type: string 30 | position: 31 | type: string 32 | type: object 33 | black_list.EmployeeCreateBody: 34 | properties: 35 | position: 36 | type: string 37 | user_id: 38 | type: string 39 | type: object 40 | black_list.GetAllHRRes: 41 | properties: 42 | count: 43 | type: integer 44 | hr: 45 | items: 46 | $ref: '#/definitions/black_list.Hr' 47 | type: array 48 | type: object 49 | black_list.Hr: 50 | properties: 51 | DateOfBirth: 52 | type: string 53 | Email: 54 | type: string 55 | FullName: 56 | type: string 57 | created_at: 58 | type: string 59 | id: 60 | type: string 61 | type: object 62 | black_list.ListEmployeeRes: 63 | properties: 64 | count: 65 | type: integer 66 | employees: 67 | items: 68 | $ref: '#/definitions/black_list.Employee' 69 | type: array 70 | type: object 71 | black_list.ListUserRes: 72 | properties: 73 | count: 74 | type: integer 75 | users: 76 | items: 77 | $ref: '#/definitions/black_list.UserRes' 78 | type: array 79 | type: object 80 | black_list.Log: 81 | properties: 82 | FullName: 83 | type: string 84 | action: 85 | type: string 86 | action_performed_by: 87 | type: string 88 | timestamp: 89 | type: string 90 | type: object 91 | black_list.Logs: 92 | properties: 93 | count: 94 | type: integer 95 | logs: 96 | items: 97 | $ref: '#/definitions/black_list.Log' 98 | type: array 99 | type: object 100 | black_list.Report: 101 | properties: 102 | FullName: 103 | type: string 104 | blacklisted_at: 105 | type: string 106 | position: 107 | type: string 108 | reason: 109 | type: string 110 | type: object 111 | black_list.Reports: 112 | properties: 113 | count: 114 | type: integer 115 | reports: 116 | items: 117 | $ref: '#/definitions/black_list.Report' 118 | type: array 119 | type: object 120 | black_list.UpdateReqBody: 121 | properties: 122 | hr_id: 123 | type: string 124 | position: 125 | type: string 126 | type: object 127 | black_list.UserRes: 128 | properties: 129 | DateOfBirth: 130 | type: string 131 | Email: 132 | type: string 133 | FullName: 134 | type: string 135 | Id: 136 | type: string 137 | Role: 138 | type: string 139 | Username: 140 | type: string 141 | type: object 142 | info: 143 | contact: {} 144 | description: API for Black List Service 145 | title: Black List API Gateway 146 | version: "1.0" 147 | paths: 148 | /admin/approve/{user_id}: 149 | post: 150 | consumes: 151 | - application/json 152 | description: Create a new hr 153 | parameters: 154 | - description: USER ID 155 | in: path 156 | name: user_id 157 | required: true 158 | type: string 159 | produces: 160 | - application/json 161 | responses: 162 | "200": 163 | description: HR created successfully 164 | schema: 165 | type: string 166 | "400": 167 | description: 'error": "error message' 168 | schema: 169 | type: string 170 | security: 171 | - BearerAuth: [] 172 | summary: Create a new hr 173 | tags: 174 | - Admin 175 | /admin/change_role: 176 | put: 177 | consumes: 178 | - application/json 179 | description: Change role of a user 180 | parameters: 181 | - description: Employee 182 | in: body 183 | name: user 184 | required: true 185 | schema: 186 | $ref: '#/definitions/black_list.ChangeRoleReq' 187 | produces: 188 | - application/json 189 | responses: 190 | "200": 191 | description: Employee updated successfully 192 | schema: 193 | type: string 194 | "400": 195 | description: Bad Request 196 | schema: 197 | type: string 198 | "404": 199 | description: Not Found 200 | schema: 201 | type: string 202 | "500": 203 | description: Internal Server Error 204 | schema: 205 | type: string 206 | security: 207 | - BearerAuth: [] 208 | summary: Change role 209 | tags: 210 | - Admin 211 | /admin/delete_hr/{hr_id}: 212 | delete: 213 | consumes: 214 | - application/json 215 | description: Delete HR 216 | parameters: 217 | - description: HR ID 218 | in: query 219 | name: hr_id 220 | required: true 221 | type: string 222 | produces: 223 | - application/json 224 | responses: 225 | "200": 226 | description: HR deleted successfully 227 | schema: 228 | type: string 229 | "400": 230 | description: 'error": "error message' 231 | schema: 232 | type: string 233 | security: 234 | - BearerAuth: [] 235 | summary: Delete HR 236 | tags: 237 | - Admin 238 | /admin/hr/{hr_id}: 239 | get: 240 | consumes: 241 | - application/json 242 | description: Get hr 243 | parameters: 244 | - description: HR Id 245 | in: query 246 | name: hr_id 247 | required: true 248 | type: string 249 | produces: 250 | - application/json 251 | responses: 252 | "200": 253 | description: OK 254 | schema: 255 | $ref: '#/definitions/black_list.Hr' 256 | "400": 257 | description: Bad Request 258 | schema: 259 | type: string 260 | "500": 261 | description: Internal Server Error 262 | schema: 263 | type: string 264 | security: 265 | - BearerAuth: [] 266 | summary: Get hr 267 | tags: 268 | - Admin 269 | /admin/hr_list: 270 | get: 271 | consumes: 272 | - application/json 273 | description: Get hr list 274 | parameters: 275 | - description: Limit 276 | in: query 277 | name: limit 278 | type: integer 279 | - description: Offset 280 | in: query 281 | name: offset 282 | type: integer 283 | produces: 284 | - application/json 285 | responses: 286 | "200": 287 | description: OK 288 | schema: 289 | $ref: '#/definitions/black_list.GetAllHRRes' 290 | "400": 291 | description: Bad Request 292 | schema: 293 | type: string 294 | "500": 295 | description: Internal Server Error 296 | schema: 297 | type: string 298 | security: 299 | - BearerAuth: [] 300 | summary: Get hr list 301 | tags: 302 | - Admin 303 | /admin/user/{user_id}: 304 | get: 305 | consumes: 306 | - application/json 307 | description: Get user 308 | parameters: 309 | - description: User Id 310 | in: query 311 | name: user_id 312 | required: true 313 | type: string 314 | produces: 315 | - application/json 316 | responses: 317 | "200": 318 | description: OK 319 | schema: 320 | $ref: '#/definitions/black_list.UserRes' 321 | "400": 322 | description: Bad Request 323 | schema: 324 | type: string 325 | "500": 326 | description: Internal Server Error 327 | schema: 328 | type: string 329 | security: 330 | - BearerAuth: [] 331 | summary: Get user 332 | tags: 333 | - Admin 334 | /admin/users: 335 | get: 336 | consumes: 337 | - application/json 338 | description: Get all users 339 | parameters: 340 | - description: UserName 341 | in: query 342 | name: username 343 | type: string 344 | - description: Full Name 345 | in: query 346 | name: full_name 347 | type: string 348 | - description: Limit 349 | in: query 350 | name: limit 351 | type: integer 352 | - description: Offset 353 | in: query 354 | name: offset 355 | type: integer 356 | produces: 357 | - application/json 358 | responses: 359 | "200": 360 | description: OK 361 | schema: 362 | $ref: '#/definitions/black_list.ListUserRes' 363 | "400": 364 | description: Bad Request 365 | schema: 366 | type: string 367 | "500": 368 | description: Internal Server Error 369 | schema: 370 | type: string 371 | security: 372 | - BearerAuth: [] 373 | summary: Get all users 374 | tags: 375 | - Admin 376 | /blacklist/add: 377 | post: 378 | consumes: 379 | - application/json 380 | description: Add employee to black list 381 | parameters: 382 | - description: Add employee 383 | in: body 384 | name: data 385 | required: true 386 | schema: 387 | $ref: '#/definitions/black_list.BlackListBody' 388 | produces: 389 | - application/json 390 | responses: 391 | "200": 392 | description: Add employee to blacklist successfully 393 | schema: 394 | type: string 395 | "400": 396 | description: Bad Request 397 | schema: 398 | type: string 399 | "404": 400 | description: Not Found 401 | schema: 402 | type: string 403 | "500": 404 | description: Internal Server Error 405 | schema: 406 | type: string 407 | security: 408 | - BearerAuth: [] 409 | summary: Add employee to black list 410 | tags: 411 | - Black List 412 | /blacklist/all: 413 | get: 414 | consumes: 415 | - application/json 416 | description: Get all employee from blacklist 417 | parameters: 418 | - description: Limit 419 | in: query 420 | name: limit 421 | type: integer 422 | - description: Offset 423 | in: query 424 | name: offset 425 | type: integer 426 | produces: 427 | - application/json 428 | responses: 429 | "200": 430 | description: OK 431 | schema: 432 | $ref: '#/definitions/black_list.Reports' 433 | "400": 434 | description: Bad Request 435 | schema: 436 | type: string 437 | "404": 438 | description: Not Found 439 | schema: 440 | type: string 441 | "500": 442 | description: Internal Server Error 443 | schema: 444 | type: string 445 | security: 446 | - BearerAuth: [] 447 | summary: Get all employee from blacklist 448 | tags: 449 | - Black List 450 | /blacklist/daily: 451 | get: 452 | consumes: 453 | - application/json 454 | description: Monitoring daily blacklist 455 | parameters: 456 | - description: Limit 457 | in: query 458 | name: limit 459 | type: integer 460 | - description: Offset 461 | in: query 462 | name: offset 463 | type: integer 464 | produces: 465 | - application/json 466 | responses: 467 | "200": 468 | description: OK 469 | schema: 470 | $ref: '#/definitions/black_list.Reports' 471 | "400": 472 | description: Bad Request 473 | schema: 474 | type: string 475 | "404": 476 | description: Not Found 477 | schema: 478 | type: string 479 | "500": 480 | description: Internal Server Error 481 | schema: 482 | type: string 483 | security: 484 | - BearerAuth: [] 485 | summary: Monitoring daily blacklist 486 | tags: 487 | - Monitoring 488 | /blacklist/logs: 489 | get: 490 | consumes: 491 | - application/json 492 | description: View logs on blacklist 493 | parameters: 494 | - description: Limit 495 | in: query 496 | name: limit 497 | type: integer 498 | - description: Offset 499 | in: query 500 | name: offset 501 | type: integer 502 | produces: 503 | - application/json 504 | responses: 505 | "200": 506 | description: OK 507 | schema: 508 | $ref: '#/definitions/black_list.Logs' 509 | "400": 510 | description: Bad Request 511 | schema: 512 | type: string 513 | "404": 514 | description: Not Found 515 | schema: 516 | type: string 517 | "500": 518 | description: Internal Server Error 519 | schema: 520 | type: string 521 | security: 522 | - BearerAuth: [] 523 | summary: View logs on blacklist 524 | tags: 525 | - Logs 526 | /blacklist/monthly: 527 | get: 528 | consumes: 529 | - application/json 530 | description: Monitoring monthly blacklist 531 | parameters: 532 | - description: Limit 533 | in: query 534 | name: limit 535 | type: integer 536 | - description: Offset 537 | in: query 538 | name: offset 539 | type: integer 540 | produces: 541 | - application/json 542 | responses: 543 | "200": 544 | description: OK 545 | schema: 546 | $ref: '#/definitions/black_list.Reports' 547 | "400": 548 | description: Bad Request 549 | schema: 550 | type: string 551 | "404": 552 | description: Not Found 553 | schema: 554 | type: string 555 | "500": 556 | description: Internal Server Error 557 | schema: 558 | type: string 559 | security: 560 | - BearerAuth: [] 561 | summary: Monitoring monthly blacklist 562 | tags: 563 | - Monitoring 564 | /blacklist/remove/{employee_id}: 565 | delete: 566 | consumes: 567 | - application/json 568 | description: Remove employee from blacklist 569 | parameters: 570 | - description: Employee Id 571 | in: path 572 | name: employee_id 573 | required: true 574 | type: string 575 | produces: 576 | - application/json 577 | responses: 578 | "200": 579 | description: Removed employee successfully from blacklist 580 | schema: 581 | type: string 582 | "400": 583 | description: Bad Request 584 | schema: 585 | type: string 586 | "404": 587 | description: Not Found 588 | schema: 589 | type: string 590 | "500": 591 | description: Internal Server Error 592 | schema: 593 | type: string 594 | security: 595 | - BearerAuth: [] 596 | summary: Remove employee from blacklist 597 | tags: 598 | - Black List 599 | /blacklist/weekly: 600 | get: 601 | consumes: 602 | - application/json 603 | description: Monitoring weekly blacklist 604 | parameters: 605 | - description: Limit 606 | in: query 607 | name: limit 608 | type: integer 609 | - description: Offset 610 | in: query 611 | name: offset 612 | type: integer 613 | produces: 614 | - application/json 615 | responses: 616 | "200": 617 | description: OK 618 | schema: 619 | $ref: '#/definitions/black_list.Reports' 620 | "400": 621 | description: Bad Request 622 | schema: 623 | type: string 624 | "404": 625 | description: Not Found 626 | schema: 627 | type: string 628 | "500": 629 | description: Internal Server Error 630 | schema: 631 | type: string 632 | security: 633 | - BearerAuth: [] 634 | summary: Monitoring weekly blacklist 635 | tags: 636 | - Monitoring 637 | /employee/{employee_id}: 638 | delete: 639 | consumes: 640 | - application/json 641 | description: This api deletes employee 642 | parameters: 643 | - description: Employee 644 | in: path 645 | name: employee_id 646 | required: true 647 | type: string 648 | produces: 649 | - application/json 650 | responses: 651 | "200": 652 | description: Employee deleted successfully 653 | schema: 654 | type: string 655 | "400": 656 | description: Bad Request 657 | schema: 658 | type: string 659 | "404": 660 | description: Not Found 661 | schema: 662 | type: string 663 | "500": 664 | description: Internal Server Error 665 | schema: 666 | type: string 667 | security: 668 | - BearerAuth: [] 669 | summary: DELETES EMPLOYEE 670 | tags: 671 | - Employee 672 | get: 673 | consumes: 674 | - application/json 675 | description: This api get employee by id 676 | parameters: 677 | - description: Employee ID 678 | in: path 679 | name: employee_id 680 | required: true 681 | type: string 682 | produces: 683 | - application/json 684 | responses: 685 | "200": 686 | description: OK 687 | schema: 688 | $ref: '#/definitions/black_list.Employee' 689 | "400": 690 | description: Bad Request 691 | schema: 692 | type: string 693 | "404": 694 | description: Not Found 695 | schema: 696 | type: string 697 | "500": 698 | description: Internal Server Error 699 | schema: 700 | type: string 701 | security: 702 | - BearerAuth: [] 703 | summary: GET EMPLOYEE 704 | tags: 705 | - Employee 706 | /employee/all: 707 | get: 708 | consumes: 709 | - application/json 710 | description: This API gets all employees 711 | parameters: 712 | - description: Position 713 | in: query 714 | name: position 715 | type: string 716 | - description: Limit 717 | in: query 718 | name: limit 719 | type: integer 720 | - description: Offset 721 | in: query 722 | name: offset 723 | type: integer 724 | produces: 725 | - application/json 726 | responses: 727 | "200": 728 | description: OK 729 | schema: 730 | $ref: '#/definitions/black_list.ListEmployeeRes' 731 | "400": 732 | description: Bad Request 733 | schema: 734 | type: string 735 | "404": 736 | description: Not Found 737 | schema: 738 | type: string 739 | "500": 740 | description: Internal Server Error 741 | schema: 742 | type: string 743 | security: 744 | - BearerAuth: [] 745 | summary: GET ALL EMPLOYEES 746 | tags: 747 | - Employee 748 | /employee/create: 749 | post: 750 | consumes: 751 | - application/json 752 | description: This api create employee 753 | parameters: 754 | - description: Employee 755 | in: body 756 | name: data 757 | required: true 758 | schema: 759 | $ref: '#/definitions/black_list.EmployeeCreateBody' 760 | produces: 761 | - application/json 762 | responses: 763 | "201": 764 | description: Employee created successfully 765 | schema: 766 | type: string 767 | "400": 768 | description: Bad Request 769 | schema: 770 | type: string 771 | "404": 772 | description: Not Found 773 | schema: 774 | type: string 775 | "500": 776 | description: Internal Server Error 777 | schema: 778 | type: string 779 | security: 780 | - BearerAuth: [] 781 | summary: CREATE EMPLOYEE 782 | tags: 783 | - Employee 784 | /employee/update/{employee_id}: 785 | put: 786 | consumes: 787 | - application/json 788 | description: This api updatedes employee 789 | parameters: 790 | - description: Employee Id 791 | in: query 792 | name: employee_id 793 | type: string 794 | - description: Employee 795 | in: body 796 | name: employee 797 | required: true 798 | schema: 799 | $ref: '#/definitions/black_list.UpdateReqBody' 800 | produces: 801 | - application/json 802 | responses: 803 | "200": 804 | description: Employee updated successfully 805 | schema: 806 | type: string 807 | "400": 808 | description: Bad Request 809 | schema: 810 | type: string 811 | "404": 812 | description: Not Found 813 | schema: 814 | type: string 815 | "500": 816 | description: Internal Server Error 817 | schema: 818 | type: string 819 | security: 820 | - BearerAuth: [] 821 | summary: UPDATES EMPLOYEE 822 | tags: 823 | - Employee 824 | /file-upload: 825 | post: 826 | consumes: 827 | - multipart/form-data 828 | description: File upload 829 | parameters: 830 | - description: File 831 | in: formData 832 | name: file 833 | required: true 834 | type: file 835 | produces: 836 | - application/json 837 | responses: 838 | "200": 839 | description: OK 840 | schema: 841 | type: string 842 | security: 843 | - BearerAuth: [] 844 | summary: File upload 845 | tags: 846 | - file-upload 847 | securityDefinitions: 848 | BearerAuth: 849 | in: header 850 | name: Authorization 851 | type: apiKey 852 | swagger: "2.0" 853 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/mirjalilova/api-gateway_blacklist 2 | 3 | go 1.22.1 4 | 5 | require ( 6 | github.com/casbin/casbin/v2 v2.98.0 7 | github.com/gin-gonic/gin v1.10.0 8 | github.com/go-redis/redis/v8 v8.11.5 9 | github.com/golang-jwt/jwt v3.2.2+incompatible 10 | github.com/google/generative-ai-go v0.17.0 11 | github.com/google/uuid v1.6.0 12 | github.com/joho/godotenv v1.5.1 13 | github.com/minio/minio-go/v7 v7.0.76 14 | github.com/pdfcrowd/pdfcrowd-go v0.0.0-20240709092452-9b112de8498f 15 | github.com/spf13/cast v1.7.0 16 | github.com/swaggo/files v1.0.1 17 | github.com/swaggo/gin-swagger v1.6.0 18 | github.com/swaggo/swag v1.16.3 19 | golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa 20 | google.golang.org/api v0.196.0 21 | google.golang.org/grpc v1.66.0 22 | google.golang.org/protobuf v1.34.2 23 | ) 24 | 25 | require ( 26 | cloud.google.com/go v0.115.1 // indirect 27 | cloud.google.com/go/ai v0.8.0 // indirect 28 | cloud.google.com/go/auth v0.9.3 // indirect 29 | cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect 30 | cloud.google.com/go/compute/metadata v0.5.0 // indirect 31 | cloud.google.com/go/longrunning v0.5.7 // indirect 32 | github.com/KyleBanks/depth v1.2.1 // indirect 33 | github.com/PuerkitoBio/purell v1.1.1 // indirect 34 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 35 | github.com/bytedance/sonic v1.11.6 // indirect 36 | github.com/bytedance/sonic/loader v0.1.1 // indirect 37 | github.com/casbin/govaluate v1.2.0 // indirect 38 | github.com/cespare/xxhash/v2 v2.3.0 // indirect 39 | github.com/cloudwego/base64x v0.1.4 // indirect 40 | github.com/cloudwego/iasm v0.2.0 // indirect 41 | github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect 42 | github.com/dustin/go-humanize v1.0.1 // indirect 43 | github.com/felixge/httpsnoop v1.0.4 // indirect 44 | github.com/gabriel-vasile/mimetype v1.4.3 // indirect 45 | github.com/gin-contrib/sse v0.1.0 // indirect 46 | github.com/go-ini/ini v1.67.0 // indirect 47 | github.com/go-logr/logr v1.4.2 // indirect 48 | github.com/go-logr/stdr v1.2.2 // indirect 49 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 50 | github.com/go-openapi/jsonreference v0.19.6 // indirect 51 | github.com/go-openapi/spec v0.20.4 // indirect 52 | github.com/go-openapi/swag v0.19.15 // indirect 53 | github.com/go-playground/locales v0.14.1 // indirect 54 | github.com/go-playground/universal-translator v0.18.1 // indirect 55 | github.com/go-playground/validator/v10 v10.20.0 // indirect 56 | github.com/goccy/go-json v0.10.3 // indirect 57 | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect 58 | github.com/google/s2a-go v0.1.8 // indirect 59 | github.com/googleapis/enterprise-certificate-proxy v0.3.3 // indirect 60 | github.com/googleapis/gax-go/v2 v2.13.0 // indirect 61 | github.com/josharian/intern v1.0.0 // indirect 62 | github.com/json-iterator/go v1.1.12 // indirect 63 | github.com/klauspost/compress v1.17.9 // indirect 64 | github.com/klauspost/cpuid/v2 v2.2.8 // indirect 65 | github.com/leodido/go-urn v1.4.0 // indirect 66 | github.com/mailru/easyjson v0.7.6 // indirect 67 | github.com/mattn/go-isatty v0.0.20 // indirect 68 | github.com/minio/md5-simd v1.1.2 // indirect 69 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 70 | github.com/modern-go/reflect2 v1.0.2 // indirect 71 | github.com/pelletier/go-toml/v2 v2.2.2 // indirect 72 | github.com/rs/xid v1.6.0 // indirect 73 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect 74 | github.com/ugorji/go/codec v1.2.12 // indirect 75 | go.opencensus.io v0.24.0 // indirect 76 | go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect 77 | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect 78 | go.opentelemetry.io/otel v1.29.0 // indirect 79 | go.opentelemetry.io/otel/metric v1.29.0 // indirect 80 | go.opentelemetry.io/otel/trace v1.29.0 // indirect 81 | golang.org/x/arch v0.8.0 // indirect 82 | golang.org/x/crypto v0.26.0 // indirect 83 | golang.org/x/net v0.28.0 // indirect 84 | golang.org/x/oauth2 v0.22.0 // indirect 85 | golang.org/x/sync v0.8.0 // indirect 86 | golang.org/x/sys v0.24.0 // indirect 87 | golang.org/x/text v0.17.0 // indirect 88 | golang.org/x/time v0.6.0 // indirect 89 | golang.org/x/tools v0.24.0 // indirect 90 | google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f // indirect 91 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect 92 | gopkg.in/yaml.v2 v2.4.0 // indirect 93 | gopkg.in/yaml.v3 v3.0.1 // indirect 94 | ) 95 | -------------------------------------------------------------------------------- /internal/config/getEnv.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/joho/godotenv" 8 | "github.com/spf13/cast" 9 | ) 10 | 11 | type Config struct { 12 | AUTH_PORT string 13 | API_GATEWAY string 14 | BLACKLIST_PORT string 15 | 16 | API_KEY string 17 | 18 | LOG_PATH string 19 | } 20 | 21 | func Load() Config { 22 | if err := godotenv.Load(); err != nil { 23 | fmt.Println("No .env file found") 24 | } 25 | 26 | config := Config{} 27 | 28 | config.AUTH_PORT = cast.ToString(coalesce("AUTH_PORT", ":8090")) 29 | config.API_GATEWAY = cast.ToString(coalesce("API_GATEWAY", ":8090")) 30 | config.BLACKLIST_PORT = cast.ToString(coalesce("BLACKLIST_PORT", ":8090")) 31 | 32 | config.API_KEY = cast.ToString(coalesce("API_KEY", "")) 33 | 34 | config.LOG_PATH = cast.ToString(coalesce("LOG_PATH", "logs/info.log")) 35 | 36 | return config 37 | } 38 | 39 | func coalesce(key string, defaultValue interface{}) interface{} { 40 | val, exists := os.LookupEnv(key) 41 | 42 | if exists { 43 | return val 44 | } 45 | 46 | return defaultValue 47 | } 48 | -------------------------------------------------------------------------------- /internal/genproto/auth/auth_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.5.1 4 | // - protoc v4.23.3 5 | // source: auth.proto 6 | 7 | package auth 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.64.0 or later. 19 | const _ = grpc.SupportPackageIsVersion9 20 | 21 | const ( 22 | AuthService_Register_FullMethodName = "/auth.AuthService/Register" 23 | AuthService_Login_FullMethodName = "/auth.AuthService/Login" 24 | AuthService_ForgotPassword_FullMethodName = "/auth.AuthService/ForgotPassword" 25 | AuthService_ResetPassword_FullMethodName = "/auth.AuthService/ResetPassword" 26 | AuthService_SaveRefreshToken_FullMethodName = "/auth.AuthService/SaveRefreshToken" 27 | AuthService_GetAllUsers_FullMethodName = "/auth.AuthService/GetAllUsers" 28 | AuthService_GEtUserById_FullMethodName = "/auth.AuthService/GEtUserById" 29 | ) 30 | 31 | // AuthServiceClient is the client API for AuthService service. 32 | // 33 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 34 | type AuthServiceClient interface { 35 | Register(ctx context.Context, in *RegisterReq, opts ...grpc.CallOption) (*Void, error) 36 | Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*User, error) 37 | ForgotPassword(ctx context.Context, in *GetByEmail, opts ...grpc.CallOption) (*Void, error) 38 | ResetPassword(ctx context.Context, in *ResetPassReq, opts ...grpc.CallOption) (*Void, error) 39 | SaveRefreshToken(ctx context.Context, in *RefToken, opts ...grpc.CallOption) (*Void, error) 40 | GetAllUsers(ctx context.Context, in *ListUserReq, opts ...grpc.CallOption) (*ListUserRes, error) 41 | GEtUserById(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*UserRes, error) 42 | } 43 | 44 | type authServiceClient struct { 45 | cc grpc.ClientConnInterface 46 | } 47 | 48 | func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient { 49 | return &authServiceClient{cc} 50 | } 51 | 52 | func (c *authServiceClient) Register(ctx context.Context, in *RegisterReq, opts ...grpc.CallOption) (*Void, error) { 53 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 54 | out := new(Void) 55 | err := c.cc.Invoke(ctx, AuthService_Register_FullMethodName, in, out, cOpts...) 56 | if err != nil { 57 | return nil, err 58 | } 59 | return out, nil 60 | } 61 | 62 | func (c *authServiceClient) Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*User, error) { 63 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 64 | out := new(User) 65 | err := c.cc.Invoke(ctx, AuthService_Login_FullMethodName, in, out, cOpts...) 66 | if err != nil { 67 | return nil, err 68 | } 69 | return out, nil 70 | } 71 | 72 | func (c *authServiceClient) ForgotPassword(ctx context.Context, in *GetByEmail, opts ...grpc.CallOption) (*Void, error) { 73 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 74 | out := new(Void) 75 | err := c.cc.Invoke(ctx, AuthService_ForgotPassword_FullMethodName, in, out, cOpts...) 76 | if err != nil { 77 | return nil, err 78 | } 79 | return out, nil 80 | } 81 | 82 | func (c *authServiceClient) ResetPassword(ctx context.Context, in *ResetPassReq, opts ...grpc.CallOption) (*Void, error) { 83 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 84 | out := new(Void) 85 | err := c.cc.Invoke(ctx, AuthService_ResetPassword_FullMethodName, in, out, cOpts...) 86 | if err != nil { 87 | return nil, err 88 | } 89 | return out, nil 90 | } 91 | 92 | func (c *authServiceClient) SaveRefreshToken(ctx context.Context, in *RefToken, opts ...grpc.CallOption) (*Void, error) { 93 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 94 | out := new(Void) 95 | err := c.cc.Invoke(ctx, AuthService_SaveRefreshToken_FullMethodName, in, out, cOpts...) 96 | if err != nil { 97 | return nil, err 98 | } 99 | return out, nil 100 | } 101 | 102 | func (c *authServiceClient) GetAllUsers(ctx context.Context, in *ListUserReq, opts ...grpc.CallOption) (*ListUserRes, error) { 103 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 104 | out := new(ListUserRes) 105 | err := c.cc.Invoke(ctx, AuthService_GetAllUsers_FullMethodName, in, out, cOpts...) 106 | if err != nil { 107 | return nil, err 108 | } 109 | return out, nil 110 | } 111 | 112 | func (c *authServiceClient) GEtUserById(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*UserRes, error) { 113 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 114 | out := new(UserRes) 115 | err := c.cc.Invoke(ctx, AuthService_GEtUserById_FullMethodName, in, out, cOpts...) 116 | if err != nil { 117 | return nil, err 118 | } 119 | return out, nil 120 | } 121 | 122 | // AuthServiceServer is the server API for AuthService service. 123 | // All implementations must embed UnimplementedAuthServiceServer 124 | // for forward compatibility. 125 | type AuthServiceServer interface { 126 | Register(context.Context, *RegisterReq) (*Void, error) 127 | Login(context.Context, *LoginReq) (*User, error) 128 | ForgotPassword(context.Context, *GetByEmail) (*Void, error) 129 | ResetPassword(context.Context, *ResetPassReq) (*Void, error) 130 | SaveRefreshToken(context.Context, *RefToken) (*Void, error) 131 | GetAllUsers(context.Context, *ListUserReq) (*ListUserRes, error) 132 | GEtUserById(context.Context, *GetById) (*UserRes, error) 133 | mustEmbedUnimplementedAuthServiceServer() 134 | } 135 | 136 | // UnimplementedAuthServiceServer must be embedded to have 137 | // forward compatible implementations. 138 | // 139 | // NOTE: this should be embedded by value instead of pointer to avoid a nil 140 | // pointer dereference when methods are called. 141 | type UnimplementedAuthServiceServer struct{} 142 | 143 | func (UnimplementedAuthServiceServer) Register(context.Context, *RegisterReq) (*Void, error) { 144 | return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") 145 | } 146 | func (UnimplementedAuthServiceServer) Login(context.Context, *LoginReq) (*User, error) { 147 | return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") 148 | } 149 | func (UnimplementedAuthServiceServer) ForgotPassword(context.Context, *GetByEmail) (*Void, error) { 150 | return nil, status.Errorf(codes.Unimplemented, "method ForgotPassword not implemented") 151 | } 152 | func (UnimplementedAuthServiceServer) ResetPassword(context.Context, *ResetPassReq) (*Void, error) { 153 | return nil, status.Errorf(codes.Unimplemented, "method ResetPassword not implemented") 154 | } 155 | func (UnimplementedAuthServiceServer) SaveRefreshToken(context.Context, *RefToken) (*Void, error) { 156 | return nil, status.Errorf(codes.Unimplemented, "method SaveRefreshToken not implemented") 157 | } 158 | func (UnimplementedAuthServiceServer) GetAllUsers(context.Context, *ListUserReq) (*ListUserRes, error) { 159 | return nil, status.Errorf(codes.Unimplemented, "method GetAllUsers not implemented") 160 | } 161 | func (UnimplementedAuthServiceServer) GEtUserById(context.Context, *GetById) (*UserRes, error) { 162 | return nil, status.Errorf(codes.Unimplemented, "method GEtUserById not implemented") 163 | } 164 | func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {} 165 | func (UnimplementedAuthServiceServer) testEmbeddedByValue() {} 166 | 167 | // UnsafeAuthServiceServer may be embedded to opt out of forward compatibility for this service. 168 | // Use of this interface is not recommended, as added methods to AuthServiceServer will 169 | // result in compilation errors. 170 | type UnsafeAuthServiceServer interface { 171 | mustEmbedUnimplementedAuthServiceServer() 172 | } 173 | 174 | func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) { 175 | // If the following call pancis, it indicates UnimplementedAuthServiceServer was 176 | // embedded by pointer and is nil. This will cause panics if an 177 | // unimplemented method is ever invoked, so we test this at initialization 178 | // time to prevent it from happening at runtime later due to I/O. 179 | if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { 180 | t.testEmbeddedByValue() 181 | } 182 | s.RegisterService(&AuthService_ServiceDesc, srv) 183 | } 184 | 185 | func _AuthService_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 186 | in := new(RegisterReq) 187 | if err := dec(in); err != nil { 188 | return nil, err 189 | } 190 | if interceptor == nil { 191 | return srv.(AuthServiceServer).Register(ctx, in) 192 | } 193 | info := &grpc.UnaryServerInfo{ 194 | Server: srv, 195 | FullMethod: AuthService_Register_FullMethodName, 196 | } 197 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 198 | return srv.(AuthServiceServer).Register(ctx, req.(*RegisterReq)) 199 | } 200 | return interceptor(ctx, in, info, handler) 201 | } 202 | 203 | func _AuthService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 204 | in := new(LoginReq) 205 | if err := dec(in); err != nil { 206 | return nil, err 207 | } 208 | if interceptor == nil { 209 | return srv.(AuthServiceServer).Login(ctx, in) 210 | } 211 | info := &grpc.UnaryServerInfo{ 212 | Server: srv, 213 | FullMethod: AuthService_Login_FullMethodName, 214 | } 215 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 216 | return srv.(AuthServiceServer).Login(ctx, req.(*LoginReq)) 217 | } 218 | return interceptor(ctx, in, info, handler) 219 | } 220 | 221 | func _AuthService_ForgotPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 222 | in := new(GetByEmail) 223 | if err := dec(in); err != nil { 224 | return nil, err 225 | } 226 | if interceptor == nil { 227 | return srv.(AuthServiceServer).ForgotPassword(ctx, in) 228 | } 229 | info := &grpc.UnaryServerInfo{ 230 | Server: srv, 231 | FullMethod: AuthService_ForgotPassword_FullMethodName, 232 | } 233 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 234 | return srv.(AuthServiceServer).ForgotPassword(ctx, req.(*GetByEmail)) 235 | } 236 | return interceptor(ctx, in, info, handler) 237 | } 238 | 239 | func _AuthService_ResetPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 240 | in := new(ResetPassReq) 241 | if err := dec(in); err != nil { 242 | return nil, err 243 | } 244 | if interceptor == nil { 245 | return srv.(AuthServiceServer).ResetPassword(ctx, in) 246 | } 247 | info := &grpc.UnaryServerInfo{ 248 | Server: srv, 249 | FullMethod: AuthService_ResetPassword_FullMethodName, 250 | } 251 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 252 | return srv.(AuthServiceServer).ResetPassword(ctx, req.(*ResetPassReq)) 253 | } 254 | return interceptor(ctx, in, info, handler) 255 | } 256 | 257 | func _AuthService_SaveRefreshToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 258 | in := new(RefToken) 259 | if err := dec(in); err != nil { 260 | return nil, err 261 | } 262 | if interceptor == nil { 263 | return srv.(AuthServiceServer).SaveRefreshToken(ctx, in) 264 | } 265 | info := &grpc.UnaryServerInfo{ 266 | Server: srv, 267 | FullMethod: AuthService_SaveRefreshToken_FullMethodName, 268 | } 269 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 270 | return srv.(AuthServiceServer).SaveRefreshToken(ctx, req.(*RefToken)) 271 | } 272 | return interceptor(ctx, in, info, handler) 273 | } 274 | 275 | func _AuthService_GetAllUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 276 | in := new(ListUserReq) 277 | if err := dec(in); err != nil { 278 | return nil, err 279 | } 280 | if interceptor == nil { 281 | return srv.(AuthServiceServer).GetAllUsers(ctx, in) 282 | } 283 | info := &grpc.UnaryServerInfo{ 284 | Server: srv, 285 | FullMethod: AuthService_GetAllUsers_FullMethodName, 286 | } 287 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 288 | return srv.(AuthServiceServer).GetAllUsers(ctx, req.(*ListUserReq)) 289 | } 290 | return interceptor(ctx, in, info, handler) 291 | } 292 | 293 | func _AuthService_GEtUserById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 294 | in := new(GetById) 295 | if err := dec(in); err != nil { 296 | return nil, err 297 | } 298 | if interceptor == nil { 299 | return srv.(AuthServiceServer).GEtUserById(ctx, in) 300 | } 301 | info := &grpc.UnaryServerInfo{ 302 | Server: srv, 303 | FullMethod: AuthService_GEtUserById_FullMethodName, 304 | } 305 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 306 | return srv.(AuthServiceServer).GEtUserById(ctx, req.(*GetById)) 307 | } 308 | return interceptor(ctx, in, info, handler) 309 | } 310 | 311 | // AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service. 312 | // It's only intended for direct use with grpc.RegisterService, 313 | // and not to be introspected or modified (even as a copy) 314 | var AuthService_ServiceDesc = grpc.ServiceDesc{ 315 | ServiceName: "auth.AuthService", 316 | HandlerType: (*AuthServiceServer)(nil), 317 | Methods: []grpc.MethodDesc{ 318 | { 319 | MethodName: "Register", 320 | Handler: _AuthService_Register_Handler, 321 | }, 322 | { 323 | MethodName: "Login", 324 | Handler: _AuthService_Login_Handler, 325 | }, 326 | { 327 | MethodName: "ForgotPassword", 328 | Handler: _AuthService_ForgotPassword_Handler, 329 | }, 330 | { 331 | MethodName: "ResetPassword", 332 | Handler: _AuthService_ResetPassword_Handler, 333 | }, 334 | { 335 | MethodName: "SaveRefreshToken", 336 | Handler: _AuthService_SaveRefreshToken_Handler, 337 | }, 338 | { 339 | MethodName: "GetAllUsers", 340 | Handler: _AuthService_GetAllUsers_Handler, 341 | }, 342 | { 343 | MethodName: "GEtUserById", 344 | Handler: _AuthService_GEtUserById_Handler, 345 | }, 346 | }, 347 | Streams: []grpc.StreamDesc{}, 348 | Metadata: "auth.proto", 349 | } 350 | -------------------------------------------------------------------------------- /internal/genproto/auth/common1.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.34.2 4 | // protoc v4.23.3 5 | // source: common1.proto 6 | 7 | package auth 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type Void struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | } 28 | 29 | func (x *Void) Reset() { 30 | *x = Void{} 31 | if protoimpl.UnsafeEnabled { 32 | mi := &file_common1_proto_msgTypes[0] 33 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 34 | ms.StoreMessageInfo(mi) 35 | } 36 | } 37 | 38 | func (x *Void) String() string { 39 | return protoimpl.X.MessageStringOf(x) 40 | } 41 | 42 | func (*Void) ProtoMessage() {} 43 | 44 | func (x *Void) ProtoReflect() protoreflect.Message { 45 | mi := &file_common1_proto_msgTypes[0] 46 | if protoimpl.UnsafeEnabled && x != nil { 47 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 48 | if ms.LoadMessageInfo() == nil { 49 | ms.StoreMessageInfo(mi) 50 | } 51 | return ms 52 | } 53 | return mi.MessageOf(x) 54 | } 55 | 56 | // Deprecated: Use Void.ProtoReflect.Descriptor instead. 57 | func (*Void) Descriptor() ([]byte, []int) { 58 | return file_common1_proto_rawDescGZIP(), []int{0} 59 | } 60 | 61 | type GetById struct { 62 | state protoimpl.MessageState 63 | sizeCache protoimpl.SizeCache 64 | unknownFields protoimpl.UnknownFields 65 | 66 | Id string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` 67 | } 68 | 69 | func (x *GetById) Reset() { 70 | *x = GetById{} 71 | if protoimpl.UnsafeEnabled { 72 | mi := &file_common1_proto_msgTypes[1] 73 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 74 | ms.StoreMessageInfo(mi) 75 | } 76 | } 77 | 78 | func (x *GetById) String() string { 79 | return protoimpl.X.MessageStringOf(x) 80 | } 81 | 82 | func (*GetById) ProtoMessage() {} 83 | 84 | func (x *GetById) ProtoReflect() protoreflect.Message { 85 | mi := &file_common1_proto_msgTypes[1] 86 | if protoimpl.UnsafeEnabled && x != nil { 87 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 88 | if ms.LoadMessageInfo() == nil { 89 | ms.StoreMessageInfo(mi) 90 | } 91 | return ms 92 | } 93 | return mi.MessageOf(x) 94 | } 95 | 96 | // Deprecated: Use GetById.ProtoReflect.Descriptor instead. 97 | func (*GetById) Descriptor() ([]byte, []int) { 98 | return file_common1_proto_rawDescGZIP(), []int{1} 99 | } 100 | 101 | func (x *GetById) GetId() string { 102 | if x != nil { 103 | return x.Id 104 | } 105 | return "" 106 | } 107 | 108 | type Filter struct { 109 | state protoimpl.MessageState 110 | sizeCache protoimpl.SizeCache 111 | unknownFields protoimpl.UnknownFields 112 | 113 | Limit int32 `protobuf:"varint,1,opt,name=limit,proto3" json:"limit,omitempty"` 114 | Offset int32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` 115 | } 116 | 117 | func (x *Filter) Reset() { 118 | *x = Filter{} 119 | if protoimpl.UnsafeEnabled { 120 | mi := &file_common1_proto_msgTypes[2] 121 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 122 | ms.StoreMessageInfo(mi) 123 | } 124 | } 125 | 126 | func (x *Filter) String() string { 127 | return protoimpl.X.MessageStringOf(x) 128 | } 129 | 130 | func (*Filter) ProtoMessage() {} 131 | 132 | func (x *Filter) ProtoReflect() protoreflect.Message { 133 | mi := &file_common1_proto_msgTypes[2] 134 | if protoimpl.UnsafeEnabled && x != nil { 135 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 136 | if ms.LoadMessageInfo() == nil { 137 | ms.StoreMessageInfo(mi) 138 | } 139 | return ms 140 | } 141 | return mi.MessageOf(x) 142 | } 143 | 144 | // Deprecated: Use Filter.ProtoReflect.Descriptor instead. 145 | func (*Filter) Descriptor() ([]byte, []int) { 146 | return file_common1_proto_rawDescGZIP(), []int{2} 147 | } 148 | 149 | func (x *Filter) GetLimit() int32 { 150 | if x != nil { 151 | return x.Limit 152 | } 153 | return 0 154 | } 155 | 156 | func (x *Filter) GetOffset() int32 { 157 | if x != nil { 158 | return x.Offset 159 | } 160 | return 0 161 | } 162 | 163 | var File_common1_proto protoreflect.FileDescriptor 164 | 165 | var file_common1_proto_rawDesc = []byte{ 166 | 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 167 | 0x04, 0x61, 0x75, 0x74, 0x68, 0x22, 0x06, 0x0a, 0x04, 0x56, 0x6f, 0x69, 0x64, 0x22, 0x19, 0x0a, 168 | 0x07, 0x47, 0x65, 0x74, 0x42, 0x79, 0x49, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 169 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x64, 0x22, 0x36, 0x0a, 0x06, 0x46, 0x69, 0x6c, 0x74, 170 | 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 171 | 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 172 | 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 173 | 0x42, 0x18, 0x5a, 0x16, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 174 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 175 | 0x6f, 0x33, 176 | } 177 | 178 | var ( 179 | file_common1_proto_rawDescOnce sync.Once 180 | file_common1_proto_rawDescData = file_common1_proto_rawDesc 181 | ) 182 | 183 | func file_common1_proto_rawDescGZIP() []byte { 184 | file_common1_proto_rawDescOnce.Do(func() { 185 | file_common1_proto_rawDescData = protoimpl.X.CompressGZIP(file_common1_proto_rawDescData) 186 | }) 187 | return file_common1_proto_rawDescData 188 | } 189 | 190 | var file_common1_proto_msgTypes = make([]protoimpl.MessageInfo, 3) 191 | var file_common1_proto_goTypes = []any{ 192 | (*Void)(nil), // 0: auth.Void 193 | (*GetById)(nil), // 1: auth.GetById 194 | (*Filter)(nil), // 2: auth.Filter 195 | } 196 | var file_common1_proto_depIdxs = []int32{ 197 | 0, // [0:0] is the sub-list for method output_type 198 | 0, // [0:0] is the sub-list for method input_type 199 | 0, // [0:0] is the sub-list for extension type_name 200 | 0, // [0:0] is the sub-list for extension extendee 201 | 0, // [0:0] is the sub-list for field type_name 202 | } 203 | 204 | func init() { file_common1_proto_init() } 205 | func file_common1_proto_init() { 206 | if File_common1_proto != nil { 207 | return 208 | } 209 | if !protoimpl.UnsafeEnabled { 210 | file_common1_proto_msgTypes[0].Exporter = func(v any, i int) any { 211 | switch v := v.(*Void); i { 212 | case 0: 213 | return &v.state 214 | case 1: 215 | return &v.sizeCache 216 | case 2: 217 | return &v.unknownFields 218 | default: 219 | return nil 220 | } 221 | } 222 | file_common1_proto_msgTypes[1].Exporter = func(v any, i int) any { 223 | switch v := v.(*GetById); i { 224 | case 0: 225 | return &v.state 226 | case 1: 227 | return &v.sizeCache 228 | case 2: 229 | return &v.unknownFields 230 | default: 231 | return nil 232 | } 233 | } 234 | file_common1_proto_msgTypes[2].Exporter = func(v any, i int) any { 235 | switch v := v.(*Filter); i { 236 | case 0: 237 | return &v.state 238 | case 1: 239 | return &v.sizeCache 240 | case 2: 241 | return &v.unknownFields 242 | default: 243 | return nil 244 | } 245 | } 246 | } 247 | type x struct{} 248 | out := protoimpl.TypeBuilder{ 249 | File: protoimpl.DescBuilder{ 250 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 251 | RawDescriptor: file_common1_proto_rawDesc, 252 | NumEnums: 0, 253 | NumMessages: 3, 254 | NumExtensions: 0, 255 | NumServices: 0, 256 | }, 257 | GoTypes: file_common1_proto_goTypes, 258 | DependencyIndexes: file_common1_proto_depIdxs, 259 | MessageInfos: file_common1_proto_msgTypes, 260 | }.Build() 261 | File_common1_proto = out.File 262 | file_common1_proto_rawDesc = nil 263 | file_common1_proto_goTypes = nil 264 | file_common1_proto_depIdxs = nil 265 | } 266 | -------------------------------------------------------------------------------- /internal/genproto/auth/user.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.34.2 4 | // protoc v4.23.3 5 | // source: user.proto 6 | 7 | package auth 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type UserRes struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | Id string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` 29 | Username string `protobuf:"bytes,2,opt,name=Username,proto3" json:"Username,omitempty"` 30 | Email string `protobuf:"bytes,3,opt,name=Email,proto3" json:"Email,omitempty"` 31 | FullName string `protobuf:"bytes,4,opt,name=FullName,proto3" json:"FullName,omitempty"` 32 | DateOfBirth string `protobuf:"bytes,5,opt,name=DateOfBirth,proto3" json:"DateOfBirth,omitempty"` 33 | Role string `protobuf:"bytes,6,opt,name=Role,proto3" json:"Role,omitempty"` 34 | } 35 | 36 | func (x *UserRes) Reset() { 37 | *x = UserRes{} 38 | if protoimpl.UnsafeEnabled { 39 | mi := &file_user_proto_msgTypes[0] 40 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 41 | ms.StoreMessageInfo(mi) 42 | } 43 | } 44 | 45 | func (x *UserRes) String() string { 46 | return protoimpl.X.MessageStringOf(x) 47 | } 48 | 49 | func (*UserRes) ProtoMessage() {} 50 | 51 | func (x *UserRes) ProtoReflect() protoreflect.Message { 52 | mi := &file_user_proto_msgTypes[0] 53 | if protoimpl.UnsafeEnabled && x != nil { 54 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 55 | if ms.LoadMessageInfo() == nil { 56 | ms.StoreMessageInfo(mi) 57 | } 58 | return ms 59 | } 60 | return mi.MessageOf(x) 61 | } 62 | 63 | // Deprecated: Use UserRes.ProtoReflect.Descriptor instead. 64 | func (*UserRes) Descriptor() ([]byte, []int) { 65 | return file_user_proto_rawDescGZIP(), []int{0} 66 | } 67 | 68 | func (x *UserRes) GetId() string { 69 | if x != nil { 70 | return x.Id 71 | } 72 | return "" 73 | } 74 | 75 | func (x *UserRes) GetUsername() string { 76 | if x != nil { 77 | return x.Username 78 | } 79 | return "" 80 | } 81 | 82 | func (x *UserRes) GetEmail() string { 83 | if x != nil { 84 | return x.Email 85 | } 86 | return "" 87 | } 88 | 89 | func (x *UserRes) GetFullName() string { 90 | if x != nil { 91 | return x.FullName 92 | } 93 | return "" 94 | } 95 | 96 | func (x *UserRes) GetDateOfBirth() string { 97 | if x != nil { 98 | return x.DateOfBirth 99 | } 100 | return "" 101 | } 102 | 103 | func (x *UserRes) GetRole() string { 104 | if x != nil { 105 | return x.Role 106 | } 107 | return "" 108 | } 109 | 110 | type EditProfileReqBpdy struct { 111 | state protoimpl.MessageState 112 | sizeCache protoimpl.SizeCache 113 | unknownFields protoimpl.UnknownFields 114 | 115 | Username string `protobuf:"bytes,1,opt,name=Username,proto3" json:"Username,omitempty"` 116 | Email string `protobuf:"bytes,2,opt,name=Email,proto3" json:"Email,omitempty"` 117 | FullName string `protobuf:"bytes,3,opt,name=FullName,proto3" json:"FullName,omitempty"` 118 | DateOfBirth string `protobuf:"bytes,4,opt,name=DateOfBirth,proto3" json:"DateOfBirth,omitempty"` 119 | } 120 | 121 | func (x *EditProfileReqBpdy) Reset() { 122 | *x = EditProfileReqBpdy{} 123 | if protoimpl.UnsafeEnabled { 124 | mi := &file_user_proto_msgTypes[1] 125 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 126 | ms.StoreMessageInfo(mi) 127 | } 128 | } 129 | 130 | func (x *EditProfileReqBpdy) String() string { 131 | return protoimpl.X.MessageStringOf(x) 132 | } 133 | 134 | func (*EditProfileReqBpdy) ProtoMessage() {} 135 | 136 | func (x *EditProfileReqBpdy) ProtoReflect() protoreflect.Message { 137 | mi := &file_user_proto_msgTypes[1] 138 | if protoimpl.UnsafeEnabled && x != nil { 139 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 140 | if ms.LoadMessageInfo() == nil { 141 | ms.StoreMessageInfo(mi) 142 | } 143 | return ms 144 | } 145 | return mi.MessageOf(x) 146 | } 147 | 148 | // Deprecated: Use EditProfileReqBpdy.ProtoReflect.Descriptor instead. 149 | func (*EditProfileReqBpdy) Descriptor() ([]byte, []int) { 150 | return file_user_proto_rawDescGZIP(), []int{1} 151 | } 152 | 153 | func (x *EditProfileReqBpdy) GetUsername() string { 154 | if x != nil { 155 | return x.Username 156 | } 157 | return "" 158 | } 159 | 160 | func (x *EditProfileReqBpdy) GetEmail() string { 161 | if x != nil { 162 | return x.Email 163 | } 164 | return "" 165 | } 166 | 167 | func (x *EditProfileReqBpdy) GetFullName() string { 168 | if x != nil { 169 | return x.FullName 170 | } 171 | return "" 172 | } 173 | 174 | func (x *EditProfileReqBpdy) GetDateOfBirth() string { 175 | if x != nil { 176 | return x.DateOfBirth 177 | } 178 | return "" 179 | } 180 | 181 | type ChangePasswordReq struct { 182 | state protoimpl.MessageState 183 | sizeCache protoimpl.SizeCache 184 | unknownFields protoimpl.UnknownFields 185 | 186 | Id string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` 187 | CurrentPassword string `protobuf:"bytes,2,opt,name=CurrentPassword,proto3" json:"CurrentPassword,omitempty"` 188 | NewPassword string `protobuf:"bytes,3,opt,name=NewPassword,proto3" json:"NewPassword,omitempty"` 189 | } 190 | 191 | func (x *ChangePasswordReq) Reset() { 192 | *x = ChangePasswordReq{} 193 | if protoimpl.UnsafeEnabled { 194 | mi := &file_user_proto_msgTypes[2] 195 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 196 | ms.StoreMessageInfo(mi) 197 | } 198 | } 199 | 200 | func (x *ChangePasswordReq) String() string { 201 | return protoimpl.X.MessageStringOf(x) 202 | } 203 | 204 | func (*ChangePasswordReq) ProtoMessage() {} 205 | 206 | func (x *ChangePasswordReq) ProtoReflect() protoreflect.Message { 207 | mi := &file_user_proto_msgTypes[2] 208 | if protoimpl.UnsafeEnabled && x != nil { 209 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 210 | if ms.LoadMessageInfo() == nil { 211 | ms.StoreMessageInfo(mi) 212 | } 213 | return ms 214 | } 215 | return mi.MessageOf(x) 216 | } 217 | 218 | // Deprecated: Use ChangePasswordReq.ProtoReflect.Descriptor instead. 219 | func (*ChangePasswordReq) Descriptor() ([]byte, []int) { 220 | return file_user_proto_rawDescGZIP(), []int{2} 221 | } 222 | 223 | func (x *ChangePasswordReq) GetId() string { 224 | if x != nil { 225 | return x.Id 226 | } 227 | return "" 228 | } 229 | 230 | func (x *ChangePasswordReq) GetCurrentPassword() string { 231 | if x != nil { 232 | return x.CurrentPassword 233 | } 234 | return "" 235 | } 236 | 237 | func (x *ChangePasswordReq) GetNewPassword() string { 238 | if x != nil { 239 | return x.NewPassword 240 | } 241 | return "" 242 | } 243 | 244 | type ChangePasswordReqBody struct { 245 | state protoimpl.MessageState 246 | sizeCache protoimpl.SizeCache 247 | unknownFields protoimpl.UnknownFields 248 | 249 | CurrentPassword string `protobuf:"bytes,1,opt,name=CurrentPassword,proto3" json:"CurrentPassword,omitempty"` 250 | NewPassword string `protobuf:"bytes,2,opt,name=NewPassword,proto3" json:"NewPassword,omitempty"` 251 | } 252 | 253 | func (x *ChangePasswordReqBody) Reset() { 254 | *x = ChangePasswordReqBody{} 255 | if protoimpl.UnsafeEnabled { 256 | mi := &file_user_proto_msgTypes[3] 257 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 258 | ms.StoreMessageInfo(mi) 259 | } 260 | } 261 | 262 | func (x *ChangePasswordReqBody) String() string { 263 | return protoimpl.X.MessageStringOf(x) 264 | } 265 | 266 | func (*ChangePasswordReqBody) ProtoMessage() {} 267 | 268 | func (x *ChangePasswordReqBody) ProtoReflect() protoreflect.Message { 269 | mi := &file_user_proto_msgTypes[3] 270 | if protoimpl.UnsafeEnabled && x != nil { 271 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 272 | if ms.LoadMessageInfo() == nil { 273 | ms.StoreMessageInfo(mi) 274 | } 275 | return ms 276 | } 277 | return mi.MessageOf(x) 278 | } 279 | 280 | // Deprecated: Use ChangePasswordReqBody.ProtoReflect.Descriptor instead. 281 | func (*ChangePasswordReqBody) Descriptor() ([]byte, []int) { 282 | return file_user_proto_rawDescGZIP(), []int{3} 283 | } 284 | 285 | func (x *ChangePasswordReqBody) GetCurrentPassword() string { 286 | if x != nil { 287 | return x.CurrentPassword 288 | } 289 | return "" 290 | } 291 | 292 | func (x *ChangePasswordReqBody) GetNewPassword() string { 293 | if x != nil { 294 | return x.NewPassword 295 | } 296 | return "" 297 | } 298 | 299 | type SettingReq struct { 300 | state protoimpl.MessageState 301 | sizeCache protoimpl.SizeCache 302 | unknownFields protoimpl.UnknownFields 303 | 304 | Id string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` 305 | PrivacyLevel string `protobuf:"bytes,2,opt,name=PrivacyLevel,proto3" json:"PrivacyLevel,omitempty"` 306 | Notification string `protobuf:"bytes,3,opt,name=Notification,proto3" json:"Notification,omitempty"` 307 | Language string `protobuf:"bytes,4,opt,name=Language,proto3" json:"Language,omitempty"` 308 | Theme string `protobuf:"bytes,5,opt,name=Theme,proto3" json:"Theme,omitempty"` 309 | } 310 | 311 | func (x *SettingReq) Reset() { 312 | *x = SettingReq{} 313 | if protoimpl.UnsafeEnabled { 314 | mi := &file_user_proto_msgTypes[4] 315 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 316 | ms.StoreMessageInfo(mi) 317 | } 318 | } 319 | 320 | func (x *SettingReq) String() string { 321 | return protoimpl.X.MessageStringOf(x) 322 | } 323 | 324 | func (*SettingReq) ProtoMessage() {} 325 | 326 | func (x *SettingReq) ProtoReflect() protoreflect.Message { 327 | mi := &file_user_proto_msgTypes[4] 328 | if protoimpl.UnsafeEnabled && x != nil { 329 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 330 | if ms.LoadMessageInfo() == nil { 331 | ms.StoreMessageInfo(mi) 332 | } 333 | return ms 334 | } 335 | return mi.MessageOf(x) 336 | } 337 | 338 | // Deprecated: Use SettingReq.ProtoReflect.Descriptor instead. 339 | func (*SettingReq) Descriptor() ([]byte, []int) { 340 | return file_user_proto_rawDescGZIP(), []int{4} 341 | } 342 | 343 | func (x *SettingReq) GetId() string { 344 | if x != nil { 345 | return x.Id 346 | } 347 | return "" 348 | } 349 | 350 | func (x *SettingReq) GetPrivacyLevel() string { 351 | if x != nil { 352 | return x.PrivacyLevel 353 | } 354 | return "" 355 | } 356 | 357 | func (x *SettingReq) GetNotification() string { 358 | if x != nil { 359 | return x.Notification 360 | } 361 | return "" 362 | } 363 | 364 | func (x *SettingReq) GetLanguage() string { 365 | if x != nil { 366 | return x.Language 367 | } 368 | return "" 369 | } 370 | 371 | func (x *SettingReq) GetTheme() string { 372 | if x != nil { 373 | return x.Theme 374 | } 375 | return "" 376 | } 377 | 378 | type Setting struct { 379 | state protoimpl.MessageState 380 | sizeCache protoimpl.SizeCache 381 | unknownFields protoimpl.UnknownFields 382 | 383 | PrivacyLevel string `protobuf:"bytes,1,opt,name=PrivacyLevel,proto3" json:"PrivacyLevel,omitempty"` 384 | Notification string `protobuf:"bytes,2,opt,name=Notification,proto3" json:"Notification,omitempty"` 385 | Language string `protobuf:"bytes,3,opt,name=Language,proto3" json:"Language,omitempty"` 386 | Theme string `protobuf:"bytes,4,opt,name=Theme,proto3" json:"Theme,omitempty"` 387 | } 388 | 389 | func (x *Setting) Reset() { 390 | *x = Setting{} 391 | if protoimpl.UnsafeEnabled { 392 | mi := &file_user_proto_msgTypes[5] 393 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 394 | ms.StoreMessageInfo(mi) 395 | } 396 | } 397 | 398 | func (x *Setting) String() string { 399 | return protoimpl.X.MessageStringOf(x) 400 | } 401 | 402 | func (*Setting) ProtoMessage() {} 403 | 404 | func (x *Setting) ProtoReflect() protoreflect.Message { 405 | mi := &file_user_proto_msgTypes[5] 406 | if protoimpl.UnsafeEnabled && x != nil { 407 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 408 | if ms.LoadMessageInfo() == nil { 409 | ms.StoreMessageInfo(mi) 410 | } 411 | return ms 412 | } 413 | return mi.MessageOf(x) 414 | } 415 | 416 | // Deprecated: Use Setting.ProtoReflect.Descriptor instead. 417 | func (*Setting) Descriptor() ([]byte, []int) { 418 | return file_user_proto_rawDescGZIP(), []int{5} 419 | } 420 | 421 | func (x *Setting) GetPrivacyLevel() string { 422 | if x != nil { 423 | return x.PrivacyLevel 424 | } 425 | return "" 426 | } 427 | 428 | func (x *Setting) GetNotification() string { 429 | if x != nil { 430 | return x.Notification 431 | } 432 | return "" 433 | } 434 | 435 | func (x *Setting) GetLanguage() string { 436 | if x != nil { 437 | return x.Language 438 | } 439 | return "" 440 | } 441 | 442 | func (x *Setting) GetTheme() string { 443 | if x != nil { 444 | return x.Theme 445 | } 446 | return "" 447 | } 448 | 449 | var File_user_proto protoreflect.FileDescriptor 450 | 451 | var file_user_proto_rawDesc = []byte{ 452 | 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x61, 0x75, 453 | 0x74, 0x68, 0x1a, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 454 | 0x6f, 0x22, 0x9d, 0x01, 0x0a, 0x07, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x12, 0x0e, 0x0a, 455 | 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x64, 0x12, 0x1a, 0x0a, 456 | 0x08, 0x55, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 457 | 0x08, 0x55, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6d, 0x61, 458 | 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 459 | 0x1a, 0x0a, 0x08, 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 460 | 0x09, 0x52, 0x08, 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x44, 461 | 0x61, 0x74, 0x65, 0x4f, 0x66, 0x42, 0x69, 0x72, 0x74, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 462 | 0x52, 0x0b, 0x44, 0x61, 0x74, 0x65, 0x4f, 0x66, 0x42, 0x69, 0x72, 0x74, 0x68, 0x12, 0x12, 0x0a, 463 | 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x52, 0x6f, 0x6c, 464 | 0x65, 0x22, 0x84, 0x01, 0x0a, 0x12, 0x45, 0x64, 0x69, 0x74, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 465 | 0x65, 0x52, 0x65, 0x71, 0x42, 0x70, 0x64, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 466 | 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x55, 0x73, 0x65, 0x72, 467 | 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 468 | 0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x46, 0x75, 469 | 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x46, 0x75, 470 | 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x44, 0x61, 0x74, 0x65, 0x4f, 0x66, 471 | 0x42, 0x69, 0x72, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x61, 0x74, 472 | 0x65, 0x4f, 0x66, 0x42, 0x69, 0x72, 0x74, 0x68, 0x22, 0x6f, 0x0a, 0x11, 0x43, 0x68, 0x61, 0x6e, 473 | 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 474 | 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x64, 0x12, 0x28, 0x0a, 475 | 0x0f, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 476 | 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x50, 477 | 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x4e, 0x65, 0x77, 0x50, 0x61, 478 | 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x4e, 0x65, 479 | 0x77, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x63, 0x0a, 0x15, 0x43, 0x68, 0x61, 480 | 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x42, 0x6f, 481 | 0x64, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x50, 0x61, 0x73, 482 | 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x43, 0x75, 0x72, 483 | 0x72, 0x65, 0x6e, 0x74, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x20, 0x0a, 0x0b, 484 | 0x4e, 0x65, 0x77, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 485 | 0x09, 0x52, 0x0b, 0x4e, 0x65, 0x77, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x96, 486 | 0x01, 0x0a, 0x0a, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 487 | 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x64, 0x12, 0x22, 0x0a, 488 | 0x0c, 0x50, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x02, 0x20, 489 | 0x01, 0x28, 0x09, 0x52, 0x0c, 0x50, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x4c, 0x65, 0x76, 0x65, 490 | 0x6c, 0x12, 0x22, 0x0a, 0x0c, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 491 | 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 492 | 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 493 | 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 494 | 0x65, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x68, 0x65, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 495 | 0x52, 0x05, 0x54, 0x68, 0x65, 0x6d, 0x65, 0x22, 0x83, 0x01, 0x0a, 0x07, 0x53, 0x65, 0x74, 0x74, 496 | 0x69, 0x6e, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x50, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x4c, 0x65, 497 | 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x50, 0x72, 0x69, 0x76, 0x61, 498 | 0x63, 0x79, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x22, 0x0a, 0x0c, 0x4e, 0x6f, 0x74, 0x69, 0x66, 499 | 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x4e, 500 | 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x4c, 501 | 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4c, 502 | 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x68, 0x65, 0x6d, 0x65, 503 | 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x68, 0x65, 0x6d, 0x65, 0x32, 0x9f, 0x02, 504 | 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2a, 0x0a, 505 | 0x0a, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x0d, 0x2e, 0x61, 0x75, 506 | 0x74, 0x68, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x79, 0x49, 0x64, 0x1a, 0x0d, 0x2e, 0x61, 0x75, 0x74, 507 | 0x68, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x12, 0x2b, 0x0a, 0x0b, 0x45, 0x64, 0x69, 508 | 0x74, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x0d, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 509 | 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x1a, 0x0d, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x55, 510 | 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x12, 0x35, 0x0a, 0x0e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 511 | 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x17, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 512 | 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 513 | 0x71, 0x1a, 0x0a, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x56, 0x6f, 0x69, 0x64, 0x12, 0x2a, 0x0a, 514 | 0x0a, 0x47, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x0d, 0x2e, 0x61, 0x75, 515 | 0x74, 0x68, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x79, 0x49, 0x64, 0x1a, 0x0d, 0x2e, 0x61, 0x75, 0x74, 516 | 0x68, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x2b, 0x0a, 0x0b, 0x45, 0x64, 0x69, 517 | 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x10, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 518 | 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x0a, 0x2e, 0x61, 0x75, 0x74, 519 | 0x68, 0x2e, 0x56, 0x6f, 0x69, 0x64, 0x12, 0x27, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 520 | 0x55, 0x73, 0x65, 0x72, 0x12, 0x0d, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x47, 0x65, 0x74, 0x42, 521 | 0x79, 0x49, 0x64, 0x1a, 0x0a, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x56, 0x6f, 0x69, 0x64, 0x42, 522 | 0x18, 0x5a, 0x16, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x70, 523 | 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 524 | 0x33, 525 | } 526 | 527 | var ( 528 | file_user_proto_rawDescOnce sync.Once 529 | file_user_proto_rawDescData = file_user_proto_rawDesc 530 | ) 531 | 532 | func file_user_proto_rawDescGZIP() []byte { 533 | file_user_proto_rawDescOnce.Do(func() { 534 | file_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_proto_rawDescData) 535 | }) 536 | return file_user_proto_rawDescData 537 | } 538 | 539 | var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 6) 540 | var file_user_proto_goTypes = []any{ 541 | (*UserRes)(nil), // 0: auth.UserRes 542 | (*EditProfileReqBpdy)(nil), // 1: auth.EditProfileReqBpdy 543 | (*ChangePasswordReq)(nil), // 2: auth.ChangePasswordReq 544 | (*ChangePasswordReqBody)(nil), // 3: auth.ChangePasswordReqBody 545 | (*SettingReq)(nil), // 4: auth.SettingReq 546 | (*Setting)(nil), // 5: auth.Setting 547 | (*GetById)(nil), // 6: auth.GetById 548 | (*Void)(nil), // 7: auth.Void 549 | } 550 | var file_user_proto_depIdxs = []int32{ 551 | 6, // 0: auth.UserService.GetProfile:input_type -> auth.GetById 552 | 0, // 1: auth.UserService.EditProfile:input_type -> auth.UserRes 553 | 2, // 2: auth.UserService.ChangePassword:input_type -> auth.ChangePasswordReq 554 | 6, // 3: auth.UserService.GetSetting:input_type -> auth.GetById 555 | 4, // 4: auth.UserService.EditSetting:input_type -> auth.SettingReq 556 | 6, // 5: auth.UserService.DeleteUser:input_type -> auth.GetById 557 | 0, // 6: auth.UserService.GetProfile:output_type -> auth.UserRes 558 | 0, // 7: auth.UserService.EditProfile:output_type -> auth.UserRes 559 | 7, // 8: auth.UserService.ChangePassword:output_type -> auth.Void 560 | 5, // 9: auth.UserService.GetSetting:output_type -> auth.Setting 561 | 7, // 10: auth.UserService.EditSetting:output_type -> auth.Void 562 | 7, // 11: auth.UserService.DeleteUser:output_type -> auth.Void 563 | 6, // [6:12] is the sub-list for method output_type 564 | 0, // [0:6] is the sub-list for method input_type 565 | 0, // [0:0] is the sub-list for extension type_name 566 | 0, // [0:0] is the sub-list for extension extendee 567 | 0, // [0:0] is the sub-list for field type_name 568 | } 569 | 570 | func init() { file_user_proto_init() } 571 | func file_user_proto_init() { 572 | if File_user_proto != nil { 573 | return 574 | } 575 | file_common1_proto_init() 576 | if !protoimpl.UnsafeEnabled { 577 | file_user_proto_msgTypes[0].Exporter = func(v any, i int) any { 578 | switch v := v.(*UserRes); i { 579 | case 0: 580 | return &v.state 581 | case 1: 582 | return &v.sizeCache 583 | case 2: 584 | return &v.unknownFields 585 | default: 586 | return nil 587 | } 588 | } 589 | file_user_proto_msgTypes[1].Exporter = func(v any, i int) any { 590 | switch v := v.(*EditProfileReqBpdy); i { 591 | case 0: 592 | return &v.state 593 | case 1: 594 | return &v.sizeCache 595 | case 2: 596 | return &v.unknownFields 597 | default: 598 | return nil 599 | } 600 | } 601 | file_user_proto_msgTypes[2].Exporter = func(v any, i int) any { 602 | switch v := v.(*ChangePasswordReq); i { 603 | case 0: 604 | return &v.state 605 | case 1: 606 | return &v.sizeCache 607 | case 2: 608 | return &v.unknownFields 609 | default: 610 | return nil 611 | } 612 | } 613 | file_user_proto_msgTypes[3].Exporter = func(v any, i int) any { 614 | switch v := v.(*ChangePasswordReqBody); i { 615 | case 0: 616 | return &v.state 617 | case 1: 618 | return &v.sizeCache 619 | case 2: 620 | return &v.unknownFields 621 | default: 622 | return nil 623 | } 624 | } 625 | file_user_proto_msgTypes[4].Exporter = func(v any, i int) any { 626 | switch v := v.(*SettingReq); i { 627 | case 0: 628 | return &v.state 629 | case 1: 630 | return &v.sizeCache 631 | case 2: 632 | return &v.unknownFields 633 | default: 634 | return nil 635 | } 636 | } 637 | file_user_proto_msgTypes[5].Exporter = func(v any, i int) any { 638 | switch v := v.(*Setting); i { 639 | case 0: 640 | return &v.state 641 | case 1: 642 | return &v.sizeCache 643 | case 2: 644 | return &v.unknownFields 645 | default: 646 | return nil 647 | } 648 | } 649 | } 650 | type x struct{} 651 | out := protoimpl.TypeBuilder{ 652 | File: protoimpl.DescBuilder{ 653 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 654 | RawDescriptor: file_user_proto_rawDesc, 655 | NumEnums: 0, 656 | NumMessages: 6, 657 | NumExtensions: 0, 658 | NumServices: 1, 659 | }, 660 | GoTypes: file_user_proto_goTypes, 661 | DependencyIndexes: file_user_proto_depIdxs, 662 | MessageInfos: file_user_proto_msgTypes, 663 | }.Build() 664 | File_user_proto = out.File 665 | file_user_proto_rawDesc = nil 666 | file_user_proto_goTypes = nil 667 | file_user_proto_depIdxs = nil 668 | } 669 | -------------------------------------------------------------------------------- /internal/genproto/auth/user_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.5.1 4 | // - protoc v4.23.3 5 | // source: user.proto 6 | 7 | package auth 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.64.0 or later. 19 | const _ = grpc.SupportPackageIsVersion9 20 | 21 | const ( 22 | UserService_GetProfile_FullMethodName = "/auth.UserService/GetProfile" 23 | UserService_EditProfile_FullMethodName = "/auth.UserService/EditProfile" 24 | UserService_ChangePassword_FullMethodName = "/auth.UserService/ChangePassword" 25 | UserService_GetSetting_FullMethodName = "/auth.UserService/GetSetting" 26 | UserService_EditSetting_FullMethodName = "/auth.UserService/EditSetting" 27 | UserService_DeleteUser_FullMethodName = "/auth.UserService/DeleteUser" 28 | ) 29 | 30 | // UserServiceClient is the client API for UserService service. 31 | // 32 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 33 | type UserServiceClient interface { 34 | GetProfile(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*UserRes, error) 35 | EditProfile(ctx context.Context, in *UserRes, opts ...grpc.CallOption) (*UserRes, error) 36 | ChangePassword(ctx context.Context, in *ChangePasswordReq, opts ...grpc.CallOption) (*Void, error) 37 | GetSetting(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*Setting, error) 38 | EditSetting(ctx context.Context, in *SettingReq, opts ...grpc.CallOption) (*Void, error) 39 | DeleteUser(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*Void, error) 40 | } 41 | 42 | type userServiceClient struct { 43 | cc grpc.ClientConnInterface 44 | } 45 | 46 | func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient { 47 | return &userServiceClient{cc} 48 | } 49 | 50 | func (c *userServiceClient) GetProfile(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*UserRes, error) { 51 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 52 | out := new(UserRes) 53 | err := c.cc.Invoke(ctx, UserService_GetProfile_FullMethodName, in, out, cOpts...) 54 | if err != nil { 55 | return nil, err 56 | } 57 | return out, nil 58 | } 59 | 60 | func (c *userServiceClient) EditProfile(ctx context.Context, in *UserRes, opts ...grpc.CallOption) (*UserRes, error) { 61 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 62 | out := new(UserRes) 63 | err := c.cc.Invoke(ctx, UserService_EditProfile_FullMethodName, in, out, cOpts...) 64 | if err != nil { 65 | return nil, err 66 | } 67 | return out, nil 68 | } 69 | 70 | func (c *userServiceClient) ChangePassword(ctx context.Context, in *ChangePasswordReq, opts ...grpc.CallOption) (*Void, error) { 71 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 72 | out := new(Void) 73 | err := c.cc.Invoke(ctx, UserService_ChangePassword_FullMethodName, in, out, cOpts...) 74 | if err != nil { 75 | return nil, err 76 | } 77 | return out, nil 78 | } 79 | 80 | func (c *userServiceClient) GetSetting(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*Setting, error) { 81 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 82 | out := new(Setting) 83 | err := c.cc.Invoke(ctx, UserService_GetSetting_FullMethodName, in, out, cOpts...) 84 | if err != nil { 85 | return nil, err 86 | } 87 | return out, nil 88 | } 89 | 90 | func (c *userServiceClient) EditSetting(ctx context.Context, in *SettingReq, opts ...grpc.CallOption) (*Void, error) { 91 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 92 | out := new(Void) 93 | err := c.cc.Invoke(ctx, UserService_EditSetting_FullMethodName, in, out, cOpts...) 94 | if err != nil { 95 | return nil, err 96 | } 97 | return out, nil 98 | } 99 | 100 | func (c *userServiceClient) DeleteUser(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*Void, error) { 101 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 102 | out := new(Void) 103 | err := c.cc.Invoke(ctx, UserService_DeleteUser_FullMethodName, in, out, cOpts...) 104 | if err != nil { 105 | return nil, err 106 | } 107 | return out, nil 108 | } 109 | 110 | // UserServiceServer is the server API for UserService service. 111 | // All implementations must embed UnimplementedUserServiceServer 112 | // for forward compatibility. 113 | type UserServiceServer interface { 114 | GetProfile(context.Context, *GetById) (*UserRes, error) 115 | EditProfile(context.Context, *UserRes) (*UserRes, error) 116 | ChangePassword(context.Context, *ChangePasswordReq) (*Void, error) 117 | GetSetting(context.Context, *GetById) (*Setting, error) 118 | EditSetting(context.Context, *SettingReq) (*Void, error) 119 | DeleteUser(context.Context, *GetById) (*Void, error) 120 | mustEmbedUnimplementedUserServiceServer() 121 | } 122 | 123 | // UnimplementedUserServiceServer must be embedded to have 124 | // forward compatible implementations. 125 | // 126 | // NOTE: this should be embedded by value instead of pointer to avoid a nil 127 | // pointer dereference when methods are called. 128 | type UnimplementedUserServiceServer struct{} 129 | 130 | func (UnimplementedUserServiceServer) GetProfile(context.Context, *GetById) (*UserRes, error) { 131 | return nil, status.Errorf(codes.Unimplemented, "method GetProfile not implemented") 132 | } 133 | func (UnimplementedUserServiceServer) EditProfile(context.Context, *UserRes) (*UserRes, error) { 134 | return nil, status.Errorf(codes.Unimplemented, "method EditProfile not implemented") 135 | } 136 | func (UnimplementedUserServiceServer) ChangePassword(context.Context, *ChangePasswordReq) (*Void, error) { 137 | return nil, status.Errorf(codes.Unimplemented, "method ChangePassword not implemented") 138 | } 139 | func (UnimplementedUserServiceServer) GetSetting(context.Context, *GetById) (*Setting, error) { 140 | return nil, status.Errorf(codes.Unimplemented, "method GetSetting not implemented") 141 | } 142 | func (UnimplementedUserServiceServer) EditSetting(context.Context, *SettingReq) (*Void, error) { 143 | return nil, status.Errorf(codes.Unimplemented, "method EditSetting not implemented") 144 | } 145 | func (UnimplementedUserServiceServer) DeleteUser(context.Context, *GetById) (*Void, error) { 146 | return nil, status.Errorf(codes.Unimplemented, "method DeleteUser not implemented") 147 | } 148 | func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {} 149 | func (UnimplementedUserServiceServer) testEmbeddedByValue() {} 150 | 151 | // UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service. 152 | // Use of this interface is not recommended, as added methods to UserServiceServer will 153 | // result in compilation errors. 154 | type UnsafeUserServiceServer interface { 155 | mustEmbedUnimplementedUserServiceServer() 156 | } 157 | 158 | func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer) { 159 | // If the following call pancis, it indicates UnimplementedUserServiceServer was 160 | // embedded by pointer and is nil. This will cause panics if an 161 | // unimplemented method is ever invoked, so we test this at initialization 162 | // time to prevent it from happening at runtime later due to I/O. 163 | if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { 164 | t.testEmbeddedByValue() 165 | } 166 | s.RegisterService(&UserService_ServiceDesc, srv) 167 | } 168 | 169 | func _UserService_GetProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 170 | in := new(GetById) 171 | if err := dec(in); err != nil { 172 | return nil, err 173 | } 174 | if interceptor == nil { 175 | return srv.(UserServiceServer).GetProfile(ctx, in) 176 | } 177 | info := &grpc.UnaryServerInfo{ 178 | Server: srv, 179 | FullMethod: UserService_GetProfile_FullMethodName, 180 | } 181 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 182 | return srv.(UserServiceServer).GetProfile(ctx, req.(*GetById)) 183 | } 184 | return interceptor(ctx, in, info, handler) 185 | } 186 | 187 | func _UserService_EditProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 188 | in := new(UserRes) 189 | if err := dec(in); err != nil { 190 | return nil, err 191 | } 192 | if interceptor == nil { 193 | return srv.(UserServiceServer).EditProfile(ctx, in) 194 | } 195 | info := &grpc.UnaryServerInfo{ 196 | Server: srv, 197 | FullMethod: UserService_EditProfile_FullMethodName, 198 | } 199 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 200 | return srv.(UserServiceServer).EditProfile(ctx, req.(*UserRes)) 201 | } 202 | return interceptor(ctx, in, info, handler) 203 | } 204 | 205 | func _UserService_ChangePassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 206 | in := new(ChangePasswordReq) 207 | if err := dec(in); err != nil { 208 | return nil, err 209 | } 210 | if interceptor == nil { 211 | return srv.(UserServiceServer).ChangePassword(ctx, in) 212 | } 213 | info := &grpc.UnaryServerInfo{ 214 | Server: srv, 215 | FullMethod: UserService_ChangePassword_FullMethodName, 216 | } 217 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 218 | return srv.(UserServiceServer).ChangePassword(ctx, req.(*ChangePasswordReq)) 219 | } 220 | return interceptor(ctx, in, info, handler) 221 | } 222 | 223 | func _UserService_GetSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 224 | in := new(GetById) 225 | if err := dec(in); err != nil { 226 | return nil, err 227 | } 228 | if interceptor == nil { 229 | return srv.(UserServiceServer).GetSetting(ctx, in) 230 | } 231 | info := &grpc.UnaryServerInfo{ 232 | Server: srv, 233 | FullMethod: UserService_GetSetting_FullMethodName, 234 | } 235 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 236 | return srv.(UserServiceServer).GetSetting(ctx, req.(*GetById)) 237 | } 238 | return interceptor(ctx, in, info, handler) 239 | } 240 | 241 | func _UserService_EditSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 242 | in := new(SettingReq) 243 | if err := dec(in); err != nil { 244 | return nil, err 245 | } 246 | if interceptor == nil { 247 | return srv.(UserServiceServer).EditSetting(ctx, in) 248 | } 249 | info := &grpc.UnaryServerInfo{ 250 | Server: srv, 251 | FullMethod: UserService_EditSetting_FullMethodName, 252 | } 253 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 254 | return srv.(UserServiceServer).EditSetting(ctx, req.(*SettingReq)) 255 | } 256 | return interceptor(ctx, in, info, handler) 257 | } 258 | 259 | func _UserService_DeleteUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 260 | in := new(GetById) 261 | if err := dec(in); err != nil { 262 | return nil, err 263 | } 264 | if interceptor == nil { 265 | return srv.(UserServiceServer).DeleteUser(ctx, in) 266 | } 267 | info := &grpc.UnaryServerInfo{ 268 | Server: srv, 269 | FullMethod: UserService_DeleteUser_FullMethodName, 270 | } 271 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 272 | return srv.(UserServiceServer).DeleteUser(ctx, req.(*GetById)) 273 | } 274 | return interceptor(ctx, in, info, handler) 275 | } 276 | 277 | // UserService_ServiceDesc is the grpc.ServiceDesc for UserService service. 278 | // It's only intended for direct use with grpc.RegisterService, 279 | // and not to be introspected or modified (even as a copy) 280 | var UserService_ServiceDesc = grpc.ServiceDesc{ 281 | ServiceName: "auth.UserService", 282 | HandlerType: (*UserServiceServer)(nil), 283 | Methods: []grpc.MethodDesc{ 284 | { 285 | MethodName: "GetProfile", 286 | Handler: _UserService_GetProfile_Handler, 287 | }, 288 | { 289 | MethodName: "EditProfile", 290 | Handler: _UserService_EditProfile_Handler, 291 | }, 292 | { 293 | MethodName: "ChangePassword", 294 | Handler: _UserService_ChangePassword_Handler, 295 | }, 296 | { 297 | MethodName: "GetSetting", 298 | Handler: _UserService_GetSetting_Handler, 299 | }, 300 | { 301 | MethodName: "EditSetting", 302 | Handler: _UserService_EditSetting_Handler, 303 | }, 304 | { 305 | MethodName: "DeleteUser", 306 | Handler: _UserService_DeleteUser_Handler, 307 | }, 308 | }, 309 | Streams: []grpc.StreamDesc{}, 310 | Metadata: "user.proto", 311 | } 312 | -------------------------------------------------------------------------------- /internal/genproto/black_list/admin_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.5.1 4 | // - protoc v4.23.3 5 | // source: admin.proto 6 | 7 | package black_list 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.64.0 or later. 19 | const _ = grpc.SupportPackageIsVersion9 20 | 21 | const ( 22 | AdminService_Approve_FullMethodName = "/black_list.AdminService/Approve" 23 | AdminService_ListHR_FullMethodName = "/black_list.AdminService/ListHR" 24 | AdminService_GetHRById_FullMethodName = "/black_list.AdminService/GetHRById" 25 | AdminService_Delete_FullMethodName = "/black_list.AdminService/Delete" 26 | AdminService_GetAllUsers_FullMethodName = "/black_list.AdminService/GetAllUsers" 27 | AdminService_ChangeRole_FullMethodName = "/black_list.AdminService/ChangeRole" 28 | AdminService_GetUserById_FullMethodName = "/black_list.AdminService/GetUserById" 29 | ) 30 | 31 | // AdminServiceClient is the client API for AdminService service. 32 | // 33 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 34 | type AdminServiceClient interface { 35 | Approve(ctx context.Context, in *CreateHR, opts ...grpc.CallOption) (*Void, error) 36 | ListHR(ctx context.Context, in *Filter, opts ...grpc.CallOption) (*GetAllHRRes, error) 37 | GetHRById(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*Hr, error) 38 | Delete(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*Void, error) 39 | GetAllUsers(ctx context.Context, in *ListUserReq, opts ...grpc.CallOption) (*ListUserRes, error) 40 | ChangeRole(ctx context.Context, in *ChangeRoleReq, opts ...grpc.CallOption) (*Void, error) 41 | GetUserById(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*UserRes, error) 42 | } 43 | 44 | type adminServiceClient struct { 45 | cc grpc.ClientConnInterface 46 | } 47 | 48 | func NewAdminServiceClient(cc grpc.ClientConnInterface) AdminServiceClient { 49 | return &adminServiceClient{cc} 50 | } 51 | 52 | func (c *adminServiceClient) Approve(ctx context.Context, in *CreateHR, opts ...grpc.CallOption) (*Void, error) { 53 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 54 | out := new(Void) 55 | err := c.cc.Invoke(ctx, AdminService_Approve_FullMethodName, in, out, cOpts...) 56 | if err != nil { 57 | return nil, err 58 | } 59 | return out, nil 60 | } 61 | 62 | func (c *adminServiceClient) ListHR(ctx context.Context, in *Filter, opts ...grpc.CallOption) (*GetAllHRRes, error) { 63 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 64 | out := new(GetAllHRRes) 65 | err := c.cc.Invoke(ctx, AdminService_ListHR_FullMethodName, in, out, cOpts...) 66 | if err != nil { 67 | return nil, err 68 | } 69 | return out, nil 70 | } 71 | 72 | func (c *adminServiceClient) GetHRById(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*Hr, error) { 73 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 74 | out := new(Hr) 75 | err := c.cc.Invoke(ctx, AdminService_GetHRById_FullMethodName, in, out, cOpts...) 76 | if err != nil { 77 | return nil, err 78 | } 79 | return out, nil 80 | } 81 | 82 | func (c *adminServiceClient) Delete(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*Void, error) { 83 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 84 | out := new(Void) 85 | err := c.cc.Invoke(ctx, AdminService_Delete_FullMethodName, in, out, cOpts...) 86 | if err != nil { 87 | return nil, err 88 | } 89 | return out, nil 90 | } 91 | 92 | func (c *adminServiceClient) GetAllUsers(ctx context.Context, in *ListUserReq, opts ...grpc.CallOption) (*ListUserRes, error) { 93 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 94 | out := new(ListUserRes) 95 | err := c.cc.Invoke(ctx, AdminService_GetAllUsers_FullMethodName, in, out, cOpts...) 96 | if err != nil { 97 | return nil, err 98 | } 99 | return out, nil 100 | } 101 | 102 | func (c *adminServiceClient) ChangeRole(ctx context.Context, in *ChangeRoleReq, opts ...grpc.CallOption) (*Void, error) { 103 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 104 | out := new(Void) 105 | err := c.cc.Invoke(ctx, AdminService_ChangeRole_FullMethodName, in, out, cOpts...) 106 | if err != nil { 107 | return nil, err 108 | } 109 | return out, nil 110 | } 111 | 112 | func (c *adminServiceClient) GetUserById(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*UserRes, error) { 113 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 114 | out := new(UserRes) 115 | err := c.cc.Invoke(ctx, AdminService_GetUserById_FullMethodName, in, out, cOpts...) 116 | if err != nil { 117 | return nil, err 118 | } 119 | return out, nil 120 | } 121 | 122 | // AdminServiceServer is the server API for AdminService service. 123 | // All implementations must embed UnimplementedAdminServiceServer 124 | // for forward compatibility. 125 | type AdminServiceServer interface { 126 | Approve(context.Context, *CreateHR) (*Void, error) 127 | ListHR(context.Context, *Filter) (*GetAllHRRes, error) 128 | GetHRById(context.Context, *GetById) (*Hr, error) 129 | Delete(context.Context, *GetById) (*Void, error) 130 | GetAllUsers(context.Context, *ListUserReq) (*ListUserRes, error) 131 | ChangeRole(context.Context, *ChangeRoleReq) (*Void, error) 132 | GetUserById(context.Context, *GetById) (*UserRes, error) 133 | mustEmbedUnimplementedAdminServiceServer() 134 | } 135 | 136 | // UnimplementedAdminServiceServer must be embedded to have 137 | // forward compatible implementations. 138 | // 139 | // NOTE: this should be embedded by value instead of pointer to avoid a nil 140 | // pointer dereference when methods are called. 141 | type UnimplementedAdminServiceServer struct{} 142 | 143 | func (UnimplementedAdminServiceServer) Approve(context.Context, *CreateHR) (*Void, error) { 144 | return nil, status.Errorf(codes.Unimplemented, "method Approve not implemented") 145 | } 146 | func (UnimplementedAdminServiceServer) ListHR(context.Context, *Filter) (*GetAllHRRes, error) { 147 | return nil, status.Errorf(codes.Unimplemented, "method ListHR not implemented") 148 | } 149 | func (UnimplementedAdminServiceServer) GetHRById(context.Context, *GetById) (*Hr, error) { 150 | return nil, status.Errorf(codes.Unimplemented, "method GetHRById not implemented") 151 | } 152 | func (UnimplementedAdminServiceServer) Delete(context.Context, *GetById) (*Void, error) { 153 | return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") 154 | } 155 | func (UnimplementedAdminServiceServer) GetAllUsers(context.Context, *ListUserReq) (*ListUserRes, error) { 156 | return nil, status.Errorf(codes.Unimplemented, "method GetAllUsers not implemented") 157 | } 158 | func (UnimplementedAdminServiceServer) ChangeRole(context.Context, *ChangeRoleReq) (*Void, error) { 159 | return nil, status.Errorf(codes.Unimplemented, "method ChangeRole not implemented") 160 | } 161 | func (UnimplementedAdminServiceServer) GetUserById(context.Context, *GetById) (*UserRes, error) { 162 | return nil, status.Errorf(codes.Unimplemented, "method GetUserById not implemented") 163 | } 164 | func (UnimplementedAdminServiceServer) mustEmbedUnimplementedAdminServiceServer() {} 165 | func (UnimplementedAdminServiceServer) testEmbeddedByValue() {} 166 | 167 | // UnsafeAdminServiceServer may be embedded to opt out of forward compatibility for this service. 168 | // Use of this interface is not recommended, as added methods to AdminServiceServer will 169 | // result in compilation errors. 170 | type UnsafeAdminServiceServer interface { 171 | mustEmbedUnimplementedAdminServiceServer() 172 | } 173 | 174 | func RegisterAdminServiceServer(s grpc.ServiceRegistrar, srv AdminServiceServer) { 175 | // If the following call pancis, it indicates UnimplementedAdminServiceServer was 176 | // embedded by pointer and is nil. This will cause panics if an 177 | // unimplemented method is ever invoked, so we test this at initialization 178 | // time to prevent it from happening at runtime later due to I/O. 179 | if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { 180 | t.testEmbeddedByValue() 181 | } 182 | s.RegisterService(&AdminService_ServiceDesc, srv) 183 | } 184 | 185 | func _AdminService_Approve_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 186 | in := new(CreateHR) 187 | if err := dec(in); err != nil { 188 | return nil, err 189 | } 190 | if interceptor == nil { 191 | return srv.(AdminServiceServer).Approve(ctx, in) 192 | } 193 | info := &grpc.UnaryServerInfo{ 194 | Server: srv, 195 | FullMethod: AdminService_Approve_FullMethodName, 196 | } 197 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 198 | return srv.(AdminServiceServer).Approve(ctx, req.(*CreateHR)) 199 | } 200 | return interceptor(ctx, in, info, handler) 201 | } 202 | 203 | func _AdminService_ListHR_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 204 | in := new(Filter) 205 | if err := dec(in); err != nil { 206 | return nil, err 207 | } 208 | if interceptor == nil { 209 | return srv.(AdminServiceServer).ListHR(ctx, in) 210 | } 211 | info := &grpc.UnaryServerInfo{ 212 | Server: srv, 213 | FullMethod: AdminService_ListHR_FullMethodName, 214 | } 215 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 216 | return srv.(AdminServiceServer).ListHR(ctx, req.(*Filter)) 217 | } 218 | return interceptor(ctx, in, info, handler) 219 | } 220 | 221 | func _AdminService_GetHRById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 222 | in := new(GetById) 223 | if err := dec(in); err != nil { 224 | return nil, err 225 | } 226 | if interceptor == nil { 227 | return srv.(AdminServiceServer).GetHRById(ctx, in) 228 | } 229 | info := &grpc.UnaryServerInfo{ 230 | Server: srv, 231 | FullMethod: AdminService_GetHRById_FullMethodName, 232 | } 233 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 234 | return srv.(AdminServiceServer).GetHRById(ctx, req.(*GetById)) 235 | } 236 | return interceptor(ctx, in, info, handler) 237 | } 238 | 239 | func _AdminService_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 240 | in := new(GetById) 241 | if err := dec(in); err != nil { 242 | return nil, err 243 | } 244 | if interceptor == nil { 245 | return srv.(AdminServiceServer).Delete(ctx, in) 246 | } 247 | info := &grpc.UnaryServerInfo{ 248 | Server: srv, 249 | FullMethod: AdminService_Delete_FullMethodName, 250 | } 251 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 252 | return srv.(AdminServiceServer).Delete(ctx, req.(*GetById)) 253 | } 254 | return interceptor(ctx, in, info, handler) 255 | } 256 | 257 | func _AdminService_GetAllUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 258 | in := new(ListUserReq) 259 | if err := dec(in); err != nil { 260 | return nil, err 261 | } 262 | if interceptor == nil { 263 | return srv.(AdminServiceServer).GetAllUsers(ctx, in) 264 | } 265 | info := &grpc.UnaryServerInfo{ 266 | Server: srv, 267 | FullMethod: AdminService_GetAllUsers_FullMethodName, 268 | } 269 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 270 | return srv.(AdminServiceServer).GetAllUsers(ctx, req.(*ListUserReq)) 271 | } 272 | return interceptor(ctx, in, info, handler) 273 | } 274 | 275 | func _AdminService_ChangeRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 276 | in := new(ChangeRoleReq) 277 | if err := dec(in); err != nil { 278 | return nil, err 279 | } 280 | if interceptor == nil { 281 | return srv.(AdminServiceServer).ChangeRole(ctx, in) 282 | } 283 | info := &grpc.UnaryServerInfo{ 284 | Server: srv, 285 | FullMethod: AdminService_ChangeRole_FullMethodName, 286 | } 287 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 288 | return srv.(AdminServiceServer).ChangeRole(ctx, req.(*ChangeRoleReq)) 289 | } 290 | return interceptor(ctx, in, info, handler) 291 | } 292 | 293 | func _AdminService_GetUserById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 294 | in := new(GetById) 295 | if err := dec(in); err != nil { 296 | return nil, err 297 | } 298 | if interceptor == nil { 299 | return srv.(AdminServiceServer).GetUserById(ctx, in) 300 | } 301 | info := &grpc.UnaryServerInfo{ 302 | Server: srv, 303 | FullMethod: AdminService_GetUserById_FullMethodName, 304 | } 305 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 306 | return srv.(AdminServiceServer).GetUserById(ctx, req.(*GetById)) 307 | } 308 | return interceptor(ctx, in, info, handler) 309 | } 310 | 311 | // AdminService_ServiceDesc is the grpc.ServiceDesc for AdminService service. 312 | // It's only intended for direct use with grpc.RegisterService, 313 | // and not to be introspected or modified (even as a copy) 314 | var AdminService_ServiceDesc = grpc.ServiceDesc{ 315 | ServiceName: "black_list.AdminService", 316 | HandlerType: (*AdminServiceServer)(nil), 317 | Methods: []grpc.MethodDesc{ 318 | { 319 | MethodName: "Approve", 320 | Handler: _AdminService_Approve_Handler, 321 | }, 322 | { 323 | MethodName: "ListHR", 324 | Handler: _AdminService_ListHR_Handler, 325 | }, 326 | { 327 | MethodName: "GetHRById", 328 | Handler: _AdminService_GetHRById_Handler, 329 | }, 330 | { 331 | MethodName: "Delete", 332 | Handler: _AdminService_Delete_Handler, 333 | }, 334 | { 335 | MethodName: "GetAllUsers", 336 | Handler: _AdminService_GetAllUsers_Handler, 337 | }, 338 | { 339 | MethodName: "ChangeRole", 340 | Handler: _AdminService_ChangeRole_Handler, 341 | }, 342 | { 343 | MethodName: "GetUserById", 344 | Handler: _AdminService_GetUserById_Handler, 345 | }, 346 | }, 347 | Streams: []grpc.StreamDesc{}, 348 | Metadata: "admin.proto", 349 | } 350 | -------------------------------------------------------------------------------- /internal/genproto/black_list/black_list_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.5.1 4 | // - protoc v4.23.3 5 | // source: black_list.proto 6 | 7 | package black_list 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.64.0 or later. 19 | const _ = grpc.SupportPackageIsVersion9 20 | 21 | const ( 22 | BlackListService_Add_FullMethodName = "/black_list.BlackListService/Add" 23 | BlackListService_GetAll_FullMethodName = "/black_list.BlackListService/GetAll" 24 | BlackListService_Remove_FullMethodName = "/black_list.BlackListService/Remove" 25 | BlackListService_MonitoringDailyReport_FullMethodName = "/black_list.BlackListService/MonitoringDailyReport" 26 | BlackListService_MonitoringWeeklyReport_FullMethodName = "/black_list.BlackListService/MonitoringWeeklyReport" 27 | BlackListService_MonitoringMonthlyReport_FullMethodName = "/black_list.BlackListService/MonitoringMonthlyReport" 28 | BlackListService_ViewLogs_FullMethodName = "/black_list.BlackListService/ViewLogs" 29 | ) 30 | 31 | // BlackListServiceClient is the client API for BlackListService service. 32 | // 33 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 34 | type BlackListServiceClient interface { 35 | Add(ctx context.Context, in *BlackListCreate, opts ...grpc.CallOption) (*Void, error) 36 | GetAll(ctx context.Context, in *Filter, opts ...grpc.CallOption) (*Reports, error) 37 | Remove(ctx context.Context, in *RemoveReq, opts ...grpc.CallOption) (*Void, error) 38 | MonitoringDailyReport(ctx context.Context, in *Filter, opts ...grpc.CallOption) (*Reports, error) 39 | MonitoringWeeklyReport(ctx context.Context, in *Filter, opts ...grpc.CallOption) (*Reports, error) 40 | MonitoringMonthlyReport(ctx context.Context, in *Filter, opts ...grpc.CallOption) (*Reports, error) 41 | ViewLogs(ctx context.Context, in *Filter, opts ...grpc.CallOption) (*Logs, error) 42 | } 43 | 44 | type blackListServiceClient struct { 45 | cc grpc.ClientConnInterface 46 | } 47 | 48 | func NewBlackListServiceClient(cc grpc.ClientConnInterface) BlackListServiceClient { 49 | return &blackListServiceClient{cc} 50 | } 51 | 52 | func (c *blackListServiceClient) Add(ctx context.Context, in *BlackListCreate, opts ...grpc.CallOption) (*Void, error) { 53 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 54 | out := new(Void) 55 | err := c.cc.Invoke(ctx, BlackListService_Add_FullMethodName, in, out, cOpts...) 56 | if err != nil { 57 | return nil, err 58 | } 59 | return out, nil 60 | } 61 | 62 | func (c *blackListServiceClient) GetAll(ctx context.Context, in *Filter, opts ...grpc.CallOption) (*Reports, error) { 63 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 64 | out := new(Reports) 65 | err := c.cc.Invoke(ctx, BlackListService_GetAll_FullMethodName, in, out, cOpts...) 66 | if err != nil { 67 | return nil, err 68 | } 69 | return out, nil 70 | } 71 | 72 | func (c *blackListServiceClient) Remove(ctx context.Context, in *RemoveReq, opts ...grpc.CallOption) (*Void, error) { 73 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 74 | out := new(Void) 75 | err := c.cc.Invoke(ctx, BlackListService_Remove_FullMethodName, in, out, cOpts...) 76 | if err != nil { 77 | return nil, err 78 | } 79 | return out, nil 80 | } 81 | 82 | func (c *blackListServiceClient) MonitoringDailyReport(ctx context.Context, in *Filter, opts ...grpc.CallOption) (*Reports, error) { 83 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 84 | out := new(Reports) 85 | err := c.cc.Invoke(ctx, BlackListService_MonitoringDailyReport_FullMethodName, in, out, cOpts...) 86 | if err != nil { 87 | return nil, err 88 | } 89 | return out, nil 90 | } 91 | 92 | func (c *blackListServiceClient) MonitoringWeeklyReport(ctx context.Context, in *Filter, opts ...grpc.CallOption) (*Reports, error) { 93 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 94 | out := new(Reports) 95 | err := c.cc.Invoke(ctx, BlackListService_MonitoringWeeklyReport_FullMethodName, in, out, cOpts...) 96 | if err != nil { 97 | return nil, err 98 | } 99 | return out, nil 100 | } 101 | 102 | func (c *blackListServiceClient) MonitoringMonthlyReport(ctx context.Context, in *Filter, opts ...grpc.CallOption) (*Reports, error) { 103 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 104 | out := new(Reports) 105 | err := c.cc.Invoke(ctx, BlackListService_MonitoringMonthlyReport_FullMethodName, in, out, cOpts...) 106 | if err != nil { 107 | return nil, err 108 | } 109 | return out, nil 110 | } 111 | 112 | func (c *blackListServiceClient) ViewLogs(ctx context.Context, in *Filter, opts ...grpc.CallOption) (*Logs, error) { 113 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 114 | out := new(Logs) 115 | err := c.cc.Invoke(ctx, BlackListService_ViewLogs_FullMethodName, in, out, cOpts...) 116 | if err != nil { 117 | return nil, err 118 | } 119 | return out, nil 120 | } 121 | 122 | // BlackListServiceServer is the server API for BlackListService service. 123 | // All implementations must embed UnimplementedBlackListServiceServer 124 | // for forward compatibility. 125 | type BlackListServiceServer interface { 126 | Add(context.Context, *BlackListCreate) (*Void, error) 127 | GetAll(context.Context, *Filter) (*Reports, error) 128 | Remove(context.Context, *RemoveReq) (*Void, error) 129 | MonitoringDailyReport(context.Context, *Filter) (*Reports, error) 130 | MonitoringWeeklyReport(context.Context, *Filter) (*Reports, error) 131 | MonitoringMonthlyReport(context.Context, *Filter) (*Reports, error) 132 | ViewLogs(context.Context, *Filter) (*Logs, error) 133 | mustEmbedUnimplementedBlackListServiceServer() 134 | } 135 | 136 | // UnimplementedBlackListServiceServer must be embedded to have 137 | // forward compatible implementations. 138 | // 139 | // NOTE: this should be embedded by value instead of pointer to avoid a nil 140 | // pointer dereference when methods are called. 141 | type UnimplementedBlackListServiceServer struct{} 142 | 143 | func (UnimplementedBlackListServiceServer) Add(context.Context, *BlackListCreate) (*Void, error) { 144 | return nil, status.Errorf(codes.Unimplemented, "method Add not implemented") 145 | } 146 | func (UnimplementedBlackListServiceServer) GetAll(context.Context, *Filter) (*Reports, error) { 147 | return nil, status.Errorf(codes.Unimplemented, "method GetAll not implemented") 148 | } 149 | func (UnimplementedBlackListServiceServer) Remove(context.Context, *RemoveReq) (*Void, error) { 150 | return nil, status.Errorf(codes.Unimplemented, "method Remove not implemented") 151 | } 152 | func (UnimplementedBlackListServiceServer) MonitoringDailyReport(context.Context, *Filter) (*Reports, error) { 153 | return nil, status.Errorf(codes.Unimplemented, "method MonitoringDailyReport not implemented") 154 | } 155 | func (UnimplementedBlackListServiceServer) MonitoringWeeklyReport(context.Context, *Filter) (*Reports, error) { 156 | return nil, status.Errorf(codes.Unimplemented, "method MonitoringWeeklyReport not implemented") 157 | } 158 | func (UnimplementedBlackListServiceServer) MonitoringMonthlyReport(context.Context, *Filter) (*Reports, error) { 159 | return nil, status.Errorf(codes.Unimplemented, "method MonitoringMonthlyReport not implemented") 160 | } 161 | func (UnimplementedBlackListServiceServer) ViewLogs(context.Context, *Filter) (*Logs, error) { 162 | return nil, status.Errorf(codes.Unimplemented, "method ViewLogs not implemented") 163 | } 164 | func (UnimplementedBlackListServiceServer) mustEmbedUnimplementedBlackListServiceServer() {} 165 | func (UnimplementedBlackListServiceServer) testEmbeddedByValue() {} 166 | 167 | // UnsafeBlackListServiceServer may be embedded to opt out of forward compatibility for this service. 168 | // Use of this interface is not recommended, as added methods to BlackListServiceServer will 169 | // result in compilation errors. 170 | type UnsafeBlackListServiceServer interface { 171 | mustEmbedUnimplementedBlackListServiceServer() 172 | } 173 | 174 | func RegisterBlackListServiceServer(s grpc.ServiceRegistrar, srv BlackListServiceServer) { 175 | // If the following call pancis, it indicates UnimplementedBlackListServiceServer was 176 | // embedded by pointer and is nil. This will cause panics if an 177 | // unimplemented method is ever invoked, so we test this at initialization 178 | // time to prevent it from happening at runtime later due to I/O. 179 | if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { 180 | t.testEmbeddedByValue() 181 | } 182 | s.RegisterService(&BlackListService_ServiceDesc, srv) 183 | } 184 | 185 | func _BlackListService_Add_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 186 | in := new(BlackListCreate) 187 | if err := dec(in); err != nil { 188 | return nil, err 189 | } 190 | if interceptor == nil { 191 | return srv.(BlackListServiceServer).Add(ctx, in) 192 | } 193 | info := &grpc.UnaryServerInfo{ 194 | Server: srv, 195 | FullMethod: BlackListService_Add_FullMethodName, 196 | } 197 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 198 | return srv.(BlackListServiceServer).Add(ctx, req.(*BlackListCreate)) 199 | } 200 | return interceptor(ctx, in, info, handler) 201 | } 202 | 203 | func _BlackListService_GetAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 204 | in := new(Filter) 205 | if err := dec(in); err != nil { 206 | return nil, err 207 | } 208 | if interceptor == nil { 209 | return srv.(BlackListServiceServer).GetAll(ctx, in) 210 | } 211 | info := &grpc.UnaryServerInfo{ 212 | Server: srv, 213 | FullMethod: BlackListService_GetAll_FullMethodName, 214 | } 215 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 216 | return srv.(BlackListServiceServer).GetAll(ctx, req.(*Filter)) 217 | } 218 | return interceptor(ctx, in, info, handler) 219 | } 220 | 221 | func _BlackListService_Remove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 222 | in := new(RemoveReq) 223 | if err := dec(in); err != nil { 224 | return nil, err 225 | } 226 | if interceptor == nil { 227 | return srv.(BlackListServiceServer).Remove(ctx, in) 228 | } 229 | info := &grpc.UnaryServerInfo{ 230 | Server: srv, 231 | FullMethod: BlackListService_Remove_FullMethodName, 232 | } 233 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 234 | return srv.(BlackListServiceServer).Remove(ctx, req.(*RemoveReq)) 235 | } 236 | return interceptor(ctx, in, info, handler) 237 | } 238 | 239 | func _BlackListService_MonitoringDailyReport_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 240 | in := new(Filter) 241 | if err := dec(in); err != nil { 242 | return nil, err 243 | } 244 | if interceptor == nil { 245 | return srv.(BlackListServiceServer).MonitoringDailyReport(ctx, in) 246 | } 247 | info := &grpc.UnaryServerInfo{ 248 | Server: srv, 249 | FullMethod: BlackListService_MonitoringDailyReport_FullMethodName, 250 | } 251 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 252 | return srv.(BlackListServiceServer).MonitoringDailyReport(ctx, req.(*Filter)) 253 | } 254 | return interceptor(ctx, in, info, handler) 255 | } 256 | 257 | func _BlackListService_MonitoringWeeklyReport_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 258 | in := new(Filter) 259 | if err := dec(in); err != nil { 260 | return nil, err 261 | } 262 | if interceptor == nil { 263 | return srv.(BlackListServiceServer).MonitoringWeeklyReport(ctx, in) 264 | } 265 | info := &grpc.UnaryServerInfo{ 266 | Server: srv, 267 | FullMethod: BlackListService_MonitoringWeeklyReport_FullMethodName, 268 | } 269 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 270 | return srv.(BlackListServiceServer).MonitoringWeeklyReport(ctx, req.(*Filter)) 271 | } 272 | return interceptor(ctx, in, info, handler) 273 | } 274 | 275 | func _BlackListService_MonitoringMonthlyReport_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 276 | in := new(Filter) 277 | if err := dec(in); err != nil { 278 | return nil, err 279 | } 280 | if interceptor == nil { 281 | return srv.(BlackListServiceServer).MonitoringMonthlyReport(ctx, in) 282 | } 283 | info := &grpc.UnaryServerInfo{ 284 | Server: srv, 285 | FullMethod: BlackListService_MonitoringMonthlyReport_FullMethodName, 286 | } 287 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 288 | return srv.(BlackListServiceServer).MonitoringMonthlyReport(ctx, req.(*Filter)) 289 | } 290 | return interceptor(ctx, in, info, handler) 291 | } 292 | 293 | func _BlackListService_ViewLogs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 294 | in := new(Filter) 295 | if err := dec(in); err != nil { 296 | return nil, err 297 | } 298 | if interceptor == nil { 299 | return srv.(BlackListServiceServer).ViewLogs(ctx, in) 300 | } 301 | info := &grpc.UnaryServerInfo{ 302 | Server: srv, 303 | FullMethod: BlackListService_ViewLogs_FullMethodName, 304 | } 305 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 306 | return srv.(BlackListServiceServer).ViewLogs(ctx, req.(*Filter)) 307 | } 308 | return interceptor(ctx, in, info, handler) 309 | } 310 | 311 | // BlackListService_ServiceDesc is the grpc.ServiceDesc for BlackListService service. 312 | // It's only intended for direct use with grpc.RegisterService, 313 | // and not to be introspected or modified (even as a copy) 314 | var BlackListService_ServiceDesc = grpc.ServiceDesc{ 315 | ServiceName: "black_list.BlackListService", 316 | HandlerType: (*BlackListServiceServer)(nil), 317 | Methods: []grpc.MethodDesc{ 318 | { 319 | MethodName: "Add", 320 | Handler: _BlackListService_Add_Handler, 321 | }, 322 | { 323 | MethodName: "GetAll", 324 | Handler: _BlackListService_GetAll_Handler, 325 | }, 326 | { 327 | MethodName: "Remove", 328 | Handler: _BlackListService_Remove_Handler, 329 | }, 330 | { 331 | MethodName: "MonitoringDailyReport", 332 | Handler: _BlackListService_MonitoringDailyReport_Handler, 333 | }, 334 | { 335 | MethodName: "MonitoringWeeklyReport", 336 | Handler: _BlackListService_MonitoringWeeklyReport_Handler, 337 | }, 338 | { 339 | MethodName: "MonitoringMonthlyReport", 340 | Handler: _BlackListService_MonitoringMonthlyReport_Handler, 341 | }, 342 | { 343 | MethodName: "ViewLogs", 344 | Handler: _BlackListService_ViewLogs_Handler, 345 | }, 346 | }, 347 | Streams: []grpc.StreamDesc{}, 348 | Metadata: "black_list.proto", 349 | } 350 | -------------------------------------------------------------------------------- /internal/genproto/black_list/common.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.34.2 4 | // protoc v4.23.3 5 | // source: common.proto 6 | 7 | package black_list 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type Void struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | } 28 | 29 | func (x *Void) Reset() { 30 | *x = Void{} 31 | if protoimpl.UnsafeEnabled { 32 | mi := &file_common_proto_msgTypes[0] 33 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 34 | ms.StoreMessageInfo(mi) 35 | } 36 | } 37 | 38 | func (x *Void) String() string { 39 | return protoimpl.X.MessageStringOf(x) 40 | } 41 | 42 | func (*Void) ProtoMessage() {} 43 | 44 | func (x *Void) ProtoReflect() protoreflect.Message { 45 | mi := &file_common_proto_msgTypes[0] 46 | if protoimpl.UnsafeEnabled && x != nil { 47 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 48 | if ms.LoadMessageInfo() == nil { 49 | ms.StoreMessageInfo(mi) 50 | } 51 | return ms 52 | } 53 | return mi.MessageOf(x) 54 | } 55 | 56 | // Deprecated: Use Void.ProtoReflect.Descriptor instead. 57 | func (*Void) Descriptor() ([]byte, []int) { 58 | return file_common_proto_rawDescGZIP(), []int{0} 59 | } 60 | 61 | type GetById struct { 62 | state protoimpl.MessageState 63 | sizeCache protoimpl.SizeCache 64 | unknownFields protoimpl.UnknownFields 65 | 66 | Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` 67 | } 68 | 69 | func (x *GetById) Reset() { 70 | *x = GetById{} 71 | if protoimpl.UnsafeEnabled { 72 | mi := &file_common_proto_msgTypes[1] 73 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 74 | ms.StoreMessageInfo(mi) 75 | } 76 | } 77 | 78 | func (x *GetById) String() string { 79 | return protoimpl.X.MessageStringOf(x) 80 | } 81 | 82 | func (*GetById) ProtoMessage() {} 83 | 84 | func (x *GetById) ProtoReflect() protoreflect.Message { 85 | mi := &file_common_proto_msgTypes[1] 86 | if protoimpl.UnsafeEnabled && x != nil { 87 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 88 | if ms.LoadMessageInfo() == nil { 89 | ms.StoreMessageInfo(mi) 90 | } 91 | return ms 92 | } 93 | return mi.MessageOf(x) 94 | } 95 | 96 | // Deprecated: Use GetById.ProtoReflect.Descriptor instead. 97 | func (*GetById) Descriptor() ([]byte, []int) { 98 | return file_common_proto_rawDescGZIP(), []int{1} 99 | } 100 | 101 | func (x *GetById) GetId() string { 102 | if x != nil { 103 | return x.Id 104 | } 105 | return "" 106 | } 107 | 108 | type Filter struct { 109 | state protoimpl.MessageState 110 | sizeCache protoimpl.SizeCache 111 | unknownFields protoimpl.UnknownFields 112 | 113 | Limit int32 `protobuf:"varint,1,opt,name=limit,proto3" json:"limit,omitempty"` 114 | Offset int32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` 115 | } 116 | 117 | func (x *Filter) Reset() { 118 | *x = Filter{} 119 | if protoimpl.UnsafeEnabled { 120 | mi := &file_common_proto_msgTypes[2] 121 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 122 | ms.StoreMessageInfo(mi) 123 | } 124 | } 125 | 126 | func (x *Filter) String() string { 127 | return protoimpl.X.MessageStringOf(x) 128 | } 129 | 130 | func (*Filter) ProtoMessage() {} 131 | 132 | func (x *Filter) ProtoReflect() protoreflect.Message { 133 | mi := &file_common_proto_msgTypes[2] 134 | if protoimpl.UnsafeEnabled && x != nil { 135 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 136 | if ms.LoadMessageInfo() == nil { 137 | ms.StoreMessageInfo(mi) 138 | } 139 | return ms 140 | } 141 | return mi.MessageOf(x) 142 | } 143 | 144 | // Deprecated: Use Filter.ProtoReflect.Descriptor instead. 145 | func (*Filter) Descriptor() ([]byte, []int) { 146 | return file_common_proto_rawDescGZIP(), []int{2} 147 | } 148 | 149 | func (x *Filter) GetLimit() int32 { 150 | if x != nil { 151 | return x.Limit 152 | } 153 | return 0 154 | } 155 | 156 | func (x *Filter) GetOffset() int32 { 157 | if x != nil { 158 | return x.Offset 159 | } 160 | return 0 161 | } 162 | 163 | var File_common_proto protoreflect.FileDescriptor 164 | 165 | var file_common_proto_rawDesc = []byte{ 166 | 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 167 | 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x06, 0x0a, 0x04, 0x56, 0x6f, 168 | 0x69, 0x64, 0x22, 0x19, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x42, 0x79, 0x49, 0x64, 0x12, 0x0e, 0x0a, 169 | 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x36, 0x0a, 170 | 0x06, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 171 | 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 172 | 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6f, 173 | 0x66, 0x66, 0x73, 0x65, 0x74, 0x42, 0x1e, 0x5a, 0x1c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 174 | 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x62, 0x6c, 0x61, 0x63, 0x6b, 175 | 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 176 | } 177 | 178 | var ( 179 | file_common_proto_rawDescOnce sync.Once 180 | file_common_proto_rawDescData = file_common_proto_rawDesc 181 | ) 182 | 183 | func file_common_proto_rawDescGZIP() []byte { 184 | file_common_proto_rawDescOnce.Do(func() { 185 | file_common_proto_rawDescData = protoimpl.X.CompressGZIP(file_common_proto_rawDescData) 186 | }) 187 | return file_common_proto_rawDescData 188 | } 189 | 190 | var file_common_proto_msgTypes = make([]protoimpl.MessageInfo, 3) 191 | var file_common_proto_goTypes = []any{ 192 | (*Void)(nil), // 0: black_list.Void 193 | (*GetById)(nil), // 1: black_list.GetById 194 | (*Filter)(nil), // 2: black_list.Filter 195 | } 196 | var file_common_proto_depIdxs = []int32{ 197 | 0, // [0:0] is the sub-list for method output_type 198 | 0, // [0:0] is the sub-list for method input_type 199 | 0, // [0:0] is the sub-list for extension type_name 200 | 0, // [0:0] is the sub-list for extension extendee 201 | 0, // [0:0] is the sub-list for field type_name 202 | } 203 | 204 | func init() { file_common_proto_init() } 205 | func file_common_proto_init() { 206 | if File_common_proto != nil { 207 | return 208 | } 209 | if !protoimpl.UnsafeEnabled { 210 | file_common_proto_msgTypes[0].Exporter = func(v any, i int) any { 211 | switch v := v.(*Void); i { 212 | case 0: 213 | return &v.state 214 | case 1: 215 | return &v.sizeCache 216 | case 2: 217 | return &v.unknownFields 218 | default: 219 | return nil 220 | } 221 | } 222 | file_common_proto_msgTypes[1].Exporter = func(v any, i int) any { 223 | switch v := v.(*GetById); i { 224 | case 0: 225 | return &v.state 226 | case 1: 227 | return &v.sizeCache 228 | case 2: 229 | return &v.unknownFields 230 | default: 231 | return nil 232 | } 233 | } 234 | file_common_proto_msgTypes[2].Exporter = func(v any, i int) any { 235 | switch v := v.(*Filter); i { 236 | case 0: 237 | return &v.state 238 | case 1: 239 | return &v.sizeCache 240 | case 2: 241 | return &v.unknownFields 242 | default: 243 | return nil 244 | } 245 | } 246 | } 247 | type x struct{} 248 | out := protoimpl.TypeBuilder{ 249 | File: protoimpl.DescBuilder{ 250 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 251 | RawDescriptor: file_common_proto_rawDesc, 252 | NumEnums: 0, 253 | NumMessages: 3, 254 | NumExtensions: 0, 255 | NumServices: 0, 256 | }, 257 | GoTypes: file_common_proto_goTypes, 258 | DependencyIndexes: file_common_proto_depIdxs, 259 | MessageInfos: file_common_proto_msgTypes, 260 | }.Build() 261 | File_common_proto = out.File 262 | file_common_proto_rawDesc = nil 263 | file_common_proto_goTypes = nil 264 | file_common_proto_depIdxs = nil 265 | } 266 | -------------------------------------------------------------------------------- /internal/genproto/black_list/hr.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.34.2 4 | // protoc v4.23.3 5 | // source: hr.proto 6 | 7 | package black_list 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type Employee struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` 29 | Email string `protobuf:"bytes,2,opt,name=Email,proto3" json:"Email,omitempty"` 30 | FullName string `protobuf:"bytes,3,opt,name=FullName,proto3" json:"FullName,omitempty"` 31 | DateOfBirth string `protobuf:"bytes,4,opt,name=DateOfBirth,proto3" json:"DateOfBirth,omitempty"` 32 | Position string `protobuf:"bytes,5,opt,name=position,proto3" json:"position,omitempty"` 33 | HrId string `protobuf:"bytes,6,opt,name=hr_id,json=hrId,proto3" json:"hr_id,omitempty"` 34 | IsBlocked string `protobuf:"bytes,7,opt,name=is_blocked,json=isBlocked,proto3" json:"is_blocked,omitempty"` 35 | } 36 | 37 | func (x *Employee) Reset() { 38 | *x = Employee{} 39 | if protoimpl.UnsafeEnabled { 40 | mi := &file_hr_proto_msgTypes[0] 41 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 42 | ms.StoreMessageInfo(mi) 43 | } 44 | } 45 | 46 | func (x *Employee) String() string { 47 | return protoimpl.X.MessageStringOf(x) 48 | } 49 | 50 | func (*Employee) ProtoMessage() {} 51 | 52 | func (x *Employee) ProtoReflect() protoreflect.Message { 53 | mi := &file_hr_proto_msgTypes[0] 54 | if protoimpl.UnsafeEnabled && x != nil { 55 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 56 | if ms.LoadMessageInfo() == nil { 57 | ms.StoreMessageInfo(mi) 58 | } 59 | return ms 60 | } 61 | return mi.MessageOf(x) 62 | } 63 | 64 | // Deprecated: Use Employee.ProtoReflect.Descriptor instead. 65 | func (*Employee) Descriptor() ([]byte, []int) { 66 | return file_hr_proto_rawDescGZIP(), []int{0} 67 | } 68 | 69 | func (x *Employee) GetId() string { 70 | if x != nil { 71 | return x.Id 72 | } 73 | return "" 74 | } 75 | 76 | func (x *Employee) GetEmail() string { 77 | if x != nil { 78 | return x.Email 79 | } 80 | return "" 81 | } 82 | 83 | func (x *Employee) GetFullName() string { 84 | if x != nil { 85 | return x.FullName 86 | } 87 | return "" 88 | } 89 | 90 | func (x *Employee) GetDateOfBirth() string { 91 | if x != nil { 92 | return x.DateOfBirth 93 | } 94 | return "" 95 | } 96 | 97 | func (x *Employee) GetPosition() string { 98 | if x != nil { 99 | return x.Position 100 | } 101 | return "" 102 | } 103 | 104 | func (x *Employee) GetHrId() string { 105 | if x != nil { 106 | return x.HrId 107 | } 108 | return "" 109 | } 110 | 111 | func (x *Employee) GetIsBlocked() string { 112 | if x != nil { 113 | return x.IsBlocked 114 | } 115 | return "" 116 | } 117 | 118 | type EmployeeCreate struct { 119 | state protoimpl.MessageState 120 | sizeCache protoimpl.SizeCache 121 | unknownFields protoimpl.UnknownFields 122 | 123 | UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` 124 | Position string `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` 125 | HrId string `protobuf:"bytes,3,opt,name=hr_id,json=hrId,proto3" json:"hr_id,omitempty"` 126 | } 127 | 128 | func (x *EmployeeCreate) Reset() { 129 | *x = EmployeeCreate{} 130 | if protoimpl.UnsafeEnabled { 131 | mi := &file_hr_proto_msgTypes[1] 132 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 133 | ms.StoreMessageInfo(mi) 134 | } 135 | } 136 | 137 | func (x *EmployeeCreate) String() string { 138 | return protoimpl.X.MessageStringOf(x) 139 | } 140 | 141 | func (*EmployeeCreate) ProtoMessage() {} 142 | 143 | func (x *EmployeeCreate) ProtoReflect() protoreflect.Message { 144 | mi := &file_hr_proto_msgTypes[1] 145 | if protoimpl.UnsafeEnabled && x != nil { 146 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 147 | if ms.LoadMessageInfo() == nil { 148 | ms.StoreMessageInfo(mi) 149 | } 150 | return ms 151 | } 152 | return mi.MessageOf(x) 153 | } 154 | 155 | // Deprecated: Use EmployeeCreate.ProtoReflect.Descriptor instead. 156 | func (*EmployeeCreate) Descriptor() ([]byte, []int) { 157 | return file_hr_proto_rawDescGZIP(), []int{1} 158 | } 159 | 160 | func (x *EmployeeCreate) GetUserId() string { 161 | if x != nil { 162 | return x.UserId 163 | } 164 | return "" 165 | } 166 | 167 | func (x *EmployeeCreate) GetPosition() string { 168 | if x != nil { 169 | return x.Position 170 | } 171 | return "" 172 | } 173 | 174 | func (x *EmployeeCreate) GetHrId() string { 175 | if x != nil { 176 | return x.HrId 177 | } 178 | return "" 179 | } 180 | 181 | type EmployeeCreateBody struct { 182 | state protoimpl.MessageState 183 | sizeCache protoimpl.SizeCache 184 | unknownFields protoimpl.UnknownFields 185 | 186 | UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` 187 | Position string `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` 188 | } 189 | 190 | func (x *EmployeeCreateBody) Reset() { 191 | *x = EmployeeCreateBody{} 192 | if protoimpl.UnsafeEnabled { 193 | mi := &file_hr_proto_msgTypes[2] 194 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 195 | ms.StoreMessageInfo(mi) 196 | } 197 | } 198 | 199 | func (x *EmployeeCreateBody) String() string { 200 | return protoimpl.X.MessageStringOf(x) 201 | } 202 | 203 | func (*EmployeeCreateBody) ProtoMessage() {} 204 | 205 | func (x *EmployeeCreateBody) ProtoReflect() protoreflect.Message { 206 | mi := &file_hr_proto_msgTypes[2] 207 | if protoimpl.UnsafeEnabled && x != nil { 208 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 209 | if ms.LoadMessageInfo() == nil { 210 | ms.StoreMessageInfo(mi) 211 | } 212 | return ms 213 | } 214 | return mi.MessageOf(x) 215 | } 216 | 217 | // Deprecated: Use EmployeeCreateBody.ProtoReflect.Descriptor instead. 218 | func (*EmployeeCreateBody) Descriptor() ([]byte, []int) { 219 | return file_hr_proto_rawDescGZIP(), []int{2} 220 | } 221 | 222 | func (x *EmployeeCreateBody) GetUserId() string { 223 | if x != nil { 224 | return x.UserId 225 | } 226 | return "" 227 | } 228 | 229 | func (x *EmployeeCreateBody) GetPosition() string { 230 | if x != nil { 231 | return x.Position 232 | } 233 | return "" 234 | } 235 | 236 | type UpdateReqBody struct { 237 | state protoimpl.MessageState 238 | sizeCache protoimpl.SizeCache 239 | unknownFields protoimpl.UnknownFields 240 | 241 | Position string `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` 242 | HrId string `protobuf:"bytes,2,opt,name=hr_id,json=hrId,proto3" json:"hr_id,omitempty"` 243 | } 244 | 245 | func (x *UpdateReqBody) Reset() { 246 | *x = UpdateReqBody{} 247 | if protoimpl.UnsafeEnabled { 248 | mi := &file_hr_proto_msgTypes[3] 249 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 250 | ms.StoreMessageInfo(mi) 251 | } 252 | } 253 | 254 | func (x *UpdateReqBody) String() string { 255 | return protoimpl.X.MessageStringOf(x) 256 | } 257 | 258 | func (*UpdateReqBody) ProtoMessage() {} 259 | 260 | func (x *UpdateReqBody) ProtoReflect() protoreflect.Message { 261 | mi := &file_hr_proto_msgTypes[3] 262 | if protoimpl.UnsafeEnabled && x != nil { 263 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 264 | if ms.LoadMessageInfo() == nil { 265 | ms.StoreMessageInfo(mi) 266 | } 267 | return ms 268 | } 269 | return mi.MessageOf(x) 270 | } 271 | 272 | // Deprecated: Use UpdateReqBody.ProtoReflect.Descriptor instead. 273 | func (*UpdateReqBody) Descriptor() ([]byte, []int) { 274 | return file_hr_proto_rawDescGZIP(), []int{3} 275 | } 276 | 277 | func (x *UpdateReqBody) GetPosition() string { 278 | if x != nil { 279 | return x.Position 280 | } 281 | return "" 282 | } 283 | 284 | func (x *UpdateReqBody) GetHrId() string { 285 | if x != nil { 286 | return x.HrId 287 | } 288 | return "" 289 | } 290 | 291 | type UpdateReq struct { 292 | state protoimpl.MessageState 293 | sizeCache protoimpl.SizeCache 294 | unknownFields protoimpl.UnknownFields 295 | 296 | Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` 297 | Position string `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` 298 | HrId string `protobuf:"bytes,3,opt,name=hr_id,json=hrId,proto3" json:"hr_id,omitempty"` 299 | } 300 | 301 | func (x *UpdateReq) Reset() { 302 | *x = UpdateReq{} 303 | if protoimpl.UnsafeEnabled { 304 | mi := &file_hr_proto_msgTypes[4] 305 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 306 | ms.StoreMessageInfo(mi) 307 | } 308 | } 309 | 310 | func (x *UpdateReq) String() string { 311 | return protoimpl.X.MessageStringOf(x) 312 | } 313 | 314 | func (*UpdateReq) ProtoMessage() {} 315 | 316 | func (x *UpdateReq) ProtoReflect() protoreflect.Message { 317 | mi := &file_hr_proto_msgTypes[4] 318 | if protoimpl.UnsafeEnabled && x != nil { 319 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 320 | if ms.LoadMessageInfo() == nil { 321 | ms.StoreMessageInfo(mi) 322 | } 323 | return ms 324 | } 325 | return mi.MessageOf(x) 326 | } 327 | 328 | // Deprecated: Use UpdateReq.ProtoReflect.Descriptor instead. 329 | func (*UpdateReq) Descriptor() ([]byte, []int) { 330 | return file_hr_proto_rawDescGZIP(), []int{4} 331 | } 332 | 333 | func (x *UpdateReq) GetId() string { 334 | if x != nil { 335 | return x.Id 336 | } 337 | return "" 338 | } 339 | 340 | func (x *UpdateReq) GetPosition() string { 341 | if x != nil { 342 | return x.Position 343 | } 344 | return "" 345 | } 346 | 347 | func (x *UpdateReq) GetHrId() string { 348 | if x != nil { 349 | return x.HrId 350 | } 351 | return "" 352 | } 353 | 354 | type ListEmployeeReq struct { 355 | state protoimpl.MessageState 356 | sizeCache protoimpl.SizeCache 357 | unknownFields protoimpl.UnknownFields 358 | 359 | Position string `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` 360 | Filter *Filter `protobuf:"bytes,2,opt,name=filter,proto3" json:"filter,omitempty"` 361 | } 362 | 363 | func (x *ListEmployeeReq) Reset() { 364 | *x = ListEmployeeReq{} 365 | if protoimpl.UnsafeEnabled { 366 | mi := &file_hr_proto_msgTypes[5] 367 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 368 | ms.StoreMessageInfo(mi) 369 | } 370 | } 371 | 372 | func (x *ListEmployeeReq) String() string { 373 | return protoimpl.X.MessageStringOf(x) 374 | } 375 | 376 | func (*ListEmployeeReq) ProtoMessage() {} 377 | 378 | func (x *ListEmployeeReq) ProtoReflect() protoreflect.Message { 379 | mi := &file_hr_proto_msgTypes[5] 380 | if protoimpl.UnsafeEnabled && x != nil { 381 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 382 | if ms.LoadMessageInfo() == nil { 383 | ms.StoreMessageInfo(mi) 384 | } 385 | return ms 386 | } 387 | return mi.MessageOf(x) 388 | } 389 | 390 | // Deprecated: Use ListEmployeeReq.ProtoReflect.Descriptor instead. 391 | func (*ListEmployeeReq) Descriptor() ([]byte, []int) { 392 | return file_hr_proto_rawDescGZIP(), []int{5} 393 | } 394 | 395 | func (x *ListEmployeeReq) GetPosition() string { 396 | if x != nil { 397 | return x.Position 398 | } 399 | return "" 400 | } 401 | 402 | func (x *ListEmployeeReq) GetFilter() *Filter { 403 | if x != nil { 404 | return x.Filter 405 | } 406 | return nil 407 | } 408 | 409 | type ListEmployeeRes struct { 410 | state protoimpl.MessageState 411 | sizeCache protoimpl.SizeCache 412 | unknownFields protoimpl.UnknownFields 413 | 414 | Employees []*Employee `protobuf:"bytes,1,rep,name=employees,proto3" json:"employees,omitempty"` 415 | Count int32 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` 416 | } 417 | 418 | func (x *ListEmployeeRes) Reset() { 419 | *x = ListEmployeeRes{} 420 | if protoimpl.UnsafeEnabled { 421 | mi := &file_hr_proto_msgTypes[6] 422 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 423 | ms.StoreMessageInfo(mi) 424 | } 425 | } 426 | 427 | func (x *ListEmployeeRes) String() string { 428 | return protoimpl.X.MessageStringOf(x) 429 | } 430 | 431 | func (*ListEmployeeRes) ProtoMessage() {} 432 | 433 | func (x *ListEmployeeRes) ProtoReflect() protoreflect.Message { 434 | mi := &file_hr_proto_msgTypes[6] 435 | if protoimpl.UnsafeEnabled && x != nil { 436 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 437 | if ms.LoadMessageInfo() == nil { 438 | ms.StoreMessageInfo(mi) 439 | } 440 | return ms 441 | } 442 | return mi.MessageOf(x) 443 | } 444 | 445 | // Deprecated: Use ListEmployeeRes.ProtoReflect.Descriptor instead. 446 | func (*ListEmployeeRes) Descriptor() ([]byte, []int) { 447 | return file_hr_proto_rawDescGZIP(), []int{6} 448 | } 449 | 450 | func (x *ListEmployeeRes) GetEmployees() []*Employee { 451 | if x != nil { 452 | return x.Employees 453 | } 454 | return nil 455 | } 456 | 457 | func (x *ListEmployeeRes) GetCount() int32 { 458 | if x != nil { 459 | return x.Count 460 | } 461 | return 0 462 | } 463 | 464 | var File_hr_proto protoreflect.FileDescriptor 465 | 466 | var file_hr_proto_rawDesc = []byte{ 467 | 0x0a, 0x08, 0x68, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x62, 0x6c, 0x61, 0x63, 468 | 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x1a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 469 | 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbe, 0x01, 0x0a, 0x08, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 470 | 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 471 | 0x64, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 472 | 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x46, 0x75, 0x6c, 0x6c, 0x4e, 473 | 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x46, 0x75, 0x6c, 0x6c, 0x4e, 474 | 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x44, 0x61, 0x74, 0x65, 0x4f, 0x66, 0x42, 0x69, 0x72, 475 | 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x61, 0x74, 0x65, 0x4f, 0x66, 476 | 0x42, 0x69, 0x72, 0x74, 0x68, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 477 | 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 478 | 0x6e, 0x12, 0x13, 0x0a, 0x05, 0x68, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 479 | 0x52, 0x04, 0x68, 0x72, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 480 | 0x63, 0x6b, 0x65, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x73, 0x42, 0x6c, 481 | 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x22, 0x5a, 0x0a, 0x0e, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 482 | 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 483 | 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 484 | 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 485 | 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x13, 0x0a, 0x05, 486 | 0x68, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x72, 0x49, 487 | 0x64, 0x22, 0x49, 0x0a, 0x12, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x43, 0x72, 0x65, 488 | 0x61, 0x74, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 489 | 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 490 | 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 491 | 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x40, 0x0a, 0x0d, 492 | 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x1a, 0x0a, 493 | 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 494 | 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x13, 0x0a, 0x05, 0x68, 0x72, 0x5f, 495 | 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x72, 0x49, 0x64, 0x22, 0x4c, 496 | 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x69, 497 | 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 498 | 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 499 | 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x13, 0x0a, 0x05, 0x68, 0x72, 0x5f, 0x69, 0x64, 500 | 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x72, 0x49, 0x64, 0x22, 0x59, 0x0a, 0x0f, 501 | 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x52, 0x65, 0x71, 0x12, 502 | 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 503 | 0x09, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x06, 0x66, 504 | 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x62, 0x6c, 505 | 0x61, 0x63, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 506 | 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x22, 0x5b, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x45, 507 | 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x52, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x09, 0x65, 0x6d, 508 | 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 509 | 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 510 | 0x79, 0x65, 0x65, 0x52, 0x09, 0x65, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x73, 0x12, 0x14, 511 | 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 512 | 0x6f, 0x75, 0x6e, 0x74, 0x32, 0xa7, 0x02, 0x0a, 0x09, 0x48, 0x52, 0x53, 0x65, 0x72, 0x76, 0x69, 513 | 0x63, 0x65, 0x12, 0x38, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1a, 0x2e, 0x62, 514 | 0x6c, 0x61, 0x63, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 515 | 0x65, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x1a, 0x10, 0x2e, 0x62, 0x6c, 0x61, 0x63, 0x6b, 516 | 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x56, 0x6f, 0x69, 0x64, 0x22, 0x00, 0x12, 0x32, 0x0a, 0x03, 517 | 0x47, 0x65, 0x74, 0x12, 0x13, 0x2e, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 518 | 0x2e, 0x47, 0x65, 0x74, 0x42, 0x79, 0x49, 0x64, 0x1a, 0x14, 0x2e, 0x62, 0x6c, 0x61, 0x63, 0x6b, 519 | 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x22, 0x00, 520 | 0x12, 0x44, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x12, 0x1b, 0x2e, 0x62, 0x6c, 0x61, 521 | 0x63, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6d, 0x70, 0x6c, 522 | 0x6f, 0x79, 0x65, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x5f, 523 | 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 524 | 0x65, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x33, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 525 | 0x12, 0x15, 0x2e, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x55, 0x70, 526 | 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x5f, 527 | 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x56, 0x6f, 0x69, 0x64, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x06, 0x44, 528 | 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x13, 0x2e, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x5f, 0x6c, 0x69, 529 | 0x73, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x79, 0x49, 0x64, 0x1a, 0x10, 0x2e, 0x62, 0x6c, 0x61, 530 | 0x63, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x56, 0x6f, 0x69, 0x64, 0x22, 0x00, 0x42, 0x1e, 531 | 0x5a, 0x1c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x70, 0x72, 532 | 0x6f, 0x74, 0x6f, 0x2f, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x62, 0x06, 533 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 534 | } 535 | 536 | var ( 537 | file_hr_proto_rawDescOnce sync.Once 538 | file_hr_proto_rawDescData = file_hr_proto_rawDesc 539 | ) 540 | 541 | func file_hr_proto_rawDescGZIP() []byte { 542 | file_hr_proto_rawDescOnce.Do(func() { 543 | file_hr_proto_rawDescData = protoimpl.X.CompressGZIP(file_hr_proto_rawDescData) 544 | }) 545 | return file_hr_proto_rawDescData 546 | } 547 | 548 | var file_hr_proto_msgTypes = make([]protoimpl.MessageInfo, 7) 549 | var file_hr_proto_goTypes = []any{ 550 | (*Employee)(nil), // 0: black_list.Employee 551 | (*EmployeeCreate)(nil), // 1: black_list.EmployeeCreate 552 | (*EmployeeCreateBody)(nil), // 2: black_list.EmployeeCreateBody 553 | (*UpdateReqBody)(nil), // 3: black_list.UpdateReqBody 554 | (*UpdateReq)(nil), // 4: black_list.UpdateReq 555 | (*ListEmployeeReq)(nil), // 5: black_list.ListEmployeeReq 556 | (*ListEmployeeRes)(nil), // 6: black_list.ListEmployeeRes 557 | (*Filter)(nil), // 7: black_list.Filter 558 | (*GetById)(nil), // 8: black_list.GetById 559 | (*Void)(nil), // 9: black_list.Void 560 | } 561 | var file_hr_proto_depIdxs = []int32{ 562 | 7, // 0: black_list.ListEmployeeReq.filter:type_name -> black_list.Filter 563 | 0, // 1: black_list.ListEmployeeRes.employees:type_name -> black_list.Employee 564 | 1, // 2: black_list.HRService.Create:input_type -> black_list.EmployeeCreate 565 | 8, // 3: black_list.HRService.Get:input_type -> black_list.GetById 566 | 5, // 4: black_list.HRService.GetAll:input_type -> black_list.ListEmployeeReq 567 | 4, // 5: black_list.HRService.Update:input_type -> black_list.UpdateReq 568 | 8, // 6: black_list.HRService.Delete:input_type -> black_list.GetById 569 | 9, // 7: black_list.HRService.Create:output_type -> black_list.Void 570 | 0, // 8: black_list.HRService.Get:output_type -> black_list.Employee 571 | 6, // 9: black_list.HRService.GetAll:output_type -> black_list.ListEmployeeRes 572 | 9, // 10: black_list.HRService.Update:output_type -> black_list.Void 573 | 9, // 11: black_list.HRService.Delete:output_type -> black_list.Void 574 | 7, // [7:12] is the sub-list for method output_type 575 | 2, // [2:7] is the sub-list for method input_type 576 | 2, // [2:2] is the sub-list for extension type_name 577 | 2, // [2:2] is the sub-list for extension extendee 578 | 0, // [0:2] is the sub-list for field type_name 579 | } 580 | 581 | func init() { file_hr_proto_init() } 582 | func file_hr_proto_init() { 583 | if File_hr_proto != nil { 584 | return 585 | } 586 | file_common_proto_init() 587 | if !protoimpl.UnsafeEnabled { 588 | file_hr_proto_msgTypes[0].Exporter = func(v any, i int) any { 589 | switch v := v.(*Employee); i { 590 | case 0: 591 | return &v.state 592 | case 1: 593 | return &v.sizeCache 594 | case 2: 595 | return &v.unknownFields 596 | default: 597 | return nil 598 | } 599 | } 600 | file_hr_proto_msgTypes[1].Exporter = func(v any, i int) any { 601 | switch v := v.(*EmployeeCreate); i { 602 | case 0: 603 | return &v.state 604 | case 1: 605 | return &v.sizeCache 606 | case 2: 607 | return &v.unknownFields 608 | default: 609 | return nil 610 | } 611 | } 612 | file_hr_proto_msgTypes[2].Exporter = func(v any, i int) any { 613 | switch v := v.(*EmployeeCreateBody); i { 614 | case 0: 615 | return &v.state 616 | case 1: 617 | return &v.sizeCache 618 | case 2: 619 | return &v.unknownFields 620 | default: 621 | return nil 622 | } 623 | } 624 | file_hr_proto_msgTypes[3].Exporter = func(v any, i int) any { 625 | switch v := v.(*UpdateReqBody); i { 626 | case 0: 627 | return &v.state 628 | case 1: 629 | return &v.sizeCache 630 | case 2: 631 | return &v.unknownFields 632 | default: 633 | return nil 634 | } 635 | } 636 | file_hr_proto_msgTypes[4].Exporter = func(v any, i int) any { 637 | switch v := v.(*UpdateReq); i { 638 | case 0: 639 | return &v.state 640 | case 1: 641 | return &v.sizeCache 642 | case 2: 643 | return &v.unknownFields 644 | default: 645 | return nil 646 | } 647 | } 648 | file_hr_proto_msgTypes[5].Exporter = func(v any, i int) any { 649 | switch v := v.(*ListEmployeeReq); i { 650 | case 0: 651 | return &v.state 652 | case 1: 653 | return &v.sizeCache 654 | case 2: 655 | return &v.unknownFields 656 | default: 657 | return nil 658 | } 659 | } 660 | file_hr_proto_msgTypes[6].Exporter = func(v any, i int) any { 661 | switch v := v.(*ListEmployeeRes); i { 662 | case 0: 663 | return &v.state 664 | case 1: 665 | return &v.sizeCache 666 | case 2: 667 | return &v.unknownFields 668 | default: 669 | return nil 670 | } 671 | } 672 | } 673 | type x struct{} 674 | out := protoimpl.TypeBuilder{ 675 | File: protoimpl.DescBuilder{ 676 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 677 | RawDescriptor: file_hr_proto_rawDesc, 678 | NumEnums: 0, 679 | NumMessages: 7, 680 | NumExtensions: 0, 681 | NumServices: 1, 682 | }, 683 | GoTypes: file_hr_proto_goTypes, 684 | DependencyIndexes: file_hr_proto_depIdxs, 685 | MessageInfos: file_hr_proto_msgTypes, 686 | }.Build() 687 | File_hr_proto = out.File 688 | file_hr_proto_rawDesc = nil 689 | file_hr_proto_goTypes = nil 690 | file_hr_proto_depIdxs = nil 691 | } 692 | -------------------------------------------------------------------------------- /internal/genproto/black_list/hr_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.5.1 4 | // - protoc v4.23.3 5 | // source: hr.proto 6 | 7 | package black_list 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.64.0 or later. 19 | const _ = grpc.SupportPackageIsVersion9 20 | 21 | const ( 22 | HRService_Create_FullMethodName = "/black_list.HRService/Create" 23 | HRService_Get_FullMethodName = "/black_list.HRService/Get" 24 | HRService_GetAll_FullMethodName = "/black_list.HRService/GetAll" 25 | HRService_Update_FullMethodName = "/black_list.HRService/Update" 26 | HRService_Delete_FullMethodName = "/black_list.HRService/Delete" 27 | ) 28 | 29 | // HRServiceClient is the client API for HRService service. 30 | // 31 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 32 | type HRServiceClient interface { 33 | Create(ctx context.Context, in *EmployeeCreate, opts ...grpc.CallOption) (*Void, error) 34 | Get(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*Employee, error) 35 | GetAll(ctx context.Context, in *ListEmployeeReq, opts ...grpc.CallOption) (*ListEmployeeRes, error) 36 | Update(ctx context.Context, in *UpdateReq, opts ...grpc.CallOption) (*Void, error) 37 | Delete(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*Void, error) 38 | } 39 | 40 | type hRServiceClient struct { 41 | cc grpc.ClientConnInterface 42 | } 43 | 44 | func NewHRServiceClient(cc grpc.ClientConnInterface) HRServiceClient { 45 | return &hRServiceClient{cc} 46 | } 47 | 48 | func (c *hRServiceClient) Create(ctx context.Context, in *EmployeeCreate, opts ...grpc.CallOption) (*Void, error) { 49 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 50 | out := new(Void) 51 | err := c.cc.Invoke(ctx, HRService_Create_FullMethodName, in, out, cOpts...) 52 | if err != nil { 53 | return nil, err 54 | } 55 | return out, nil 56 | } 57 | 58 | func (c *hRServiceClient) Get(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*Employee, error) { 59 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 60 | out := new(Employee) 61 | err := c.cc.Invoke(ctx, HRService_Get_FullMethodName, in, out, cOpts...) 62 | if err != nil { 63 | return nil, err 64 | } 65 | return out, nil 66 | } 67 | 68 | func (c *hRServiceClient) GetAll(ctx context.Context, in *ListEmployeeReq, opts ...grpc.CallOption) (*ListEmployeeRes, error) { 69 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 70 | out := new(ListEmployeeRes) 71 | err := c.cc.Invoke(ctx, HRService_GetAll_FullMethodName, in, out, cOpts...) 72 | if err != nil { 73 | return nil, err 74 | } 75 | return out, nil 76 | } 77 | 78 | func (c *hRServiceClient) Update(ctx context.Context, in *UpdateReq, opts ...grpc.CallOption) (*Void, error) { 79 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 80 | out := new(Void) 81 | err := c.cc.Invoke(ctx, HRService_Update_FullMethodName, in, out, cOpts...) 82 | if err != nil { 83 | return nil, err 84 | } 85 | return out, nil 86 | } 87 | 88 | func (c *hRServiceClient) Delete(ctx context.Context, in *GetById, opts ...grpc.CallOption) (*Void, error) { 89 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 90 | out := new(Void) 91 | err := c.cc.Invoke(ctx, HRService_Delete_FullMethodName, in, out, cOpts...) 92 | if err != nil { 93 | return nil, err 94 | } 95 | return out, nil 96 | } 97 | 98 | // HRServiceServer is the server API for HRService service. 99 | // All implementations must embed UnimplementedHRServiceServer 100 | // for forward compatibility. 101 | type HRServiceServer interface { 102 | Create(context.Context, *EmployeeCreate) (*Void, error) 103 | Get(context.Context, *GetById) (*Employee, error) 104 | GetAll(context.Context, *ListEmployeeReq) (*ListEmployeeRes, error) 105 | Update(context.Context, *UpdateReq) (*Void, error) 106 | Delete(context.Context, *GetById) (*Void, error) 107 | mustEmbedUnimplementedHRServiceServer() 108 | } 109 | 110 | // UnimplementedHRServiceServer must be embedded to have 111 | // forward compatible implementations. 112 | // 113 | // NOTE: this should be embedded by value instead of pointer to avoid a nil 114 | // pointer dereference when methods are called. 115 | type UnimplementedHRServiceServer struct{} 116 | 117 | func (UnimplementedHRServiceServer) Create(context.Context, *EmployeeCreate) (*Void, error) { 118 | return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") 119 | } 120 | func (UnimplementedHRServiceServer) Get(context.Context, *GetById) (*Employee, error) { 121 | return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") 122 | } 123 | func (UnimplementedHRServiceServer) GetAll(context.Context, *ListEmployeeReq) (*ListEmployeeRes, error) { 124 | return nil, status.Errorf(codes.Unimplemented, "method GetAll not implemented") 125 | } 126 | func (UnimplementedHRServiceServer) Update(context.Context, *UpdateReq) (*Void, error) { 127 | return nil, status.Errorf(codes.Unimplemented, "method Update not implemented") 128 | } 129 | func (UnimplementedHRServiceServer) Delete(context.Context, *GetById) (*Void, error) { 130 | return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") 131 | } 132 | func (UnimplementedHRServiceServer) mustEmbedUnimplementedHRServiceServer() {} 133 | func (UnimplementedHRServiceServer) testEmbeddedByValue() {} 134 | 135 | // UnsafeHRServiceServer may be embedded to opt out of forward compatibility for this service. 136 | // Use of this interface is not recommended, as added methods to HRServiceServer will 137 | // result in compilation errors. 138 | type UnsafeHRServiceServer interface { 139 | mustEmbedUnimplementedHRServiceServer() 140 | } 141 | 142 | func RegisterHRServiceServer(s grpc.ServiceRegistrar, srv HRServiceServer) { 143 | // If the following call pancis, it indicates UnimplementedHRServiceServer was 144 | // embedded by pointer and is nil. This will cause panics if an 145 | // unimplemented method is ever invoked, so we test this at initialization 146 | // time to prevent it from happening at runtime later due to I/O. 147 | if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { 148 | t.testEmbeddedByValue() 149 | } 150 | s.RegisterService(&HRService_ServiceDesc, srv) 151 | } 152 | 153 | func _HRService_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 154 | in := new(EmployeeCreate) 155 | if err := dec(in); err != nil { 156 | return nil, err 157 | } 158 | if interceptor == nil { 159 | return srv.(HRServiceServer).Create(ctx, in) 160 | } 161 | info := &grpc.UnaryServerInfo{ 162 | Server: srv, 163 | FullMethod: HRService_Create_FullMethodName, 164 | } 165 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 166 | return srv.(HRServiceServer).Create(ctx, req.(*EmployeeCreate)) 167 | } 168 | return interceptor(ctx, in, info, handler) 169 | } 170 | 171 | func _HRService_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 172 | in := new(GetById) 173 | if err := dec(in); err != nil { 174 | return nil, err 175 | } 176 | if interceptor == nil { 177 | return srv.(HRServiceServer).Get(ctx, in) 178 | } 179 | info := &grpc.UnaryServerInfo{ 180 | Server: srv, 181 | FullMethod: HRService_Get_FullMethodName, 182 | } 183 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 184 | return srv.(HRServiceServer).Get(ctx, req.(*GetById)) 185 | } 186 | return interceptor(ctx, in, info, handler) 187 | } 188 | 189 | func _HRService_GetAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 190 | in := new(ListEmployeeReq) 191 | if err := dec(in); err != nil { 192 | return nil, err 193 | } 194 | if interceptor == nil { 195 | return srv.(HRServiceServer).GetAll(ctx, in) 196 | } 197 | info := &grpc.UnaryServerInfo{ 198 | Server: srv, 199 | FullMethod: HRService_GetAll_FullMethodName, 200 | } 201 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 202 | return srv.(HRServiceServer).GetAll(ctx, req.(*ListEmployeeReq)) 203 | } 204 | return interceptor(ctx, in, info, handler) 205 | } 206 | 207 | func _HRService_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 208 | in := new(UpdateReq) 209 | if err := dec(in); err != nil { 210 | return nil, err 211 | } 212 | if interceptor == nil { 213 | return srv.(HRServiceServer).Update(ctx, in) 214 | } 215 | info := &grpc.UnaryServerInfo{ 216 | Server: srv, 217 | FullMethod: HRService_Update_FullMethodName, 218 | } 219 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 220 | return srv.(HRServiceServer).Update(ctx, req.(*UpdateReq)) 221 | } 222 | return interceptor(ctx, in, info, handler) 223 | } 224 | 225 | func _HRService_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 226 | in := new(GetById) 227 | if err := dec(in); err != nil { 228 | return nil, err 229 | } 230 | if interceptor == nil { 231 | return srv.(HRServiceServer).Delete(ctx, in) 232 | } 233 | info := &grpc.UnaryServerInfo{ 234 | Server: srv, 235 | FullMethod: HRService_Delete_FullMethodName, 236 | } 237 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 238 | return srv.(HRServiceServer).Delete(ctx, req.(*GetById)) 239 | } 240 | return interceptor(ctx, in, info, handler) 241 | } 242 | 243 | // HRService_ServiceDesc is the grpc.ServiceDesc for HRService service. 244 | // It's only intended for direct use with grpc.RegisterService, 245 | // and not to be introspected or modified (even as a copy) 246 | var HRService_ServiceDesc = grpc.ServiceDesc{ 247 | ServiceName: "black_list.HRService", 248 | HandlerType: (*HRServiceServer)(nil), 249 | Methods: []grpc.MethodDesc{ 250 | { 251 | MethodName: "Create", 252 | Handler: _HRService_Create_Handler, 253 | }, 254 | { 255 | MethodName: "Get", 256 | Handler: _HRService_Get_Handler, 257 | }, 258 | { 259 | MethodName: "GetAll", 260 | Handler: _HRService_GetAll_Handler, 261 | }, 262 | { 263 | MethodName: "Update", 264 | Handler: _HRService_Update_Handler, 265 | }, 266 | { 267 | MethodName: "Delete", 268 | Handler: _HRService_Delete_Handler, 269 | }, 270 | }, 271 | Streams: []grpc.StreamDesc{}, 272 | Metadata: "hr.proto", 273 | } 274 | -------------------------------------------------------------------------------- /internal/media/invoice.txt: -------------------------------------------------------------------------------- 1 | Bahodirova Mubina 2 | Tashkent, Uzbekistan | bahodirovamubina505@gmail.com | +998 97 022 4979 | gitlab | github | 3 | t.me/Mbahodirovaa 4 | 5 | Profile 6 | Enthusiastic Golang developer with a strong focus on building robust and -DEMO- microservices. Experienced in 7 | technologies such as gRPC, Protocol Buffers, PostgreSQL, Docker, Kafka, and Redis. Proficient in creating API 8 | gateways and distributed services, -DEMO- excellent technical skills and problem-solving abilities. Seeking to apply 9 | my knowledge and passion in a backend development -DEMO- to contribute to innovative and impactful projects. 10 | 11 | Projects 12 | Olympy Games | Go, gRPC, Kafka, WebSocket, Casbin, Swagger, MongoDB, Docker 13 | • Developed and deployed a comprehensive system for tracking Olympic Games events with real-time updates. 14 | 15 | • Built an admin panel to efficiently manage scores, statuses, matches, and rounds. 16 | 17 | • Integrated WebSockets and Kafka to ensure real-time data streaming and high-performance interactions. 18 | 19 | 20 | Project Control | Go, gRPC, Kafka, -DEMO-, Swagger, Docker github 21 | • Each project is assigned a Swagger URL to manage and share API documentation, and seamless team integration, 22 | 23 | centralized technical management. 24 | • A platform for team members to store and manage their phone numbers and Telegram usernames for easy and 25 | 26 | quick communication within teams. 27 | • Effective management of individual and team projects, -DEMO- document storage and powerful improve 28 | 29 | communication between team members. 30 | 31 | Black List | Go, gRPC, Kafka, Casbin, Swagger, Docker 32 | • Created a blacklist system for HR departments to monitor and manage employee behavior and performance. 33 | 34 | • Enabled daily, weekly, and monthly monitoring with criteria for blacklisting and removal. 35 | 36 | 37 | 38 | Technical Skills 39 | Languages: Go, SQL 40 | Technologies: RESTful APIs, Microservices, Docker, Kafka, Redis, JWT, MongoDB, PostgreSQL, Swagger, Google 41 | Cloud, CI/CD 42 | Tools: Git, Linux 43 | Soft Skills: Teamwork, Leadership, Communication, Problem Solving 44 | 45 | Education 46 | Najot Ta’lim Tashkent, -DEMO- 47 | Golang Bootcamp March 2024 – September 2024 48 | In-depth study of Golang, including Gin, Gorilla Mux, gRPC, Swagger UI, microservices architecture, RESTful APIs and 49 | PostgreSQL. 50 | Najot Ta’lim Tashkent, Uzbekistan 51 | Bootcamp Foundation September 2023 – March 2024 52 | Foundations of computer science, databases, algorithms, data structures, C programming and Python programming. 53 | 54 | Languages 55 | Uzbek Native 56 | English Pre-Intermediate 57 | Russian A2 58 | -------------------------------------------------------------------------------- /internal/scripts/gen-proto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | CURRENT_DIR=$1 3 | rm -rf ${CURRENT_DIR}/genproto 4 | for x in $(find ${CURRENT_DIR}/black_list_submodule/* -type d); do 5 | protoc -I=${x} -I=${CURRENT_DIR}/black_list_submodule -I /usr/local/go --go_out=${CURRENT_DIR} \ 6 | --go-grpc_out=${CURRENT_DIR} ${x}/*.proto 7 | done 8 | -------------------------------------------------------------------------------- /pkg/app/app.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/go-redis/redis/v8" 7 | "github.com/mirjalilova/api-gateway_blacklist/api" 8 | "github.com/mirjalilova/api-gateway_blacklist/api/handler" 9 | _ "github.com/mirjalilova/api-gateway_blacklist/docs" 10 | "github.com/mirjalilova/api-gateway_blacklist/internal/config" 11 | "github.com/mirjalilova/api-gateway_blacklist/pkg/minio" 12 | "golang.org/x/exp/slog" 13 | "github.com/mirjalilova/api-gateway_blacklist/pkg/genai" 14 | ) 15 | 16 | func Run(cfg *config.Config) { 17 | 18 | // // Kafka 19 | // brokers := []string{"kafka_medtrack:29092"} 20 | // pr, err := prd.NewKafkaProducer(brokers) 21 | // if err != nil { 22 | // slog.Error("Failed to create Kafka producer:", err) 23 | // return 24 | // } 25 | 26 | // Redis 27 | rd := redis.NewClient(&redis.Options{ 28 | Addr: "redis_blacklist:6379", 29 | Password: "", 30 | DB: 0, 31 | }) 32 | if err := rd.Ping(context.Background()).Err(); err != nil { 33 | slog.Error("Failed to connect to Redis", err) 34 | return 35 | } 36 | 37 | minioClient, err := minio.MinIOConnect(cfg) 38 | if err != nil { 39 | slog.Error("Failed to connect to MinIO", err) 40 | return 41 | } 42 | 43 | advice, err := genai.ConnectGenai(cfg) 44 | if err != nil { 45 | slog.Error("Failed to connect to GenAI", err) 46 | return 47 | } 48 | 49 | h := handler.NewHandlerStruct(cfg, rd, minioClient, advice) 50 | 51 | router := api.NewGin(h) 52 | if err := router.Run(cfg.API_GATEWAY); err != nil { 53 | slog.Error("Failed to start API Gateway", err) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /pkg/clients/client.go: -------------------------------------------------------------------------------- 1 | package clients 2 | 3 | import ( 4 | "log/slog" 5 | 6 | "github.com/mirjalilova/api-gateway_blacklist/internal/config" 7 | pb "github.com/mirjalilova/api-gateway_blacklist/internal/genproto/black_list" 8 | "google.golang.org/grpc" 9 | "google.golang.org/grpc/credentials/insecure" 10 | ) 11 | 12 | type Clients struct { 13 | AdminClient pb.AdminServiceClient 14 | HrClient pb.HRServiceClient 15 | BlacklistClient pb.BlackListServiceClient 16 | } 17 | 18 | func NewClients(cnf config.Config) *Clients { 19 | conn, err := grpc.NewClient("black_list"+cnf.BLACKLIST_PORT, grpc.WithTransportCredentials(insecure.NewCredentials())) 20 | if err != nil { 21 | slog.Error("error:", err) 22 | } 23 | 24 | adminC := pb.NewAdminServiceClient(conn) 25 | hrC := pb.NewHRServiceClient(conn) 26 | blacklistC := pb.NewBlackListServiceClient(conn) 27 | 28 | return &Clients{ 29 | AdminClient: adminC, 30 | BlacklistClient: blacklistC, 31 | HrClient: hrC, 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /pkg/genai/connect.go: -------------------------------------------------------------------------------- 1 | package genai 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/google/generative-ai-go/genai" 8 | "github.com/mirjalilova/api-gateway_blacklist/internal/config" 9 | "google.golang.org/api/option" 10 | ) 11 | 12 | func ConnectGenai(cnf *config.Config) (*genai.ChatSession, error) { 13 | apiKey := cnf.API_KEY 14 | if apiKey == "" { 15 | return nil, fmt.Errorf("API_KEY environment variable is not set") 16 | } 17 | 18 | client, err := genai.NewClient(context.Background(), option.WithAPIKey(apiKey)) 19 | if err != nil { 20 | return nil, err 21 | } 22 | 23 | model := client.GenerativeModel("gemini-1.5-flash") 24 | advice := model.StartChat() 25 | 26 | return advice, nil 27 | } -------------------------------------------------------------------------------- /pkg/helper/findname.go: -------------------------------------------------------------------------------- 1 | package helper 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "io/ioutil" 7 | "strings" 8 | 9 | "github.com/google/generative-ai-go/genai" 10 | ) 11 | 12 | func GetTextFromFile(filename string) (string, error) { 13 | data, err := ioutil.ReadFile(filename) 14 | if err != nil { 15 | return "", fmt.Errorf("failed to read file: %v", err) 16 | } 17 | 18 | text := string(data) 19 | // fmt.Println("1........", text) 20 | cleanedText := strings.TrimSpace(text) 21 | // fmt.Println("2........", cleanedText) 22 | 23 | return cleanedText, nil 24 | } 25 | 26 | func GetName(advice *genai.ChatSession, filePath string) (string, error) { 27 | text, err := GetTextFromFile(filePath) 28 | if err != nil { 29 | return "", err 30 | } 31 | 32 | request := fmt.Sprintf(`Based on the content of this document: %s, 33 | provide only the full name 34 | (first and last name) 35 | of the author. 36 | Do not include any additional information.`, 37 | text) 38 | 39 | resp, err := advice.SendMessage(context.Background(), genai.Text(request)) 40 | if err != nil { 41 | return "", err 42 | } 43 | 44 | var output string 45 | for _, candidate := range resp.Candidates { 46 | for _, part := range candidate.Content.Parts { 47 | output += fmt.Sprintf("%v", part) 48 | } 49 | } 50 | 51 | cleanedOutput := strings.TrimSpace(output) 52 | 53 | return cleanedOutput, nil 54 | } -------------------------------------------------------------------------------- /pkg/helper/helper.go: -------------------------------------------------------------------------------- 1 | package helper 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "time" 7 | 8 | "github.com/go-redis/redis/v8" 9 | ) 10 | 11 | var cacheExpiration = 15 * time.Minute // Updated to a more reasonable cache expiration 12 | 13 | // CacheData caches the data in Redis 14 | func CacheData(ctx context.Context, client *redis.Client, key string, data interface{}) error { 15 | jsonData, err := json.Marshal(data) 16 | if err != nil { 17 | return err 18 | } 19 | return client.Set(ctx, key, jsonData, cacheExpiration).Err() 20 | } 21 | 22 | // GetCachedData retrieves the data from Redis 23 | func GetCachedData(ctx context.Context, client *redis.Client, key string, dest interface{}) error { 24 | jsonData, err := client.Get(ctx, key).Bytes() 25 | if err != nil { 26 | return err 27 | } 28 | return json.Unmarshal(jsonData, dest) 29 | } -------------------------------------------------------------------------------- /pkg/helper/pdftotxt.go: -------------------------------------------------------------------------------- 1 | package helper 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | "path/filepath" 8 | 9 | "github.com/pdfcrowd/pdfcrowd-go" 10 | "golang.org/x/exp/slog" 11 | ) 12 | 13 | func readFile(fileName string) ([]byte, error) { 14 | content, err := ioutil.ReadFile(fileName) 15 | if err != nil { 16 | slog.Error("Error reading file: %v", err) 17 | return nil, err 18 | } 19 | return content, nil 20 | } 21 | 22 | func ConvertationToTXT(path string) (string, error) { 23 | client := pdfcrowd.NewPdfToTextClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d") 24 | 25 | outputFilePath := filepath.Join("internal", "media", "invoice.txt") 26 | outputStream, err := os.Create(outputFilePath) 27 | if err != nil { 28 | return "", fmt.Errorf("error creating output file: %v", err) 29 | } 30 | defer outputStream.Close() 31 | 32 | fileContent, err := readFile(path) 33 | if err != nil { 34 | return "", fmt.Errorf("error reading PDF file: %v", err) 35 | } 36 | 37 | err = client.ConvertRawDataToStream(fileContent, outputStream) 38 | if err != nil { 39 | return "", fmt.Errorf("error converting PDF to text: %v", err) 40 | } 41 | 42 | return outputFilePath, nil 43 | } 44 | -------------------------------------------------------------------------------- /pkg/minio/connect.go: -------------------------------------------------------------------------------- 1 | package minio 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/minio/minio-go/v7" 8 | "github.com/minio/minio-go/v7/pkg/credentials" 9 | "github.com/mirjalilova/api-gateway_blacklist/internal/config" 10 | "golang.org/x/exp/slog" 11 | ) 12 | 13 | type MinIO struct { 14 | Client *minio.Client 15 | Cnf *config.Config 16 | } 17 | 18 | var bucketName = "blacklist" 19 | 20 | // Connect to MinIO and create a bucket if it doesn't exist 21 | func MinIOConnect(cnf *config.Config) (*MinIO, error) { 22 | endpoint := "minio:9000" 23 | accessKeyID := "minioadmin" 24 | secretAccessKey := "minioadmin123" 25 | 26 | 27 | minioClient, err := minio.New(endpoint, &minio.Options{ 28 | Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), 29 | Secure: false, 30 | }) 31 | if err != nil { 32 | slog.Error("Failed to connect to MinIO: %v", err) 33 | return nil, err 34 | } 35 | 36 | // Create the bucket if it doesn't exist 37 | err = minioClient.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{}) 38 | if err != nil { 39 | // Check if the bucket already exists 40 | exists, errBucketExists := minioClient.BucketExists(context.Background(), bucketName) 41 | if errBucketExists == nil && exists { 42 | slog.Warn("Bucket already exists: %s\n", bucketName) 43 | } else { 44 | slog.Error("Error while making bucket %s: %v\n", bucketName, err) 45 | } 46 | } else { 47 | slog.Info("Successfully created bucket: %s\n", bucketName) 48 | } 49 | 50 | policy := fmt.Sprintf(`{ 51 | "Version": "2012-10-17", 52 | "Statement": [ 53 | { 54 | "Effect": "Allow", 55 | "Principal": "*", 56 | "Action": ["s3:GetObject"], 57 | "Resource": ["arn:aws:s3:::%s/*"] 58 | } 59 | ] 60 | }`, bucketName) 61 | 62 | err = minioClient.SetBucketPolicy(context.Background(), bucketName, policy) 63 | if err != nil { 64 | slog.Error("Error while setting bucket policy: %v", err) 65 | return nil, err 66 | } 67 | 68 | return &MinIO{ 69 | Client: minioClient, 70 | Cnf: cnf, 71 | }, nil 72 | } 73 | 74 | func (m *MinIO) Upload(fileName, filePath string) (string, error) { 75 | contentType := "application/pdf" 76 | 77 | _, err := m.Client.FPutObject(context.Background(), bucketName, fileName, filePath, minio.PutObjectOptions{ContentType: contentType}) 78 | if err != nil { 79 | slog.Error("Error while uploading %s to bucket %s: %v\n", fileName, bucketName, err) 80 | return "", err 81 | } 82 | 83 | minioURL := fmt.Sprintf("http://localhost:9000/%s/%s", bucketName, fileName) 84 | 85 | return minioURL, nil 86 | } 87 | --------------------------------------------------------------------------------