package com.younike.member;

import com.younike.common.annotation.Log;
import com.younike.common.core.controller.BaseController;
import com.younike.common.core.domain.AjaxResult;
import com.younike.common.core.page.TableDataInfo;
import com.younike.common.enums.BusinessType;
import com.younike.common.utils.poi.ExcelUtil;
import com.younike.system.domain.OrderVerificationRecord;
import com.younike.system.service.IOrderVerificationRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 团购订单核销记录Controller
 * 
 * @author dail
 * @date 2022-03-14
 */
@Api("团购订单核销记录接口")
@RestController
@RequestMapping("/member/verificationRecord")
public class MemberOrderVerificationRecordController extends BaseController {
    @Autowired
    private IOrderVerificationRecordService orderVerificationRecordService;

    /**
     * 查询团购订单核销记录列表
     */
    @ApiOperation("查询团购订单核销记录列表")
    @PreAuthorize("@ss.hasPermi('system:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderVerificationRecord orderVerificationRecord) {
        startPage();
        List<OrderVerificationRecord> list = orderVerificationRecordService.selectOrderVerificationRecordList(orderVerificationRecord);
        return getDataTable(list);
    }

    /**
     * 导出团购订单核销记录列表
     */
    @ApiOperation("导出团购订单核销记录列表")
    @PreAuthorize("@ss.hasPermi('system:record:export')")
    @Log(title = "团购订单核销记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OrderVerificationRecord orderVerificationRecord) {
        List<OrderVerificationRecord> list = orderVerificationRecordService.selectOrderVerificationRecordList(orderVerificationRecord);
        ExcelUtil<OrderVerificationRecord> util = new ExcelUtil<OrderVerificationRecord>(OrderVerificationRecord.class);
        return util.exportExcel(list, "团购订单核销记录数据");
    }

    /**
     * 获取团购订单核销记录详细信息
     */
    @ApiOperation("获取团购订单核销记录详细信息")
    @PreAuthorize("@ss.hasPermi('system:record:query')")
    @GetMapping(value = "/{orderVerificationRecordId}")
    public AjaxResult getInfo(@PathVariable("orderVerificationRecordId") Long orderVerificationRecordId) {
        return AjaxResult.success(orderVerificationRecordService.selectOrderVerificationRecordByOrderVerificationRecordId(orderVerificationRecordId));
    }

    /**
     * 新增团购订单核销记录
     */
    @ApiOperation("新增团购订单核销记录")
    @PreAuthorize("@ss.hasPermi('system:record:add')")
    @Log(title = "团购订单核销记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderVerificationRecord orderVerificationRecord) {
        return toAjax(orderVerificationRecordService.insertOrderVerificationRecord(orderVerificationRecord));
    }

    /**
     * 修改团购订单核销记录
     */
    @ApiOperation("修改团购订单核销记录")
    @PreAuthorize("@ss.hasPermi('system:record:edit')")
    @Log(title = "团购订单核销记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderVerificationRecord orderVerificationRecord) {
        return toAjax(orderVerificationRecordService.updateOrderVerificationRecord(orderVerificationRecord));
    }

    /**
     * 删除团购订单核销记录
     */
    @ApiOperation("删除团购订单核销记录")
    @PreAuthorize("@ss.hasPermi('system:record:remove')")
    @Log(title = "团购订单核销记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderVerificationRecordIds}")
    public AjaxResult remove(@PathVariable Long[] orderVerificationRecordIds) {
        return toAjax(orderVerificationRecordService.deleteOrderVerificationRecordByOrderVerificationRecordIds(orderVerificationRecordIds));
    }
}
