package com.huijy.web.controller.management;

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.huijy.common.annotation.Log;
import com.huijy.common.core.controller.BaseController;
import com.huijy.common.core.domain.AjaxResult;
import com.huijy.common.enums.BusinessType;
import com.huijy.management.domain.ShopSalesRecord;
import com.huijy.management.service.IShopSalesRecordService;
import com.huijy.common.utils.poi.ExcelUtil;
import com.huijy.common.core.page.TableDataInfo;

/**
 * 店铺销售记录Controller
 *
 * @author luobo
 * @date 2021-09-12
 */
@RestController
@RequestMapping("/management/record")
public class ShopSalesRecordController extends BaseController
{
    @Autowired
    private IShopSalesRecordService shopSalesRecordService;

    /**
     * 查询店铺销售记录列表
     */
    @PreAuthorize("@ss.hasPermi('management:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopSalesRecord shopSalesRecord)
    {
        startPage();
        List<ShopSalesRecord> list = shopSalesRecordService.selectShopSalesRecordList(shopSalesRecord);
        return getDataTable(list);
    }

    /**
     * 导出店铺销售记录列表
     */
    @PreAuthorize("@ss.hasPermi('management:record:export')")
    @Log(title = "店铺销售记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ShopSalesRecord shopSalesRecord)
    {
        List<ShopSalesRecord> list = shopSalesRecordService.selectShopSalesRecordList(shopSalesRecord);
        ExcelUtil<ShopSalesRecord> util = new ExcelUtil<ShopSalesRecord>(ShopSalesRecord.class);
        return util.exportExcel(list, "店铺销售记录数据");
    }

    /**
     * 获取店铺销售记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('management:record:query')")
    @GetMapping(value = "/{shopSalesRecordId}")
    public AjaxResult getInfo(@PathVariable("shopSalesRecordId") Long shopSalesRecordId)
    {
        return AjaxResult.success(shopSalesRecordService.selectShopSalesRecordByShopSalesRecordId(shopSalesRecordId));
    }

    /**
     * 新增店铺销售记录
     */
    @PreAuthorize("@ss.hasPermi('management:record:add')")
    @Log(title = "店铺销售记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopSalesRecord shopSalesRecord)
    {
        return toAjax(shopSalesRecordService.insertShopSalesRecord(shopSalesRecord));
    }

    /**
     * 修改店铺销售记录
     */
    @PreAuthorize("@ss.hasPermi('management:record:edit')")
    @Log(title = "店铺销售记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopSalesRecord shopSalesRecord)
    {
        return toAjax(shopSalesRecordService.updateShopSalesRecord(shopSalesRecord));
    }

    /**
     * 删除店铺销售记录
     */
    @PreAuthorize("@ss.hasPermi('management:record:remove')")
    @Log(title = "店铺销售记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shopSalesRecordIds}")
    public AjaxResult remove(@PathVariable Long[] shopSalesRecordIds)
    {
        return toAjax(shopSalesRecordService.deleteShopSalesRecordByShopSalesRecordIds(shopSalesRecordIds));
    }
}
