feige
2023-09-16 d29cce61fb3a38f9f57a64a2a20d276b0d1254bc
zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java
@@ -19,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;
@@ -26,6 +27,7 @@
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@@ -54,6 +56,9 @@
    @Resource
    ZfCollectionMapper zfCollectionMapper;
    @Resource
    ZfLogService zfLogService;
    private LambdaQueryWrapper<ZfCollection> buildCondition(ZfCollection zfCollection,List<Long> familyIdList) {
        LambdaQueryWrapper<ZfCollection> lqw = new LambdaQueryWrapper<>();
@@ -403,24 +408,31 @@
        //先记录下谁更新、何时更新、更新了哪里
        LambdaQueryWrapper<ZfCollection> lqw = new LambdaQueryWrapper<>();
        lqw.eq(ZfCollection::getId,zfCollection.getId());
        zfCollectionService.getOne(lqw);
        ZfCollection oldData = getOne(lqw);
//        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+"字段");
//            }
//        }
        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)){