|
@@ -7,6 +7,7 @@ import com.gqy.common.core.domain.entity.SysUser;
|
|
|
import com.gqy.common.core.domain.model.LoginUser;
|
|
|
import com.gqy.common.core.text.Convert;
|
|
|
import com.gqy.common.enums.BusinessType;
|
|
|
+import com.gqy.common.utils.SecurityUtils;
|
|
|
import com.gqy.document.domain.vo.PageResult;
|
|
|
import com.gqy.document.domain.Document;
|
|
|
import com.gqy.document.service.IDocumentService;
|
|
@@ -14,15 +15,14 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import com.gqy.common.annotation.Log;
|
|
|
import com.gqy.common.core.controller.BaseController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -105,5 +105,59 @@ public class DcDocumentController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/searchlistDoc")
|
|
|
+ public @ResponseBody AjaxResultCQY searchlistDoc(@RequestBody Map maps){
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 获取请求参数
|
|
|
+ Integer page = (Integer) maps.get("page");
|
|
|
+ Integer pageSize =(Integer) maps.get("pageSize");
|
|
|
+ String title =(String) maps.get("title");
|
|
|
+ String category_id = (String) maps.get("category_id");
|
|
|
+
|
|
|
+ // 构建查询对象
|
|
|
+ Document document = new Document();
|
|
|
+ document.setTitle(title);
|
|
|
+ if (category_id != null && !"".equals(category_id)) {
|
|
|
+ document.setCategory_id(Long.valueOf(category_id));
|
|
|
+ }
|
|
|
+ // 获取当前登录用户信息
|
|
|
+ Long loginUserId = SecurityUtils.getUserId();
|
|
|
+ // 判断是否为管理员
|
|
|
+ boolean isAdmin = SecurityUtils.isAdmin(loginUserId);
|
|
|
+
|
|
|
+ // 设置权限过滤
|
|
|
+ if (isAdmin) {
|
|
|
+ document.getParams().put("is_admin", true);
|
|
|
+ } else {
|
|
|
+ document.getParams().put("is_admin", false);
|
|
|
+ document.getParams().put("login_user_id", loginUserId);
|
|
|
+ }
|
|
|
+ PageResult pageResult = documentService.searchlistDoc(page, pageSize, document);
|
|
|
+
|
|
|
+ // 6. 返回成功结果
|
|
|
+ return AjaxResultCQY.success("查询成功", pageResult);
|
|
|
+ }catch(Exception e){
|
|
|
+ log.error("查询文档列表失败", e);
|
|
|
+ return AjaxResultCQY.success("查询成功", new PageResult());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取文档详细信息
|
|
|
+ */
|
|
|
+ @PostMapping("/info")
|
|
|
+ public @ResponseBody AjaxResultCQY info(@RequestBody Map map) {
|
|
|
+ Integer id = (Integer) map.get("id");
|
|
|
+ if (id == null || "".equals(id)) {
|
|
|
+ return AjaxResultCQY.error("文档ID不能为空");
|
|
|
+ }
|
|
|
+ Document document = documentService.info(Long.valueOf(id));
|
|
|
+ if (document == null) {
|
|
|
+ return AjaxResultCQY.error("文档不存在或无权限访问");
|
|
|
+ }
|
|
|
+ return AjaxResultCQY.success(document);
|
|
|
+ }
|
|
|
|
|
|
}
|