vue版本上线

This commit is contained in:
季圣华
2021-04-07 23:53:57 +08:00
parent 76a0033a4e
commit f4ef5aa067
803 changed files with 171959 additions and 27 deletions

View File

@@ -0,0 +1,83 @@
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");
Integer userId = StringUtil.parseInteger(StringUtil.getInfo(search, "userId"));
String clientIp = StringUtil.getInfo(search, "clientIp");
Integer status = StringUtil.parseInteger(StringUtil.getInfo(search, "status"));
String beginTime = StringUtil.getInfo(search, "beginTime");
String endTime = StringUtil.getInfo(search, "endTime");
String content = StringUtil.getInfo(search, "content");
return logService.select(operation, userId, clientIp, status, 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");
Integer userId = StringUtil.parseInteger(StringUtil.getInfo(search, "userId"));
String clientIp = StringUtil.getInfo(search, "clientIp");
Integer status = StringUtil.parseInteger(StringUtil.getInfo(search, "status"));
String beginTime = StringUtil.getInfo(search, "beginTime");
String endTime = StringUtil.getInfo(search, "endTime");
String content = StringUtil.getInfo(search, "content");
return logService.countLog(operation, userId, clientIp, status, 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

@@ -0,0 +1,15 @@
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

@@ -0,0 +1,180 @@
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.StringUtil;
import com.jsh.erp.utils.Tools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import static com.jsh.erp.utils.Tools.getLocalIp;
@Service
public class LogService {
private Logger logger = LoggerFactory.getLogger(LogService.class);
@Resource
private LogMapper logMapper;
@Resource
private LogMapperEx logMapperEx;
@Resource
private UserService userService;
@Resource
private RedisService redisService;
public Log getLog(long id)throws Exception {
Log result=null;
try{
result=logMapper.selectByPrimaryKey(id);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public List<Log> getLog()throws Exception {
LogExample example = new LogExample();
List<Log> list=null;
try{
list=logMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<LogVo4List> select(String operation, Integer userId, String clientIp, Integer status, String beginTime, String endTime,
String content, int offset, int rows)throws Exception {
List<LogVo4List> list=null;
try{
list=logMapperEx.selectByConditionLog(operation, userId, clientIp, status, beginTime, endTime,
content, offset, rows);
if (null != list) {
for (LogVo4List log : list) {
log.setCreateTimeStr(Tools.getCenternTime(log.getCreateTime()));
}
}
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public Long countLog(String operation, Integer userId, String clientIp, Integer status, String beginTime, String endTime,
String content)throws Exception {
Long result=null;
try{
result=logMapperEx.countsByLog(operation, userId, clientIp, status, 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);
int result=0;
try{
result=logMapper.insertSelective(log);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateLog(JSONObject obj, HttpServletRequest request)throws Exception {
Log log = JSONObject.parseObject(obj.toJSONString(), Log.class);
int result=0;
try{
result=logMapper.updateByPrimaryKeySelective(log);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteLog(Long id, HttpServletRequest request)throws Exception {
int result=0;
try{
result=logMapper.deleteByPrimaryKey(id);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteLog(String ids, HttpServletRequest request)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
LogExample example = new LogExample();
example.createCriteria().andIdIn(idList);
int result=0;
try{
result=logMapper.deleteByExample(example);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
public void insertLog(String moduleName, String content, HttpServletRequest request)throws Exception{
try{
Long userId = userService.getUserId(request);
if(userId!=null) {
Log log = new Log();
log.setUserId(userId);
log.setOperation(moduleName);
log.setClientIp(getLocalIp(request));
log.setCreateTime(new Date());
Byte status = 0;
log.setStatus(status);
log.setContent(content);
logMapper.insertSelective(log);
}
}catch(Exception e){
JshException.writeFail(logger, e);
}
}
public void insertLogWithUserId(Long userId, Long tenantId, String moduleName, String content, HttpServletRequest request)throws Exception{
try{
if(userId!=null) {
Log log = new Log();
log.setUserId(userId);
log.setOperation(moduleName);
log.setClientIp(getLocalIp(request));
log.setCreateTime(new Date());
Byte status = 0;
log.setStatus(status);
log.setContent(content);
log.setTenantId(tenantId);
logMapper.insertSelective(log);
}
}catch(Exception e){
JshException.writeFail(logger, e);
}
}
}