Skip to content

Commit a378c93

Browse files
committed
modullar bilan ishlash yaxshilandi
1 parent 01509eb commit a378c93

File tree

12 files changed

+72
-44
lines changed

12 files changed

+72
-44
lines changed

examples/controllers/root.bug

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import "jst.facades.controllers";
2+
3+
class RootController(controllers.BaseController){
4+
func health(){
5+
return {"detail": "ok"};
6+
}
7+
}

examples/controllers/user.bug

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import "jst.facades.controllers.generic" as controllers;
2+
3+
class UserController(controllers.GenericAPIViewset){
4+
func query(){
5+
return [
6+
{
7+
"first_name": "Samandar",
8+
"last_name": "Azamov",
9+
"phone": "998888112309",
10+
}
11+
];
12+
}
13+
}

examples/handlers/root.bug

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/handlers/user.bug

Lines changed: 0 additions & 29 deletions
This file was deleted.

examples/index.bug

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
header("Content-Type", "application/json");
2-
import "routes.routes";
2+
import "jst.routes";
33
import "json";
4-
import "handlers.user";
5-
import "handlers.root";
4+
import "controllers.user";
5+
import "controllers.root";
66

77

8-
user = new user.User();
8+
user = new user.UserController();
9+
root = new root.RootController();
910

1011
router = new routes.Routes();
1112
router.get("/", root.health);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
3+
4+
class GenericAPIViewset(){
5+
6+
func query(){
7+
return [];
8+
}
9+
10+
func list(){
11+
return this.query();
12+
}
13+
14+
func detail(){
15+
return this.query()[0];
16+
}
17+
18+
func create(){
19+
query = this.query();
20+
query.append({
21+
"first_name": "User 2",
22+
"last_name": "User 2",
23+
"phone": "998888112309",
24+
});
25+
return query;
26+
}
27+
28+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
class BaseController(){
3+
func query(){
4+
return "salom";
5+
}
6+
}
File renamed without changes.

examples/routes/api.bug

Whitespace-only changes.

internal/runtime/enviroment/enviroment.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ func (e *Enviroment) DeclareVariable(name string, value any, line int) any {
3232
return value
3333
}
3434

35+
func (e *Enviroment) GetModules() *Module {
36+
if e.Modules == nil {
37+
return e.Owner.GetModules()
38+
}
39+
return e.Modules
40+
}
41+
3542
func (e *Enviroment) AssignmenVariable(name string, value any, line int) any {
3643
e.Variables[name] = value
3744
return value

0 commit comments

Comments
 (0)