package com.mx.cneeds.server.device.web;

import com.mx.cneeds.common.pager.PageUtils;
import com.mx.cneeds.common.result.R;
import com.mx.cneeds.common.validator.ValidatorUtils;
import com.mx.cneeds.server.entity.DeviceLogsettingEntity;
import com.mx.cneeds.server.device.service.DeviceLogsettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

//import org.apache.shiro.authz.annotation.RequiresPermissions;


/**
 * 设备日志设置
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2020-01-09 15:09:01
 */
@RestController
@RequestMapping("device/devicelogsetting")
public class DeviceLogsettingController {
    @Autowired
    private DeviceLogsettingService deviceLogsettingService;

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

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


    /**
     * 信息
     */
    @RequestMapping("/info/{logsettingId}")
//    @RequiresPermissions("sys:devicelogsetting:info")
    public R info(@PathVariable("logsettingId") Long logsettingId){
        DeviceLogsettingEntity deviceLogsetting = deviceLogsettingService.getById(logsettingId);

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

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("sys:devicelogsetting:save")
    public R save(@RequestBody DeviceLogsettingEntity deviceLogsetting){
        deviceLogsettingService.save(deviceLogsetting);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("sys:devicelogsetting:update")
    public R update(@RequestBody DeviceLogsettingEntity deviceLogsetting){
        ValidatorUtils.validateEntity(deviceLogsetting);
        deviceLogsettingService.updateById(deviceLogsetting);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("sys:devicelogsetting:delete")
    public R delete(@RequestBody Long[] logsettingIds){
        deviceLogsettingService.removeByIds(Arrays.asList(logsettingIds));

        return R.ok();
    }

}
