Skip to content

homework #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

homework #2

wants to merge 9 commits into from

Conversation

DxWang36
Copy link

@DxWang36 DxWang36 commented Nov 8, 2023

No description provided.

Copy link

@JCLTW JCLTW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一些反馈

}

[HttpGet]
public async Task<ActionResult<List<ParkingLot>>> GetAllAsync(int? pageIndex, int? pageSize = 15)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pageSize 暂时没有需要更新的需求,可以定义为常量,不暴露给客户,允许其修改

}
public async Task<ParkingLot> CreateAsync( ParkingLotDto parkingLotDto)
{
if (parkingLotDto.Capacity < 10) throw new InvaildCapacityException();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

定义常量

{
var skip = (pageIndex - 1) * pageSize;
var query = _parkingLotCollection.Find(a => true);
var parkinglots = await query.Skip(skip).Limit(pageSize).ToListAsync();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好,没有在内存中分页

}

[HttpPut("{id}")]
public async Task<ActionResult> UpdateAsync(string id, [FromBody] ParkingLotDto parkingLotDto)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably you could define a new DTO with capacity only since we only modify capacity.


internal async Task<ParkingLot> UpdateAsync(string id, ParkingLotDto parkingLotDto)
{
return await _parkingLotRepository.Update(id, parkingLotDto.ToModel());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably could check capacity is less than 10

@dianjing104
Copy link

dianjing104 commented Nov 9, 2023

Well:

  • Baby step commit.
  • meaningful commit message.
  • no long method.
  • does not split page size in memory
  • Check duplicate parking lot names.
  • Handle all exceptions in service layer.

Less well:

  • In update parkinglot does not check when updated capacity is less 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants