package com.liangjian.dataplatform.member.controller;

import com.liangjian.dataplatform.member.entity.po.secondary.UserPointRmbRule;
import com.liangjian.dataplatform.member.entity.response.ResultObject;
import com.liangjian.dataplatform.member.service.IUserPointRmbRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 黄树文
 * @Date: 2019/12/05
 */
@RestController
@RequestMapping("/userPointRmbRule")
@Api(value = "积分兑换RMB规则", tags = "积分兑换RMB规则", description = "积分兑换RMB规则")
public class UserPointRmbRuleController {
    @Autowired
    private IUserPointRmbRuleService iUserPointRmbRuleService;

    @GetMapping("/rule")
    @ApiOperation(value = "查询积分兑换RMB规则")
    public ResultObject<UserPointRmbRule> query() {
        UserPointRmbRule userPointRmbRule = iUserPointRmbRuleService.queryPointRmbRule();
        return ResultObject.success(userPointRmbRule);
    }


    @PostMapping("/rule")
    @ApiOperation(value = "添加积分兑换RMB规则")
    public ResultObject<Object> addPointRmbRule(@ApiParam(value = "积分兑换RMB规则", required = true) @RequestBody UserPointRmbRule rule) {
        if(iUserPointRmbRuleService.addPointRmbRule(rule)) {
            return ResultObject.success("保存成功",null);
        } else {
            return ResultObject.error("保存失败");
        }
    }
}
