(req dto.AgentAccountUpdateReq)
| 1045 | } |
| 1046 | |
| 1047 | func (a AgentService) UpdateAccount(req dto.AgentAccountUpdateReq) error { |
| 1048 | account, err := agentAccountRepo.GetFirst(repo.WithByID(req.ID)) |
| 1049 | if err != nil { |
| 1050 | return err |
| 1051 | } |
| 1052 | provider := account.Provider |
| 1053 | resolvedInput, err := resolveAgentAccountInput(provider, req.APIKey, req.BaseURL) |
| 1054 | if err != nil { |
| 1055 | return err |
| 1056 | } |
| 1057 | account.Name = req.Name |
| 1058 | account.APIKey = resolvedInput.APIKey |
| 1059 | account.RememberAPIKey = req.RememberAPIKey |
| 1060 | account.BaseURL = resolvedInput.BaseURL |
| 1061 | account.APIType = req.APIType |
| 1062 | account.Remark = req.Remark |
| 1063 | account.Verified = true |
| 1064 | |
| 1065 | if err := global.DB.Save(account).Error; err != nil { |
| 1066 | return err |
| 1067 | } |
| 1068 | terminalai.InvalidateTerminalRuntimeCache() |
| 1069 | terminalai.InvalidateFileAIRuntimeCache() |
| 1070 | if req.SyncAgents { |
| 1071 | if err := a.syncAgentsByAccount(account); err != nil { |
| 1072 | return err |
| 1073 | } |
| 1074 | } |
| 1075 | return nil |
| 1076 | } |
| 1077 | |
| 1078 | func (a AgentService) PageAccounts(req dto.AgentAccountSearch) (int64, []dto.AgentAccountInfo, error) { |
| 1079 | var opts []repo.DBOption |
nothing calls this directly
no test coverage detected