package com.vctgo.system.service.impl;

import java.util.List;
import java.util.Date;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vctgo.common.security.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.vctgo.system.mapper.SysPlatformExpertWorkExperienceMapper;
import com.vctgo.system.domain.SysPlatformExpertWorkExperience;
import com.vctgo.system.service.ISysPlatformExpertWorkExperienceService;
import com.vctgo.system.util.ConstantUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vctgo.common.core.text.Convert;
import com.vctgo.common.core.utils.ServletUtils;
import com.vctgo.common.mybatisplus.constant.MybatisPageConstants;

/**
 * 专家与工作经历关联Service业务层处理
 *
 * @author caesar
 * @date 2024-03-27
 */
@Slf4j
@Service
public class SysPlatformExpertWorkExperienceServiceImpl
        extends ServiceImpl<SysPlatformExpertWorkExperienceMapper, SysPlatformExpertWorkExperience>
        implements ISysPlatformExpertWorkExperienceService {
    @Autowired
    private SysPlatformExpertWorkExperienceMapper sysPlatformExpertWorkExperienceMapper;

    /**
     * 查询专家与工作经历关联
     *
     * @param id 专家与工作经历关联主键
     * @return 专家与工作经历关联
     */
    @Override
    public SysPlatformExpertWorkExperience selectSysPlatformExpertWorkExperienceById(Long id) {
        return sysPlatformExpertWorkExperienceMapper.selectById(id);
    }

    /**
     * 查询专家与工作经历关联列表-分页
     *
     * @param sysPlatformExpertWorkExperience 专家与工作经历关联
     * @return 专家与工作经历关联
     */
    @Override
    public IPage<SysPlatformExpertWorkExperience> selectSysPlatformExpertWorkExperiencePage(SysPlatformExpertWorkExperience sysPlatformExpertWorkExperience) {
        Page mpPage = new Page(Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_NUM), 1L)
                , Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_SIZE), 10L));
        return sysPlatformExpertWorkExperienceMapper.selectSysPlatformExpertWorkExperienceList(mpPage, sysPlatformExpertWorkExperience);
    }

    /**
     * 查询专家与工作经历关联列表
     *
     * @param sysPlatformExpertWorkExperience 专家与工作经历关联
     * @return 专家与工作经历关联
     */
    @Override
    public List<SysPlatformExpertWorkExperience> selectSysPlatformExpertWorkExperienceList(SysPlatformExpertWorkExperience sysPlatformExpertWorkExperience) {
        return sysPlatformExpertWorkExperienceMapper.selectSysPlatformExpertWorkExperienceList(sysPlatformExpertWorkExperience);
    }

    /**
     * 新增专家与工作经历关联
     *
     * @param sysPlatformExpertWorkExperience 专家与工作经历关联
     * @return 结果
     */

    @Override
    public int insertSysPlatformExpertWorkExperience(SysPlatformExpertWorkExperience sysPlatformExpertWorkExperience) {
        return sysPlatformExpertWorkExperienceMapper.insert(sysPlatformExpertWorkExperience);
    }

    /**
     * 修改专家与工作经历关联
     *
     * @param sysPlatformExpertWorkExperience 专家与工作经历关联
     * @return 结果
     */
    @Override
    public int updateSysPlatformExpertWorkExperience(SysPlatformExpertWorkExperience sysPlatformExpertWorkExperience) {
        return sysPlatformExpertWorkExperienceMapper.updateById(sysPlatformExpertWorkExperience);
    }

    /**
     * 逻辑删除专家与工作经历关联
     *
     * @param ids 需要删除的专家与工作经历关联主键
     * @return 结果
     */
    @Override
    public int logicalDeleteSysPlatformExpertWorkExperienceByIds(Long[] ids) {
        SysPlatformExpertWorkExperience sysPlatformExpertWorkExperience = new SysPlatformExpertWorkExperience();
        sysPlatformExpertWorkExperience.setUpdateById(SecurityUtils.getUserId());
        sysPlatformExpertWorkExperience.setUpdateBy(SecurityUtils.getUsername());
        sysPlatformExpertWorkExperience.setUpdateTime(new Date());
        sysPlatformExpertWorkExperience.setIsDeleted(ConstantUtils.IS_DELETED_1);
        return sysPlatformExpertWorkExperienceMapper.logicalDeleteSysPlatformExpertWorkExperienceByIds(ids, sysPlatformExpertWorkExperience);
    }

    /**
     * 批量删除专家与工作经历关联
     *
     * @param ids 需要删除的专家与工作经历关联主键
     * @return 结果
     */
    @Override
    public int deleteSysPlatformExpertWorkExperienceByIds(Long[] ids) {
        return sysPlatformExpertWorkExperienceMapper.deleteSysPlatformExpertWorkExperienceByIds(ids);
    }

    /**
     * 删除专家与工作经历关联信息
     *
     * @param id 专家与工作经历关联主键
     * @return 结果
     */
    @Override
    public int deleteSysPlatformExpertWorkExperienceById(Long id) {
        return sysPlatformExpertWorkExperienceMapper.deleteById(id);
    }
}
