package com.mosty.base.manager.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mosty.base.model.dto.jcgl.TbJcglKfdDto;
import com.mosty.base.model.dto.qwzx.AppSearchQuery;
import com.mosty.base.model.entity.jcgl.TbJcglKfd;
import com.mosty.base.model.query.jcgl.TbJcglKfdQuery;
import com.mosty.base.manager.service.TbJcglKfdService;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.entity.log.BusinessType;
import com.mosty.common.base.entity.log.Log;
import com.mosty.common.token.JwtSysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author dw
 * @since 2022/8/4
 **/
@RestController
@AllArgsConstructor
@RequestMapping("/tpJcglKfd")
@Api(tags = "快返点")
public class TbJcglKfdController {

    private final TbJcglKfdService tbJcglKfdService;

    @GetMapping({"/selectKfdList"})
    @JwtSysUser
    @ApiOperation(value = "查询快返点列表")
    public ResponseResult<IPage<TbJcglKfdDto>> selectKfdList(TbJcglKfdQuery dto) {
        return ResponseResult.success(tbJcglKfdService.selectKfdList(dto));
    }

    @PostMapping("/addKfd")
    @JwtSysUser
    @Log(title = "新增快返点", businessType = BusinessType.INSERT)
    @ApiOperation("新增快返点")
    public ResponseResult<Integer> addKfd(@RequestBody TbJcglKfdDto dto) {
        return ResponseResult.success(tbJcglKfdService.addKfd(dto));
    }


    @PostMapping({"/updateKfd"})
    @JwtSysUser
    @Log(title = "修改快返点列表", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改快返点列表")
    public ResponseResult<Integer> updateKfd(@RequestBody TbJcglKfdDto dto) {
        return ResponseResult.success(tbJcglKfdService.updateKfd(dto));
    }

    @GetMapping({"/selectByid"})
    @JwtSysUser
    @ApiOperation(value = "查询快返点详情")
    public ResponseResult<TbJcglKfdDto> selectByid(String id) {
        return ResponseResult.success(tbJcglKfdService.selectByid(id));
    }

    @PostMapping({"/deleteKfd"})
    @JwtSysUser
    @Log(title = "删除返点详情", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除返点")
    public ResponseResult<Void> deleteKfd(@RequestBody List<String> id) {
        tbJcglKfdService.deleteKfd(id);
        return ResponseResult.success();
    }

    @GetMapping("getKfdList")
    @JwtSysUser
    @ApiOperation(value = "app获取快反点列表")
    public ResponseResult<Page<TbJcglKfd>> getKfdList(AppSearchQuery dto) {
        return ResponseResult.success(tbJcglKfdService.getKfdList(dto));
    }

    @PostMapping("getListAll")
    @JwtSysUser
    @ApiOperation(value = "获取所有快反点")
    public ResponseResult<List<TbJcglKfdDto>> getListAll() {
        return ResponseResult.success(tbJcglKfdService.getListAll());
    }
}
