Merge pull request '工作项负责人排序+项目仪表盘中动态记录补充知识库类型' (#948) from wanjia9506/microservices:dev_weeklyReport_refact into master
This commit is contained in:
commit
4f306a4b19
|
@ -7,9 +7,9 @@ import com.microservices.system.api.domain.SysLogininfor;
|
||||||
import com.microservices.system.api.domain.SysOperLog;
|
import com.microservices.system.api.domain.SysOperLog;
|
||||||
import com.microservices.system.api.factory.RemoteLogFallbackFactory;
|
import com.microservices.system.api.factory.RemoteLogFallbackFactory;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志服务
|
* 日志服务
|
||||||
|
@ -38,4 +38,20 @@ public interface RemoteLogService
|
||||||
*/
|
*/
|
||||||
@PostMapping("/logininfor")
|
@PostMapping("/logininfor")
|
||||||
public R<Boolean> saveLogininfor(@RequestBody SysLogininfor sysLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
public R<Boolean> saveLogininfor(@RequestBody SysLogininfor sysLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取操作日志列表
|
||||||
|
*
|
||||||
|
* @param title 日志标题
|
||||||
|
* @param operUrl 操作地址
|
||||||
|
* @param status 操作状态
|
||||||
|
* @param topN 获取最新N条
|
||||||
|
* @return 操作日志列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/operlog/latest")
|
||||||
|
R<List<SysOperLog>> getLatestOperLogList(@RequestParam(value = "title", required = false) String title,
|
||||||
|
@RequestParam(value = "operUrl", required = false) String operUrl,
|
||||||
|
@RequestParam(value = "status", required = false) Integer status,
|
||||||
|
@RequestParam(value = "topN") Integer topN,
|
||||||
|
@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志服务降级处理
|
* 日志服务降级处理
|
||||||
*
|
*
|
||||||
|
@ -36,6 +38,12 @@ public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogServic
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<List<SysOperLog>> getLatestOperLogList(String title, String operUrl, Integer status, Integer topN, String source)
|
||||||
|
{
|
||||||
|
return R.fail("获取最新操作日志失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||||
|
|
||||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
|
||||||
|
public static String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
|
||||||
|
|
||||||
private static String[] parsePatterns = {
|
private static String[] parsePatterns = {
|
||||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||||
|
@ -265,4 +267,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||||
cal.add(Calendar.DATE, -7 * times);
|
cal.add(Calendar.DATE, -7 * times);
|
||||||
return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, cal.getTime());
|
return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, cal.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long dateTimeToUnix(Date date) {
|
||||||
|
// date.getTime() 返回当前 Date 对象表示的毫秒数,除以 1000 后得到以秒为单位的时间戳,即 10 位时间戳
|
||||||
|
return date.getTime() / 1000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,9 @@ public class PmsDocumentController extends BaseController {
|
||||||
@ApiOperation(value = "删除项目管理-文档库")
|
@ApiOperation(value = "删除项目管理-文档库")
|
||||||
public AjaxResult remove(@PathVariable Long[] ids,
|
public AjaxResult remove(@PathVariable Long[] ids,
|
||||||
@ApiParam("企业id") @RequestParam(name = "enterpriseId") Long enterpriseId,
|
@ApiParam("企业id") @RequestParam(name = "enterpriseId") Long enterpriseId,
|
||||||
@ApiParam("项目id") @RequestParam(name = "pmsProjectId", defaultValue = "0") Long pmsProjectId) {
|
@ApiParam("项目id") @RequestParam(name = "pmsProjectId", defaultValue = "0") Long pmsProjectId,
|
||||||
|
@ApiParam("文档名称,多个逗号分隔") @RequestParam(name = "names", required = false) String names,
|
||||||
|
@ApiParam("文件类型 1-文档目录 2-文档 3-附件 4-wiki库,多个逗号分隔") @RequestParam(name = "docTypes", required = false) String docTypes) {
|
||||||
return toAjax(pmsDocumentService.deletePmsDocumentByIds(ids, enterpriseId, pmsProjectId));
|
return toAjax(pmsDocumentService.deletePmsDocumentByIds(ids, enterpriseId, pmsProjectId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,15 @@ public enum PmsDocumentType {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getNameByKey(Integer docType) {
|
||||||
|
for (PmsDocumentType value : PmsDocumentType.values()) {
|
||||||
|
if (value.getKey() == docType) {
|
||||||
|
return value.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public int getKey() {
|
public int getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class PmsProjectIssuesSearchVo {
|
||||||
@ApiModelProperty(value = "负责人id")
|
@ApiModelProperty(value = "负责人id")
|
||||||
private String assignerId;
|
private String assignerId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "排序方式: issues.updated_on 更新时间 issues.created_on 创建时间 issue_priorities.position 优先级")
|
@ApiModelProperty(value = "排序方式: issues.updated_on 更新时间 issues.created_on 创建时间 issue_priorities.position 优先级 assigners 负责人(昵称/login首字母排序)")
|
||||||
private String sortBy;
|
private String sortBy;
|
||||||
|
|
||||||
@ApiModelProperty(value = "排序方向:asc 正序 desc 倒序")
|
@ApiModelProperty(value = "排序方向:asc 正序 desc 倒序")
|
||||||
|
|
|
@ -303,13 +303,17 @@ public class PmsProjectIssuesService {
|
||||||
|
|
||||||
private JSONObject genDeleteUserJsonObject() {
|
private JSONObject genDeleteUserJsonObject() {
|
||||||
SysUser deleteUser = SysUser.genDeleteUser();
|
SysUser deleteUser = SysUser.genDeleteUser();
|
||||||
JSONObject deleteUserJSONObject = new JSONObject();
|
return getUserJsonObject(deleteUser.getGitlinkUserId(), deleteUser.getAvatar(), deleteUser.getUserName(), deleteUser.getNickName());
|
||||||
deleteUserJSONObject.put("id", deleteUser.getGitlinkUserId());
|
}
|
||||||
deleteUserJSONObject.put("image_url", deleteUser.getAvatar());
|
|
||||||
deleteUserJSONObject.put("login", deleteUser.getUserName());
|
public JSONObject getUserJsonObject(Long gitlinkUserId, String avatar, String userName, String nickName) {
|
||||||
deleteUserJSONObject.put("name", deleteUser.getNickName());
|
JSONObject user = new JSONObject();
|
||||||
deleteUserJSONObject.put("type", "User");
|
user.put("id", gitlinkUserId);
|
||||||
return deleteUserJSONObject;
|
user.put("image_url", avatar);
|
||||||
|
user.put("login", userName);
|
||||||
|
user.put("name", nickName);
|
||||||
|
user.put("type", "User");
|
||||||
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setIssueAssignersState(JSONObject issueResult, HashMap<Long, String> gitlinkUserNickNameMap) {
|
private void setIssueAssignersState(JSONObject issueResult, HashMap<Long, String> gitlinkUserNickNameMap) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.microservices.pms.project.service.impl;
|
package com.microservices.pms.project.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.microservices.common.core.constant.HttpStatus;
|
import com.microservices.common.core.constant.HttpStatus;
|
||||||
import com.microservices.common.core.constant.SecurityConstants;
|
import com.microservices.common.core.constant.SecurityConstants;
|
||||||
|
@ -10,9 +11,13 @@ import com.microservices.common.core.utils.StringUtils;
|
||||||
import com.microservices.common.core.utils.bean.BeanUtils;
|
import com.microservices.common.core.utils.bean.BeanUtils;
|
||||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||||
import com.microservices.common.httpClient.util.GitLinkRequestHelper;
|
import com.microservices.common.httpClient.util.GitLinkRequestHelper;
|
||||||
|
import com.microservices.common.log.enums.BusinessType;
|
||||||
import com.microservices.pms.common.service.IPmsCommonService;
|
import com.microservices.pms.common.service.IPmsCommonService;
|
||||||
|
import com.microservices.pms.document.domain.PmsDocument;
|
||||||
|
import com.microservices.pms.document.mapper.PmsDocumentMapper;
|
||||||
import com.microservices.pms.enterprise.domain.PmsEnterprise;
|
import com.microservices.pms.enterprise.domain.PmsEnterprise;
|
||||||
import com.microservices.pms.enterprise.service.IPmsEnterpriseService;
|
import com.microservices.pms.enterprise.service.IPmsEnterpriseService;
|
||||||
|
import com.microservices.pms.enums.PmsDocumentType;
|
||||||
import com.microservices.pms.product.domain.PmsProduct;
|
import com.microservices.pms.product.domain.PmsProduct;
|
||||||
import com.microservices.pms.product.service.IPmsProductService;
|
import com.microservices.pms.product.service.IPmsProductService;
|
||||||
import com.microservices.pms.project.domain.PmsProject;
|
import com.microservices.pms.project.domain.PmsProject;
|
||||||
|
@ -27,11 +32,15 @@ import com.microservices.pms.project.service.PmsProjectIssuesService;
|
||||||
import com.microservices.pms.utils.PmsGitLinkRequestUrl;
|
import com.microservices.pms.utils.PmsGitLinkRequestUrl;
|
||||||
import com.microservices.pms.utils.PmsUtils;
|
import com.microservices.pms.utils.PmsUtils;
|
||||||
import com.microservices.system.api.RemoteDeptService;
|
import com.microservices.system.api.RemoteDeptService;
|
||||||
|
import com.microservices.system.api.RemoteLogService;
|
||||||
import com.microservices.system.api.RemoteNoticeService;
|
import com.microservices.system.api.RemoteNoticeService;
|
||||||
import com.microservices.system.api.domain.SimpleSysUser;
|
import com.microservices.system.api.domain.SimpleSysUser;
|
||||||
import com.microservices.system.api.domain.SysNotice;
|
import com.microservices.system.api.domain.SysNotice;
|
||||||
|
import com.microservices.system.api.domain.SysOperLog;
|
||||||
import com.microservices.system.api.domain.SysUser;
|
import com.microservices.system.api.domain.SysUser;
|
||||||
import com.microservices.system.api.utils.FeignUtils;
|
import com.microservices.system.api.utils.FeignUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -97,6 +106,13 @@ public class PmsProjectServiceImpl implements IPmsProjectService {
|
||||||
@Resource
|
@Resource
|
||||||
private PmsProjectTestReportMapper pmsProjectTestReportMapper;
|
private PmsProjectTestReportMapper pmsProjectTestReportMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RemoteLogService remoteLogService;
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(PmsProjectServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
private PmsDocumentMapper pmsDocumentMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询项目
|
* 查询项目
|
||||||
*
|
*
|
||||||
|
@ -481,7 +497,7 @@ public class PmsProjectServiceImpl implements IPmsProjectService {
|
||||||
selectAndCheckPmsProjectById(pmProjectId);
|
selectAndCheckPmsProjectById(pmProjectId);
|
||||||
JSONObject result = gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_OPERATE_JOURNALS(pmProjectId));
|
JSONObject result = gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_OPERATE_JOURNALS(pmProjectId));
|
||||||
//todo 获取项目其他模块操作记录,和项目动态合并,取top10
|
//todo 获取项目其他模块操作记录,和项目动态合并,取top10
|
||||||
return result.getJSONObject(DATA_KEY);
|
return mergeProjectDocumentDynamics(result, pmProjectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -545,4 +561,144 @@ public class PmsProjectServiceImpl implements IPmsProjectService {
|
||||||
return pmsEnterpriseService.getUserListByPerms(enterpriseIdentifier, search, UserConstants.PMS_PERMS_PROJECT_EDIT);
|
return pmsEnterpriseService.getUserListByPerms(enterpriseIdentifier, search, UserConstants.PMS_PERMS_PROJECT_EDIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JSONObject mergeProjectDocumentDynamics(JSONObject result, Long pmProjectId) {
|
||||||
|
try {
|
||||||
|
JSONObject data = result.getJSONObject(DATA_KEY);
|
||||||
|
JSONArray projectDynamics = data.getJSONArray("journals");
|
||||||
|
Integer totalCount = data.getInteger("total_count");
|
||||||
|
JSONArray projectDocumentDynamics = getDocumentDynamics(pmProjectId);
|
||||||
|
|
||||||
|
totalCount += projectDocumentDynamics.size();
|
||||||
|
projectDynamics.addAll(projectDocumentDynamics);
|
||||||
|
getTopNOrderedDynamics(projectDynamics, 10);
|
||||||
|
|
||||||
|
data.put("journals", projectDynamics);
|
||||||
|
data.put("total_count", totalCount);
|
||||||
|
return data;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 记录错误日志
|
||||||
|
logger.error("合并项目动态和文档动态时发生错误", e);
|
||||||
|
// 返回从 result 中获取的 data,可能包含部分数据或默认结构
|
||||||
|
return result.getJSONObject(DATA_KEY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private JSONArray getDocumentDynamics(Long pmProjectId) {
|
||||||
|
PmsEnterprise pmsEnterprise = pmsEnterpriseService.getEnterpriseByProjectId(pmProjectId);
|
||||||
|
String operUrl = String.format("/%s/document", pmsEnterprise.getEnterpriseIdentifier());
|
||||||
|
|
||||||
|
List<SysOperLog> sysOperLogList = FeignUtils.getReturnData(
|
||||||
|
remoteLogService.getLatestOperLogList("项目管理-文档库", operUrl, 0, 10, SecurityConstants.INNER));
|
||||||
|
return sysOperLogList != null ? transferDocumentDynamics(sysOperLogList) : new JSONArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private JSONArray transferDocumentDynamics(List<SysOperLog> sysOperLogList) {
|
||||||
|
JSONArray journals = new JSONArray();
|
||||||
|
for (SysOperLog log : sysOperLogList) {
|
||||||
|
JSONObject documentDynamics = new JSONObject();
|
||||||
|
JSONObject operParam = JSONObject.parseObject(log.getOperParam());
|
||||||
|
Integer pmsProjectId = operParam.getInteger("pmsProjectId");
|
||||||
|
if (pmsProjectId == null || pmsProjectId == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Long documentId = operParam.getLong("id");
|
||||||
|
String docName = operParam.getString("name");
|
||||||
|
Integer docType = operParam.getInteger("docType");
|
||||||
|
Integer isTop = operParam.getInteger("isTop");
|
||||||
|
Integer businessType = log.getBusinessType();
|
||||||
|
|
||||||
|
// 处理时间字段
|
||||||
|
Date operTime = log.getOperTime();
|
||||||
|
Long operTimeUnix = DateUtils.dateTimeToUnix(operTime);
|
||||||
|
String formattedTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM, operTime);
|
||||||
|
documentDynamics.put("created_at", formattedTime);
|
||||||
|
documentDynamics.put("updated_at", formattedTime);
|
||||||
|
documentDynamics.put("created_time", operTimeUnix);
|
||||||
|
documentDynamics.put("updated_time", operTimeUnix);
|
||||||
|
|
||||||
|
// 构建用户信息
|
||||||
|
JSONObject user = buildUserJson(pmsCommonService.getSimpleSysUserByUsername(log.getOperName()));
|
||||||
|
documentDynamics.put("user", user);
|
||||||
|
|
||||||
|
// 处理操作内容
|
||||||
|
String operateContent;
|
||||||
|
if (BusinessType.DELETE.ordinal() == businessType) {
|
||||||
|
String docNames = operParam.getString("names");
|
||||||
|
String docTypes = operParam.getString("docTypes");
|
||||||
|
operateContent = generateBatchDeleteOperateContent(docNames, docTypes);
|
||||||
|
} else {
|
||||||
|
if (isTop != null && isTop == 1) {
|
||||||
|
PmsDocument pmsDocument = pmsDocumentMapper.selectPmsDocumentById(documentId);
|
||||||
|
if (pmsDocument != null) {
|
||||||
|
docName = pmsDocument.getName();
|
||||||
|
docType = pmsDocument.getDocType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (docName == null || docType == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
operateContent = generateOperateContent(businessType, docType, docName, isTop);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加到结果集
|
||||||
|
if (operateContent != null) {
|
||||||
|
documentDynamics.put("operate_content", operateContent);
|
||||||
|
journals.add(documentDynamics);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return journals;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String generateBatchDeleteOperateContent(String docNames, String docTypes) {
|
||||||
|
if (docNames == null || docTypes == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String[] nameArray = docNames.split(",");
|
||||||
|
String[] typeArray = docTypes.split(",");
|
||||||
|
if (nameArray.length != typeArray.length) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("在知识库删除了");
|
||||||
|
for (int i = 0; i < nameArray.length; i++) {
|
||||||
|
if (i > 0) {
|
||||||
|
sb.append(" , ");
|
||||||
|
}
|
||||||
|
sb.append("<b>").append(nameArray[i]).append("</b>");
|
||||||
|
sb.append(getNameByKey(Integer.parseInt(typeArray[i])));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getNameByKey(Integer docType) {
|
||||||
|
return PmsDocumentType.getNameByKey(docType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String generateOperateContent(Integer businessType, Integer docType, String docName, Integer isTop) {
|
||||||
|
String docTypeName = getNameByKey(docType);
|
||||||
|
switch (businessType) {
|
||||||
|
case 1: //新增
|
||||||
|
return String.format("在知识库%s了<b>%s</b>%s",
|
||||||
|
docType == PmsDocumentType.ATTACHMENT.getKey() ? "上传" : "新建", docName, docTypeName);
|
||||||
|
case 2: //更新
|
||||||
|
return String.format("在知识库%s了<b>%s</b>%s", (isTop != null && isTop == 1) ? "置顶" : "更新", docName, docTypeName);
|
||||||
|
case 3: //删除
|
||||||
|
return String.format("在知识库删除了<b>%s</b>%s", docName, docTypeName);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private JSONObject buildUserJson(SimpleSysUser simpleSysUser) {
|
||||||
|
return pmsProjectIssuesService.getUserJsonObject(simpleSysUser.getGitlinkUserId(), simpleSysUser.getAvatar(), simpleSysUser.getUserName(), simpleSysUser.getNickName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getTopNOrderedDynamics(JSONArray projectDynamics, int limit) {
|
||||||
|
List<JSONObject> dynamicsList = projectDynamics.toJavaList(JSONObject.class);
|
||||||
|
dynamicsList.sort(Comparator.comparingLong(o -> -o.getLong("created_time")));
|
||||||
|
projectDynamics.clear();
|
||||||
|
projectDynamics.addAll(dynamicsList.subList(0, Math.min(dynamicsList.size(), limit)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.microservices.system.controller;
|
package com.microservices.system.controller;
|
||||||
|
|
||||||
|
import com.microservices.common.core.domain.R;
|
||||||
import com.microservices.common.core.utils.poi.ExcelUtil;
|
import com.microservices.common.core.utils.poi.ExcelUtil;
|
||||||
import com.microservices.common.core.web.controller.BaseController;
|
import com.microservices.common.core.web.controller.BaseController;
|
||||||
import com.microservices.common.core.web.domain.AjaxResult;
|
import com.microservices.common.core.web.domain.AjaxResult;
|
||||||
|
@ -10,6 +11,7 @@ import com.microservices.common.security.annotation.InnerAuth;
|
||||||
import com.microservices.common.security.annotation.RequiresPermissions;
|
import com.microservices.common.security.annotation.RequiresPermissions;
|
||||||
import com.microservices.system.api.domain.SysOperLog;
|
import com.microservices.system.api.domain.SysOperLog;
|
||||||
import com.microservices.system.service.ISysOperLogService;
|
import com.microservices.system.service.ISysOperLogService;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@ -70,4 +72,17 @@ public class SysOperlogController extends BaseController
|
||||||
{
|
{
|
||||||
return toAjax(operLogService.insertOperlog(operLog));
|
return toAjax(operLogService.insertOperlog(operLog));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 内部服务调用,获取最新N条日志
|
||||||
|
*/
|
||||||
|
@InnerAuth
|
||||||
|
@GetMapping("/latest")
|
||||||
|
public R<List<SysOperLog>> latestList(@RequestParam(value = "title", required = false) String title,
|
||||||
|
@RequestParam(value = "operUrl", required = false) String operUrl,
|
||||||
|
@RequestParam(value = "status", required = false) Integer status,
|
||||||
|
@RequestParam(value = "topN") Integer topN)
|
||||||
|
{
|
||||||
|
return R.ok(operLogService.selectLatestOperLogList(title, operUrl, status, topN));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.microservices.system.mapper;
|
package com.microservices.system.mapper;
|
||||||
|
|
||||||
import com.microservices.system.api.domain.SysOperLog;
|
import com.microservices.system.api.domain.SysOperLog;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -46,4 +47,6 @@ public interface SysOperLogMapper
|
||||||
* 清空操作日志
|
* 清空操作日志
|
||||||
*/
|
*/
|
||||||
public void cleanOperLog();
|
public void cleanOperLog();
|
||||||
|
|
||||||
|
List<SysOperLog> selectLatestOperLogList(@Param("title") String title, @Param("operUrl") String operUrl , @Param("status") Integer status, @Param("topN") Integer topN);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,4 +47,6 @@ public interface ISysOperLogService
|
||||||
* 清空操作日志
|
* 清空操作日志
|
||||||
*/
|
*/
|
||||||
public void cleanOperLog();
|
public void cleanOperLog();
|
||||||
|
|
||||||
|
List<SysOperLog> selectLatestOperLogList(String title, String operUrl , Integer status, Integer topN);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,4 +75,9 @@ public class SysOperLogServiceImpl implements ISysOperLogService
|
||||||
{
|
{
|
||||||
operLogMapper.cleanOperLog();
|
operLogMapper.cleanOperLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysOperLog> selectLatestOperLogList(String title, String operUrl , Integer status, Integer topN) {
|
||||||
|
return operLogMapper.selectLatestOperLogList(title, operUrl, status, topN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<include refid="selectOperLogVo"/>
|
<include refid="selectOperLogVo"/>
|
||||||
where oper_id = #{operId}
|
where oper_id = #{operId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectLatestOperLogList" resultMap="SysOperLogResult">
|
||||||
|
<include refid="selectOperLogVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="title != null and title != ''">
|
||||||
|
AND title like concat('%', #{title}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
AND status = #{status}
|
||||||
|
</if>
|
||||||
|
<if test="operUrl != null and operUrl != ''">
|
||||||
|
AND oper_url like concat(#{operUrl}, '%')
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by oper_id desc
|
||||||
|
limit #{topN}
|
||||||
|
</select>
|
||||||
|
|
||||||
<update id="cleanOperLog">
|
<update id="cleanOperLog">
|
||||||
truncate table sys_oper_log
|
truncate table sys_oper_log
|
||||||
</update>
|
</update>
|
||||||
|
|
Loading…
Reference in New Issue