RiderWithdrawController.java 1.67 KB
package com.diligrp.rider.controller;

import com.diligrp.rider.common.result.Result;
import com.diligrp.rider.dto.RiderWithdrawApplyDTO;
import com.diligrp.rider.service.RiderWithdrawService;
import com.diligrp.rider.vo.PageResultVO;
import com.diligrp.rider.vo.RiderWithdrawApplyVO;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/rider/withdraw")
@RequiredArgsConstructor
public class RiderWithdrawController {

    private final RiderWithdrawService withdrawService;

    @PostMapping("/apply")
    public Result<Void> apply(@Valid @RequestBody RiderWithdrawApplyDTO dto, HttpServletRequest request) {
        Long riderId = (Long) request.getAttribute("riderId");
        withdrawService.apply(riderId, dto);
        return Result.success();
    }

    @GetMapping("/list")
    public Result<PageResultVO<RiderWithdrawApplyVO>> list(@RequestParam(required = false) Integer status,
                                                           @RequestParam(defaultValue = "1") int page,
                                                           HttpServletRequest request) {
        Long riderId = (Long) request.getAttribute("riderId");
        return Result.success(withdrawService.riderList(riderId, status, page));
    }
}