package com.ruoyi.mall.controller;

import java.util.List;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.domain.MallMeetAddress;
import com.ruoyi.mall.service.IMallMeetAddressService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 接货地址Controller
 *
 * @author ruoyi
 * @date 2024-04-15
 */
@RestController
@RequestMapping("/mall/mallMeetAddress")
public class MallMeetAddressController extends BaseController
{
    @Resource
    private IMallMeetAddressService mallMeetAddressService;

    /**
     * 查询接货地址列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMeetAddress:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallMeetAddress mallMeetAddress)
    {
        startPage();
        List<MallMeetAddress> list = mallMeetAddressService.selectMallMeetAddressList(mallMeetAddress);
        return getDataTable(list);
    }

    /**
     * 导出接货地址列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMeetAddress:export')")
    @Log(title = "接货地址", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallMeetAddress mallMeetAddress)
    {
        List<MallMeetAddress> list = mallMeetAddressService.selectMallMeetAddressList(mallMeetAddress);
        ExcelUtil<MallMeetAddress> util = new ExcelUtil<MallMeetAddress>(MallMeetAddress.class);
        return util.exportExcel(list, "接货地址数据");
    }

    /**
     * 获取接货地址详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMeetAddress:query')")
    @GetMapping(value = "/{meetId}")
    public AjaxResult getInfo(@PathVariable("meetId") Long meetId)
    {
        return AjaxResult.success(mallMeetAddressService.selectMallMeetAddressByMeetId(meetId));
    }

    /**
     * 新增接货地址
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMeetAddress:add')")
    @Log(title = "接货地址", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallMeetAddress mallMeetAddress)
    {
        return toAjax(mallMeetAddressService.insertMallMeetAddress(mallMeetAddress));
    }

    /**
     * 修改接货地址
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMeetAddress:edit')")
    @Log(title = "接货地址", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallMeetAddress mallMeetAddress)
    {
        return toAjax(mallMeetAddressService.updateMallMeetAddress(mallMeetAddress));
    }

    /**
     * 删除接货地址
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMeetAddress:remove')")
    @Log(title = "接货地址", businessType = BusinessType.DELETE)
	@DeleteMapping("/{meetIds}")
    public AjaxResult remove(@PathVariable Long[] meetIds)
    {
        return toAjax(mallMeetAddressService.deleteMallMeetAddressByMeetIds(meetIds));
    }
}
