package com.iformall.controller.basic;

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxMall;
import com.iformall.service.WxMallService;
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.*;

@RestController
@RequestMapping("wxMall")
public class WxMallController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private WxMallService wxMallService;

    @ApiOperation("根据id更新接口")
    @PostMapping("update")
    @SystemControllerLog(description = "商城-更新")
    public ResultData update(@RequestBody WxMall wxMall) {
        logger.debug("[" + getIpAddr() + "] WxMallController::update");
        wxMallService.update(wxMall);
        return new ResultData();
    }

    @ApiOperation("根据id查询接口")
    @GetMapping("/mallinfoExt")
    @SystemControllerLog(description = "商城-查询")
    public ResultData mallinfoExt() {
        logger.debug("[" + getIpAddr() + "] WxMallController::mallinfoExt");
        return new ResultData(wxMallService.getByTenantIdExt(getTenantId()));
    }

    @ApiOperation("查询当前mall的信息")
    @GetMapping("/mallinfo")
    @SystemControllerLog(description = "商城-当前查询")
    public ResultData mallinfo() {
        logger.debug("[" + getIpAddr() + "] WxMallController::mallinfo");
        return new ResultData(wxMallService.getByTenantId(getTenantId()));
    }


}
