# Template untuk mengupdate Service Interface dan Implementation

## 1. Service Interface Update

**Before:**
```go
type ModuleService interface {
    All(clientId *uuid.UUID, authToken string, req request.ModuleQueryRequest) (data []*response.ModuleResponse, paging paginator.Pagination, err error)
    Show(clientId *uuid.UUID, id uint) (data *response.ModuleResponse, err error)
    Save(clientId *uuid.UUID, req request.ModuleCreateRequest, authToken string) (data *entity.Module, err error)
    Update(clientId *uuid.UUID, id uint, req request.ModuleUpdateRequest) (err error)
    Delete(clientId *uuid.UUID, id uint) error
}
```

**After:**
```go
type ModuleService interface {
    All(authToken string, req request.ModuleQueryRequest) (data []*response.ModuleResponse, paging paginator.Pagination, err error)
    Show(authToken string, id uint) (data *response.ModuleResponse, err error)
    Save(authToken string, req request.ModuleCreateRequest) (data *entity.Module, err error)
    Update(authToken string, id uint, req request.ModuleUpdateRequest) (err error)
    Delete(authToken string, id uint) error
}
```

## 2. Service Implementation Update

**Before:**
```go
func (_i *moduleService) All(clientId *uuid.UUID, authToken string, req request.ModuleQueryRequest) (data []*response.ModuleResponse, paging paginator.Pagination, err error) {
    // Extract userLevelId from authToken
    var userLevelId *uint
    if authToken != "" {
        user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken)
        if user != nil {
            userLevelId = &user.UserLevelId
        }
    }

    results, paging, err := _i.Repo.GetAll(clientId, userLevelId, req)
    // ... rest of implementation
}
```

**After:**
```go
func (_i *moduleService) All(authToken string, req request.ModuleQueryRequest) (data []*response.ModuleResponse, paging paginator.Pagination, err error) {
    // Extract clientId and userLevelId from authToken
    var clientId *uuid.UUID
    var userLevelId *uint
    
    if authToken != "" {
        user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken)
        if user != nil {
            clientId = user.ClientId
            userLevelId = &user.UserLevelId
            _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
        }
    }

    results, paging, err := _i.Repo.GetAll(clientId, userLevelId, req)
    // ... rest of implementation
}
```

## 3. Controller Update

**Before:**
```go
func (_i *moduleController) All(c *fiber.Ctx) error {
    // ... pagination setup ...
    
    // Get ClientId from context
    clientId := middleware.GetClientID(c)
    
    // Get Authorization token from header
    authToken := c.Get("Authorization")
    
    data, paging, err := _i.moduleService.All(clientId, authToken, req)
    // ... rest of implementation
}
```

**After:**
```go
func (_i *moduleController) All(c *fiber.Ctx) error {
    // ... pagination setup ...
    
    // Get Authorization token from header
    authToken := c.Get("Authorization")
    _i.Log.Info().Str("authToken", authToken).Msg("")
    
    data, paging, err := _i.moduleService.All(authToken, req)
    // ... rest of implementation
}
```

## 4. Swagger Documentation Update

**Before:**
```go
// @Param        X-Client-Key header string true "Insert the X-Client-Key"
// @Param        Authorization header string false "Insert your access token" default(Bearer <Add access token here>)
```

**After:**
```go
// @Param        Authorization header string false "Insert your access token" default(Bearer <Add access token here>)
```

## 5. Import Cleanup

Remove unused middleware import:
```go
// Remove this line if no longer needed:
"netidhub-saas-be/app/middleware"
```

## 6. Key Changes Summary

1. **Remove X-Client-Key header** from all Swagger documentation
2. **Remove GetClientID() calls** from controllers
3. **Update service interfaces** to use authToken instead of clientId parameter
4. **Update service implementations** to extract clientId from authToken using GetUserInfo()
5. **Remove middleware import** if no longer needed
6. **Update all method calls** to match new signatures

## 7. Benefits

- **Simpler API**: No need for X-Client-Key header
- **Auth-based**: clientId comes from authenticated user
- **Consistent**: Same pattern across all modules
- **Secure**: Tied to user authentication
- **Maintainable**: Less parameters to manage
