mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package com.panzhihua.service_community.service.impl;
 
import javax.annotation.Resource;
 
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
 
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.dtos.PageDTO;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.shop.ShopOperLogVO;
import com.panzhihua.common.service.user.UserService;
import com.panzhihua.service_community.dao.ComShopOperLogDAO;
import com.panzhihua.service_community.model.dos.ComShopOperLogDO;
import com.panzhihua.service_community.service.ComShopOperLogService;
 
import lombok.extern.slf4j.Slf4j;
 
/**
 * @auther cedoo
 * @create 2021-4-17 10:51:12
 * @describe 日志服务
 */
@Slf4j
@Service
public class ComShopOperLogServiceImpl extends ServiceImpl<ComShopOperLogDAO, ComShopOperLogDO>
    implements ComShopOperLogService {
 
    @Resource
    private UserService userService;
 
    @Override
    public R saveLog(ShopOperLogVO shopOperLogVO) {
        if (shopOperLogVO == null) {
            return R.ok("500", "数据为空!");
        }
        ComShopOperLogDO theDo = new ComShopOperLogDO();
        BeanUtils.copyProperties(shopOperLogVO, theDo);
        this.baseMapper.insert(theDo);
        return R.ok();
    }
 
    @Override
    public R pageShopOperLog(PageDTO pageDTO) {
        Page page = new Page<>(pageDTO.getPageNum(), pageDTO.getPageSize());
        IPage<ComShopOperLogDO> comShopOperLogDOIPage =
            this.baseMapper.selectPage(page, new LambdaQueryWrapper<ComShopOperLogDO>()
                .orderByDesc(ComShopOperLogDO::getOperTime).eq(ComShopOperLogDO::getUserId, pageDTO.getUserId()));
 
        IPage<ShopOperLogVO> comShopOperLogVOIPage = comShopOperLogDOIPage.convert(comShopOperLogDO -> {
            ShopOperLogVO shopOperLogVO = new ShopOperLogVO();
            BeanUtils.copyProperties(comShopOperLogDO, shopOperLogVO);
            /**
             * 隐藏敏感信息
             */
            shopOperLogVO.setJsonResult("****");
            shopOperLogVO.setOperParam("****");
 
            String businessTypeName = "";
            switch (comShopOperLogDO.getBusinessType()) {
                case 1:
                    businessTypeName = "登录";
                    break;
                case 2:
                    businessTypeName = "修改密码";
                    break;
                case 3:
                    businessTypeName = "添加商品";
                    break;
                case 4:
                    businessTypeName = "编辑商品";
                    break;
                case 5:
                    businessTypeName = "下架商品";
                    break;
                case 6:
                    businessTypeName = "上架商品";
                    break;
                case 7:
                    businessTypeName = "删除商品";
                    break;
                case 8:
                    businessTypeName = "取消订单";
                    break;
                case 9:
                    businessTypeName = "发货";
                    break;
                case 10:
                    businessTypeName = "配送";
                    break;
                case 11:
                    businessTypeName = "查看订单详情";
                    break;
                case 12:
                    businessTypeName = "导出订单";
                    break;
                case 13:
                    businessTypeName = "导出资金流水";
                    break;
                default:
                    break;
            }
            shopOperLogVO.setBusinessName(businessTypeName);
 
            R<LoginUserInfoVO> usrInfo = userService.getUserInfoByUserId(comShopOperLogDO.getUserId() + "");
            if (R.isOk(usrInfo)) {
                LoginUserInfoVO loginUserInfoVO =
                    JSONObject.parseObject(JSONObject.toJSONString(usrInfo.getData()), LoginUserInfoVO.class);
                shopOperLogVO.setUserName(loginUserInfoVO.getName());
            }
            return shopOperLogVO;
        });
        return R.ok(comShopOperLogVOIPage);
    }
}