package com.loan.system.controller.admin;

import com.loan.system.domain.dto.BizRecommenderDTO;
import com.loan.system.domain.pojo.Result;
import com.loan.system.service.RecommenderService;
import com.loan.system.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/recommender")
@Api(tags = "推荐人管理")
public class RecommenderController {
    @Autowired
    private RecommenderService recommenderService;

    @GetMapping
    @ApiOperation("查询推荐人")
    public Result getRecommenders(Integer pageNum, Integer pageSize){
        return ResultUtil.success("success",recommenderService.getRecommenders(pageNum, pageSize));
    }

    @PostMapping
    @ApiOperation("添加推荐人")
    public Result addRecommender(@RequestBody BizRecommenderDTO bizRecommenderDTO){
        recommenderService.addRecommender(bizRecommenderDTO);

        return ResultUtil.success("success");
    }

    @PutMapping("/{id}")
    @ApiOperation("修改推荐人")
    public Result updateRecommender(@PathVariable("id")Long id, @RequestBody BizRecommenderDTO bizRecommenderDTO){
        recommenderService.updateRecommenderById(bizRecommenderDTO,id);

        return ResultUtil.success("success");
    }


}
