package com.ruoyi.web.controller.staff;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.ValidGroup;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.ss.store.domain.StoreBO;
import com.ruoyi.ss.store.domain.StoreQuery;
import com.ruoyi.ss.store.domain.StoreVo;
import com.ruoyi.ss.store.service.StoreAssembler;
import com.ruoyi.ss.store.service.StoreService;
import com.ruoyi.ss.store.service.StoreValidator;
import com.ruoyi.ss.storeStaff.domain.enums.StoreStaffPermissions;
import com.ruoyi.ss.storeStaff.service.StoreStaffValidator;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 员工 店铺Controller
 * @author wjh
 * 2024/11/23
 */
@RestController
@RequestMapping("/staff/store")
public class StaffStoreController extends BaseController {

    @Autowired
    private StoreService storeService;

    @Autowired
    private StoreAssembler storeAssembler;

    @ApiOperation("员工获取管理的店铺列表")
    @GetMapping("/list")
    public TableDataInfo list(StoreQuery query) {
        startPage();
        query.setStaffUserId(getUserId());
        query.setStaffPermission(StoreStaffPermissions.STORE_VIEW.getCode());
        List<StoreVo> list = storeService.selectStaffStoreList(query);
        // 拼接设备数量
        storeAssembler.assembleDeviceCount(list);
        // 拼接营收数据
        storeAssembler.assembleRevenue(list);
        return getDataTable(list);
    }


}
