Some fixes and additions
This commit is contained in:
@@ -48,6 +48,16 @@ class FalukantController {
|
||||
this.advanceNobility = this.advanceNobility.bind(this);
|
||||
this.getHealth = this.getHealth.bind(this);
|
||||
this.healthActivity = this.healthActivity.bind(this);
|
||||
this.getPoliticsOverview = this.getPoliticsOverview.bind(this);
|
||||
this.getOpenPolitics = this.getOpenPolitics.bind(this);
|
||||
this.getElections = this.getElections.bind(this);
|
||||
this.vote = this.vote.bind(this);
|
||||
this.getOpenPolitics = this.getOpenPolitics.bind(this);
|
||||
this.applyForElections = this.applyForElections.bind(this);
|
||||
this.getRegions = this.getRegions.bind(this);
|
||||
this.renovate = this.renovate.bind(this);
|
||||
this.renovateAll = this.renovateAll.bind(this);
|
||||
this.createBranch = this.createBranch.bind(this);
|
||||
}
|
||||
|
||||
async getUser(req, res) {
|
||||
@@ -117,6 +127,29 @@ class FalukantController {
|
||||
}
|
||||
}
|
||||
|
||||
async createBranch(req, res) {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
const { cityId, branchTypeId } = req.body;
|
||||
const result = await FalukantService.createBranch(hashedUserId, cityId, branchTypeId);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async getBranchTypes(req, res) {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
const result = await FalukantService.getBranchTypes(hashedUserId);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async getBranch(req, res) {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
@@ -325,6 +358,7 @@ class FalukantController {
|
||||
const result = await FalukantService.convertProposalToDirector(hashedUserId, proposalId);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
console.log(error.message, error.stack);
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
}
|
||||
@@ -482,7 +516,6 @@ class FalukantController {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
const result = await FalukantService.getUserHouse(hashedUserId);
|
||||
console.log(result);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
@@ -671,6 +704,108 @@ class FalukantController {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async getPoliticsOverview(req, res) {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
const result = await FalukantService.getPoliticsOverview(hashedUserId);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async getOpenPolitics(req, res) {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
const result = await FalukantService.getOpenPolitics(hashedUserId);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async getElections(req, res) {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
const result = await FalukantService.getElections(hashedUserId);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async vote(req, res) {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
const { votes } = req.body;
|
||||
const result = await FalukantService.vote(hashedUserId, votes);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async getOpenPolitics(req, res) {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
const result = await FalukantService.getOpenPolitics(hashedUserId);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async applyForElections(req, res) {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
const { electionIds } = req.body;
|
||||
const result = await FalukantService.applyForElections(hashedUserId, electionIds);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async getRegions(req, res) {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
const result = await FalukantService.getRegions(hashedUserId);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async renovate(req, res) {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
const { element } = req.body;
|
||||
const result = await FalukantService.renovate(hashedUserId, element);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async renovateAll(req, res) {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
const result = await FalukantService.renovateAll(hashedUserId);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default FalukantController;
|
||||
|
||||
Reference in New Issue
Block a user