zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java
@@ -1,9 +1,11 @@
package com.ruoyi.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.JsonParser;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.MapUtils;
@@ -17,6 +19,7 @@
import com.ruoyi.service.ZAuthorityService;
import com.ruoyi.service.ZInfoUserService;
import com.ruoyi.service.ZfCollectionService;
import com.ruoyi.service.ZfLogService;
import com.ruoyi.util.ArraysUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -24,10 +27,8 @@
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import static com.ruoyi.constant.MenuAuthority.*;
@@ -55,6 +56,9 @@
    @Resource
    ZfCollectionMapper zfCollectionMapper;
    @Resource
    ZfLogService zfLogService;
    private LambdaQueryWrapper<ZfCollection> buildCondition(ZfCollection zfCollection,List<Long> familyIdList) {
        LambdaQueryWrapper<ZfCollection> lqw = new LambdaQueryWrapper<>();
@@ -268,7 +272,7 @@
                        bean.setOwnData(0);
                    }
                }
        ).collect(Collectors.toList());
        ).sorted((a,b)-> b.getOwnData()-a.getOwnData()).collect(Collectors.toList());
    }
    @Override
@@ -402,7 +406,37 @@
            throw new RuntimeException("你没有权限操作此家庭的数据");
        }
        //先记录下谁更新、何时更新、更新了哪里
//        LambdaQueryWrapper<ZfCollection> lqw = new LambdaQueryWrapper<>();
//        lqw.eq(ZfCollection::getId,zfCollection.getId());
//        zfCollectionService.getOne(lqw);
//        ZfCollection oldData = getOne(lqw);
//
//        String oldJson = JSONObject.toJSONString(oldData);
//        String newJson = JSONObject.toJSONString(zfCollection);
//
//        Map oldMap = JSONObject.parseObject(oldJson, Map.class);
//        Map newMap = JSONObject.parseObject(newJson, Map.class);
//
//        for (Object key : oldMap.keySet()) {
//            if(newMap.get(key)!=null && !newMap.get(key).equals(oldMap.get(key))){
//                System.out.println(newMap.get(key)+"     "+oldMap.get(key));
//                Date date = new Date();
//                System.out.println("用户"+myself.getNickName()+"在"+date+"这个时间"+"修改了<收藏荣誉>模块的"+key+"字段");
//            }
//        }
        //操作后加入日志
        ZfLog zfLog = new ZfLog();
        zfLog.setUpdateTime(LocalDateTime.now());
        zfLog.setModule("收藏荣誉");
        zfLog.setUpdater(zInfoUserService.getMyself().getNickName());
        zfLogService.save(zfLog);
        if(updateById(zfCollection)){
            return AjaxResult.success();
        }else {
            return AjaxResult.error();