zhuguifei
2025-04-28 442928123f63ee497d766f9a7a14f0a6ee067e25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package org.jeecg.modules.doc.service.impl;
 
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.IPUtils;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.modules.doc.constant.Constant;
import org.jeecg.modules.doc.dto.UploadFileDTO;
import org.jeecg.modules.doc.entity.DocFilePath;
import org.jeecg.modules.doc.entity.DocOperationHis;
import org.jeecg.modules.doc.mapper.DocOperationHisMapper;
import org.jeecg.modules.doc.service.IDocOperationHisService;
import org.springframework.stereotype.Service;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.Map;
 
/**
 * @Description: doc_operation_his
 * @Author: jeecg-boot
 * @Date:   2022-09-16
 * @Version: V1.0
 */
@Service
public class DocOperationHisServiceImpl extends ServiceImpl<DocOperationHisMapper, DocOperationHis> implements IDocOperationHisService {
 
    @Override
    public void saveHis(LoginUser user, DocFilePath filePath, int type) {
        DocOperationHis entity = new DocOperationHis();
        //获取request
        HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
        entity.setClientIp(IPUtils.getIpAddr(request));
        entity.setFileName(filePath.getFileName() + "." + filePath.getExtendName());
        entity.setFilePath(filePath.getFilePath());
        entity.setOperationTime(new Date());
        entity.setOperationType(String.valueOf(type));
        entity.setUserId(user.getId());
        entity.setUsername(user.getUsername());
 
        this.baseMapper.insert(entity);
    }
 
    @Override
    public void saveHis(LoginUser user, UploadFileDTO uploadFileDto, int type) {
        DocOperationHis entity = new DocOperationHis();
        //获取request
        HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
        entity.setClientIp(IPUtils.getIpAddr(request));
        entity.setFileName(uploadFileDto.getFilename());
        entity.setFilePath(uploadFileDto.getFilePath());
        entity.setOperationTime(new Date());
        entity.setOperationType(String.valueOf(type));
        entity.setUserId(user.getId());
        entity.setUsername(user.getUsername());
 
        this.baseMapper.insert(entity);
    }
 
    @Override
    public void saveHis(Map<String, String> byToken, DocFilePath userFile, int type) {
        DocOperationHis entity = new DocOperationHis();
        //获取request
        HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
        entity.setClientIp(IPUtils.getIpAddr(request));
        entity.setFileName(userFile.getFileName()+ "." + userFile.getExtendName());
        entity.setFilePath(userFile.getFilePath());
        entity.setOperationTime(new Date());
        entity.setOperationType(String.valueOf(type));
        entity.setUserId(byToken.get("sysUserId"));
        entity.setUsername(byToken.get("sysUserCode"));
 
        this.baseMapper.insert(entity);
    }
}