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.OrderClothAdjunct;
import com.yiqi.order.service.IOrderClothAdjunctService;
import com.yiqi.common.utils.poi.ExcelUtil;
import com.yiqi.common.core.page.TableDataInfo;

/**
 * 订单衣服附件Controller
 *
 * @author xiaohei
 * @date 2023-10-06
 */
@Api(tags = "管理后台 - 订单衣服附件")
@RestController
@RequestMapping(UrlConstants.managerApi + "/order/clothAdjunct")
public class OrderClothAdjunctController extends BaseController {
    @Autowired
    private IOrderClothAdjunctService orderClothAdjunctService;

    /**
     * 查询订单衣服附件列表
     */
    @PreAuthorize("@ss.hasPermi('order:cloth:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询订单衣服附件列表")
    public TableDataInfo list(OrderClothAdjunct orderClothAdjunct) {
        startPage();
        List<OrderClothAdjunct> list = orderClothAdjunctService.selectOrderClothAdjunctList(orderClothAdjunct);
        return getDataTable(list);
    }

    /**
     * 导出订单衣服附件列表
     */
    @PreAuthorize("@ss.hasPermi('order:cloth:export')")
    @Log(title = "订单衣服附件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出订单衣服附件列表")
    public void export(HttpServletResponse response, OrderClothAdjunct orderClothAdjunct) {
        List<OrderClothAdjunct> list = orderClothAdjunctService.selectOrderClothAdjunctList(orderClothAdjunct);
        ExcelUtil<OrderClothAdjunct> util = new ExcelUtil<OrderClothAdjunct>(OrderClothAdjunct. class);
        util.exportExcel(response, list, "订单衣服附件数据");
    }

    /**
     * 获取订单衣服附件详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:cloth:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取订单衣服附件详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(orderClothAdjunctService.selectOrderClothAdjunctById(id));
    }

    /**
     * 新增订单衣服附件
     */
    @PreAuthorize("@ss.hasPermi('order:cloth:add')")
    @Log(title = "订单衣服附件", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增订单衣服附件")
    public AjaxResult add(@RequestBody OrderClothAdjunct orderClothAdjunct) {
        orderClothAdjunct.setCreateById(getUserId());
        orderClothAdjunct.setCreateBy(getUsername());
        return toAjax(orderClothAdjunctService.insertOrderClothAdjunct(orderClothAdjunct));
    }

    /**
     * 修改订单衣服附件
     */
    @PreAuthorize("@ss.hasPermi('order:cloth:edit')")
    @Log(title = "订单衣服附件", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改订单衣服附件")
    public AjaxResult edit(@RequestBody OrderClothAdjunct orderClothAdjunct) {
        orderClothAdjunct.setUpdateById(getUserId());
        orderClothAdjunct.setUpdateBy(getUsername());
        return toAjax(orderClothAdjunctService.updateOrderClothAdjunct(orderClothAdjunct));
    }

    /**
     * 删除订单衣服附件
     */
    @PreAuthorize("@ss.hasPermi('order:cloth:remove')")
    @Log(title = "订单衣服附件", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除订单衣服附件")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(orderClothAdjunctService.deleteOrderClothAdjunctByIds(ids));
    }

}
