package com.bonus.canteen.core.supermarket.controller;

import com.bonus.canteen.core.device.dto.DeviceDTO;
import com.bonus.canteen.core.supermarket.domain.SupermarketInfo;
import com.bonus.canteen.core.supermarket.service.SupermarketDeviceService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xliu
 * @date 2025/5/8 9:46
 */

@Api(tags = "设备接口")
@RestController
@RequestMapping("/supermarket_device")
public class SupermarketDeviceController  extends BaseController {
    @Resource
    private SupermarketDeviceService supermarketDeviceService;

    @ApiOperation(value = "新增 - 双屏超市收银机")
    @SysLog(title = "超市", businessType = OperaType.INSERT, logType = 1,module = "商超管理->新增 -双屏超市收银机")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody DeviceDTO dto) {
        try {
            return toAjax(supermarketDeviceService.insertSupermarketDevice(dto));
        } catch (Exception e) {
            return error("系统错误, " + e.getMessage());
        }
    }

    @ApiOperation(value = "修改 - 双屏超市收银机")
    @SysLog(title = "超市", businessType = OperaType.INSERT, logType = 1,module = "商超管理->修改 -双屏超市收银机")
    @PostMapping("/update")
    public AjaxResult update(@RequestBody DeviceDTO dto) {
        try {
            return toAjax(supermarketDeviceService.updateSupermarketDevice(dto));
        } catch (Exception e) {
            return error("系统错误, " + e.getMessage());
        }
    }


    @ApiOperation(value = "查询 - 双屏超市收银机")
    @SysLog(title = "超市", businessType = OperaType.INSERT, logType = 1,module = "商超管理->查询 -双屏超市收银机")
    @GetMapping("/list")
    public TableDataInfo list(DeviceDTO dto) {
        try {
            startPage();
            return getDataTable(supermarketDeviceService.selectSupermarketDevice(dto));
        } catch (Exception e) {
            throw new RuntimeException("系统错误, " + e.getMessage());
        }
    }



}
