From c3821df233523ab715fdf06d54c142394411c968 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Tue, 9 Jul 2024 11:31:08 +0530 Subject: added logo/signature upload routes --- user/service.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'user/service.go') diff --git a/user/service.go b/user/service.go index 4544cb4..222df4a 100644 --- a/user/service.go +++ b/user/service.go @@ -1,5 +1,5 @@ /* openbills - Server for web based Libre Billing Software - * Copyright (C) 2023 Vidhu Kant Sharma + * Copyright (C) 2023-2024 Vidhu Kant Sharma * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -75,3 +75,22 @@ func (u *User) del() error { return nil } + +func (u *User) update(changes map[string]interface{}) error { + res := db.Model(&u). + Omit("email"). + Omit("password"). + Omit("username"). + Updates(changes) + + // TODO: handle potential errors + if res.Error != nil { + return res.Error + } + + if res.RowsAffected == 0 { + return e.ErrNotFound + } + + return nil +} -- cgit v1.2.3