package cn.iocoder.yudao.module.shop.controller;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.core.controller.BaseController;
import cn.iocoder.yudao.module.shop.entity.PartnerDetail;
import cn.iocoder.yudao.module.shop.service.IPartnerDetailService;
import cn.iocoder.yudao.util.ExcelUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2023-08-13
 */
@RestController
@RequestMapping("/admin-api/partner/detail")
public class PartnerDetailController extends BaseController
{
    @Autowired
    private IPartnerDetailService partnerDetailService;

    /**
     * 查询【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('system:detail:list')")
    @GetMapping("/list")
    public CommonResult list(PartnerDetail partnerDetail,
                              @RequestParam(value = "pageNum",required = false ,defaultValue = "1") Integer pageNum,
                              @RequestParam(value = "pageSize",required = false ,defaultValue = "10") Integer pageSize)
    {
        Page<PartnerDetail> page = new Page<>(pageNum, pageSize);
        IPage<PartnerDetail> list = partnerDetailService.selectPartnerDetailList(page,partnerDetail);
        return success(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:detail:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, PartnerDetail partnerDetail,
                       @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum,
                       @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize)
    {
        Page<PartnerDetail> page = new Page<>(pageNum, pageSize);
        IPage<PartnerDetail> list = partnerDetailService.selectPartnerDetailList(page,partnerDetail);
        ExcelUtil<PartnerDetail> util = new ExcelUtil<PartnerDetail>(PartnerDetail.class);

        util.exportExcel(response, list.getRecords(), "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:detail:query')")
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(partnerDetailService.selectPartnerDetailById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PostMapping("/add")
    public CommonResult add(@RequestBody PartnerDetail partnerDetail)
    {
        return toAjax(partnerDetailService.insertPartnerDetail(partnerDetail));
    }

    /**
     * 修改【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:detail:edit')")
    @PutMapping
    public CommonResult edit(@RequestBody PartnerDetail partnerDetail)
    {
        return toAjax(partnerDetailService.updatePartnerDetail(partnerDetail));
    }

    /**
     * 修改【审核接口】
     */
//    @PreAuthorize("@ss.hasPermi('system:detail:edit')")
    @PostMapping("/examine")
    public CommonResult examine(@RequestBody PartnerDetail partnerDetail) throws Exception {
        partnerDetailService.examine(partnerDetail);
        return success();
    }

    /**
     * 删除【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:detail:remove')")
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(partnerDetailService.deletePartnerDetailByIds(ids));
    }
}
