package com.blueland.sys.app.web;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blueland.model.TPfApplicationDb;
import com.blueland.result.R;
import com.blueland.service.IAppDatabaseService;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.blueland.bo.AppDatabaseEntity;



@RestController
@RequestMapping(value = "/web/pfAppDatabase")
public class AppDatabaseRest {
	@Autowired
	IAppDatabaseService pfAppDatabaseService;
	
	
	/** 
	 * 搜索对象 
	 **/
	@RequestMapping(value = "",method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
	@ResponseBody
	@CrossOrigin
	public R<Page<AppDatabaseEntity>> list(AppDatabaseEntity pfAppDatabaseEntity) {
		Page<AppDatabaseEntity> page = this.pfAppDatabaseService.findPage(pfAppDatabaseEntity);
		return R.ok(page);
	}

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


	/** 
	 * 查看对象（支持多条件查询）
	 **/
	@RequestMapping(value = "get",method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
	@ResponseBody
	@CrossOrigin
	public R<TPfApplicationDb> get(AppDatabaseEntity model)  {
		TPfApplicationDb pfAppDatabaseEntity  = pfAppDatabaseService.queryOne(model);
		return R.ok(pfAppDatabaseEntity);
	}
	
	
	/** 
	 * 新增对象
	 **/
	@RequestMapping(value = "",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
	@ResponseBody
	@CrossOrigin
	public R<TPfApplicationDb> save(@RequestBody TPfApplicationDb model)  {
		pfAppDatabaseService.save(model);
		return R.ok(model);
	}
	
	
	/**
	 * 更新对象
	 * @return 
	 **/
	@RequestMapping(value = "",method = RequestMethod.PUT,produces = "application/json;charset=UTF-8")
	@ResponseBody
	@CrossOrigin
	public R<Boolean> update(@RequestBody TPfApplicationDb model)  {
		pfAppDatabaseService.updateById(model);
		return R.ok();
	}
	
	/**
	 * 删除对象
	 * @return 
	 **/
	@RequestMapping(value = "/{id}",method = RequestMethod.DELETE,produces = "application/json;charset=UTF-8")
	@ResponseBody
	@CrossOrigin
	public R<Boolean> delete(@PathVariable String id) {
		pfAppDatabaseService.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++) {
			pfAppDatabaseService.removeById(ids[i]);
		}
		return R.ok();
	}
	
}



