Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
BookingMyHrManagement
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chanachai
BookingMyHrManagement
Commits
271ccc2c
Commit
271ccc2c
authored
Mar 18, 2025
by
Ooh-Ao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
borrow
parent
4d1f4a91
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
38 additions
and
18 deletions
+38
-18
borrow_transaction.cpython-312.pyc
...src/models/__pycache__/borrow_transaction.cpython-312.pyc
+0
-0
member.cpython-312.pyc
API-Fast/src/models/__pycache__/member.cpython-312.pyc
+0
-0
borrow_transaction.py
API-Fast/src/models/borrow_transaction.py
+8
-10
member.py
API-Fast/src/models/member.py
+3
-0
borrow_schema.cpython-312.pyc
...ast/src/schemas/__pycache__/borrow_schema.cpython-312.pyc
+0
-0
borrow_schema.py
API-Fast/src/schemas/borrow_schema.py
+11
-0
admin-project-equirement.component.html
...roject-equirement/admin-project-equirement.component.html
+5
-5
borrow-transactions.ts
Web-Manage/src/app/DPU/models/borrow-transactions.ts
+11
-3
No files found.
API-Fast/src/models/__pycache__/borrow_transaction.cpython-312.pyc
View file @
271ccc2c
No preview for this file type
API-Fast/src/models/__pycache__/member.cpython-312.pyc
View file @
271ccc2c
No preview for this file type
API-Fast/src/models/borrow_transaction.py
View file @
271ccc2c
...
...
@@ -6,13 +6,6 @@ from uuid import uuid4
from
sqlalchemy.orm
import
relationship
from
..config.database
import
Base
import
uuid
from
datetime
import
datetime
from
sqlalchemy
import
Column
,
Integer
,
String
,
DateTime
,
ForeignKey
from
sqlalchemy.dialects.postgresql
import
UUID
from
..config.database
import
Base
from
sqlalchemy.orm
import
relationship
class
BorrowTransaction
(
Base
):
__tablename__
=
"borrow_transactions"
...
...
@@ -24,9 +17,15 @@ class BorrowTransaction(Base):
returned_date
=
Column
(
DateTime
,
nullable
=
True
)
created_at
=
Column
(
DateTime
,
nullable
=
False
,
server_default
=
func
.
now
())
#
ฟิลด์สำหรับการอนุมัติ
#
Approval fields
approved_by
=
Column
(
UUID
(
as_uuid
=
True
),
ForeignKey
(
"member.memberId"
),
nullable
=
True
)
approved_at
=
Column
(
DateTime
,
nullable
=
True
)
rejected_reason
=
Column
(
String
,
nullable
=
True
)
project_equipment
=
relationship
(
"ProjectEquipment"
,
back_populates
=
"borrow_transactions"
)
\ No newline at end of file
# Relationships
# Relationship สำหรับผู้เบิก
member
=
relationship
(
"Member"
,
foreign_keys
=
[
memberId
],
back_populates
=
"borrow_transactions"
,
lazy
=
"joined"
)
# Relationship สำหรับ ProjectEquipment
project_equipment
=
relationship
(
"ProjectEquipment"
,
back_populates
=
"borrow_transactions"
,
lazy
=
"joined"
)
# Relationship สำหรับผู้อนุมัติ
approved_by_member
=
relationship
(
"Member"
,
foreign_keys
=
[
approved_by
],
back_populates
=
"borrow_transactions"
,
lazy
=
"joined"
)
API-Fast/src/models/member.py
View file @
271ccc2c
...
...
@@ -35,6 +35,9 @@ class Member(Base):
# ProjectEmployees = relationship("ProjectEmployee", back_populates="member")
project_member
=
relationship
(
"ProjectMember"
,
back_populates
=
"member"
)
borrow_transactions
=
relationship
(
"BorrowTransaction"
,
foreign_keys
=
"[BorrowTransaction.memberId]"
,
back_populates
=
"member"
)
# Relationship สำหรับ BorrowTransaction ที่ผู้อนุมัติ
approved_borrow_transactions
=
relationship
(
"BorrowTransaction"
,
foreign_keys
=
"[BorrowTransaction.approved_by]"
,
back_populates
=
"approved_by_member"
)
# ฟังก์ชันเพื่อแฮชรหัสผ่านก่อนบันทึก
def
hash_password
(
self
,
password
):
self
.
passwordHash
=
bcrypt
.
hash
(
password
)
...
...
API-Fast/src/schemas/__pycache__/borrow_schema.cpython-312.pyc
View file @
271ccc2c
No preview for this file type
API-Fast/src/schemas/borrow_schema.py
View file @
271ccc2c
# myproject/schemas/borrow_schema.py
from
pydantic
import
BaseModel
from
uuid
import
UUID
from
typing
import
Optional
from
datetime
import
datetime
from
.member_schema
import
MemberResponse
# Schema สำหรับ Member
from
.project_equipment_schema
import
ProjectEquipmentResponse
# Schema สำหรับ ProjectEquipment
class
BorrowTransactionBase
(
BaseModel
):
peId
:
Optional
[
UUID
]
=
None
quantity_borrowed
:
int
...
...
@@ -20,6 +24,12 @@ class BorrowTransactionResponse(BorrowTransactionBase):
created_at
:
datetime
peId
:
UUID
memberId
:
UUID
# แสดงข้อมูลของสมาชิกที่เบิกอุปกรณ์ (จาก memberId)
member
:
Optional
[
MemberResponse
]
=
None
# แสดงข้อมูลของ project_equipment ที่ผูกกับ peId ซึ่งจะมีข้อมูลอุปกรณ์ (ผ่าน relationship ใน ORM)
project_equipment
:
Optional
[
ProjectEquipmentResponse
]
=
None
# แสดงข้อมูลของสมาชิกที่อนุมัติ (จาก approved_by)
approved_by_member
:
Optional
[
MemberResponse
]
=
None
class
Config
:
orm_mode
=
True
\ No newline at end of file
Web-Manage/src/app/DPU/company-management/admin-project-equirement/admin-project-equirement.component.html
View file @
271ccc2c
...
...
@@ -289,12 +289,12 @@
<td>
<div
class=
"flex items-center"
>
<div
class=
"me-2"
>
<
!-- <
span class="avatar avatar-md avatar-rounded">
<img src={{product.img
}} alt="">
</span> --
>
<span
class=
"avatar avatar-md avatar-rounded"
>
<img
src=
{{product.member.getPicture()
}}
alt=
""
>
</span
>
</div>
<div
class=
"font-semibold"
>
{{product.member
Id
}}
{{product.member
.getFullname()
}}
</div>
</div>
</td>
...
...
@@ -302,7 +302,7 @@
<td>
{{product.created_at}}
</td>
<td>
{{product.returned_date}}
</td>
<td>
{{product.status}}
</td>
<td>
{{product.approved_by}}
</td>
<td>
{{product.approved_by
_member.getFullname()
}}
</td>
<!-- <td>
<span class="badge bg-light text-default"> {{product.category}}</span>
</td>
...
...
Web-Manage/src/app/DPU/models/borrow-transactions.ts
View file @
271ccc2c
import
{
TranslateService
}
from
"@ngx-translate/core"
;
import
{
BaseModel
}
from
"./base.model"
;
import
{
UserProfileModel
}
from
"./user.model"
;
import
{
EquipmentModel
}
from
"./equipments.model"
;
export
class
BorrowTransactionsModel
extends
BaseModel
{
peId
:
string
;
quantity_borrowed
:
number
;
status
:
string
;
returned_date
:
string
;
borrowId
:
string
;
created_at
:
string
;
peId
:
string
;
memberId
:
string
;
approved_by
:
string
;
borrowId
:
string
;
created_at
:
string
;
member
:
UserProfileModel
;
project_equipment
:
EquipmentModel
;
approved_by_member
:
UserProfileModel
;
constructor
(
data
?:
Partial
<
BorrowTransactionsModel
>
,
translateService
?:
TranslateService
)
{
super
(
data
,
translateService
);
...
...
@@ -20,5 +25,8 @@ export class BorrowTransactionsModel extends BaseModel {
this
.
returned_date
=
data
?.
returned_date
??
''
this
.
memberId
=
data
?.
memberId
??
''
this
.
approved_by
=
data
?.
approved_by
??
''
this
.
member
=
data
?.
member
?
new
UserProfileModel
(
data
.
member
)
:
new
UserProfileModel
();
this
.
approved_by_member
=
data
?.
approved_by_member
?
new
UserProfileModel
(
data
.
approved_by_member
)
:
new
UserProfileModel
();
this
.
project_equipment
=
data
?.
project_equipment
?
new
EquipmentModel
(
data
.
project_equipment
)
:
new
EquipmentModel
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment