package com.yida.data.school.index.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yida.data.common.core.entity.home.EduHomeFunction;
import com.yida.data.school.index.mapper.EduHomeFunctionMapper;
import com.yida.data.school.index.service.EduHomeFunctionService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
@Transactional
@RequiredArgsConstructor
public class EduHomeFunctionServiceImpl extends ServiceImpl<EduHomeFunctionMapper, EduHomeFunction> implements
    EduHomeFunctionService {

    @Override
    public void updateFunction(EduHomeFunction function) {
        EduHomeFunction exist = getOne(Wrappers.<EduHomeFunction>lambdaQuery().eq(EduHomeFunction::getDeptId, function.getDeptId())
            .select(EduHomeFunction::getId));
        function.setId(exist.getId());
        updateById(function);
    }
}
