package com.iformall.controller.sys;

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxBusiness;
import com.iformall.domain.po.WxSubBusiness;
import com.iformall.service.WxBusinessService;
import com.iformall.service.WxSubBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("wxBusiness")
@Api(description = "业态接口")
public class WxBusinessController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private WxBusinessService wxBusinessService;

    @Autowired
    private WxSubBusinessService wxSubBusinessService;

    @ApiOperation("业态全列表接口")
    @GetMapping("listAll")
    @SystemControllerLog(description = "业态-全列表")
    public ResultData listAll() {
        logger.debug("[" + getIpAddr() + "] WxBusinessController::getList");
        final List<WxBusiness> busList = wxBusinessService.findListAll(getTenantId(),null);
        return new ResultData(busList);
    }

    @ApiOperation("子业态表接口")
    @GetMapping("listSub")
    @SystemControllerLog(description = "子业态")
    public ResultData listSub(@ModelAttribute WxSubBusiness wxSubBusiness) {
        logger.debug("[" + getIpAddr() + "] WxBusinessController::getList");
        final List<WxSubBusiness> busList = wxSubBusinessService.findList(wxSubBusiness);
        return new ResultData(busList);
    }

}
