From af7782a9a386696387dd009541200442e08a2b17 Mon Sep 17 00:00:00 2001 From: snowgitea Date: Wed, 1 Jul 2026 17:57:34 +0800 Subject: [PATCH] chore: src/modules/user/controller/app/address.ts --- src/modules/user/controller/app/address.ts | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/modules/user/controller/app/address.ts diff --git a/src/modules/user/controller/app/address.ts b/src/modules/user/controller/app/address.ts new file mode 100644 index 0000000..ae3eba5 --- /dev/null +++ b/src/modules/user/controller/app/address.ts @@ -0,0 +1,39 @@ +import { Get, Inject, Provide } from '@midwayjs/core'; +import { CoolController, BaseController } from '@cool-midway/core'; +import { UserAddressEntity } from '../../entity/address'; +import { UserAddressService } from '../../service/address'; + +/** + * 地址 + */ +@Provide() +@CoolController({ + api: ['add', 'delete', 'update', 'info', 'list', 'page'], + entity: UserAddressEntity, + service: UserAddressService, + insertParam: ctx => { + return { + userId: ctx.user.id, + }; + }, + pageQueryOp: { + where: async ctx => { + return [['userId =:userId', { userId: ctx.user.id }]]; + }, + addOrderBy: { + isDefault: 'DESC', + }, + }, +}) +export class AppUserAddressController extends BaseController { + @Inject() + userAddressService: UserAddressService; + + @Inject() + ctx; + + @Get('/default', { summary: '默认地址' }) + async default() { + return this.ok(await this.userAddressService.default(this.ctx.user.id)); + } +}