package com.kxs.user.biz.controller.kxsapp;

import com.kxs.common.core.util.R;
import com.kxs.common.security.annotation.Inner;
import com.kxs.user.api.model.KxsUserAdvance;
import com.kxs.user.biz.service.KxsUserAdvanceService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.service.annotation.DeleteExchange;

/**
 * 用户预扣款控制器
 *
 * @author 没秃顶的码农
 * @date 2024-01-08
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("userAdvance")
public class UserAdvanceController {

    private final KxsUserAdvanceService kxsUserAdvanceService;


    /**
     * 预扣款信息
     *
     * @param advanceId 预扣款ID
     * @return KxsAdvance
     */
    @Inner
    @PostMapping("/loadByAdvanceId")
    public R loadByAdvanceId(@RequestParam("advanceId") Integer advanceId) {

        return R.ok(kxsUserAdvanceService.getById(advanceId));
    }

    /**
     * 删除预扣款信息
     *
     * @param advanceId 预扣款ID
     * @return Boolean
     */
    @Inner
    @DeleteMapping("/removeById")
    public R removeById(@RequestBody Integer advanceId) {

        return R.ok(kxsUserAdvanceService.removeById(advanceId));
    }

    /**
     * 退回预扣款
     *
     * @param id 预扣款ID
     * @return Boolean
     */
    @Inner
    @GetMapping("/returnAdvance")
    public R returnAdvance(@RequestParam("id") Integer id) {

        return kxsUserAdvanceService.returnAdvance(id);
    }




}
