So yes that could be done in one controller, the best way to view how controllers work is to review how normal auto-generated models functions (or maybe looking at some of our other plugins).
I would suggest reviewing these 3 documents first:
- (Controllers) Backend customization - Strapi Developer Documentation
- (Services) Backend customization - Strapi Developer Documentation
- (Queries) Backend customization - Strapi Developer Documentation
Now functionally speaking your, lets say single controller, would work is your plugin frontend code in the admin makes a request to this controller passing along the request body and your admin JWT (in an authorization header). Given I am making the assumption that this request is happening for the admin, it doesn’t have to.
The logic of your controller would be to accept the incoming body on ctx.request.body and do something with it. Now depending on your use-case I would suggest making the async call to the external resource first and then use the strapi.query('your-collection-type').create({ yourDataHere}) instead of the syntax you provided.
However you could do the strapi.query('your-collection-type').create({ yourDataHere}) first, then do a strapi.query('your-collection-type').update({ id: theIDYouCreated }, {yourUpdatedDataHere }) also but it’s not as efficient since you are making 2 calls to the database instead of one.
In this case you are skipping the services entirely, but you could abstract out those direct queries to services that could be reused elsewhere, but the same is not true for controllers, generally speaking every endpoint/route/handler (these are used interchangeably but they mean the same thing) should always have their own controller.
Controllers (Koa calls them handler functions) are specific to Koa.js itself, they are the logic that koa runs when a route is called. Services are something we added to Strapi to create reusable functions that could be pulled in and used by multiple controllers, and queries are just that the Internal API abstraction layer between the Strapi framework and the Database ORM used to translate them to a database query (SQL or NoSQL syntax).
Hopefully that makes a little more sense.