package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxScoreRules;
import com.iformall.service.WxScoreRulesService;
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.*;

@RestController
@RequestMapping("wxScoreRules")
@Api(description = "成长值规则相关接口")
public class WxScoreRulesController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private WxScoreRulesService wxScoreRulesService;

    @ApiOperation("成长值配置")
    @GetMapping("setting")
    public ResultData list() {
        logger.debug("[" + getIpAddr() + "] WxScoreRulesController::list");
        WxScoreRules scoreRules = wxScoreRulesService.getScoreRules(getTenantId());
        return new ResultData(scoreRules);
    }

    @ApiOperation("新增接口")
    @PostMapping("add")
    public ResultData add(@RequestBody WxScoreRules wxScoreRules) {
        logger.debug("[" + getIpAddr() + "] WxScoreRulesController::add");
        wxScoreRules.setTenantId(getTenantId());
        wxScoreRulesService.saveOrUpdate(wxScoreRules);
        return new ResultData();
    }
}
