package com.yiqi.admin.controller.order;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.yiqi.common.constant.UrlConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yiqi.common.annotation.Log;
import com.yiqi.common.core.controller.BaseController;
import com.yiqi.common.core.domain.AjaxResult;
import com.yiqi.common.enums.BusinessType;
import com.yiqi.order.domain.OrderClothRefund;
import com.yiqi.order.service.IOrderClothRefundService;
import com.yiqi.common.utils.poi.ExcelUtil;
import com.yiqi.common.core.page.TableDataInfo;

/**
 * 洗衣退款订单Controller
 *
 * @author douya
 * @date 2024-08-13
 */
@Api(tags = "管理后台 - 洗衣退款订单")
@RestController
@RequestMapping(UrlConstants.managerApi + "/order/clothRefund")
public class OrderClothRefundController extends BaseController {
    @Autowired
    private IOrderClothRefundService orderClothRefundService;


    //<editor-folder desc="基础函数">

    /**
     * 查询洗衣退款订单列表
     */
    @PreAuthorize("@ss.hasPermi('order:clothRefund:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询洗衣退款订单列表")
    public TableDataInfo list(OrderClothRefund orderClothRefund) {
        startPage();
        List<OrderClothRefund> list = orderClothRefundService.selectOrderClothRefundList(orderClothRefund);
        return getDataTable(list);
    }

    /**
     * 导出洗衣退款订单列表
     */
    @PreAuthorize("@ss.hasPermi('order:clothRefund:export')")
    @Log(title = "洗衣退款订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出洗衣退款订单列表")
    public void export(HttpServletResponse response, OrderClothRefund orderClothRefund) {
        List<OrderClothRefund> list = orderClothRefundService.selectOrderClothRefundList(orderClothRefund);
        ExcelUtil<OrderClothRefund> util = new ExcelUtil<OrderClothRefund>(OrderClothRefund.class);
        util.exportExcel(response, list, "洗衣退款订单数据");
    }

    /**
     * 获取洗衣退款订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:clothRefund:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取洗衣退款订单详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(orderClothRefundService.selectOrderClothRefundById(id));
    }

    /**
     * 新增洗衣退款订单
     */
    @PreAuthorize("@ss.hasPermi('order:clothRefund:add')")
    @Log(title = "洗衣退款订单", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增洗衣退款订单")
    public AjaxResult add(@RequestBody OrderClothRefund orderClothRefund) {
        orderClothRefund.setCreateById(getUserId());
        orderClothRefund.setCreateBy(getUsername());
        return toAjax(orderClothRefundService.insertOrderClothRefund(orderClothRefund));
    }

    /**
     * 修改洗衣退款订单
     */
    @PreAuthorize("@ss.hasPermi('order:clothRefund:edit')")
    @Log(title = "洗衣退款订单", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改洗衣退款订单")
    public AjaxResult edit(@RequestBody OrderClothRefund orderClothRefund) {
        orderClothRefund.setUpdateById(getUserId());
        orderClothRefund.setUpdateBy(getUsername());
        return toAjax(orderClothRefundService.updateOrderClothRefund(orderClothRefund));
    }

    /**
     * 删除洗衣退款订单
     */
    @PreAuthorize("@ss.hasPermi('order:clothRefund:remove')")
    @Log(title = "洗衣退款订单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除洗衣退款订单")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(orderClothRefundService.deleteOrderClothRefundByIds(ids));
    }


    //</editor-folder>
}
