package io.renren.modules.aspen.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.aspen.entity.TDashboarddataEntity;
import io.renren.modules.aspen.service.TDashboarddataService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 报警统计表（当天）
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2021-05-11 16:13:06
 */
@RestController
@RequestMapping("aspen/talarmstatisticsday")
public class TDashboarddataController {
    @Autowired
    private TDashboarddataService tDashboarddataService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("aspen:talarmstatisticsday:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tDashboarddataService.queryPage(params);

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


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("aspen:talarmstatisticsday:info")
    public R info(@PathVariable("id") Integer id){
		TDashboarddataEntity tDashboarddata = tDashboarddataService.getById(id);

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

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("aspen:talarmstatisticsday:save")
    public R save(@RequestBody TDashboarddataEntity tDashboarddata){
        tDashboarddataService.save(tDashboarddata);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("aspen:talarmstatisticsday:update")
    public R update(@RequestBody TDashboarddataEntity tDashboarddata){
        tDashboarddataService.updateById(tDashboarddata);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("aspen:talarmstatisticsday:delete")
    public R delete(@RequestBody Integer[] ids){
        tDashboarddataService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
