package com.ruoyi.web.controller.basic;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.RestResponse;
import com.ruoyi.basic.service.YjAppUserService;
import com.ruoyi.common.core.domain.entity.AppUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.basic.domain.YjStore;
import com.ruoyi.basic.service.impl.YjStoreServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api(tags = "021-首页", description = "提供首页信息相关的API")
@RestController
@RequestMapping("/api/index")
public class IndexController {
    @Resource
    private YjStoreServiceImpl storeService;



    @ApiOperation("门店列表")
    @PostMapping("/getStores")
    public RestResponse getStoreList(){
        return storeService.storesTree();
    }

    @ApiOperation("切换门店")
    @PostMapping("/changeStore")
    public RestResponse changeStore(@RequestBody Map<String,Long> map){
        Long visitStoreId =map.get("visitStoreId");
        //登录用户的访问门店字段修改
        return storeService.changeStore(visitStoreId);
    }

    @ApiOperation("获取首页及分类页菜单")
    @GetMapping("/getIndex")
    public RestResponse getIndex(){
        return storeService.getIndex();
    }

}
