package com.liangjian.dataplatform.member.controller;

import com.liangjian.dataplatform.member.entity.po.secondary.UserPointClearRule;
import com.liangjian.dataplatform.member.entity.response.ResultObject;
import com.liangjian.dataplatform.member.service.IUserPointClearRuleService;
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("/userPointClearRule")
@Api(value = "积分清零规则", tags = "积分清零规则", description = "积分清零规则")
public class UserPointClearRuleController {
    @Autowired
    private IUserPointClearRuleService iUserPointClearRuleService;

    @GetMapping("/rule")
    @ApiOperation(value = "查询成积分清零规则")
    public ResultObject<UserPointClearRule> query() {
        UserPointClearRule userPointClearRule = iUserPointClearRuleService.queryPointClearRule();
        return ResultObject.success(userPointClearRule);
    }


    @PostMapping("/rule")
    @ApiOperation(value = "添加积分清零规则")
    public ResultObject<Object> addPointClearRule(@ApiParam(value = "积分清零规则对象", required = true) @RequestBody UserPointClearRule rule) {
        if(iUserPointClearRuleService.addPointClearRule(rule)) {
            return ResultObject.success("保存成功",null);
        } else {
            return ResultObject.error("保存失败");
        }
    }
}
