Start implementation of branches, new form element tabledropdown, model improvements

This commit is contained in:
Torsten Schulz
2024-12-06 23:35:28 +01:00
parent 8c15fb7f2b
commit 1bb2bd49d5
57 changed files with 2176 additions and 170 deletions

View File

@@ -1,13 +1,69 @@
import * as falukantService from '../services/falukantService.js';
import FalukantService from '../services/falukantService.js';
class FalukantController {
constructor() {
this.exampleMethod = this.exampleMethod.bind(this);
this.getUser = this.getUser.bind(this);
this.createUser = this.createUser.bind(this);
this.randomFirstName = this.randomFirstName.bind(this);
this.randomLastName = this.randomLastName.bind(this);
this.getInfo = this.getInfo.bind(this);
}
async exampleMethod(req, res) {
async getUser(req, res) {
try {
const result = await falukantService.exampleMethod();
const { userid: hashedUserId } = req.headers;
const result = await FalukantService.getUser(hashedUserId);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
}
async createUser(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const { gender, firstname: firstName, lastname: lastName } = req.body;
console.log(req.body);
const result = await FalukantService.createUser(hashedUserId, gender, firstName, lastName);
res.status(201).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
}
async randomFirstName(req, res) {
try {
const { gender } = req.params;
const result = await FalukantService.randomFirstName(gender);
res.status(200).json({ name: result });
} catch (error) {
res.status(500).json({ error: error.message });
}
}
async randomLastName(req, res) {
try {
const result = await FalukantService.randomLastName();
res.status(200).json({ name: result });
} catch (error) {
res.status(500).json({ error: error.message });
}
}
async getInfo(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const result = await FalukantService.getInfo(hashedUserId);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
}
async getBranches(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const result = await FalukantService.getBranches(hashedUserId);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });