package com.yuchen.saas.park.service.controller.notice;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.entity.park.PmgBatParkNotice;
import com.yuchen.saas.park.api.entity.park.PmgBatParkVisitor;
import com.yuchen.saas.park.service.service.PmgBatParkNoticeService;
import com.yuchen.saas.park.service.util.VideoEventsUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.nest.springwrap.core.mp.support.Condition;
import org.nest.springwrap.core.mp.support.Query;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author 刘通
 * @version 1.0
 * @date 2021/3/27 17:37
 */
@RestController
@AllArgsConstructor
@RequestMapping("/parkNotice")
@Api(value = "园区公告", tags = "园区公告")
public class PmgBatParkNoticeController {

	@Autowired
	private PmgBatParkNoticeService pmgBatParkNoticeService;


	/**
	 * 分页 园区公告
	 */
	@GetMapping("/list")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "分页 园区公告", notes = "分页 园区公告")
	public R<IPage<PmgBatParkNotice>> list(PmgBatParkNotice pmgBatParkNotice, Query query) {
		return R.data(pmgBatParkNoticeService.list(pmgBatParkNotice,query));
	}


	/**
	 * 明细 园区公告
	 */
	@GetMapping("/getDetail")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "明细 园区公告", notes = "明细  园区公告")
	public R<PmgBatParkNotice> getDetail(Long id) {
		return R.data(pmgBatParkNoticeService.getById(id));
	}

	/**
	 * 明细 园区公告
	 */
	@GetMapping("/copy")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "明细 园区公告", notes = "明细  园区公告")
	public R copy() {
		pmgBatParkNoticeService.copy2();
		return R.success();
	}


	/**
	 * 埋点浏览 园区公告
	 */
	@GetMapping("/addViewCount")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "明细 园区公告", notes = "明细  园区公告")
	public R addViewCount(Long id) {
		PmgBatParkNotice pmgBatParkNotice=	pmgBatParkNoticeService.getById(id);
		 int viewCount=pmgBatParkNotice.getViewCount()+1;
		pmgBatParkNotice.setViewCount(viewCount);
		pmgBatParkNoticeService.updateById(pmgBatParkNotice);
		return R.success();
	}
}
