package com.ruoyi.web.controller.basic;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.RestResponse;
import com.ruoyi.basic.domain.YjStore;
import com.ruoyi.basic.service.YjStoreService;
import com.ruoyi.basic.service.impl.YjStoreServiceImpl;
import com.ruoyi.system.domain.SysTeacher;
import com.ruoyi.system.service.SysTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 门店
 */
@Api(tags = "032-了解场馆", description = "提供门店相关的API")
@RestController
@RequestMapping("/api/store")
public class StoreController {

    @Resource
    private YjStoreService storeService;

    @Resource
    private SysTeacherService teacherService;
    /**
     *  企业简介+门店列表
     * @param map
     * @return
     */
    @ApiOperation(value = "创始人+企业简介+门店列表")
    @PostMapping("/getList")
    public RestResponse getList(@RequestBody Map map){
        Map map1=new HashMap();
        YjStore store=storeService.getOne(Long.parseLong(map.get("visitStore").toString()));
        String tenantId=store.getTenantId();
        List<YjStore> list= storeService.getStoreListByTenantId(tenantId);
        List<YjStore> list1=new ArrayList<>();
        list.forEach(l->{
            if (l.getParentId()==0l){
                l.setStoreName(l.getStoreName()+"（总店）");
            }
            list1.add(l);

        });
        map1.put("companyIntroduction",store);
        map1.put("storeList",list1);

        return new RestResponse().setSuccess(true).setMessage("成功").setData(map1);
    }


}
