package com.platform.modules.live.controller;

import java.util.List;

import com.platform.modules.live.aspect.LiveTenant;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.platform.common.annotation.SysLog;
import com.platform.common.utils.R;
import com.platform.modules.live.entity.LiveSceneLiveInfoEntity;
import com.platform.modules.live.service.LiveSceneLiveInfoService;

import io.swagger.annotations.ApiOperation;


/**
 * 现场直播信息表
 * 
 * @author TROY
 * @email 
 * @date 2019-01-19 14:50:50
 */
@RestController
@RequestMapping("/live/livesceneliveinfo")
public class LiveSceneLiveInfoController {
	@Autowired
	private LiveSceneLiveInfoService liveSceneLiveInfoService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("live:livesceneliveinfo:list")
	public R list(LiveSceneLiveInfoEntity liveSceneLiveInfo){
		List<LiveSceneLiveInfoEntity> list =  liveSceneLiveInfoService.selectList(new EntityWrapper<>(liveSceneLiveInfo));
		return R.ok().put("list", list);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info")
	@RequiresPermissions("live:livesceneliveinfo:info")
	public R info(Integer id){
		return R.ok().put("info", liveSceneLiveInfoService.selectById(id));
	}
	
	/**
	 * 保存
	 */
	@SysLog("保存现场直播信息")
	@RequestMapping("/save")
	@RequiresPermissions("live:livesceneliveinfo:save")
	public R save(LiveSceneLiveInfoEntity liveSceneLiveInfo,BindingResult bindingResult){
		liveSceneLiveInfoService.save(liveSceneLiveInfo);
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@SysLog("修改现场直播信息")
	@RequestMapping("/update")
	@RequiresPermissions("live:livesceneliveinfo:update")
	public R update(LiveSceneLiveInfoEntity liveSceneLiveInfo,BindingResult bindingResult){
		liveSceneLiveInfoService.update(liveSceneLiveInfo);
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@SysLog("删除现场直播信息")
	@RequestMapping("/delete")
	@RequiresPermissions("live:livesceneliveinfo:delete")
	public R delete(Integer[] ids){
		liveSceneLiveInfoService.deleteBatch(ids);
		return R.ok();
	}
	
	/**
	 * 排序
	 */
	@SysLog("现场直播信息排序")
	@PostMapping("/priority")
	@RequiresPermissions("live:livesceneliveinfo:priority")
	@ApiOperation("排序")
	@LiveTenant(value = "ids", tenantTableClazz = LiveSceneLiveInfoService.class)
	public R priority(Integer[] ids,Integer[] prioritys){
		if(ids==null || ids.length==0){
			return R.error("报道ID不能为空");
		}
		liveSceneLiveInfoService.priority(ids, prioritys);
		return R.ok();
	}
	
}
