implemented

- assigning new customer numbers to contacts that don`t have one
- updating customer number counter in company table

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-10-31 22:09:59 +01:00
parent dc0b381aba
commit 4468f45064
14 changed files with 157 additions and 20 deletions

View File

@@ -10,7 +10,7 @@ public interface ContactDb {
Map<Long,Contact> listContactsOf(long userId) throws UmbrellaException;
Contact load(long id, long userId);
Contact load(long contactId, long userId);
Contact save(Contact contact);

View File

@@ -114,6 +114,11 @@ public class ContactModule extends BaseHandler implements ContactService {
return sendContent(ex,mapValues(listContactsOf(user)));
}
@Override
public Contact load(long userId, long contactId) {
return contactDb.load(contactId,userId);
}
@Override
public Map<Long,Contact> listContactsOf(UmbrellaUser user) throws UmbrellaException {
return contactDb.listContactsOf(user.id());
@@ -130,4 +135,9 @@ public class ContactModule extends BaseHandler implements ContactService {
contactDb.setOwner(user.id(),contact);
return sendContent(ex,contact);
}
@Override
public Contact save(Contact contact) {
return contactDb.save(contact);
}
}

View File

@@ -87,14 +87,14 @@ public class SqliteDb extends BaseDb implements ContactDb{
}
@Override
public Contact load(long id, long userId) {
public Contact load(long contactId, long userId) {
try {
var rs = select(ALL).from(TABLE_CONTACTS).leftJoin(ID,TABLE_CONTACTS_USERS,CONTACT_ID).where(USER_ID,equal(userId)).where(ID,equal(id)).exec(db);
var rs = select(ALL).from(TABLE_CONTACTS).leftJoin(ID,TABLE_CONTACTS_USERS,CONTACT_ID).where(USER_ID,equal(userId)).where(ID,equal(contactId)).exec(db);
Contact contact = null;
if (rs.next()) contact = Contact.of(rs);
rs.close();
if (contact != null) return contact;
throw notFound("Failed to load contact with id = {0}",id);
throw notFound("Failed to load contact with id = {0}", contactId);
} catch (SQLException e) {
throw databaseException("Failed to load contacts of user {0}",userId);
}