feat: Add company linking to personal contacts
- Add companyId column to personal_contacts table - Update personal-contact service to include companyName in list - Add getContactsByCompanyId function for company contacts endpoint - Add GET /companies/:companyId/contacts endpoint - Add companyId to contact validation schema 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import express from 'express';
|
||||
import * as companyController from '../controllers/company.controller.js';
|
||||
import * as personalContactController from '../controllers/personal-contact.controller.js';
|
||||
import { authenticate } from '../middlewares/auth/authMiddleware.js';
|
||||
import { requireAdmin } from '../middlewares/auth/roleMiddleware.js';
|
||||
import { checkCompanyAccess } from '../middlewares/auth/resourceAccessMiddleware.js';
|
||||
@@ -188,4 +189,12 @@ router.delete(
|
||||
companyController.removeUserFromCompany
|
||||
);
|
||||
|
||||
// Company Contacts (Personal contacts linked to company)
|
||||
router.get(
|
||||
'/:companyId/contacts',
|
||||
validateParams(z.object({ companyId: z.string().uuid() })),
|
||||
checkCompanyAccess,
|
||||
personalContactController.getContactsByCompany
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -12,6 +12,7 @@ const createContactSchema = z.object({
|
||||
phone: z.string().min(3, 'Telefón je povinný'),
|
||||
email: z.string().email('Neplatný email'),
|
||||
secondaryEmail: z.union([z.string().email('Neplatný email'), z.literal('')]).optional(),
|
||||
companyId: z.union([z.string().uuid(), z.literal(''), z.null()]).optional(),
|
||||
})
|
||||
|
||||
const updateContactSchema = createContactSchema.partial()
|
||||
|
||||
Reference in New Issue
Block a user