Inventory Management | Customer Management | Invoice Management Done | Commodity Rate Sync Done

This commit is contained in:
2026-08-20 20:35:41 +05:30
parent ba9a9fd8a4
commit 5f620022f3
101 changed files with 9091 additions and 240 deletions

View File

@@ -0,0 +1,37 @@
import re
import os
files = [
'src/main/java/com/kifi/api/controller/customer/CustomerController.java',
'src/main/java/com/kifi/api/controller/invoice/InvoiceController.java'
]
for file in files:
with open(file, 'r') as f:
content = f.read()
# Add import org.springframework.security.core.Authentication; if not present
if 'import org.springframework.security.core.Authentication;' not in content:
content = content.replace('import org.springframework.web.bind.annotation.*;',
'import org.springframework.security.core.Authentication;\nimport org.springframework.web.bind.annotation.*;')
# Replace @RequestAttribute("userId") Long userId, with Authentication authentication,
content = content.replace('@RequestAttribute("userId") Long userId,', 'Authentication authentication,')
# Replace @RequestAttribute("userId") Long userId with Authentication authentication
content = content.replace('@RequestAttribute("userId") Long userId', 'Authentication authentication')
# Now, find all method declarations that have (..., Authentication authentication, ...) {
# and insert Long userId = Long.valueOf(authentication.getDetails().toString()); right after the {
# We can use regex to find method bodies
pattern = re.compile(r'(public\s+[^\(]+\([^\)]*Authentication authentication[^\)]*\)\s*\{)')
def replacer(match):
return match.group(1) + '\n Long userId = Long.valueOf(authentication.getDetails().toString());'
content = pattern.sub(replacer, content)
with open(file, 'w') as f:
f.write(content)
print("Controllers fixed!")