chore: src/modules/user/controller/app/address.ts

This commit is contained in:
2026-07-01 17:57:34 +08:00
parent af609de690
commit af7782a9a3
@@ -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));
}
}