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.DeviceLogmediaEntity;
import com.mx.cneeds.server.device.service.DeviceLogmediaService;
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/devicelogmedia")
public class DeviceLogmediaController {
    @Autowired
    private DeviceLogmediaService deviceLogmediaService;

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

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


    /**
     * 信息
     */
    @RequestMapping("/info/{logmediaId}")
//    @RequiresPermissions("sys:devicelogmedia:info")
    public R info(@PathVariable("logmediaId") Long logmediaId){
        DeviceLogmediaEntity deviceLogmedia = deviceLogmediaService.getById(logmediaId);

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

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("sys:devicelogmedia:save")
    public R save(@RequestBody DeviceLogmediaEntity deviceLogmedia){
        deviceLogmediaService.save(deviceLogmedia);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("sys:devicelogmedia:update")
    public R update(@RequestBody DeviceLogmediaEntity deviceLogmedia){
        ValidatorUtils.validateEntity(deviceLogmedia);
        deviceLogmediaService.updateById(deviceLogmedia);
        
        return R.ok();
    }

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

        return R.ok();
    }

}
