给日志、菜单等页面优化接口

This commit is contained in:
jishenghua
2025-02-23 09:54:00 +08:00
parent a73a8d2db2
commit db090f8dd5
22 changed files with 275 additions and 431 deletions

View File

@@ -1,85 +0,0 @@
package com.jsh.erp.service.log;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.service.ICommonQuery;
import com.jsh.erp.utils.Constants;
import com.jsh.erp.utils.QueryUtils;
import com.jsh.erp.utils.StringUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@Service(value = "log_component")
@LogResource
public class LogComponent implements ICommonQuery {
@Resource
private LogService logService;
@Override
public Object selectOne(Long id) throws Exception {
return logService.getLog(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getLogList(map);
}
private List<?> getLogList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String operation = StringUtil.getInfo(search, "operation");
String userInfo = StringUtil.getInfo(search, "userInfo");
String clientIp = StringUtil.getInfo(search, "clientIp");
String tenantLoginName = StringUtil.getInfo(search, "tenantLoginName");
String tenantType = StringUtil.getInfo(search, "tenantType");
String beginTime = StringUtil.getInfo(search, "beginTime");
String endTime = StringUtil.getInfo(search, "endTime");
String content = StringUtil.getInfo(search, "content");
return logService.select(operation, userInfo, clientIp, tenantLoginName, tenantType, beginTime, endTime, content,
QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String operation = StringUtil.getInfo(search, "operation");
String userInfo = StringUtil.getInfo(search, "userInfo");
String clientIp = StringUtil.getInfo(search, "clientIp");
String tenantLoginName = StringUtil.getInfo(search, "tenantLoginName");
String tenantType = StringUtil.getInfo(search, "tenantType");
String beginTime = StringUtil.getInfo(search, "beginTime");
String endTime = StringUtil.getInfo(search, "endTime");
String content = StringUtil.getInfo(search, "content");
return logService.countLog(operation, userInfo, clientIp, tenantLoginName, tenantType, beginTime, endTime, content);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
return logService.insertLog(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return logService.updateLog(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return logService.deleteLog(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return logService.batchDeleteLog(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return 0;
}
}

View File

@@ -1,15 +0,0 @@
package com.jsh.erp.service.log;
import com.jsh.erp.service.ResourceInfo;
import java.lang.annotation.*;
/**
* @author jishenghua qq752718920 2018-10-7 15:26:27
*/
@ResourceInfo(value = "log")
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface LogResource {
}

View File

@@ -2,17 +2,15 @@ package com.jsh.erp.service.log;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.Log;
import com.jsh.erp.datasource.entities.LogExample;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.LogMapper;
import com.jsh.erp.datasource.mappers.LogMapperEx;
import com.jsh.erp.datasource.vo.LogVo4List;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.redis.RedisService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.PageUtils;
import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.Tools;
import org.slf4j.Logger;
@@ -64,13 +62,14 @@ public class LogService {
}
public List<LogVo4List> select(String operation, String userInfo, String clientIp, String tenantLoginName, String tenantType,
String beginTime, String endTime, String content, int offset, int rows)throws Exception {
String beginTime, String endTime, String content)throws Exception {
List<LogVo4List> list=null;
try{
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
PageUtils.startPage();
list=logMapperEx.selectByConditionLog(operation, userInfo, clientIp, tenantLoginName, tenantType, beginTime, endTime,
content, offset, rows);
content);
if (null != list) {
for (LogVo4List log : list) {
log.setCreateTimeStr(Tools.getCenternTime(log.getCreateTime()));
@@ -82,19 +81,6 @@ public class LogService {
return list;
}
public Long countLog(String operation, String userInfo, String clientIp, String tenantLoginName, String tenantType,
String beginTime, String endTime, String content)throws Exception {
Long result=null;
try{
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
result=logMapperEx.countsByLog(operation, userInfo, clientIp, tenantLoginName, tenantType, beginTime, endTime, content);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertLog(JSONObject obj, HttpServletRequest request) throws Exception{
Log log = JSONObject.parseObject(obj.toJSONString(), Log.class);