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

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

@@ -12,6 +12,7 @@ import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.systemConfig.SystemConfigService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.service.userBusiness.UserBusinessService;
import com.jsh.erp.utils.PageUtils;
import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -94,6 +95,7 @@ public class DepotService {
public List<DepotEx> select(String name, Integer type, String remark)throws Exception {
List<DepotEx> list=null;
try{
PageUtils.startPage();
list=depotMapperEx.selectByConditionDepot(name, type, remark);
}catch(Exception e){
JshException.readFail(logger, e);

View File

@@ -12,6 +12,7 @@ import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.systemConfig.SystemConfigService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.PageUtils;
import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -81,6 +82,7 @@ public class FunctionService {
List<FunctionEx> list=null;
try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
PageUtils.startPage();
list = functionMapperEx.selectByConditionFunction(name, type);
}
}catch(Exception e){

View File

@@ -1,75 +0,0 @@
package com.jsh.erp.service.inOutItem;
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 = "inOutItem_component")
@InOutItemResource
public class InOutItemComponent implements ICommonQuery {
@Resource
private InOutItemService inOutItemService;
@Override
public Object selectOne(Long id) throws Exception {
return inOutItemService.getInOutItem(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getFunctionsList(map);
}
private List<?> getFunctionsList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type");
String remark = StringUtil.getInfo(search, "remark");
String order = QueryUtils.order(map);
return inOutItemService.select(name, type, remark, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type");
String remark = StringUtil.getInfo(search, "remark");
return inOutItemService.countInOutItem(name, type, remark);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
return inOutItemService.insertInOutItem(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return inOutItemService.updateInOutItem(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return inOutItemService.deleteInOutItem(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return inOutItemService.batchDeleteInOutItem(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return inOutItemService.checkIsNameExist(id, name);
}
}

View File

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

View File

@@ -14,6 +14,7 @@ import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.PageUtils;
import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -79,26 +80,17 @@ public class InOutItemService {
return list;
}
public List<InOutItem> select(String name, String type, String remark, int offset, int rows)throws Exception {
public List<InOutItem> select(String name, String type, String remark)throws Exception {
List<InOutItem> list=null;
try{
list=inOutItemMapperEx.selectByConditionInOutItem(name, type, remark, offset, rows);
PageUtils.startPage();
list=inOutItemMapperEx.selectByConditionInOutItem(name, type, remark);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public Long countInOutItem(String name, String type, String remark)throws Exception {
Long result=null;
try{
result=inOutItemMapperEx.countsByInOutItem(name, type, remark);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertInOutItem(JSONObject obj, HttpServletRequest request)throws Exception {
InOutItem inOutItem = JSONObject.parseObject(obj.toJSONString(), InOutItem.class);

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);

View File

@@ -1,72 +0,0 @@
package com.jsh.erp.service.msg;
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 = "msg_component")
@MsgResource
public class MsgComponent implements ICommonQuery {
@Resource
private MsgService msgService;
@Override
public Object selectOne(Long id) throws Exception {
return msgService.getMsg(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getMsgList(map);
}
private List<?> getMsgList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String order = QueryUtils.order(map);
String filter = QueryUtils.filter(map);
return msgService.select(name, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
public Long counts(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
return msgService.countMsg(name);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
return msgService.insertMsg(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return msgService.updateMsg(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return msgService.deleteMsg(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return msgService.batchDeleteMsg(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return msgService.checkIsNameExist(id, name);
}
}

View File

@@ -1,15 +0,0 @@
package com.jsh.erp.service.msg;
import com.jsh.erp.service.ResourceInfo;
import java.lang.annotation.*;
/**
* @author jishenghua qq752718920 2019-9-7 22:52:35
*/
@ResourceInfo(value = "msg")
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface MsgResource {
}

View File

@@ -14,6 +14,7 @@ import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.depotHead.DepotHeadService;
import com.jsh.erp.service.log.LogService;
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;
@@ -77,12 +78,13 @@ public class MsgService {
return list;
}
public List<MsgEx> select(String name, int offset, int rows)throws Exception {
public List<MsgEx> select(String name)throws Exception {
List<MsgEx> list=null;
try{
User userInfo = userService.getCurrentUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
list = msgMapperEx.selectByConditionMsg(userInfo.getId(), name, offset, rows);
PageUtils.startPage();
list = msgMapperEx.selectByConditionMsg(userInfo.getId(), name);
if (null != list) {
for (MsgEx msgEx : list) {
if (msgEx.getCreateTime() != null) {
@@ -100,22 +102,6 @@ public class MsgService {
return list;
}
public Long countMsg(String name)throws Exception {
Long result=null;
try{
User userInfo = userService.getCurrentUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
result = msgMapperEx.countsByMsg(userInfo.getId(), name);
}
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE, ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertMsg(JSONObject obj, HttpServletRequest request)throws Exception {
Msg msg = JSONObject.parseObject(obj.toJSONString(), Msg.class);

View File

@@ -15,6 +15,7 @@ import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.PageUtils;
import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -86,6 +87,7 @@ public class PersonService {
public List<Person> select(String name, String type)throws Exception {
List<Person> list=null;
try{
PageUtils.startPage();
list=personMapperEx.selectByConditionPerson(name, type);
}catch(Exception e){
JshException.readFail(logger, e);