|
@@ -1,34 +1,21 @@
|
|
|
package org.jeecg.modules.ctop.controller;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.TagInfo;
|
|
|
+import cn.com.ctop.common.module.model.TagInfoTreeModel;
|
|
|
import cn.com.ctop.common.module.service.ITagInfoService;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
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.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
-import org.jeecg.common.util.oConvertUtils;
|
|
|
-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.jeecg.modules.system.service.ISysDepartService;
|
|
|
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 javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
-import java.net.URLDecoder;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 标签信息
|
|
@@ -155,71 +142,18 @@ public class TagInfoController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 导出excel
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- */
|
|
|
- @RequestMapping(value = "/exportXls")
|
|
|
- public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
|
|
- // Step.1 组装查询条件
|
|
|
- QueryWrapper<TagInfo> queryWrapper = null;
|
|
|
- try {
|
|
|
- String paramsStr = request.getParameter("paramsStr");
|
|
|
- if (oConvertUtils.isNotEmpty(paramsStr)) {
|
|
|
- String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
|
|
- TagInfo tagInfo = JSON.parseObject(deString, TagInfo.class);
|
|
|
- queryWrapper = QueryGenerator.initQueryWrapper(tagInfo, request.getParameterMap());
|
|
|
- }
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- //Step.2 AutoPoi 导出Excel
|
|
|
- ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
- List<TagInfo> pageList = tagInfoService.list(queryWrapper);
|
|
|
- //导出文件名称
|
|
|
- mv.addObject(NormalExcelConstants.FILE_NAME, "标签信息列表");
|
|
|
- mv.addObject(NormalExcelConstants.CLASS, TagInfo.class);
|
|
|
- mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("标签信息列表数据", "导出人:Jeecg", "导出信息"));
|
|
|
- mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
|
|
- return mv;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过excel导入数据
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
- public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
- MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
|
- Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
|
|
- for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
|
|
- MultipartFile file = entity.getValue();
|
|
|
- ImportParams params = new ImportParams();
|
|
|
- params.setTitleRows(2);
|
|
|
- params.setHeadRows(1);
|
|
|
- params.setNeedSave(true);
|
|
|
- try {
|
|
|
- List<TagInfo> listTagInfos = ExcelImportUtil.importExcel(file.getInputStream(), TagInfo.class, params);
|
|
|
- tagInfoService.saveBatch(listTagInfos);
|
|
|
- return Result.ok("文件导入成功!数据行数:" + listTagInfos.size());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(e.getMessage(),e);
|
|
|
- return Result.error("文件导入失败:"+e.getMessage());
|
|
|
- } finally {
|
|
|
- try {
|
|
|
- file.getInputStream().close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return Result.ok("文件导入失败!");
|
|
|
- }
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ISysDepartService sysDepartService;
|
|
|
+ @RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
|
|
|
+ public Result<List<TagInfoTreeModel>> queryTreeList() {
|
|
|
+ Result<List<TagInfoTreeModel>> result = new Result<>();
|
|
|
+ try {
|
|
|
+ List<TagInfoTreeModel> list = tagInfoService.queryTreeList();
|
|
|
+ result.setResult(list);
|
|
|
+ result.setSuccess(true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|