package com.zcloud.modules.qps.controller;

import com.zcloud.common.annotation.SysLog;
import com.zcloud.common.utils.PageUtils;
import com.zcloud.common.utils.R;
import com.zcloud.modules.qps.entity.BusQpsLogEntity;
import com.zcloud.modules.qps.service.BusQpsLogService;
import com.zcloud.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.Map;

/**
 * @Author makejava
 * @Desc QPS购买记录(BusQpsLog)表控制层
 * @Date 2024-04-08 09:01:20
 */
@Api(tags = "QPS购买记录")
@RestController
@RequestMapping("busQpsLog")
public class BusQpsLogController extends AbstractController {

    @Autowired
    private BusQpsLogService busQpsLogService;

    @ApiOperation("QPS购买记录-新增数据")
    @SysLog("QPS购买记录-新增数据")
    @PostMapping("/save")
    public R insert(@RequestBody BusQpsLogEntity param) {
        param.setCreator(getUserId());
        busQpsLogService.save(param);

        return R.ok();
    }

    @ApiOperation("QPS购买记录-编辑数据")
    @SysLog("QPS购买记录-编辑数据")
    @PostMapping("/update")
    public R update(@RequestBody BusQpsLogEntity param) {
        busQpsLogService.updateById(param);

        return R.ok();
    }


    @ApiOperation("QPS购买记录-删除数据")
    @SysLog("QPS购买记录-删除数据")
    @PostMapping("/delete")
    public R delete(@RequestBody BusQpsLogEntity param) {
        busQpsLogService.delete(param.getQpsLogId(),getUserId());
        return R.ok();
    }

    @ApiOperation("QPS购买记录-分页查询")
    @SysLog("QPS购买记录-分页查询")
    @PostMapping("/listPage")
    public R listPage(@RequestBody Map<String, Object> params) {
        PageUtils page = busQpsLogService.listPage(params);

		return R.ok().put("page", page);
    }


    @ApiOperation("QPS购买记录-根据ID查详情")
    @SysLog("QPS购买记录-根据ID查详情")
    @PostMapping("/info")
    public R info(@RequestBody BusQpsLogEntity param) {
        BusQpsLogEntity busQpsLog = busQpsLogService.getInfoById(param.getQpsLogId());
        return R.ok().put("busQpsLog", busQpsLog);
    }

}
