|
|
|
@ -4,15 +4,20 @@ package com.ruoyi.gysl.controller;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
|
import com.ruoyi.gysl.entity.Xmzsk;
|
|
|
|
|
import com.ruoyi.gysl.entity.request.XmzskPageReq;
|
|
|
|
|
import com.ruoyi.gysl.service.XmzskService;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@ -92,5 +97,49 @@ public class XmzskController extends BaseController {
|
|
|
|
|
public AjaxResult delete(@RequestParam("idList") List<Long> idList) {
|
|
|
|
|
return success(xmzskService.removeByIds(idList));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出项目数据
|
|
|
|
|
*/
|
|
|
|
|
// @PreAuthorize("@ss.hasAnyRoles('admin,common')")
|
|
|
|
|
@ApiOperation("导出项目数据")
|
|
|
|
|
@PostMapping("/exportInfo")
|
|
|
|
|
public void exportInfo(HttpServletResponse response,XmzskPageReq req) {
|
|
|
|
|
List<Xmzsk> pE = xmzskService.page(req);
|
|
|
|
|
ExcelUtil<Xmzsk> util = new ExcelUtil<>(Xmzsk.class);
|
|
|
|
|
util.exportExcel(response, pE, "项目知识库数据");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 模板信息
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("导出基本信息模板")
|
|
|
|
|
@PostMapping("/importTemplate")
|
|
|
|
|
public void importTemplate(HttpServletResponse response) {
|
|
|
|
|
ExcelUtil<Xmzsk> util = new ExcelUtil<>(Xmzsk.class);
|
|
|
|
|
util.importTemplateExcel(response, "项目知识库数据");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 项目知识库信息批量导入
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "项目知识库信息批量导入")
|
|
|
|
|
// @PreAuthorize("@ss.hasAnyRoles('admin,common')")
|
|
|
|
|
@PostMapping(value = "/import", consumes = "multipart/form-data")
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public AjaxResult importTemplateProject(@RequestPart("file") MultipartFile file) throws Exception {
|
|
|
|
|
ExcelUtil<Xmzsk> util = new ExcelUtil<>(Xmzsk.class);
|
|
|
|
|
List<Xmzsk> proList = util.importExcel(file.getInputStream());
|
|
|
|
|
StringBuilder successMsg = new StringBuilder();
|
|
|
|
|
if (proList == null || proList.isEmpty()) {
|
|
|
|
|
throw new ServiceException("项目知识库导入数据不能为空");
|
|
|
|
|
} else {
|
|
|
|
|
xmzskService.saveBatch(proList);
|
|
|
|
|
successMsg.append("导入成功");
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success(successMsg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|