api in groups + agents types & sprites

This commit is contained in:
STEINNI
2025-10-12 19:45:57 +00:00
parent 2e85b18ed4
commit 5e01d35820
5 changed files with 218 additions and 153 deletions
+41
View File
@@ -0,0 +1,41 @@
import { authGuard } from '../authGuard.js'
export const mappings = [
{ method: 'get', url:'/agent-types', handler: 'getAgentTypes', middlewares: [authGuard]},
{ method: 'get', url:'/agent-sprites/:group', handler: 'getAgentSprites', middlewares: [authGuard]},
]
export const methods = {
async getAgentTypes(req, res) {
let results
if(req.params.family){
results = await this.db.execute(`
SELECT *
FROM p42SIM.agent_types
WHERE atp_fam_name = ?
`, [req.params.family])
} else {
results = await this.db.execute(`SELECT * FROM p42SIM.agent_types`, [])
}
this.ok(req, res, {
agentTypes : results
})
},
async getAgentSprites(req, res) {
const results = await this.db.execute(`
SELECT *
FROM p42SIM.agent_types
LEFT JOIN p42GUI.agents_sprites on asp_atp_id = atp_id
WHERE asp_group = ?`, [req.params.group])
const fullObj = {}
for(const row of results){
fullObj[row.atp_name] = row.asp_3d
}
this.ok(req, res, {
agentSprites: fullObj
})
},
}