feige
2023-09-16 d29cce61fb3a38f9f57a64a2a20d276b0d1254bc
zhang-content/src/main/java/com/ruoyi/service/impl/ZfEventServiceImpl.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.EsModel;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.MapUtils;
import com.ruoyi.common.utils.SecurityUtils;
@@ -14,9 +15,7 @@
import com.ruoyi.domain.ZfEvent;
import com.ruoyi.domain.ZfEvent;
import com.ruoyi.mapper.ZfEventMapper;
import com.ruoyi.service.ZAuthorityService;
import com.ruoyi.service.ZInfoUserService;
import com.ruoyi.service.ZfEventService;
import com.ruoyi.service.*;
import com.ruoyi.util.ArraysUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -24,6 +23,7 @@
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@@ -49,7 +49,9 @@
    @Resource
    ZAuthorityService zAuthorityService;
    //加入到es中
    @Resource
    private esService esSer;
    private LambdaQueryWrapper<ZfEvent> buildCondition(ZfEvent zfEvent,List<Long> familyIdList) {
        LambdaQueryWrapper<ZfEvent> lqw = new LambdaQueryWrapper<>();
        lqw.orderByDesc(ZfEvent::getCreateTime);
@@ -311,26 +313,26 @@
    @Override
    public AjaxResult addData(ZfEvent zfEvent) {
        ZInfoUser myself = zInfoUserService.getMyself();
        Long familyId = myself.getFamilyId();
        if(familyId == null){
            throw new RuntimeException("您还未加入任何家庭");
        }
        List<ZAuthority> authority = zAuthorityService.getAuthority();
        List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(EVENT_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList());
        familyIdList.add(familyId);
        if (zfEvent.getFamilyId()!=null && !familyIdList.contains(zfEvent.getFamilyId())) {
            throw new RuntimeException("你没有权限操作此家庭的数据");
        }
        if(zfEvent.getFamilyId() == null){
            //默认添加自己家庭的数据
            zfEvent.setFamilyId(familyId);
        }
//        ZInfoUser myself = zInfoUserService.getMyself();
//        Long familyId = myself.getFamilyId();
//
//        if(familyId == null){
//            throw new RuntimeException("您还未加入任何家庭");
//        }
//
//        List<ZAuthority> authority = zAuthorityService.getAuthority();
//        List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(EVENT_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList());
//        familyIdList.add(familyId);
//
//        if (zfEvent.getFamilyId()!=null && !familyIdList.contains(zfEvent.getFamilyId())) {
//            throw new RuntimeException("你没有权限操作此家庭的数据");
//        }
//
//
//        if(zfEvent.getFamilyId() == null){
//            //默认添加自己家庭的数据
//            zfEvent.setFamilyId(familyId);
//        }
        //判断是否有重复数据
        LambdaQueryWrapper<ZfEvent> lqw = uniqueCondition(zfEvent);
@@ -341,6 +343,22 @@
        }
        if (save(zfEvent)) {
            //  飞  加入
            EsModel esModel = new EsModel();
            Integer inte = zfEvent.getId();
            String uuid = UUID.randomUUID().toString().replace("-","");
            esModel.setId(uuid);
            esModel.setCtId(Long.valueOf(inte));
            esModel.setCtName(zfEvent.getTitle());
            esModel.setCtContent(zfEvent.getAddress());
            esModel.setBy1(zfEvent.getRemark());
            //这里存储查询详情的路径
            esModel.setBy5("/family/zfEvent");
            // esModel.setCtTableName("tb_ajk");
            //   esModel.setCtName("大家");
            //  esModel.setCtContent("大家好,才是真的好");//处事由
            esSer.insertTable(esModel);
            return AjaxResult.success();
        } else {
            return AjaxResult.error();
@@ -403,6 +421,9 @@
    }
    @Resource
    ZfLogService zfLogService;
    @Override
    public AjaxResult updateData(ZfEvent zfEvent) {
        ZInfoUser myself = zInfoUserService.getMyself();
@@ -419,6 +440,13 @@
            throw new RuntimeException("你没有权限操作此家庭的数据");
        }
        //操作后加入日志
        ZfLog zfLog = new ZfLog();
        zfLog.setUpdateTime(LocalDateTime.now());
        zfLog.setModule("家大事记");
        zfLog.setUpdater(zInfoUserService.getMyself().getNickName());
        zfLogService.save(zfLog);
        if(updateById(zfEvent)){
            return AjaxResult.success();
        }else {