package org.jeecg.modules.fbsViewAll.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringEscapeUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.fbsViewAll.entity.FbsViewAll;
import org.jeecg.modules.fbsViewAll.service.IFbsViewAllService;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;

import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;

 /**
 * @Title: Controller
 * @Description: 页面数据
 * @author： jeecg-boot
 * @date：   2020-10-31
 * @version： V1.0
 */
@RestController
@RequestMapping("/fbsViewAll/fbsViewAll")
@Slf4j
public class FbsViewAllController {
	@Autowired
	private IFbsViewAllService fbsViewAllService;
	
	/**
	 */
	@GetMapping(value = "/list")
	public Result<FbsViewAll> queryPageList() {
		Result<FbsViewAll> result = new Result<FbsViewAll>();
		QueryWrapper<FbsViewAll> fbsViewAll = new QueryWrapper<>();
		List<FbsViewAll> list = fbsViewAllService.list(fbsViewAll);
		if(list.size() < 1){
			result.setSuccess(true);
			result.setResult(null);
			return result;
		}
		result.setSuccess(true);
		result.setResult(list.get(0));
		return result;
	}
	
	/**
	  *   添加
	 * @return
	 */
	@RequestMapping(value = "/add")
	public Result<FbsViewAll> add(@RequestBody Map<String,Object> map) {
		Result<FbsViewAll> result = new Result<FbsViewAll>();
		try {
			fbsViewAllService.delAll();
			FbsViewAll fbsViewAll = new FbsViewAll();
			fbsViewAll.setAllFile(map.get("account").toString());
			fbsViewAllService.save(fbsViewAll);
			result.success("添加成功！");
		} catch (Exception e) {
			e.printStackTrace();
			log.info(e.getMessage());
			result.error500("操作失败");
		}
		return result;
	}

	/**
	  *   通过id删除
	 * @return
	 */
	@RequestMapping(value = "/delete")
	public Result<FbsViewAll> delete() {
		Result result = new Result();
		fbsViewAllService.delAll();
		result.success("删除成功!");
		return result;
	}

	 public static void main(String[] args) {
		 String str = StringEscapeUtils.unescapeJava("&lt;p&gt;【产品名称】艾酷维多种维生素锌软糖&lt;/p&gt;");
		 System.out.println(str);
		 String str2 = StringEscapeUtils.escapeHtml("<p>【产品名称】艾酷维多种维生素锌软糖</p>");
		 System.out.println(str2);
	 }
}
