|
@@ -0,0 +1,48 @@
|
|
|
|
+import {
|
|
|
|
+ Body,
|
|
|
|
+ Controller,
|
|
|
|
+ Del,
|
|
|
|
+ Get,
|
|
|
|
+ Inject,
|
|
|
|
+ Param,
|
|
|
|
+ Post,
|
|
|
|
+} from '@midwayjs/core';
|
|
|
|
+import { OrganizationService } from '../../service/system/organization.service';
|
|
|
|
+import { RF } from '../../response/CustomerResponse';
|
|
|
|
+import { Page, Query } from '../../decorator/page.decorator';
|
|
|
|
+
|
|
|
|
+@Controller('/organization')
|
|
|
|
+export class OrganizationController {
|
|
|
|
+ @Inject()
|
|
|
|
+ service: OrganizationService;
|
|
|
|
+
|
|
|
|
+ @Post('/')
|
|
|
|
+ async create(@Body() body) {
|
|
|
|
+ const data = await this.service.create(body);
|
|
|
|
+ return RF.success(data);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Get('/')
|
|
|
|
+ async query(@Query() query, @Page() page) {
|
|
|
|
+ const result = await this.service.page(query, page);
|
|
|
|
+ return RF.success(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Get('/:id')
|
|
|
|
+ async fetch(@Param('id') _id: string) {
|
|
|
|
+ const result = await this.service.findOne({ _id });
|
|
|
|
+ return RF.success(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Post('/:id')
|
|
|
|
+ async update(@Param('id') _id: string, @Body() body) {
|
|
|
|
+ const result = await this.service.update({ _id }, body);
|
|
|
|
+ return RF.success(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Del('/:id')
|
|
|
|
+ async delete(@Param('id') _id: string) {
|
|
|
|
+ await this.service.delete({ _id });
|
|
|
|
+ return RF.success();
|
|
|
|
+ }
|
|
|
|
+}
|