package com.talentcard.server.business.merchant; import java.util.Map; import com.talentcard.server.business.PageResult; import com.talentcard.server.business.merchant.auth.MerchantAuthService; import com.talentcard.server.business.merchant.auth.MerchantPrincipal; import com.talentcard.server.common.ApiResponse; import com.talentcard.server.request.MerchantParkingPlateRegistrationRequest; import com.talentcard.server.request.ParkingPlateStatusUpdateRequest; import com.talentcard.server.service.ParkingPlateMerchantService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestAttribute; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @Tag(name = "商户端-停车车牌登记", description = "商户端查询、录入和处理停车车牌登记记录") @RestController @RequestMapping("/api/merchant/parking-plate-registrations") public class MerchantParkingPlateRegistrationController { private final ParkingPlateMerchantService service; public MerchantParkingPlateRegistrationController(ParkingPlateMerchantService service) { this.service = service; } @Operation(summary = "查询车牌登记列表", description = "商户端分页查询当前停车商家的车牌登记记录") @GetMapping public ApiResponse>> page( @RequestAttribute(MerchantAuthService.PRINCIPAL_ATTRIBUTE) MerchantPrincipal principal, @Parameter(description = "停车场ID") @RequestParam(required = false) Long parkingLotId, @Parameter(description = "持卡人姓名、手机号、卡号、车牌号、登记单号或停车场关键词") @RequestParam(required = false) String keyword, @Parameter(description = "人才卡等级") @RequestParam(required = false) String cardLevel, @Parameter(description = "处理状态") @RequestParam(required = false) String status, @Parameter(description = "提交类型:新增/修改") @RequestParam(required = false) String submissionType, @Parameter(description = "提交开始日期,格式yyyy-MM-dd") @RequestParam(required = false) String submittedStart, @Parameter(description = "提交结束日期,格式yyyy-MM-dd") @RequestParam(required = false) String submittedEnd, @Parameter(description = "页码") @RequestParam(defaultValue = "1") int page, @Parameter(description = "每页条数") @RequestParam(defaultValue = "10") int size ) { return ApiResponse.success(service.page(principal, parkingLotId, keyword, cardLevel, status, submissionType, submittedStart, submittedEnd, page, size)); } @Operation(summary = "查询车牌登记详情", description = "查看持卡人信息、停车场信息和处理状态") @GetMapping("/{id}") public ApiResponse> detail( @RequestAttribute(MerchantAuthService.PRINCIPAL_ATTRIBUTE) MerchantPrincipal principal, @Parameter(description = "车牌登记ID") @PathVariable Long id ) { return ApiResponse.success(service.detail(principal, id)); } @Operation(summary = "商户录入车牌", description = "商户端直接录入车牌到当前停车商家,校验人才卡停车权益后写入车牌登记表并置为已处理") @PostMapping public ApiResponse> create( @RequestAttribute(MerchantAuthService.PRINCIPAL_ATTRIBUTE) MerchantPrincipal principal, @Valid @RequestBody MerchantParkingPlateRegistrationRequest request, @RequestHeader(value = "X-Idempotency-Key", required = false) String idempotencyKey ) { return ApiResponse.success(service.create(principal, request, idempotencyKey)); } @Operation(summary = "处理车牌登记", description = "商户端维护车牌登记处理状态和处理备注") @PatchMapping("/{id}/status") public ApiResponse> updateStatus( @RequestAttribute(MerchantAuthService.PRINCIPAL_ATTRIBUTE) MerchantPrincipal principal, @Parameter(description = "车牌登记ID") @PathVariable Long id, @Valid @RequestBody ParkingPlateStatusUpdateRequest request ) { return ApiResponse.success(service.updateStatus(principal, id, request)); } }