package com.wgcloud.service;
|
|
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageInfo;
|
import com.wgcloud.entity.FileSafe;
|
import com.wgcloud.mapper.FileSafeMapper;
|
import com.wgcloud.util.DateUtil;
|
import com.wgcloud.util.HostUtil;
|
import com.wgcloud.util.UUIDUtil;
|
import com.wgcloud.util.staticvar.StaticKeys;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @version v3.3
|
* @ClassName:FileSafeService.java
|
* @author: http://www.wgstart.com
|
* @date: 2021年9月21日
|
* @Description: FileSafeService.java
|
* @Copyright: 2019-2021 wgcloud. All rights reserved.
|
*/
|
@Service
|
public class FileSafeService {
|
|
public PageInfo selectByParams(Map<String, Object> params, int currPage, int pageSize) throws Exception {
|
PageHelper.startPage(currPage, pageSize);
|
List<FileSafe> list = fileSafeMapper.selectByParams(params);
|
PageInfo<FileSafe> pageInfo = new PageInfo<FileSafe>(list);
|
return pageInfo;
|
}
|
|
public void save(FileSafe FileSafe) throws Exception {
|
FileSafe.setId(UUIDUtil.getUUID());
|
FileSafe.setCreateTime(DateUtil.getNowTime());
|
if (!StringUtils.isEmpty(FileSafe.getFileSign())) {
|
FileSafe.setFileSign(FileSafe.getFileSign().trim());
|
}
|
fileSafeMapper.save(FileSafe);
|
}
|
|
public int deleteByHostName(Map<String, Object> map) throws Exception {
|
return fileSafeMapper.deleteByHostName(map);
|
}
|
|
@Transactional
|
public void saveRecord(List<FileSafe> recordList) throws Exception {
|
if (recordList.size() < 1) {
|
return;
|
}
|
for (FileSafe as : recordList) {
|
as.setId(UUIDUtil.getUUID());
|
}
|
fileSafeMapper.insertList(recordList);
|
}
|
|
public void downByHostName(List<String> recordList) throws Exception {
|
if (recordList.size() < 1) {
|
return;
|
}
|
fileSafeMapper.downByHostName(recordList);
|
}
|
|
public int countByParams(Map<String, Object> params) throws Exception {
|
return fileSafeMapper.countByParams(params);
|
}
|
|
@Transactional
|
public int deleteById(String[] id) throws Exception {
|
return fileSafeMapper.deleteById(id);
|
}
|
|
@Transactional
|
public void updateRecord(List<FileSafe> recordList) throws Exception {
|
if (recordList.size() < 1) {
|
return;
|
}
|
fileSafeMapper.updateList(recordList);
|
}
|
|
public void updateById(FileSafe FileSafe)
|
throws Exception {
|
fileSafeMapper.updateById(FileSafe);
|
}
|
|
public FileSafe selectById(String id) throws Exception {
|
return fileSafeMapper.selectById(id);
|
}
|
|
public List<FileSafe> selectAllByParams(Map<String, Object> params) throws Exception {
|
return fileSafeMapper.selectAllByParams(params);
|
}
|
|
/**
|
* 保存操作日志
|
*
|
* @param request 获取当前登录用户
|
* @param action 操作标识
|
*/
|
public void saveLog(HttpServletRequest request, String action, FileSafe fileSafe) {
|
if(null == fileSafe){
|
return;
|
}
|
logInfoService.save(HostUtil.getAccountByRequest(request).getAccount() + action + "文件防篡改监测信息:" + fileSafe.getHostname() + "," + fileSafe.getFileName(),
|
"文件名称:" + fileSafe.getFileName() + ",文件路径:" + fileSafe.getFilePath(), StaticKeys.LOG_XTCZ);
|
}
|
|
|
@Autowired
|
private FileSafeMapper fileSafeMapper;
|
@Autowired
|
private LogInfoService logInfoService;
|
|
|
}
|