更新后端,采用Springboot+mybatis
This commit is contained in:
83
src/main/java/com/jsh/erp/service/log/LogComponent.java
Normal file
83
src/main/java/com/jsh/erp/service/log/LogComponent.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package com.jsh.erp.service.log;
|
||||
|
||||
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(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getUserList(map);
|
||||
}
|
||||
|
||||
private List<?> getUserList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String operation = StringUtil.getInfo(search, "operation");
|
||||
Integer usernameID = StringUtil.parseInteger(StringUtil.getInfo(search, "usernameID"));
|
||||
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 contentdetails = StringUtil.getInfo(search, "contentdetails");
|
||||
String order = QueryUtils.order(map);
|
||||
return logService.select(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails,
|
||||
QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String operation = StringUtil.getInfo(search, "operation");
|
||||
Integer usernameID = StringUtil.parseInteger(StringUtil.getInfo(search, "usernameID"));
|
||||
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 contentdetails = StringUtil.getInfo(search, "contentdetails");
|
||||
return logService.countLog(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return logService.insertLog(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return logService.updateLog(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return logService.deleteLog(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return logService.batchDeleteLog(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
15
src/main/java/com/jsh/erp/service/log/LogResource.java
Normal file
15
src/main/java/com/jsh/erp/service/log/LogResource.java
Normal 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", type = 25)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface LogResource {
|
||||
}
|
||||
68
src/main/java/com/jsh/erp/service/log/LogService.java
Normal file
68
src/main/java/com/jsh/erp/service/log/LogService.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.jsh.erp.service.log;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.Log;
|
||||
import com.jsh.erp.datasource.entities.LogExample;
|
||||
import com.jsh.erp.datasource.mappers.LogMapper;
|
||||
import com.jsh.erp.utils.ExceptionCodeConstants;
|
||||
import com.jsh.erp.utils.JshException;
|
||||
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 javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class LogService {
|
||||
private Logger logger = LoggerFactory.getLogger(LogService.class);
|
||||
@Resource
|
||||
private LogMapper logMapper;
|
||||
|
||||
public Log getLog(long id) {
|
||||
return logMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Log> getLog() {
|
||||
LogExample example = new LogExample();
|
||||
return logMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Log> select(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime,
|
||||
String contentdetails, int offset, int rows) {
|
||||
return logMapper.selectByConditionLog(operation, usernameID, clientIp, status, beginTime, endTime,
|
||||
contentdetails, offset, rows);
|
||||
}
|
||||
|
||||
public int countLog(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime,
|
||||
String contentdetails) {
|
||||
return logMapper.countsByLog(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails);
|
||||
}
|
||||
|
||||
public int insertLog(String beanJson, HttpServletRequest request) {
|
||||
Log log = JSONObject.parseObject(beanJson, Log.class);
|
||||
return logMapper.insertSelective(log);
|
||||
}
|
||||
|
||||
public int updateLog(String beanJson, Long id) {
|
||||
Log log = JSONObject.parseObject(beanJson, Log.class);
|
||||
log.setId(id);
|
||||
return logMapper.updateByPrimaryKeySelective(log);
|
||||
}
|
||||
|
||||
public int deleteLog(Long id) {
|
||||
return logMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteLog(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
LogExample example = new LogExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return logMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user