package org.jeecg.modules.ctop.controller;

import cn.com.ctop.common.module.annotation.AutoLog;
import cn.com.ctop.common.module.entity.TencentWatermarkTemplate;
import cn.com.ctop.common.module.service.ITencentWatermarkTemplateService;
import cn.com.ctop.common.module.utils.QueryGenerator;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

 /**
 * 水印模板
 * @author jeecg-boot
 * @date   2019-12-20
 * @version V1.0
 */
@Slf4j
@Api(tags="水印模板")
@RestController
@RequestMapping("/ctop/videoWatermarkTemplate")
public class VideoWatermarkTemplateController {

	@Autowired
	private ITencentWatermarkTemplateService tencentWatermarkTemplateService;

     /**
	  * 分页列表查询
	 * @param videoWatermarkTemplate
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	@AutoLog(value = "水印模板-分页列表查询")
	@ApiOperation(value="水印模板-分页列表查询", notes="水印模板-分页列表查询")
	@GetMapping(value = "/list")
	public Result<IPage<TencentWatermarkTemplate>> queryPageList(TencentWatermarkTemplate videoWatermarkTemplate,
																 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
																 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
																 HttpServletRequest req) {
        Result<IPage<TencentWatermarkTemplate>> result = new Result<>();
		QueryWrapper<TencentWatermarkTemplate> queryWrapper = QueryGenerator.initQueryWrapper(videoWatermarkTemplate, req.getParameterMap());
        Page<TencentWatermarkTemplate> page = new Page<>(pageNo, pageSize);
		IPage<TencentWatermarkTemplate> pageList = tencentWatermarkTemplateService.page(page, queryWrapper);
		result.setSuccess(true);
		result.setResult(pageList);
		return result;
	}

	@GetMapping(value= "/queryById")
	public Result<TencentWatermarkTemplate> queryById(){
		Result<TencentWatermarkTemplate> result = new Result<>();
		TencentWatermarkTemplate tencentWatermarkTemplate=tencentWatermarkTemplateService.getById(5);
		result.setSuccess(true);
		result.setResult(tencentWatermarkTemplate);
		return result;
	}
 }
