package com.ruoyi.web.controller.staff;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.ss.device.domain.DeviceQuery;
import com.ruoyi.ss.device.domain.vo.DeviceVO;
import com.ruoyi.ss.device.service.DeviceAssembler;
import com.ruoyi.ss.device.service.DeviceService;
import com.ruoyi.ss.storeStaff.domain.enums.StoreStaffPermissions;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wjh
 * 2024/11/27
 */
@RestController
@RequestMapping("/staff/device")
public class StaffDeviceController extends BaseController {

    @Autowired
    private DeviceService deviceService;

    @Autowired
    private DeviceAssembler deviceAssembler;

    @ApiOperation("员工查询设备列表")
    @GetMapping("/list")
    public TableDataInfo list(DeviceQuery query) {
        startPage();
        startOrderBy();
        query.setStaffUserId(getUserId());
        query.setStaffPermission(StoreStaffPermissions.DEVICE_VIEW.getCode());
        List<DeviceVO> list = deviceService.selectStaffDeviceList(query);
        deviceService.pullDeviceInfoList(list);
        return getDataTable(list);
    }

}
