package com.iformall.controller.market;

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxPowerBillAutoConfig;
import com.iformall.service.WxPowerBillAutoConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
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.*;


/**
 * @author gongbiao
 */
@RestController
@RequestMapping("wxPowerBillAutoConfig")
@Api(description = "电费自动生成配置")
public class WxPowerBillAutoConfigController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private WxPowerBillAutoConfigService wxPowerBillAutoConfigService;


    @ApiOperation("查询数据列表")
    @GetMapping("/list")
    @SystemControllerLog(description = "查询数据列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
    public ResultData findCouponDataList(@ModelAttribute WxPowerBillAutoConfig wxPowerBillAutoConfig, Integer pageNum, Integer pageSize) {
        logger.debug("[" + getIpAddr() + "] WxPowerBillAutoConfigController::list");
        wxPowerBillAutoConfig.setTenantId(getTenantId());
        wxPowerBillAutoConfig.setSortColumns(BaseEntity.SortField.CreateDate_DESC);
        final PageInfo<WxPowerBillAutoConfig> page = wxPowerBillAutoConfigService.listAsPage(wxPowerBillAutoConfig, pageNum, pageSize);
        return new ResultData(page);
    }


    @ApiOperation("修改")
    @PostMapping("/modify")
    @SystemControllerLog(description = "修改")
    public ResultData add(@RequestBody WxPowerBillAutoConfig wxPowerBillAutoConfig) {
        logger.debug("[" + getIpAddr() + "] WxPowerBillAutoConfigController::modify");
        return wxPowerBillAutoConfigService.modify(wxPowerBillAutoConfig);
    }


    @ApiOperation("得到配置信息")
    @GetMapping("/getConfig")
    @SystemControllerLog(description = "id查询")
    public ResultData getConfig() {
        logger.debug("[" + getIpAddr() + "] WxPowerBillAutoConfigController::getConfig");
        return new ResultData(Result.SUCCESS, "查询成功", wxPowerBillAutoConfigService.getConfig(getTenantId()));
    }


}
