package com.blueland.sys.log.web;


import java.util.Map;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blueland.core.util.UserUtils;
import com.blueland.model.TPfSysPvlog;
import com.blueland.result.R;
import com.blueland.service.ISysPvlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.blueland.bo.SysPvlogEntity;

import io.swagger.annotations.Api;


@Api(value = "sysPvlog")
@RestController
@RequestMapping(value = "/api/sysPvlog")
public class SysPvlogRest {
	@Autowired
	private ISysPvlogService sysPvlogService;
	
	/**
	 *查询list
	 */
	@ResponseBody
	@RequestMapping(value="/list", method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
	public Page<SysPvlogEntity> listPage(@RequestParam Map<String,Object> queryParams){
    	queryParams.put("orderByColumns", "T1.aceess_time DESC");
		Page<SysPvlogEntity> page = sysPvlogService.findSysPvlogPageListByParams(queryParams,Integer.parseInt(queryParams.get("pageNum").toString()),Integer.parseInt(queryParams.get("pageSize").toString()));
		return page;
	}
	
	/** 
	 * 搜索对象 
	 **/
	@RequestMapping(value = "",method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
	@ResponseBody
	@CrossOrigin
	public R<Page<SysPvlogEntity>> list(SysPvlogEntity sysPvlogEntity) {
		Page<SysPvlogEntity> page = sysPvlogService.findPage(sysPvlogEntity);
		return R.ok(page);
	}

	
	/** 
	 * 查看对象
	 **/
	@RequestMapping(value = "/{id}",method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
	@ResponseBody
	@CrossOrigin
	public R<TPfSysPvlog> view(@PathVariable String id)  {
		TPfSysPvlog sysPvlogEntity  = sysPvlogService.getById(id);
		return R.ok(sysPvlogEntity);
	}


	/** 
	 * 查看对象（支持多条件查询）
	 **/
	@RequestMapping(value = "get",method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
	@ResponseBody
	@CrossOrigin
	public R<TPfSysPvlog> get(SysPvlogEntity model)  {
		TPfSysPvlog sysPvlogEntity  = sysPvlogService.get(model);
		return R.ok(sysPvlogEntity);
	}
	
	
	/** 
	 * 新增对象
	 **/
	@RequestMapping(value = "",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
	@ResponseBody
	@CrossOrigin
	public R<SysPvlogEntity> save(@RequestBody SysPvlogEntity model)  {
		TPfSysPvlog pfSysPvlog = BeanUtil.copyProperties(model, TPfSysPvlog.class);
		pfSysPvlog.setAppId(UserUtils.getTenantId());
		sysPvlogService.save(pfSysPvlog);
		return R.ok(model);
	}
	
	
	/**
	 * 更新对象
	 * @return 
	 **/
	@RequestMapping(value = "",method = RequestMethod.PUT,produces = "application/json;charset=UTF-8")
	@ResponseBody
	@CrossOrigin
	public R<SysPvlogEntity> update(@RequestBody SysPvlogEntity model)  {
		TPfSysPvlog pfSysPvlog = BeanUtil.copyProperties(model, TPfSysPvlog.class);
		pfSysPvlog.setAppId(UserUtils.getTenantId());
		sysPvlogService.updateById(pfSysPvlog);
		return R.ok(model);
	}
	
	/**
	 * 删除对象
	 * @return 
	 **/
	@RequestMapping(value = "/{id}",method = RequestMethod.DELETE,produces = "application/json;charset=UTF-8")
	@ResponseBody
	@CrossOrigin
	public R<Boolean> delete(@PathVariable String id) {
		sysPvlogService.removeById(id);
		return R.ok();
	}
	
	/**
	 *  批量删除对象
	 * @return 
	 **/
	@RequestMapping(value = "deleteBatch",method = RequestMethod.DELETE,produces = "application/json;charset=UTF-8")
	@ResponseBody
	@CrossOrigin
	public R<Boolean> deleteBatch(String[] ids) {
		for (int i = 0; i < ids.length; i++) {
			sysPvlogService.removeById(ids[i]);
		}
		return R.ok();
	}
	
}



