package com.iformall.controller.market;

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

@RestController
@RequestMapping("pushLimit")
@Api(description = "疲劳度相关接口")
public class PushLimitController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private PushLimitService pushLimitService;

    @ApiOperation("疲劳度配置")
    @GetMapping("setting")
    @SystemControllerLog(description = "疲劳度-配置获取")
    public ResultData list() {
        logger.debug("[" + getIpAddr() + "] PushLimitController::list");
        PushLimit pushLimit = pushLimitService.getPushLimit(getTenantId());
        return new ResultData(pushLimit);
    }

    @ApiOperation("根据id更新接口")
    @PostMapping("update")
    @SystemControllerLog(description = "疲劳度-配置更新")
    public ResultData update(@RequestBody PushLimit pushLimit) {
        logger.debug("[" + getIpAddr() + "] PushLimitController::update");
        pushLimit.setTenantId(getTenantId());
        pushLimitService.saveOrUpdate(pushLimit);
        return new ResultData();
    }

}
