Alt-Org / Altzone-Server

REST API
3 stars 1 forks source link

Change/implement item logic 108 #130

Closed apulkGIT closed 1 month ago

apulkGIT commented 1 month ago

Put back BasicService and deleted the unneeded imports.

apulkGIT commented 1 month ago

Hi!

I did all the below changes. However when I pulled the request I accidently put it on main while it should been on dev. I cancelled and tried again, now I do not know did it do it again or not. Inform me if I should put again it.

@MIKHAILDERIABIN requested changes on this pull request.

There are another few changes need to be done:

  • recycling.enum.ts:

  • Move the recycling.enum.ts file to the item folder, for example to /item/enum

  • rename the recycling name to Recycling (not file, the code):

1 export enum recycling {

1 export enum Recycling {

*

createItem.dto.ts:

  • Add a decorator for validating that the recycling field is the Recycling enum. Check the @IsEnum() decorator from the class-decorator lib docs here [1]

item.dto.ts:

*

remove commented out the isInStock field:

36 @.***() 37 //isInStock: boolean;

*

updateItem.dto.ts:

*

remove commented out the isInStock field:

37 @.() 38 @.() 39 //isInStock: boolean;

*

item.controller.ts:

*

remove create, update, delete methods:

27 public @.() body: CreateItemDto) { ... 51 public @.() body: UpdateItemDto){ ... 58 public @.***() param: _idDto) {

*

Remove the comments:

34 @.() ... 39 @.() @.({action: Action.read, subject: ItemDto}) @.(ModelName.ITEM) @.(ItemDto) @.(ItemDto) @.(ItemDto) @.(ModelName.ITEM) //public @.***() query: IGetAllQuery) { // return this.service.readAll(query); //}

*

item.schema.ts:

*

Remove inline comments:

30 @.***({ type: Boolean, required: true, default: false }) //isInStock: boolean;

*

the room_id field should be a reference to the Room not to the Stock:

39 @Prop({ type: MongooseSchema.Types.ObjectId, ref: ModelName.STOCK }) room_id: Room;

to

39 @Prop({ type: MongooseSchema.Types.ObjectId, ref: ModelName.ROOM }) room_id: Room;

*

Add the reference to the Room collection as it is for the Stock collection on lines 44-50:

44 ItemSchema.set('collection', ModelName.ITEM); ItemSchema.virtual(ModelName.STOCK, { ref: ModelName.STOCK, localField: 'stock_id', foreignField: '_id', justOne: true });

*

item.service.ts:

*

remove all inline comments for unused code, such as on line 18:

18 @.***()

and etc. As well as comments from the clarifying inline comments left from characterClass folder such as on line 55. *

fix JSDocs for all methods such as:

49 * Creates a new CharacterClass in DB.

to

49 * Creates a new Item in DB.

*

remove the inline comments from lines 77-89:

77 /**

  • Reads all CharacterClasses based on the provided options.
  • @param options - Options for reading CharacterClasses.
  • @returns An array of CharacterClasses if succeeded or an array of ServiceErrors if error occurred. */ //async readAll(options?: TIServiceReadManyOptions) { // let optionsToApply = options; // if(options?.includeRefs) // optionsToApply.includeRefs = options.includeRefs.filter((ref) => this.refsInModel.includes(ref));

    // return this.basicService.readMany(optionsToApply); //}

-- Reply to this email directly, view it on GitHub [2], or unsubscribe [3]. You are receiving this because you authored the thread.Message ID: @.***>

Links:

[1] https://github.com/typestack/class-validator?tab=readme-ov-file#validation-decorators [2] https://github.com/Alt-Org/Altzone-Server/pull/130#pullrequestreview-2240202859 [3] https://github.com/notifications/unsubscribe-auth/BBBIXEX44GH4N6SCFNGVQVLZRSG7VAVCNFSM6AAAAABMRWXWNCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDENBQGIYDEOBVHE